#[non_exhaustive]pub struct AudioConfig {Show 14 fields
pub broadcast: Option<Relative>,
pub track: Option<String>,
pub label: Option<String>,
pub codec: AudioCodec,
pub sample_rate: u32,
pub channel_count: u32,
pub layout: Option<AudioLayout>,
pub bitrate: Option<u64>,
pub enabled: bool,
pub description: Option<Bytes>,
pub container: Container,
pub jitter: Option<Duration>,
pub warmup: Option<Duration>,
pub delay: Option<Duration>,
}Expand description
Audio decoder configuration based on WebCodecs AudioDecoderConfig.
This struct contains all the information needed to initialize an audio decoder, including codec-specific parameters, sample rate, and channel configuration.
Reference: https://www.w3.org/TR/webcodecs/#audio-decoder-config
Marked #[non_exhaustive] so additional optional fields can be added
without bumping the major version. External callers build a config with
AudioConfig::new and then assign whichever optional fields they need;
struct-literal construction (with or without ..base) is not available
outside this crate.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.broadcast: Option<Relative>Optional reference to another broadcast that publishes this track, expressed
relative to the broadcast that served this catalog (e.g. ./source). If unset,
the track lives in the same broadcast as the catalog.
Resolve it with Path::resolve: a reference that walks
above the root names no broadcast, so the catalog is rejected.
track: Option<String>The track’s name in its broadcast, when it differs from this entry’s ID: its key in the catalog. Absent means the ID is the track name, as in every catalog before this field.
Set it only when the ID can’t be the name, such as two renditions of same-named tracks
from different broadcasts. Readers resolve the name with
Reference::track; one that predates the
field subscribes to the ID instead.
label: Option<String>Human-readable rendition name for track pickers.
codec: AudioCodecThe codec, see the registry for details: https://w3c.github.io/webcodecs/codec_registry.html
sample_rate: u32The sample rate of the audio in Hz, never zero.
channel_count: u32The number of channels in the audio, never zero.
layout: Option<AudioLayout>What the decoded channels carry, or the codec’s own channel order when absent.
Live state, like video color.
bitrate: Option<u64>The maximum bitrate of the audio track in bits per second, at most 2^53 - 1.
enabled: boolWhether this rendition may be selected. When false, no frames are coming and a consumer must not select it. Only written when false.
description: Option<Bytes>Some codecs include a description so the decoder can be initialized without extra data. If not provided, there may be in-band metadata (marginally higher overhead).
container: ContainerContainer format for frame encoding. Defaults to “legacy” for backward compatibility.
jitter: Option<Duration>The largest media span the publisher hands to the transport behind a frame’s presentation timestamp: the reorder delay of a frame presented after frames decoded behind it, or the span of a batch written together, such as a run of audio packets between video packets in TS. A consumer’s jitter buffer should be at least this large. Absent when the publisher measured none.
Measured from media timestamps alone, so a frame written in presentation order adds nothing, whatever the frame rate; encoder latency and the network don’t count. It only ever grows over the life of a stream.
Serialized as a whole number of milliseconds, rounded up, so an upper bound never rounds down into a promise the publisher can’t keep.
warmup: Option<Duration>After a non-continuous join, decode from the group start, present at start plus warmup, and join that much earlier. Serialized as whole milliseconds, rounded up so presentation never starts early.
delay: Option<Duration>How far this rendition’s frames reach the transport behind the broadcast’s other renditions: a constant offset, either supplied by the publisher or measured as the least its frames trailed the others’ over a window of a second of media, keeping the largest window. Lateness only some frames have, such as B-frame reorder, is left out, since a consumer measures it. Absent on a rendition that trails nothing, and on any rendition the publisher neither supplied nor measured.
A consumer adds a frame duration on top, so a publisher that knows its frames trail by no
more than their own duration, such as an encoder configured not to reorder or queue, states
Some(Duration::ZERO). It is never measured, and is omitted on the
wire like an absent value, which means the same to a consumer. None leaves it to
measurement.
A consumer holds delay + jitter for this rendition and MUST NOT subtract one rendition’s
delay from another’s: each is taken against whichever rendition was ahead, so two need not
share an origin. It only ever grows over the life of a stream, and is serialized like
jitter.
Implementations§
Source§impl AudioConfig
impl AudioConfig
Sourcepub fn new(
codec: impl Into<AudioCodec>,
sample_rate: u32,
channel_count: u32,
) -> Self
pub fn new( codec: impl Into<AudioCodec>, sample_rate: u32, channel_count: u32, ) -> Self
Construct a config with the required fields set and every optional
field cleared. container defaults to Container::default. Fields
are pub, so callers set whatever they need by assignment afterwards.
This is the only path external crates have to build an AudioConfig
since the type is #[non_exhaustive].
Sourcepub fn same_identity(&self, other: &Self) -> bool
pub fn same_identity(&self, other: &Self) -> bool
Whether other keeps this config’s track identity: the fields a consumer cannot change
without reinitializing its decoder or demuxer (codec, description, container,
sample_rate, and channel_count).
A track name always means the same content, so a publisher that changes any of them publishes under a new name; every other field may update in place. See the draft’s Track Identity.