Skip to main content

Transcoder

Trait Transcoder 

Source
pub trait Transcoder: Send {
    // Required method
    fn on_fragment(&mut self, fragment: &Fragment);

    // Provided methods
    fn on_start(&mut self, _ctx: &TranscoderContext) { ... }
    fn on_stop(&mut self) { ... }
}
Expand description

In-process consumer of source Fragment values for one (broadcast, track, rendition) tuple. The 104 A trait is observe-only; 105 B extends the concrete implementations with an output-publish side without changing the trait surface.

Lifecycle is identical to [lvqr_agent::Agent]:

All three calls are wrapped in std::panic::catch_unwind(AssertUnwindSafe(..)) by the crate::TranscodeRunner; see the crate-level docs.

The trait is sync. Transcoders that want async or blocking work (every real gstreamer pipeline) spawn from inside Transcoder::on_start with a bounded channel to a worker thread / task – typical pattern for the 105 B SoftwareTranscoder.

Required Methods§

Source

fn on_fragment(&mut self, fragment: &Fragment)

Process one source fragment.

Synchronous. Heavy work MUST be offloaded to a worker thread spawned in on_start; blocking here back-pressures the per-broadcast drain task with lvqr_fragment::FragmentBroadcaster’s documented RecvError::Lagged skip semantics.

Provided Methods§

Source

fn on_start(&mut self, _ctx: &TranscoderContext)

One-shot setup. Called exactly once before the first Transcoder::on_fragment. Default: no-op.

Source

fn on_stop(&mut self)

One-shot teardown after the source broadcaster closes. Default: no-op.

on_stop does NOT fire when the crate::TranscodeRunnerHandle is dropped mid-stride (the spawned task is aborted). Matches the [lvqr_agent::AgentRunner] shutdown shape.

Implementors§