Skip to main content

Producer

Struct Producer 

Source
pub struct Producer<E: CatalogExt = ()> { /* private fields */ }
Expand description

Publishes encoded video frames as a moq track (avc3 / hev1 depending on the codec).

Built on the async side so the track is advertised (and the catalog registered) before the camera opens; this is what lets a subscriber trigger capture on demand. The moq_mux::codec importer for the codec handles catalog registration and framing. E is the catalog’s application extension, defaulting to none. A host carrying its own catalog sections (the FFI bindings use hang::Extra) publishes into a catalog of the same shape.

Implementations§

Source§

impl<E: CatalogExt> Producer<E>

Source

pub fn new( broadcast: Producer, catalog: Producer<E>, rendition: VideoConfig, ) -> Result<Self, Error>

Publish a track carrying rendition into broadcast, registering it in catalog. The frames fed to publish must be in that codec’s framing, which is what the Encoder the rendition was probed from emits.

rendition comes from Config::probe, so it is what the encoder will actually emit rather than a guess. It is published immediately, before anything is encoded, which is what lets a subscriber discover a track an on-demand encoder has not run for yet; because it already says what the first keyframe says, that keyframe confirms the catalog instead of correcting it.

Source

pub fn demand(&self) -> Demand

A watch-only handle to the track’s subscriber demand, created eagerly so subscription state is observable before any frames arrive. Watch it via used / unused.

Source

pub fn publish(&mut self, encoded: &[Encoded]) -> Result<(), Error>

Publish already-encoded frames, each at its own timestamp. Each frame is one whole access unit in the producer’s codec framing.

Source

pub fn discontinuity(&mut self) -> Result<(), Error>

Mark a break in the published timeline: whatever is published next does not continue what came before.

Call this when the encoder stops rather than merely pausing between frames – a capture that goes idle, a source switch, anything that will resume on a re-anchored clock. See Producer::discontinuity for what the marker buys a consumer.

Source

pub fn finish(self) -> Result<(), Error>

Finalize the track.

Consumes the producer: nothing can be published after the track ends, so this is the last call rather than one leaving a dead producer in your hands.

Source

pub fn abort(self, err: Error)

Abort the track with err instead of finishing it cleanly, so subscribers see the real cause rather than moq_net::Error::Dropped.

Consumes the producer, like finish.

Auto Trait Implementations§

§

impl<E = ()> !Freeze for Producer<E>

§

impl<E> RefUnwindSafe for Producer<E>

§

impl<E> Send for Producer<E>

§

impl<E> Sync for Producer<E>

§

impl<E> Unpin for Producer<E>

§

impl<E> UnsafeUnpin for Producer<E>

§

impl<E> UnwindSafe for Producer<E>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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