pub struct Consumer { /* private fields */ }Expand description
Subscribe to a moq-mux audio track and emit decoded PCM in the requested
Output.
The mirror of encode::Producer: output format /
sample rate / layout are fixed at construction, and
read returns Read events carrying decoded samples and track boundaries.
Implementations§
Source§impl Consumer
impl Consumer
Sourcepub async fn new(
broadcast: &Consumer,
catalog: &AudioConfig,
name: impl Into<String>,
options: Options,
) -> Result<Self, Error>
pub async fn new( broadcast: &Consumer, catalog: &AudioConfig, name: impl Into<String>, options: Options, ) -> Result<Self, Error>
Subscribe to name in broadcast, using the catalog entry to pick the
codec.
Sourcepub fn max_delay(&self) -> Duration
pub fn max_delay(&self) -> Duration
The effective skip budget after clamping to the track’s max age, excluding decoder warmup.
Sourcepub fn set_max_delay(&mut self, max: Duration)
pub fn set_max_delay(&mut self, max: Duration)
Move Delay::max mid-stream, clamped to the track’s max age like Options::delay.
A player whose playout delay moves calls this to keep the subscription reaching as far
behind it, as moq play keeps it at the delay plus its time stretch.
A history subscription, Start::Oldest with no Delay::max, reads every group in
order and ignores it: the transport delivers nothing past a missing group, so there is no
budget to skip at.
Sourcepub fn set_priority(&mut self, priority: i8)
pub fn set_priority(&mut self, priority: i8)
Move Options::priority mid-stream, updating the subscription in place rather than
resubscribing, so nothing already fetched is dropped or fetched again.
Sourcepub fn delay(&self) -> Duration
pub fn delay(&self) -> Duration
The playout delay to hold ahead of the playhead right now: the fixed
Delay::min, or with Options::estimate the estimate from every frame read so far.
The estimate measures when each packet landed in this node’s cache
([moq_mux::container::Consumer::arrival]), so neither a hole the container waits out nor
a late read holds the packets behind it as jitter.
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
Sample rate samples are actually delivered at, which is
Output::sample_rate resolved against the catalog.
Sourcepub fn backpressure(&mut self) -> Backpressure
pub fn backpressure(&mut self) -> Backpressure
Gate decoding behind the returned Backpressure, replacing any earlier gate.
read keeps reading packets as they arrive and holds them encoded
until the gate admits them. Dropping the handle decodes every packet as it arrives
again.
Sourcepub fn arrival(&self) -> Option<Instant>
pub fn arrival(&self) -> Option<Instant>
When the packet behind the latest decoded frame landed in this node’s cache
([moq_mux::container::Consumer::arrival]), which a hole or a gate holding it encoded
may have kept well before read handed the frame over.
Sourcepub async fn read(&mut self) -> Result<Option<Read>, Error>
pub async fn read(&mut self) -> Result<Option<Read>, Error>
Read decoded PCM or a track boundary, or None when the track ends.
Frame::activity reports whether the packet these samples came from
coded audio. It describes where the frame begins, so a resampled
frame that straddles a change carries the activity its first sample came
from and the next frame carries the new one.
A timestamp that doesn’t continue the previous packet is a hole in the output, not a splice: nothing is carried across it, and the frames on either side stay anchored to their own packet timeline, so the hole is there to see. “Doesn’t continue” allows for the quantization the stamps carry, which on a millisecond-stamped ingest is most of a millisecond.