summaryrefslogtreecommitdiff
path: root/test/byte-stream-buffer.cpp
AgeCommit message (Collapse)Author
2020-05-16libcamera: Move internal headers to include/libcamera/internal/Laurent Pinchart
The libcamera internal headers are located in src/libcamera/include/. The directory is added to the compiler headers search path with a meson include_directories() directive, and internal headers are included with (e.g. for the internal semaphore.h header) #include "semaphore.h" All was well, until libcxx decided to implement the C++20 synchronization library. The __threading_support header gained a #include <semaphore.h> to include the pthread's semaphore support. As include_directories() adds src/libcamera/include/ to the compiler search path with -I, the internal semaphore.h is included instead of the pthread version. Needless to say, the compiler isn't happy. Three options have been considered to fix this issue: - Use -iquote instead of -I. The -iquote option instructs gcc to only consider the header search path for headers included with the "" version. Meson unfortunately doesn't support this option. - Rename the internal semaphore.h header. This was deemed to be the beginning of a long whack-a-mole game, where namespace clashes with system libraries would appear over time (possibly dependent on particular system configurations) and would need to be constantly fixed. - Move the internal headers to another directory to create a unique namespace through path components. This causes lots of churn in all the existing source files through the all project. The first option would be best, but isn't available to us due to missing support in meson. Even if -iquote support was added, we would need to fix the problem before a new version of meson containing the required support would be released. The third option is thus the only practical solution available. Bite the bullet, and do it, moving headers to include/libcamera/internal/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2019-11-20test: Add ByteStreamBuffer testLaurent Pinchart
The test exercises the API of the ByteStreamBuffer class in both read and write modes, including carve out buffers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
#n86'>86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
{#-
 # SPDX-License-Identifier: LGPL-2.1-or-later
 # Copyright (C) 2020, Google Inc.
-#}
{%- import "proxy_functions.tmpl" as proxy_funcs -%}

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2020, Google Inc.
 *
 * {{module_name}}_ipa_proxy.h - Image Processing Algorithm proxy for {{module_name}}
 *
 * This file is auto-generated. Do not edit.
 */

#ifndef __LIBCAMERA_INTERNAL_IPA_PROXY_{{module_name|upper}}_H__
#define __LIBCAMERA_INTERNAL_IPA_PROXY_{{module_name|upper}}_H__

#include <libcamera/ipa/ipa_interface.h>
#include <libcamera/ipa/{{module_name}}_ipa_interface.h>

#include <libcamera/base/thread.h>

#include "libcamera/internal/control_serializer.h"
#include "libcamera/internal/ipa_proxy.h"
#include "libcamera/internal/ipc_pipe.h"
#include "libcamera/internal/ipc_pipe_unixsocket.h"
#include "libcamera/internal/ipc_unixsocket.h"

namespace libcamera {
{%- if has_namespace %}
{% for ns in namespace %}
namespace {{ns}} {
{% endfor %}
{%- endif %}

class {{proxy_name}} : public IPAProxy, public {{interface_name}}, public Object
{
public:
	{{proxy_name}}(IPAModule *ipam, bool isolate);
	~{{proxy_name}}();

{% for method in interface_main.methods %}
{{proxy_funcs.func_sig(proxy_name, method, "", false, true)|indent(8, true)}};
{% endfor %}

{%- for method in interface_event.methods %}
	Signal<
{%- for param in method.parameters -%}
		{{"const " if not param|is_pod}}{{param|name}}{{" &" if not param|is_pod}}
		{{- ", " if not loop.last}}
{%- endfor -%}
> {{method.mojom_name}};
{% endfor %}

private:
	void recvMessage(const IPCMessage &data);

{% for method in interface_main.methods %}
{{proxy_funcs.func_sig(proxy_name, method, "Thread", false)|indent(8, true)}};
{{proxy_funcs.func_sig(proxy_name, method, "IPC", false)|indent(8, true)}};
{% endfor %}
{% for method in interface_event.methods %}
{{proxy_funcs.func_sig(proxy_name, method, "Thread", false)|indent(8, true)}};
	void {{method.mojom_name}}IPC(
		std::vector<uint8_t>::const_iterator data,
		size_t dataSize,
		const std::vector<FileDescriptor> &fds);
{% endfor %}

	/* Helper class to invoke async functions in another thread. */
	class ThreadProxy : public Object
	{
	public:
		ThreadProxy()
			: ipa_(nullptr)
		{
		}

		void setIPA({{interface_name}} *ipa)
		{
			ipa_ = ipa;
		}

		void stop()
		{
			ipa_->stop();
		}
{% for method in interface_main.methods %}
{%- if method|is_async %}
		{{proxy_funcs.func_sig(proxy_name, method, "", false)|indent(16)}}
		{
			ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}});
		}
{%- elif method.mojom_name == "start" %}
		{{proxy_funcs.func_sig(proxy_name, method, "", false)|indent(16)}}
		{
{%- if method|method_return_value != "void" %}
			return ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}});
{%- else %}
			ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}}
	{{- ", " if method|method_param_outputs|params_comma_sep -}}
	{{- method|method_param_outputs|params_comma_sep}});
{%- endif %}
		}
{%- endif %}
{%- endfor %}

	private:
		{{interface_name}} *ipa_;
	};

	Thread thread_;
	ThreadProxy proxy_;
	std::unique_ptr<{{interface_name}}> ipa_;

	const bool isolate_;

	std::unique_ptr<IPCPipeUnixSocket> ipc_;

	ControlSerializer controlSerializer_;

{# \todo Move this to IPCPipe #}
	uint32_t seq_;
};

{%- if has_namespace %}
{% for ns in namespace|reverse %}
} /* namespace {{ns}} */
{% endfor %}
{%- endif %}
} /* namespace libcamera */

#endif /* __LIBCAMERA_INTERNAL_IPA_PROXY_{{module_name|upper}}_H__ */