/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2019, Google Inc. * * Control (de)serializer */ #pragma once #include #include #include #include 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 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> controlIds_; std::vector> controlIdMaps_; std::map infoMaps_; std::map infoMapHandles_; }; } /* namespace libcamera */