pub struct Consumer { /* private fields */ }Expand description
Subscribe to a moq-mux audio track and emit decoded PCM in the layout
declared by Config.
The mirror of encode::Producer: output format /
sample rate / channel count 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>,
config: Config,
) -> Result<Self, Error>
pub async fn new( broadcast: &Consumer, catalog: &AudioConfig, name: impl Into<String>, config: Config, ) -> Result<Self, Error>
Subscribe to name in broadcast, using the catalog entry to pick the
codec.
Sourcepub fn latency_max(&self) -> Duration
pub fn latency_max(&self) -> Duration
The effective latency 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
Config::sample_rate resolved against the catalog.
Sourcepub fn channels(&self) -> u32
pub fn channels(&self) -> u32
Channel count samples are actually delivered at, which is
Config::channels 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.