summaryrefslogtreecommitdiff
path: root/utils/ipc/generators/libcamera_templates/serializer.tmpl
blob: 77bae36fe6b7faa79be875cf876d7fce7b4ccd4d (plain)
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
{#-
 # SPDX-License-Identifier: LGPL-2.1-or-later
 # Copyright (C) 2020, Google Inc.
-#}
{#
 # \brief Verify that there is enough bytes to deserialize
 #
 # Generate code that verifies that \a size is not greater than \a dataSize.
 # Otherwise log an error with \a name and \a typename.
 #}
{%- macro check_data_size(size, dataSize, name, typename) %}
		if ({{dataSize}} < {{size}}) {
			LOG(IPADataSerializer, Error)
				<< "Failed to deserialize " << "{{name}}"
				<< ": not enough {{typename}}, expected "
				<< ({{size}}) << ", got " << ({{dataSize}});
			return ret;
		}
{%- endmacro %}


{#
 # \brief Serialize a field into return vector
 #
 # Generate code to serialize \a field into retData, including size of the
 # field and fds (where appropriate).
 # This code is meant to be used by the IPADataSerializer specialization.
 #
 # \todo Avoid intermediate vectors
 #}
{%- macro serializer_field(field, namespace, loop) %}
{%- if field|is_pod or field|is_enum %}
		std::vector<uint8_t> {{field.mojom_name}};
		std::tie({{field.mojom_name}}, std::ignore) =
	{%- if field|is_pod %}
			IPADataSerializer<{{field|name}}>::serialize(data.{{field.mojom_name}});
	{%- elif field|is_enum %}
			IPADataSerializer<uint{{field|bit_width}}_t>::serialize(data.{{field.mojom_name}});
	{%- endif %}
		retData.insert(retData.end(), {{field.mojom_name}}.begin(), {{field.mojom_name}}.end());
{%- elif field|is_fd %}
		std::vector<uint8_t> {{field.mojom_name}};
		std::vector<SharedFD> {{field.mojom_name}}Fds;
		std::tie({{field.mojom_name}}, {{field.mojom_name}}Fds) =
			IPADataSerializer<{{field|name}}>::serialize(data.{{field.mojom_name}});
		retData.insert(retData.end(), {{field.mojom_name}}.begin(), {{field.mojom_name}}.end());
		retFds.insert(retFds.end(), {{field.mojom_name}}Fds.begin(), {{field.mojom_name}}Fds.end());
{%- elif field|is_controls %}
		if (data.{{field.mojom_name}}.size() > 0) {
			std::vector<uint8_t> {{field.mojom_name}};
			std::tie({{field.mojom_name}}, std::ignore) =
				IPADataSerializer<{{field|name}}>::serialize(data.{{field.mojom_name}}, cs);
			appendPOD<uint32_t>(retData, {{field.mojom_name}}.size());
			retData.insert(retData.end(), {{field.mojom_name}}.begin(), {{field.mojom_name}}.end());
		} else {
			appendPOD<uint32_t>(retData, 0);
		}
{%- elif field|is_plain_struct or field|is_array or field|is_map or field|is_str %}
		std::vector<uint8_t> {{field.mojom_name}};
	{%- if field|has_fd %}
		std::vector<SharedFD> {{field.mojom_name}}Fds;
		std::tie({{field.mojom_name}}, {{field.mojom_name}}Fds) =
	{%- else %}
		std::tie({{field.mojom_name}}, std::ignore) =
	{%- endif %}
	{%- if field|is_array or field|is_map %}
			IPADataSerializer<{{field|name}}>::serialize(data.{{field.mojom_name}}, cs);
	{%- elif field|is_str %}
			IPADataSerializer<{{field|name}}>::serialize(data.{{field.mojom_name}});
	{%- else %}
			IPADataSerializer<{{field|name_full}}>::serialize(data.{{field.mojom_name}}, cs);
	{%- endif %}
		appendPOD<uint32_t>(retData, {{field.mojom_name}}.size());
	{%- if field|has_fd %}
		appendPOD<uint32_t>(retData, {{field.mojom_name}}Fds.size());
	{%- endif %}
		retData.insert(retData.end(), {{field.mojom_name}}.begin(), {{field.mojom_name}}.end());
	{%- if field|has_fd %}
		retFds.insert(retFds.end(), {{field.mojom_name}}Fds.begin(), {{field.mojom_name}}Fds.end());
	{%- endif %}
{%- else %}
		/* Unknown serialization for {{field.mojom_name}}. */
{%- endif %}
{%- endmacro %}


{#
 # \brief Deserialize a field into return struct
 #
 # Generate code to deserialize \a field into object ret.
 # This code is meant to be used by the IPADataSerializer specialization.
 #}
{%- macro deserializer_field(field, namespace, loop) %}
{% if field|is_pod or field|is_enum %}
	{%- set field_size = (field|bit_width|int / 8)|int %}
		{{- check_data_size(field_size, 'dataSize', field.mojom_name, 'data')}}
		{%- if field|is_pod %}
		ret.{{field.mojom_name}} = IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field_size}});
		{%- else %}
		ret.{{field.mojom_name}} = static_cast<{{field|name_full}}>(IPADataSerializer<uint{{field|bit_width}}_t>::deserialize(m, m + {{field_size}}));
		{%- endif %}
	{%- if not loop.last %}
		m += {{field_size}};
		dataSize -= {{field_size}};
	{%- endif %}
{% elif field|is_fd %}
	{%- set field_size = 4 %}
		{{- check_data_size(field_size, 'dataSize', field.mojom_name, 'data')}}
		ret.{{field.mojom_name}} = IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field_size}}, n, n + 1, cs);
	{%- if not loop.last %}
		m += {{field_size}};
		dataSize -= {{field_size}};
		n += ret.{{field.mojom_name}}.isValid() ? 1 : 0;
		fdsSize -= ret.{{field.mojom_name}}.isValid() ? 1 : 0;
	{%- endif %}
{% elif field|is_controls %}
	{%- set field_size = 4 %}
		{{- check_data_size(field_size, 'dataSize', field.mojom_name + 'Size', 'data')}}
		const size_t {{field.mojom_name}}Size = readPOD<uint32_t>(m, 0, dataEnd);
		m += {{field_size}};
		dataSize -= {{field_size}};
	{%- set field_size = field.mojom_name + 'Size' -%}
		{{- check_data_size(field_size, 'dataSize', field.mojom_name, 'data')}}
		if ({{field.mojom_name}}Size > 0)
			ret.{{field.mojom_name}} =
				IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field.mojom_name}}Size, cs);
	{%- if not loop.last %}
		m += {{field_size}};
		dataSize -= {{field_size}};
	{%- endif %}
{% elif field|is_plain_struct or field|is_array or field|is_map or field|is_str %}
	{%- set field_size = 4 %}
		{{- check_data_size(field_size, 'dataSize', field.mojom_name + 'Size', 'data')}}
		const size_t {{field.mojom_name}}Size = readPOD<uint32_t>(m, 0, dataEnd);
		m += {{field_size}};
		dataSize -= {{field_size}};
	{%- if field|has_fd %}
	{%- set field_size = 4 %}
		{{- check_data_size(field_size, 'dataSize', field.mojom_name + 'FdsSize', 'data')}}
		const size_t {{field.mojom_name}}FdsSize = readPOD<uint32_t>(m, 0, dataEnd);
		m += {{field_size}};
		dataSize -= {{field_size}};
		{{- check_data_size(field.mojom_name + 'FdsSize', 'fdsSize', field.mojom_name, 'fds')}}
	{%- endif %}
	{%- set field_size = field.mojom_name + 'Size' -%}
		{{- check_data_size(field_size, 'dataSize', field.mojom_name, 'data')}}
		ret.{{field.mojom_name}} =
	{%- if field|is_str %}
			IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field.mojom_name}}Size);
	{%- elif field|has_fd and (field|is_array or field|is_map) %}
			IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field.mojom_name}}Size, n, n + {{field.mojom_name}}FdsSize, cs);
	{%- elif field|has_fd and (not (field|is_array or field|is_map)) %}
			IPADataSerializer<{{field|name_full}}>::deserialize(m, m + {{field.mojom_name}}Size, n, n + {{field.mojom_name}}FdsSize, cs);
	{%- elif (not field|has_fd) and (field|is_array or field|is_map) %}
			IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field.mojom_name}}Size, cs);
	{%- else %}
			IPADataSerializer<{{field|name_full}}>::deserialize(m, m + {{field.mojom_name}}Size, cs);
	{%- endif %}
	{%- if not loop.last %}
		m += {{field_size}};
		dataSize -= {{field_size}};
	{%- if field|has_fd %}
		n += {{field.mojom_name}}FdsSize;
		fdsSize -= {{field.mojom_name}}FdsSize;
	{%- endif %}
	{%- endif %}
{% else %}
		/* Unknown deserialization for {{field.mojom_name}}. */
{%- endif %}
{%- endmacro %}


{#
 # \brief Serialize a struct
 #
 # Generate code for IPADataSerializer specialization, for serializing
 # \a struct.
 #}
{%- macro serializer(struct, namespace) %}
	static std::tuple<std::vector<uint8_t>, std::vector<SharedFD>>
	serialize(const {{struct|name_full}} &data,
{%- if struct|needs_control_serializer %}
		  ControlSerializer *cs)
{%- else %}
		  [[maybe_unused]] ControlSerializer *cs = nullptr)
{%- endif %}
	{
		std::vector<uint8_t> retData;
{%- if struct|has_fd %}
		std::vector<SharedFD> retFds;
{%- endif %}
{%- for field in struct.fields %}
{{serializer_field(field, namespace, loop)}}
{%- endfor %}
{% if struct|has_fd %}
		return {retData, retFds};
{%- else %}
		return {retData, {}};
{%- endif %}
	}
{%- endmacro %}


{#
 # \brief Deserialize a struct that has fds
 #
 # Generate code for IPADataSerializer specialization, for deserializing
 # \a struct, in the case that \a struct has file descriptors.
 #}
{%- macro deserializer_fd(struct, namespace) %}
	static {{struct|name_full}}
	deserialize(std::vector<uint8_t> &data,
		    std::vector<SharedFD> &fds,
{%- if struct|needs_control_serializer %}
		    ControlSerializer *cs)
{%- else %}
		    ControlSerializer *cs = nullptr)
{%- endif %}
	{
		return IPADataSerializer<{{struct|name_full}}>::deserialize(data.cbegin(), data.cend(), fds.cbegin(), fds.cend(), cs);
	}

{# \todo Don't inline this function #}
	static {{struct|name_full}}
	deserialize(std::vector<uint8_t>::const_iterator dataBegin,
		    std::vector<uint8_t>::const_iterator dataEnd,
		    std::vector<SharedFD>::const_iterator fdsBegin,
		    std::vector<SharedFD>::const_iterator fdsEnd,
{%- if struct|needs_control_serializer %}
		    ControlSerializer *cs)
{%- else %}
		    [[maybe_unused]] ControlSerializer *cs = nullptr)
{%- endif %}
	{
		{{struct|name_full}} ret;
		std::vector<uint8_t>::const_iterator m = dataBegin;
		std::vector<SharedFD>::const_iterator n = fdsBegin;

		size_t dataSize = std::distance(dataBegin, dataEnd);
		[[maybe_unused]] size_t fdsSize = std::distance(fdsBegin, fdsEnd);
{%- for field in struct.fields -%}
{{deserializer_field(field, namespace, loop)}}
{%- endfor %}
		return ret;
	}
{%- endmacro %}

{#
 # \brief Deserialize a struct that has fds, using non-fd
 #
 # Generate code for IPADataSerializer specialization, for deserializing
 # \a struct, in the case that \a struct has no file descriptors but requires
 # deserializers with file descriptors.
 #}
{%- macro deserializer_fd_simple(struct, namespace) %}
	static {{struct|name_full}}
	deserialize(std::vector<uint8_t> &data,
		    [[maybe_unused]] std::vector<SharedFD> &fds,
		    ControlSerializer *cs = nullptr)
	{
		return IPADataSerializer<{{struct|name_full}}>::deserialize(data.cbegin(), data.cend(), cs);
	}

	static {{struct|name_full}}
	deserialize(std::vector<uint8_t>::const_iterator dataBegin,
		    std::vector<uint8_t>::const_iterator dataEnd,
		    [[maybe_unused]] std::vector<SharedFD>::const_iterator fdsBegin,
		    [[maybe_unused]] std::vector<SharedFD>::const_iterator fdsEnd,
		    ControlSerializer *cs = nullptr)
	{
		return IPADataSerializer<{{struct|name_full}}>::deserialize(dataBegin, dataEnd, cs);
	}
{%- endmacro %}


{#
 # \brief Deserialize a struct that has no fds
 #
 # Generate code for IPADataSerializer specialization, for deserializing
 # \a struct, in the case that \a struct does not have file descriptors.
 #}
{%- macro deserializer_no_fd(struct, namespace) %}
	static {{struct|name_full}}
	deserialize(std::vector<uint8_t> &data,
{%- if struct|needs_control_serializer %}
		    ControlSerializer *cs)
{%- else %}
		    ControlSerializer *cs = nullptr)
{%- endif %}
	{
		return IPADataSerializer<{{struct|name_full}}>::deserialize(data.cbegin(), data.cend(), cs);
	}

{# \todo Don't inline this function #}
	static {{struct|name_full}}
	deserialize(std::vector<uint8_t>::const_iterator dataBegin,
		    std::vector<uint8_t>::const_iterator dataEnd,
{%- if struct|needs_control_serializer %}
		    ControlSerializer *cs)
{%- else %}
		    [[maybe_unused]] ControlSerializer *cs = nullptr)
{%- endif %}
	{
		{{struct|name_full}} ret;
		std::vector<uint8_t>::const_iterator m = dataBegin;

		size_t dataSize = std::distance(dataBegin, dataEnd);
{%- for field in struct.fields -%}
{{deserializer_field(field, namespace, loop)}}
{%- endfor %}
		return ret;
	}
{%- endmacro %}
pan> stream->size != Size{ 1024, 768 }) { cerr << "configure(): Invalid configuration for stream 1" << endl; return report(Op_configure, TestFail); } iter = streamConfig.find(2); if (iter == streamConfig.end()) { cerr << "configure(): No configuration for stream 2" << endl; return report(Op_configure, TestFail); } stream = &iter->second; if (stream->pixelFormat != V4L2_PIX_FMT_NV12 || stream->size != Size{ 800, 600 }) { cerr << "configure(): Invalid configuration for stream 2" << endl; return report(Op_configure, TestFail); } /* Verify entityControls. */ auto ctrlIter = entityControls.find(42); if (ctrlIter == entityControls.end()) { cerr << "configure(): Controls not found" << endl; return report(Op_configure, TestFail); } const ControlInfoMap &infoMap = ctrlIter->second; if (infoMap.count(V4L2_CID_BRIGHTNESS) != 1 || infoMap.count(V4L2_CID_CONTRAST) != 1 || infoMap.count(V4L2_CID_SATURATION) != 1) { cerr << "configure(): Invalid control IDs" << endl; return report(Op_configure, TestFail); } report(Op_configure, TestPass); } void mapBuffers(const std::vector<IPABuffer> &buffers) override { if (buffers.size() != 2) { cerr << "mapBuffers(): Invalid number of buffers " << buffers.size() << endl; return report(Op_mapBuffers, TestFail); } if (buffers[0].id != 10 || buffers[1].id != 11) { cerr << "mapBuffers(): Invalid buffer IDs" << endl; return report(Op_mapBuffers, TestFail); } if (buffers[0].planes.size() != 3 || buffers[1].planes.size() != 3) { cerr << "mapBuffers(): Invalid number of planes" << endl; return report(Op_mapBuffers, TestFail); } if (buffers[0].planes[0].length != 4096 || buffers[0].planes[1].length != 0 || buffers[0].planes[2].length != 0 || buffers[0].planes[0].length != 4096 || buffers[1].planes[1].length != 4096 || buffers[1].planes[2].length != 0) { cerr << "mapBuffers(): Invalid length" << endl; return report(Op_mapBuffers, TestFail); } if (buffers[0].planes[0].fd.fd() == -1 || buffers[0].planes[1].fd.fd() != -1 || buffers[0].planes[2].fd.fd() != -1 || buffers[0].planes[0].fd.fd() == -1 || buffers[1].planes[1].fd.fd() == -1 || buffers[1].planes[2].fd.fd() != -1) { cerr << "mapBuffers(): Invalid dmabuf" << endl; return report(Op_mapBuffers, TestFail); } report(Op_mapBuffers, TestPass); } void unmapBuffers(const std::vector<unsigned int> &ids) override { if (ids.size() != 2) { cerr << "unmapBuffers(): Invalid number of ids " << ids.size() << endl; return report(Op_unmapBuffers, TestFail); } if (ids[0] != 10 || ids[1] != 11) { cerr << "unmapBuffers(): Invalid buffer IDs" << endl; return report(Op_unmapBuffers, TestFail); } report(Op_unmapBuffers, TestPass); } void processEvent(const IPAOperationData &data) override { /* Verify operation and data. */ if (data.operation != Op_processEvent) { cerr << "processEvent(): Invalid operation " << data.operation << endl; return report(Op_processEvent, TestFail); } if (data.data != std::vector<unsigned int>{ 1, 2, 3, 4 }) { cerr << "processEvent(): Invalid data" << endl; return report(Op_processEvent, TestFail); } /* Verify controls. */ if (data.controls.size() != 1) { cerr << "processEvent(): Controls not found" << endl; return report(Op_processEvent, TestFail); } const ControlList &controls = data.controls[0]; if (controls.get(V4L2_CID_BRIGHTNESS).get<int32_t>() != 10 || controls.get(V4L2_CID_CONTRAST).get<int32_t>() != 20 || controls.get(V4L2_CID_SATURATION).get<int32_t>() != 30) { cerr << "processEvent(): Invalid controls" << endl; return report(Op_processEvent, TestFail); } report(Op_processEvent, TestPass); } private: void report(Operation op, int status) { IPAOperationData data; data.operation = op; data.data.resize(1); data.data[0] = status; queueFrameAction.emit(sequence_++, data); } unsigned int sequence_; }; #define INVOKE(method, ...) \ invoke(&IPAInterface::method, Op_##method, #method, ##__VA_ARGS__) class IPAWrappersTest : public Test { public: IPAWrappersTest() : subdev_(nullptr), wrapper_(nullptr), sequence_(0), fd_(-1) { } protected: int init() override { /* Locate the VIMC Sensor B subdevice. */ enumerator_ = unique_ptr<DeviceEnumerator>(DeviceEnumerator::create()); if (!enumerator_) { cerr << "Failed to create device enumerator" << endl; return TestFail; } if (enumerator_->enumerate()) { cerr << "Failed to enumerate media devices" << endl; return TestFail; } DeviceMatch dm("vimc"); media_ = enumerator_->search(dm); if (!media_) { cerr << "No VIMC media device found: skip test" << endl; return TestSkip; } MediaEntity *entity = media_->getEntityByName("Sensor A"); if (!entity) { cerr << "Unable to find media entity 'Sensor A'" << endl; return TestFail; } subdev_ = new V4L2Subdevice(entity); if (subdev_->open() < 0) { cerr << "Unable to open 'Sensor A' subdevice" << endl; return TestFail; } /* Force usage of the C API as that's what we want to test. */ int ret = setenv("LIBCAMERA_IPA_FORCE_C_API", "", 1); if (ret) return TestFail; std::unique_ptr<IPAInterface> intf = std::make_unique<TestIPAInterface>(); wrapper_ = new IPAContextWrapper(new IPAInterfaceWrapper(std::move(intf))); wrapper_->queueFrameAction.connect(this, &IPAWrappersTest::queueFrameAction); /* Create a file descriptor for the buffer-related operations. */ fd_ = open("/tmp", O_TMPFILE | O_RDWR, 0600); if (fd_ == -1) return TestFail; ret = ftruncate(fd_, 4096); if (ret < 0) return TestFail; return TestPass; } int run() override { int ret; /* Test configure(). */ CameraSensorInfo sensorInfo{ .model = "sensor", .bitsPerPixel = 8, .activeAreaSize = { 2576, 1956 }, .analogCrop = { 8, 8, 2560, 1940 }, .outputSize = { 2560, 1940 }, .pixelRate = 96000000, .lineLength = 2918, }; std::map<unsigned int, IPAStream> config{ { 1, { V4L2_PIX_FMT_YUYV, { 1024, 768 } } }, { 2, { V4L2_PIX_FMT_NV12, { 800, 600 } } }, }; std::map<unsigned int, const ControlInfoMap &> controlInfo; controlInfo.emplace(42, subdev_->controls()); ret = INVOKE(configure, sensorInfo, config, controlInfo); if (ret == TestFail) return TestFail; /* Test mapBuffers(). */ std::vector<IPABuffer> buffers(2); buffers[0].planes.resize(3); buffers[0].id = 10; buffers[0].planes[0].fd = FileDescriptor(fd_); buffers[0].planes[0].length = 4096; buffers[1].id = 11; buffers[1].planes.resize(3); buffers[1].planes[0].fd = FileDescriptor(fd_); buffers[1].planes[0].length = 4096; buffers[1].planes[1].fd = FileDescriptor(fd_); buffers[1].planes[1].length = 4096; ret = INVOKE(mapBuffers, buffers); if (ret == TestFail) return TestFail; /* Test unmapBuffers(). */ std::vector<unsigned int> bufferIds = { 10, 11 }; ret = INVOKE(unmapBuffers, bufferIds); if (ret == TestFail) return TestFail; /* Test processEvent(). */ IPAOperationData data; data.operation = Op_processEvent; data.data = { 1, 2, 3, 4 }; data.controls.emplace_back(subdev_->controls()); ControlList &controls = data.controls.back(); controls.set(V4L2_CID_BRIGHTNESS, static_cast<int32_t>(10)); controls.set(V4L2_CID_CONTRAST, static_cast<int32_t>(20)); controls.set(V4L2_CID_SATURATION, static_cast<int32_t>(30)); ret = INVOKE(processEvent, data); if (ret == TestFail) return TestFail; /* * Test init(), start() and stop() last to ensure nothing in the * wrappers or serializer depends on them being called first. */ IPASettings settings{ .configurationFile = "/ipa/configuration/file" }; ret = INVOKE(init, settings); if (ret == TestFail) { cerr << "Failed to run init()"; return TestFail; } ret = INVOKE(start); if (ret == TestFail) { cerr << "Failed to run start()"; return TestFail; } ret = INVOKE(stop); if (ret == TestFail) { cerr << "Failed to run stop()"; return TestFail; } return TestPass; } void cleanup() override { delete wrapper_; delete subdev_; if (fd_ != -1) close(fd_); } private: template<typename T, typename... Args1, typename... Args2> int invoke(T (IPAInterface::*func)(Args1...), Operation op, const char *name, Args2... args) { data_ = IPAOperationData(); (wrapper_->*func)(args...); if (frame_ != sequence_) { cerr << "IPAInterface::" << name << "(): invalid frame number " << frame_ << ", expected " << sequence_; return TestFail; } sequence_++; if (data_.operation != op) { cerr << "IPAInterface::" << name << "(): failed to propagate" << endl; return TestFail; } if (data_.data[0] != TestPass) { cerr << "IPAInterface::" << name << "(): reported an error" << endl; return TestFail; } return TestPass; } void queueFrameAction(unsigned int frame, const IPAOperationData &data) { frame_ = frame; data_ = data; } std::shared_ptr<MediaDevice> media_; std::unique_ptr<DeviceEnumerator> enumerator_; V4L2Subdevice *subdev_; IPAContextWrapper *wrapper_; IPAOperationData data_; unsigned int sequence_; unsigned int frame_; int fd_; }; TEST_REGISTER(IPAWrappersTest)