From 2c5f0ad23aa40d7410b28e01405c730e75c6cf83 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 26 Oct 2019 20:25:56 +0300 Subject: libcamera: Add controls serializer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new ControlSerializer helper to serialize and deserialize ControlInfoMap and ControlList instances. This will be used to implement the C IPA protocol and the communication with IPA through IPC. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/include/control_serializer.h | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/libcamera/include/control_serializer.h (limited to 'src/libcamera/include/control_serializer.h') diff --git a/src/libcamera/include/control_serializer.h b/src/libcamera/include/control_serializer.h new file mode 100644 index 00000000..bb3cb8e7 --- /dev/null +++ b/src/libcamera/include/control_serializer.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * control_serializer.h - Control (de)serializer + */ +#ifndef __LIBCAMERA_CONTROL_SERIALIZER_H__ +#define __LIBCAMERA_CONTROL_SERIALIZER_H__ + +#include +#include +#include + +#include + +namespace libcamera { + +class ByteStreamBuffer; + +class ControlSerializer +{ +public: + void reset(); + + static size_t binarySize(const ControlInfoMap &info); + static size_t binarySize(const ControlList &list); + + int serialize(const ControlInfoMap &info, ByteStreamBuffer &buffer); + int serialize(const ControlList &list, ByteStreamBuffer &buffer); + + template + T deserialize(ByteStreamBuffer &buffer); + +private: + static size_t binarySize(const ControlValue &value); + static size_t binarySize(const ControlRange &range); + + static void store(const ControlValue &value, ByteStreamBuffer &buffer); + static void store(const ControlRange &range, ByteStreamBuffer &buffer); + + template + T load(ControlType type, ByteStreamBuffer &b); + + unsigned int serial_; + std::vector> controlIds_; + std::map infoMaps_; + std::map infoMapHandles_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_CONTROL_SERIALIZER_H__ */ -- cgit v1.2.1