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 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.