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 Frames carrying the codec activity they
were decoded from.
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_age(&self) -> Duration
pub fn max_age(&self) -> Duration
The effective age budget after clamping to the publisher’s retention window.
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 async fn read(&mut self) -> Result<Option<Frame>, Error>
pub async fn read(&mut self) -> Result<Option<Frame>, Error>
Read the next decoded PCM frame, 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.