1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 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 135 136 137 138 139 140 141 142 143 144 145
|
{#-
# 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.
*
* Image Processing Algorithm proxy for {{module_name}}
*
* This file is auto-generated. Do not edit.
*/
#pragma once
#include <libcamera/ipa/ipa_interface.h>
#include <libcamera/ipa/{{module_name}}_ipa_interface.h>
#include <libcamera/base/object.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}}Threaded;
class {{proxy_name}}Isolated;
class {{proxy_name}} : public IPAProxy, public {{interface_name}}, public Object
{
public:
using Threaded = {{proxy_name}}Threaded;
using Isolated = {{proxy_name}}Isolated;
protected:
using IPAProxy::IPAProxy;
};
class {{proxy_name}}Threaded : public {{proxy_name}}
{
public:
{{proxy_name}}Threaded(IPAModule *ipam, const GlobalConfiguration &configuration);
~{{proxy_name}}Threaded();
{% for method in interface_main.methods %}
{{proxy_funcs.func_sig(proxy_name + "Threaded", method, "", false, true)|indent(8, true)}};
{% endfor %}
private:
{% for method in interface_event.methods %}
{{proxy_funcs.func_sig(proxy_name + "Threaded", method, "Handler", false)|indent(8, true)}};
{% 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 + "Threaded", method, "", false)|indent(16)}}
{
ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}});
}
{%- elif method.mojom_name == "start" %}
{{proxy_funcs.func_sig(proxy_name + "Threaded", 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_;
};
class {{proxy_name}}Isolated : public {{proxy_name}}
{
public:
{{proxy_name}}Isolated(IPAModule *ipam, const GlobalConfiguration &configuration);
~{{proxy_name}}Isolated();
{% for method in interface_main.methods %}
{{proxy_funcs.func_sig(proxy_name + "Isolated", method, "", false, true)|indent(8, true)}};
{% endfor %}
private:
void recvMessage(const IPCMessage &data);
{% for method in interface_event.methods %}
void {{method.mojom_name}}Handler(
std::vector<uint8_t>::const_iterator data,
size_t dataSize,
const std::vector<SharedFD> &fds);
{% endfor %}
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 */
|