Expand description
Native audio encoding and decoding for Media over QUIC.
Sits on top of moq_mux and hang and adds the missing piece
for native callers: a Rust-native Opus codec implementation that
turns raw PCM into the bitstreams moq_mux::codec::opus already
knows how to ingest (and vice versa for decode).
AudioFormatmirrors WebCodecsAudioData.format. The helpers convert between any supported layout and the interleavedf32representation libopus expects.Frameis a thin owned buffer: just a timestamp and a payload. PCM layout lives on theEncoder/DecoderviaEncoderInput/EncoderOutput/DecoderOutput, not on each frame, so callers can’t drift between calls.Encoder/Decoderare the Opus codec types.AudioProducer/AudioConsumerwire those together withmoq_mux::containerand thehangcatalog.
Re-exports§
pub use consumer::AudioConsumer;pub use producer::AudioProducer;
Modules§
- consumer
- Subscribe to an encoded audio track and emit raw PCM.
- producer
- Publish raw PCM as encoded audio in a moq broadcast.
Structs§
- Decoder
- Opus decoder producing interleaved
f32PCM. - Decoder
Output - PCM layout the caller wants out of
Decoder::decode_f32/AudioConsumer::read.sample_rateandchannelsNonemeans “match the codec’s native shape from the catalog”. - Encoder
- Opus encoder over the PCM layout declared in
EncoderInput. - Encoder
Input - PCM layout the caller hands to
Encoder::encode_f32/AudioProducer::write. - Encoder
Output - Codec-side configuration.
sample_rateandchannelsare optional overrides;Nonemeans “match input (snapping the rate up to a libopus-supported value if necessary)”. - Frame
- One unit of audio passed across the codec boundary.
- Resampler
- Sample-rate converter over interleaved
f32PCM.
Enums§
- Audio
Error - Errors returned by
moq-audio. - Audio
Format - Raw PCM sample format.
- Codec
- Codec identifier. Opus is the only variant today; AAC may follow.
Functions§
- pick_
opus_ rate - Snap an arbitrary sample rate up to the nearest libopus-supported rate (8/12/16/24/48 kHz); falls back to 48 kHz for anything above.