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>
impl<E: CatalogExt> Producer<E>
Sourcepub fn new(
broadcast: Producer,
catalog: Producer<E>,
rendition: VideoConfig,
) -> Result<Self, Error>
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.
Sourcepub fn publish(&mut self, encoded: &[Encoded]) -> Result<(), Error>
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.
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 finish(self) -> Result<(), Error>
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.
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.
Consumes the producer, like finish.