Skip to main content

Publisher

Struct Publisher 

Source
pub struct Publisher { /* private fields */ }
Expand description

Publishes already-encoded video frames as a moq track (avc3 / hev1 depending on the codec), for a caller that runs its own encoder.

The moq_mux::codec importer for the codec handles catalog registration and framing. Producer runs the encoder too, and follows the uplink’s grant.

Implementations§

Source§

impl Publisher

Source

pub fn new<E: CatalogExt>( track: Producer, reserved: Reserved<E>, rendition: VideoConfig, ) -> Result<Self, Error>

Publish rendition on track, registering it under reserved, a catalog::Producer::reserve that carries any per-track hint such as the encoder’s GOP duration (Reserved::with_interval). 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 wanted / wanted_changed.

Source

pub fn abort_handle(&self) -> AbortHandle

A handle that aborts the published track without keeping it open, for an owner that must end it while this publisher is busy elsewhere.

Source

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

Publish one already-encoded frame at its own timestamp: 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 set_enabled(&mut self, enabled: bool) -> Result<(), Error>

Advertise whether this rendition is being encoded, as the catalog’s enabled.

Disable it when the encoder stops for lack of bandwidth (a rate::Target::Disabled), so viewers select a lower rendition instead of waiting for frames, and mark the discontinuity too. The advertised rendition is otherwise unchanged, its maximum bitrate included. Enable it again with the keyframe that resumes it.

Source

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

Finalize the track.

Consumes the publisher, releasing the splitter. The returned Finished keeps the track and its catalog rendition published, and can still abort them. A finish that fails ends the track with an error instead.

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.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

Source§

fn upcast(&self) -> Option<&T>

Source§

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

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