Struct CompressedAudio

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::optional<Timestamp> timestamp

Timestamp of the start of the audio chunk.

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.

  • 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.

std::string format

Audio format. Values supported by Foxglove are opus for raw Opus packets and mp4a.40.2 for AAC-LC ADTS frames.

Public Static Functions

static Schema schema()

Get the CompressedAudio schema.

The schema data returned is statically allocated.