libcamera: include/libcamera/internal/control_serializer.h Source File

libcamera v0.0.4 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
control_serializer.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2019, Google Inc.
4 *
5 * control_serializer.h - Control (de)serializer
6 */
7
8#pragma once
9
10#include <map>
11#include <memory>
12#include <vector>
13
14#include <libcamera/controls.h>
15
16namespace libcamera {
17
18class ByteStreamBuffer;
19
20 class ControlSerializer
21{
22public:
23 enum class Role {
24 Proxy,
25 Worker
26 };
27
28 ControlSerializer(Role role);
29
30 void reset();
31
32 static size_t binarySize(const ControlInfoMap &infoMap);
33 static size_t binarySize(const ControlList &list);
34
35 int serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer);
36 int serialize(const ControlList &list, ByteStreamBuffer &buffer);
37
38 template<typename T>
39 T deserialize(ByteStreamBuffer &buffer);
40
41 bool isCached(const ControlInfoMap &infoMap);
42
43private:
44 static size_t binarySize(const ControlValue &value);
45 static size_t binarySize(const ControlInfo &info);
46
47 static void store(const ControlValue &value, ByteStreamBuffer &buffer);
48 static void store(const ControlInfo &info, ByteStreamBuffer &buffer);
49
50 ControlValue loadControlValue(ByteStreamBuffer &buffer,
51 bool isArray = false, unsigned int count = 1);
52 ControlInfo loadControlInfo(ByteStreamBuffer &buffer);
53
54 unsigned int serial_;
55 unsigned int serialSeed_;
56 std::vector<std::unique_ptr<ControlId>> controlIds_;
57 std::vector<std::unique_ptr<ControlIdMap>> controlIdMaps_;
58 std::map<unsigned int, ControlInfoMap> infoMaps_;
59 std::map<const ControlInfoMap *, unsigned int> infoMapHandles_;
60};
61
62} /* namespace libcamera */
libcamera::ByteStreamBuffer
Wrap a memory buffer and provide sequential data read and write.
Definition: byte_stream_buffer.h:20
libcamera::ControlInfoMap
A map of ControlId to ControlInfo.
Definition: controls.h:306
libcamera::ControlInfo
Describe the limits of valid values for a Control.
Definition: controls.h:269
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition: controls.h:350
libcamera::ControlSerializer
Serializer and deserializer for control-related classes.
Definition: control_serializer.h:21
libcamera::ControlSerializer::binarySize
static size_t binarySize(const ControlInfoMap &infoMap)
Retrieve the size in bytes required to serialize a ControlInfoMap.
Definition: control_serializer.cpp:164
libcamera::ControlSerializer::deserialize
T deserialize(ByteStreamBuffer &buffer)
Deserialize an object from a binary buffer.
libcamera::ControlSerializer::reset
void reset()
Reset the serializer.
Definition: control_serializer.cpp:135
libcamera::ControlSerializer::isCached
bool isCached(const ControlInfoMap &infoMap)
Check if a ControlInfoMap is cached.
Definition: control_serializer.cpp:643
libcamera::ControlSerializer::Role
Role
Define the role of the IPC component using the control serializer.
Definition: control_serializer.h:23
libcamera::ControlSerializer::Role::Worker
@ Worker
The control serializer is used by the IPC ProxyWorker classes.
libcamera::ControlSerializer::Role::Proxy
@ Proxy
The control serializer is used by the IPC Proxy classes.
libcamera::ControlSerializer::serialize
int serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer)
Serialize a ControlInfoMap in a buffer.
Definition: control_serializer.cpp:224
libcamera::ControlValue
Abstract type representing the value of a control.
Definition: controls.h:97
controls.h
Framework to manage controls related to an object.
libcamera
Top-level libcamera namespace.
Definition: backtrace.h:17