libcamera  v0.0.0+100-debian/0_git20200629+e7aa92a-8-9-g77f5237c-dirty (2021-05-05T16:20:29+01:00)
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>
34  T deserialize(ByteStreamBuffer &buffer);
35 
36  bool isCached(const ControlInfoMap &infoMap);
37 
38 private:
39  static size_t binarySize(const ControlValue &value);
40  static size_t binarySize(const ControlInfo &info);
41 
42  static void store(const ControlValue &value, ByteStreamBuffer &buffer);
43  static void store(const ControlInfo &info, ByteStreamBuffer &buffer);
44 
45  ControlValue loadControlValue(ControlType type, ByteStreamBuffer &buffer,
46  bool isArray = false, unsigned int count = 1);
47  ControlInfo loadControlInfo(ControlType type, ByteStreamBuffer &buffer);
48 
49  unsigned int serial_;
50  std::vector<std::unique_ptr<ControlId>> controlIds_;
51  std::map<unsigned int, ControlInfoMap> infoMaps_;
52  std::map<const ControlInfoMap *, unsigned int> infoMapHandles_;
53 };
54 
55 } /* namespace libcamera */
56 
57 #endif /* __LIBCAMERA_INTERNAL_CONTROL_SERIALIZER_H__ */
Describe the limits of valid values for a Control.
Definition: controls.h:266
int serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer)
Serialize a ControlInfoMap in a buffer.
Definition: control_serializer.cpp:173
bool isCached(const ControlInfoMap &infoMap)
Check if a ControlInfoMap is cached.
Definition: control_serializer.cpp:509
T deserialize(ByteStreamBuffer &buffer)
Deserialize an object from a binary buffer.
Top-level libcamera namespace.
Definition: bound_method.h:15
Abstract type representing the value of a control.
Definition: controls.h:94
static size_t binarySize(const ControlInfoMap &infoMap)
Retrieve the size in bytes required to serialize a ControlInfoMap.
Definition: control_serializer.cpp:116
A map of ControlId to ControlInfo.
Definition: controls.h:301
ControlType
Define the data type of a Control.
Definition: controls.h:25
Serializer and deserializer for control-related classes.
Definition: control_serializer.h:20
Wrap a memory buffer and provide sequential data read and write.
Definition: byte_stream_buffer.h:19
void reset()
Reset the serializer.
Definition: control_serializer.cpp:88
Associate a list of ControlId with their values for an object.
Definition: controls.h:346
Framework to manage controls related to an object.