11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
22PROMEKI_NAMESPACE_BEGIN
104class AncSt2020Audio {
106 PROMEKI_DATATYPE(AncSt2020Audio, DataTypeSt2020Audio, 1)
110 enum ChannelPair : uint8_t {
111 NoAssociation = 0x01,
112 ChannelPair1_2 = 0x02,
113 ChannelPair3_4 = 0x03,
114 ChannelPair5_6 = 0x04,
115 ChannelPair7_8 = 0x05,
116 ChannelPair9_10 = 0x06,
117 ChannelPair11_12 = 0x07,
118 ChannelPair13_14 = 0x08,
119 ChannelPair15_16 = 0x09,
125 static constexpr size_t MaxSinglePacketBytes = 254;
129 static constexpr size_t MaxMetadataFrameBytes = 2 * MaxSinglePacketBytes;
133 static constexpr uint8_t PayloadDescriptorCompatibilityBit = 0x80;
138 static constexpr uint8_t PayloadDescriptorVersionV1 = 0x08;
141 static constexpr uint8_t PayloadDescriptorDoubleBit = 0x04;
144 static constexpr uint8_t PayloadDescriptorSecondBit = 0x02;
147 static constexpr uint8_t PayloadDescriptorDuplicateBit = 0x01;
151 static constexpr uint8_t PayloadDescriptorVersionMask = 0x18;
154 AncSt2020Audio() =
default;
159 uint8_t channelPair()
const {
return _channelPair; }
162 void setChannelPair(uint8_t v) { _channelPair = v; }
175 bool duplicate()
const {
return _duplicate; }
178 void setDuplicate(
bool b) { _duplicate = b; }
183 const Buffer &metadataFrame()
const {
return _metadataFrame; }
195 void setMetadataFrame(Buffer bytes) { _metadataFrame = std::move(bytes); }
200 bool operator==(
const AncSt2020Audio &o)
const {
201 return _channelPair == o._channelPair && _duplicate == o._duplicate &&
202 _metadataFrame == o._metadataFrame;
206 bool operator!=(
const AncSt2020Audio &o)
const {
return !(*
this == o); }
211 String toString()
const;
214 JsonObject toJson()
const;
219 Error writeToStream(DataStream &s)
const;
222 template <u
int32_t V>
static Result<AncSt2020Audio> readFromStream(DataStream &s);
225 uint8_t _channelPair = NoAssociation;
226 bool _duplicate =
false;
227 Buffer _metadataFrame;