Loading...
Searching...
No Matches
control_serializer.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* Control (de)serializer
*/
#pragma once
#include <map>
#include <memory>
#include <vector>
#include <libcamera/controls.h>
namespace libcamera {
class ByteStreamBuffer;
class ControlSerializer
{
public:
enum class Role {
Proxy,
Worker
};
ControlSerializer(Role role);
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);
bool isCached(const ControlInfoMap &infoMap);
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);
void populateControlValueEntry(struct ipa_control_value_entry &entry,
const ControlValue &value,
uint32_t offset);
ControlValue loadControlValue(ByteStreamBuffer &buffer,
ControlType type,
bool isArray, unsigned int count);
unsigned int serial_;
unsigned int serialSeed_;
std::vector<std::unique_ptr<ControlId>> controlIds_;
std::vector<std::unique_ptr<ControlIdMap>> controlIdMaps_;
std::map<unsigned int, ControlInfoMap> infoMaps_;
std::map<const ControlInfoMap *, unsigned int> infoMapHandles_;
};
} /* 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:365
libcamera::ControlInfo
Describe the limits of valid values for a Control.
Definition controls.h:330
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition controls.h:409
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::ControlSerializer
ControlSerializer(Role role)
Construct a new ControlSerializer.
Definition control_serializer.cpp:106
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:673
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.
Definition control_serializer.h:25
libcamera::ControlSerializer::Role::Proxy
@ Proxy
The control serializer is used by the IPC Proxy classes.
Definition control_serializer.h:24
libcamera::ControlSerializer::deserialize
T deserialize(ByteStreamBuffer &buffer)
Deserialize an object from a binary buffer.
libcamera::ControlSerializer::serialize
int serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer)
Serialize a ControlInfoMap in a buffer.
Definition control_serializer.cpp:225
libcamera::ControlValue
Abstract type representing the value of a control.
Definition controls.h:134
controls.h
Framework to manage controls related to an object.
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
libcamera::ControlType
ControlType
Define the data type of a Control.
Definition controls.h:29
libcamera::ipa_control_value_entry
Description of a serialized ControlValue entry.
Definition ipa_controls.h:36