11#include <promeki/config.h>
12#if PROMEKI_ENABLE_NETWORK
20PROMEKI_NAMESPACE_BEGIN
64 static constexpr uint32_t DefaultMaxValueBytes = 64u * 1024u * 1024u;
73 KlvFrame() : key(0, 0, 0, 0) {}
80 KlvFrame(FourCC k,
const Buffer &buf) : key(k), value(buf) {}
102 explicit KlvReader(IODevice *device) : _device(device) {}
115 Error readHeader(FourCC &key, uint32_t &valueSize);
127 Error readValue(
void *buf, uint32_t size);
137 Error skipValue(uint32_t size);
153 Error readFrame(KlvFrame &out, uint32_t maxValueBytes = KlvFrame::DefaultMaxValueBytes);
156 IODevice *_device =
nullptr;
174 explicit KlvWriter(IODevice *device) : _device(device) {}
186 Error writeHeader(FourCC key, uint32_t valueSize);
198 Error writeValue(
const void *buf, uint32_t size);
208 Error writeFrame(FourCC key,
const void *value, uint32_t size);
211 Error writeFrame(FourCC key);
214 Error writeFrame(FourCC key,
const Buffer &value);
217 Error writeFrame(
const KlvFrame &frame) {
return writeFrame(frame.key, frame.value); }
220 IODevice *_device =
nullptr;