libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
ancst2020audio.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
13#include <cstdint>
14#include <promeki/buffer.h>
15#include <promeki/datatype.h>
16#include <promeki/error.h>
17#include <promeki/json.h>
18#include <promeki/namespace.h>
19#include <promeki/result.h>
20#include <promeki/string.h>
21
22PROMEKI_NAMESPACE_BEGIN
23
24class DataStream;
25
104class AncSt2020Audio {
105 public:
106 PROMEKI_DATATYPE(AncSt2020Audio, DataTypeSt2020Audio, 1)
107
108
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,
120 };
121
125 static constexpr size_t MaxSinglePacketBytes = 254;
126
129 static constexpr size_t MaxMetadataFrameBytes = 2 * MaxSinglePacketBytes;
130
133 static constexpr uint8_t PayloadDescriptorCompatibilityBit = 0x80;
134
138 static constexpr uint8_t PayloadDescriptorVersionV1 = 0x08;
139
141 static constexpr uint8_t PayloadDescriptorDoubleBit = 0x04;
142
144 static constexpr uint8_t PayloadDescriptorSecondBit = 0x02;
145
147 static constexpr uint8_t PayloadDescriptorDuplicateBit = 0x01;
148
151 static constexpr uint8_t PayloadDescriptorVersionMask = 0x18;
152
154 AncSt2020Audio() = default;
155
156 // -- Channel pair association ----------------------------
157
159 uint8_t channelPair() const { return _channelPair; }
160
162 void setChannelPair(uint8_t v) { _channelPair = v; }
163
164 // -- Duplicate flag --------------------------------------
165
175 bool duplicate() const { return _duplicate; }
176
178 void setDuplicate(bool b) { _duplicate = b; }
179
180 // -- Metadata frame --------------------------------------
181
183 const Buffer &metadataFrame() const { return _metadataFrame; }
184
195 void setMetadataFrame(Buffer bytes) { _metadataFrame = std::move(bytes); }
196
197 // -- Comparison -----------------------------------------
198
200 bool operator==(const AncSt2020Audio &o) const {
201 return _channelPair == o._channelPair && _duplicate == o._duplicate &&
202 _metadataFrame == o._metadataFrame;
203 }
204
206 bool operator!=(const AncSt2020Audio &o) const { return !(*this == o); }
207
208 // -- Diagnostics ----------------------------------------
209
211 String toString() const;
212
214 JsonObject toJson() const;
215
216 // -- DataStream -----------------------------------------
217
219 Error writeToStream(DataStream &s) const;
220
222 template <uint32_t V> static Result<AncSt2020Audio> readFromStream(DataStream &s);
223
224 private:
225 uint8_t _channelPair = NoAssociation;
226 bool _duplicate = false;
227 Buffer _metadataFrame;
228};
229
230PROMEKI_NAMESPACE_END
231
232#endif // PROMEKI_ENABLE_PROAV