Struct CompressedAudio¶
Defined in File messages.hpp
Struct Documentation¶
-
struct CompressedAudio¶
A single chunk of a compressed audio bitstream.
Public Functions
-
FoxgloveError encode(uint8_t *ptr, size_t len, size_t *encoded_len)¶
Encoded the CompressedAudio as protobuf to the provided buffer.
On success, writes the serialized length to *encoded_len. If the provided buffer has insufficient capacity, writes the required capacity to *encoded_len and returns FoxgloveError::BufferTooShort. If the message cannot be encoded, writes the reason to stderr and returns FoxgloveError::EncodeError.
- Parameters:
ptr – the destination buffer. must point to at least len valid bytes.
len – the length of the destination buffer.
encoded_len – where the serialized length or required capacity will be written to.
Public Members
-
std::vector<std::byte> data¶
Compressed audio data. Packet duration is determined by the codec during encoding. Messages should generally contain approximately 20 ms of audio.
For each
formatvalue, thedatafield contains compressed audio data serialized as follows:opus:Each message must contain a complete raw Opus packet, without Ogg, WebM, or other container framing, as described in RFC 6716 section 3.
Each packet contains all information necessary for decoding, and may be decoded at any sample rate supported by Opus (8, 12, 16, 24, or 48 kHz).
A single raw Opus packet represents mono or stereo audio; multichannel Opus requires multistream or container metadata and is not supported by this schema.
mp4a.40.2:Each message must contain a complete MPEG-4 AAC-LC ADTS frame, including the ADTS header, as described in section 1.A.3.2 of ISO/IEC 14496-3:2019.
The ADTS header supplies stream parameters such as sample rate and channel configuration.
g726-16,g726-24,g726-32, andg726-40:Each message must contain raw G.726 codewords without WAV, RTP, or other container framing. Codewords may not span messages.
Audio is mono at 8 kHz. The suffix specifies the bitrate in kbps and therefore the number of bits per sample: 2, 3, 4, or 5 respectively.
Codewords are packed beginning with the least-significant bit, as described in RFC 3551 section 4.5.4.
Codewords may cross octet boundaries. To keep every codeword within one message, the message length must be a multiple of 1, 3, 1, or 5 octets for
g726-16,g726-24,g726-32, andg726-40respectively, holding 4, 8, 2, or 8 codewords.Messages form a continuous encoded stream and preserve G.726 predictor and quantizer state across message boundaries.
aal2-g726-16,aal2-g726-24,aal2-g726-32, andaal2-g726-40:These formats have the same requirements as the corresponding
g726-*formats, except codewords use the opposite bit-packing order specified for AAL2.
Public Static Functions
-
static Schema schema()¶
Get the CompressedAudio schema.
The schema data returned is statically allocated.
-
FoxgloveError encode(uint8_t *ptr, size_t len, size_t *encoded_len)¶