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
impl Publisher
Sourcepub fn new<E: CatalogExt>(
track: Producer,
reserved: Reserved<E>,
rendition: VideoConfig,
) -> Result<Self, Error>
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.
Sourcepub fn demand(&self) -> Demand
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.
Sourcepub fn abort_handle(&self) -> AbortHandle
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.
Sourcepub fn publish(&mut self, encoded: &Encoded) -> Result<(), Error>
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.
Sourcepub fn discontinuity(&mut self) -> Result<(), Error>
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.
Sourcepub fn set_enabled(&mut self, enabled: bool) -> Result<(), Error>
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.
Sourcepub fn abort(self, err: Error)
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.