control_serializer.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* control_serializer.h - Control (de)serializer
*/
#ifndef __LIBCAMERA_INTERNAL_CONTROL_SERIALIZER_H__
#define __LIBCAMERA_INTERNAL_CONTROL_SERIALIZER_H__
#include <map>
#include <memory>
#include <vector>
#include <libcamera/controls.h>
namespace libcamera {
class ByteStreamBuffer;
class ControlSerializer
{
public:
ControlSerializer();
void reset();
static size_t binarySize(const ControlInfoMap &infoMap);
static size_t binarySize(const ControlList &list);
int serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer);
int serialize(const ControlList &list, ByteStreamBuffer &buffer);
template<typename T>
T deserialize(ByteStreamBuffer &buffer);
private:
static size_t binarySize(const ControlValue &value);
static size_t binarySize(const ControlInfo &info);
static void store(const ControlValue &value, ByteStreamBuffer &buffer);
static void store(const ControlInfo &info, ByteStreamBuffer &buffer);
ControlValue loadControlValue(ControlType type, ByteStreamBuffer &buffer,
bool isArray = false, unsigned int count = 1);
ControlInfo loadControlInfo(ControlType type, ByteStreamBuffer &buffer);
unsigned int serial_;
std::vector<std::unique_ptr<ControlId>> controlIds_;
std::map<unsigned int, ControlInfoMap> infoMaps_;
std::map<const ControlInfoMap *, unsigned int> infoMapHandles_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_CONTROL_SERIALIZER_H__ */
libcamera::ByteStreamBuffer
Wrap a memory buffer and provide sequential data read and write.
Definition: byte_stream_buffer.h:19
libcamera::ControlInfoMap
A map of ControlId to ControlInfo.
Definition: controls.h:297
libcamera::ControlInfo
Describe the limits of valid values for a Control.
Definition: controls.h:266
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition: controls.h:342
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:116
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:88
libcamera::ControlSerializer::serialize
int serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer)
Serialize a ControlInfoMap in a buffer.
Definition: control_serializer.cpp:173
libcamera::ControlValue
Abstract type representing the value of a control.
Definition: controls.h:93
controls.h
Framework to manage controls related to an object.
libcamera::ControlType
ControlType
Define the data type of a Control.
Definition: controls.h:23