Struct RawAudio

Struct Documentation

struct RawAudio

A single block of an audio bitstream.

Public Functions

FoxgloveError encode(uint8_t *ptr, size_t len, size_t *encoded_len)

Encoded the RawAudio 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 block.

std::vector<std::byte> data

Raw audio data without WAV, container, or RTP headers. Samples must be interleaved. Multibyte samples must be little-endian.

For each format value, the data field contains audio sample data serialized as follows:

  • pcm-s16:

    • Each sample is a signed 16-bit PCM value.

    • The byte length must be divisible by 2 * number_of_channels so the block contains complete sample frames.

  • g711-alaw:

    • Each byte is one G.711 A-law encoded sample.

    • The byte length must be divisible by number_of_channels so the block contains complete sample frames.

  • g711-ulaw:

    • Each byte is one G.711 mu-law encoded sample.

    • The byte length must be divisible by number_of_channels so the block contains complete sample frames.

std::string format

Format of the audio data. See the data field description for supported values. Consumers may support a subset of these formats.

uint32_t sample_rate = 0

Sample rate in Hz. This must be greater than zero.

uint32_t number_of_channels = 0

Number of channels in the audio block. This must be greater than zero.

Public Static Functions

static Schema schema()

Get the RawAudio schema.

The schema data returned is statically allocated.