1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//! [`Transcoder`] trait + [`TranscoderFactory`] + [`TranscoderContext`].
//!
//! Mirrors [`lvqr_agent::Agent`] / [`lvqr_agent::AgentFactory`]
//! with a [`RenditionSpec`] carried through the context, so a
//! single factory type (e.g. `SoftwareTranscoderFactory` in
//! session 105 B) can be instantiated multiple times, once per
//! rendition, to produce an ABR ladder.
use ;
use crateRenditionSpec;
/// Snapshot of the `(broadcast, track, FragmentMeta, rendition)`
/// tuple a fresh [`Transcoder`] sees at construction time.
///
/// `meta` is a snapshot at transcoder-build time; see the same
/// caveat as [`lvqr_agent::AgentContext::meta`]. For the 4.6
/// software / hardware encoders the codec + timescale never
/// change mid-broadcast, so the snapshot is sufficient.
/// 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`]:
///
/// * [`Transcoder::on_start`] runs exactly once before the first
/// [`Transcoder::on_fragment`].
/// * [`Transcoder::on_fragment`] fires for every source fragment.
/// * [`Transcoder::on_stop`] runs exactly once after the source
/// [`lvqr_fragment::BroadcasterStream`] closes (every producer
/// clone dropped).
///
/// 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`.
/// Factory that builds a [`Transcoder`] for one specific
/// rendition of one specific `(broadcast, track)` stream.
///
/// One factory instance per rendition: for an ABR ladder of three
/// rungs the caller registers three factory instances on the
/// [`crate::TranscodeRunner`], each carrying its own
/// [`RenditionSpec`]. The factory either returns a fresh
/// `Box<dyn Transcoder>` (one instance per source stream the
/// factory opts into) or `None` to skip this stream.
///
/// `Send + Sync + 'static` so the factory lives behind an `Arc`
/// shared across the registry callback's worker thread.