Expand description
Native audio capture, encoding, and decoding for Media over QUIC.
Counterpart to moq-video for audio
tracks, and shaped the same way. Sits on top of [moq_mux] and [hang] and
adds the missing piece for native callers: Rust-native Opus and uncompressed
PCM codecs that turn raw samples into HANG audio tracks and back, plus AAC-LC,
which is what the gateways (RTMP, SRT, HLS, gstreamer) publish. AAC decodes in
software and encodes only through a platform encoder.
capturedescribes an audio source (capture::Config) and grabs buffers per platform: a microphone via cpal (CoreAudio / WASAPI / ALSA) everywhere, or macOS system audio via ScreenCaptureKit.capture::Sourcepicks between them andcapture::deviceslists the inputs and hands back the ids it takes. Opencapture::Produceronce, give each bus or encoder a consumer, and drive itsrunalongside them. Requires thecapturefeature: they don’t exist in a default build.encodeencodes PCM and publishes it throughmoq_mux::container, registering the rendition in thehangcatalog. Two entry points:encode::publish_capturepublishes an already-open capture consumer, returning aPublicationthat reports its state and level, and theDriverthat encodes. Its rendition is registered before processing samples. Capture keeps running while raw audio waits for a subscriber, then encodes that history and continues live. Setencode::Capture::retainto false to encode continuously instead.encode::Producerpublishes PCM you hand it.
decodesubscribes to an encoded track and decodes it back to PCM.decode::Consumeris the mirror ofencode::Producer. It reads AAC-LC too, since a broadcast that came in through a gateway is AAC rather than one of the codecs we encode in software.playbackplays decoded PCM out a speaker.playback::Engineowns the output device and mixes theplayback::Sinks registered with it, so one device serves every track in a call. Requires theplaybackfeature, so these names are unlinked here too.busmixes any number of PCM sources, each with its own gain, mute, pan, sync delay, and meter, into several mixes advanced on the caller’s own clock: a studio’s program audio and its return feeds.aeckeeps the speaker out of the microphone, which is what a conference on a laptop needs to not send itself back.aec::Processorprocesses PCM supplied by any audio stack without enabling device features. With bothcaptureandplayback,playback::Engine::cancellerwires it tocapture::Config::aec.
Format mirrors WebCodecs AudioData.format; the helpers convert between
any supported layout and the interleaved f32 representation libopus
expects. Frame is a thin owned buffer: a timestamp, a payload, and the
Activity it was decoded from, which is how a caller tells coded audio
from the frames an Opus sender withholds while its input is silent. PCM
layout lives on the producer / consumer via encode::Input /
decode::Output, not on each frame, so callers can’t drift between calls.
Modules§
- aec
- Acoustic echo cancellation: keep the speaker out of the microphone.
- bus
- Route PCM sources into several mixes, advanced on the caller’s clock.
- capture
- Audio capture: a microphone via
cpal(pure-Rust: CoreAudio / WASAPI / ALSA), or macOS system audio via ScreenCaptureKit. - decode
- Subscribe to an encoded audio track and decode it to raw PCM.
- encode
- Encode raw PCM and publish it as a moq audio track.
- playback
- Play decoded PCM out a speaker, via
cpal(CoreAudio / WASAPI / ALSA).
Structs§
- Frame
- One unit of raw PCM crossing the codec boundary: what
encode::Producer::writetakes and whatdecode::Read::Framecarries. - Level
- How loud a stretch of audio was, for drawing a meter.