Skip to main content

Consumer

Struct Consumer 

Source
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

Source

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.

Source

pub fn name(&self) -> &str

The decoder backend name in use, e.g. "libopus" or "symphonia".

Source

pub fn options(&self) -> &Options

The options this consumer was built with.

Source

pub fn max_delay(&self) -> Duration

The effective skip budget after clamping to the track’s max age, excluding decoder warmup.

Source

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.

Source

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.

Source

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.

Source

pub fn sample_rate(&self) -> u32

Sample rate samples are actually delivered at, which is Output::sample_rate resolved against the catalog.

Source

pub fn layout(&self) -> Layout

Layout samples are actually delivered in.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more