libcamera  v0.0.0
Supporting cameras in Linux since 2019
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 #ifndef __LIBCAMERA_INTERNAL_CONTROL_SERIALIZER_H__
8 #define __LIBCAMERA_INTERNAL_CONTROL_SERIALIZER_H__
9 
10 #include <map>
11 #include <memory>
12 #include <vector>
13 
14 #include <libcamera/controls.h>
15 
16 namespace libcamera {
17 
18 class ByteStreamBuffer;
19 
21 {
22 public:
24 
25  void reset();
26 
27  static size_t binarySize(const ControlInfoMap &infoMap);
28  static size_t binarySize(const ControlList &list);
29 
30  int serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer);
31  int serialize(const ControlList &list, ByteStreamBuffer &buffer);
32 
33  template<typename T>
35 
36 private:
37  static size_t binarySize(const ControlValue &value);
38  static size_t binarySize(const ControlInfo &info);
39 
40  static void store(const ControlValue &value, ByteStreamBuffer &buffer);
41  static void store(const ControlInfo &info, ByteStreamBuffer &buffer);
42 
43  ControlValue loadControlValue(ControlType type, ByteStreamBuffer &buffer,
44  bool isArray = false, unsigned int count = 1);
45  ControlInfo loadControlInfo(ControlType type, ByteStreamBuffer &buffer);
46 
47  unsigned int serial_;
48  std::vector<std::unique_ptr<ControlId>> controlIds_;
49  std::map<unsigned int, ControlInfoMap> infoMaps_;
50  std::map<const ControlInfoMap *, unsigned int> infoMapHandles_;
51 };
52 
53 } /* namespace libcamera */
54 
55 #endif /* __LIBCAMERA_INTERNAL_CONTROL_SERIALIZER_H__ */
Wrap a memory buffer and provide sequential data read and write.
Definition: byte_stream_buffer.h:19
A map of ControlId to ControlInfo.
Definition: controls.h:297
Describe the limits of valid values for a Control.
Definition: controls.h:266
Associate a list of ControlId with their values for an object.
Definition: controls.h:342
Serializer and deserializer for control-related classes.
Definition: control_serializer.h:21
static size_t binarySize(const ControlInfoMap &infoMap)
Retrieve the size in bytes required to serialize a ControlInfoMap.
Definition: control_serializer.cpp:116
T deserialize(ByteStreamBuffer &buffer)
Deserialize an object from a binary buffer.
void reset()
Reset the serializer.
Definition: control_serializer.cpp:88
int serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer)
Serialize a ControlInfoMap in a buffer.
Definition: control_serializer.cpp:173
Abstract type representing the value of a control.
Definition: controls.h:93
Framework to manage controls related to an object.
ControlType
Define the data type of a Control.
Definition: controls.h:23