Skip to main content

ll_hls_runtime/client/
output.rs

1//! Output events — [`Output`] out of [`crate::client::LlHlsClient::next_output`].
2
3use alloc::vec::Vec;
4
5use transmux::Sample;
6
7/// One unit of decoded output, drained in order via
8/// [`crate::client::LlHlsClient::next_output`].
9///
10/// The ordering contract: exactly one [`Output::Init`] is emitted before any
11/// [`Output::Samples`] for a given track, and `Samples` are emitted in decode
12/// order with no gap and no repeat — a fetched Part's samples are emitted
13/// exactly once, whether it arrived as a standalone Part fetch or was
14/// coalesced into its parent's closed-segment view (see the crate docs'
15/// "Dedup" section).
16#[derive(Debug, Clone)]
17#[non_exhaustive]
18pub enum Output {
19    /// The Media Initialization Section bytes (`ftyp`+`moov`, RFC 8216bis
20    /// §4.4.4.5's `EXT-X-MAP` resource) — hand to the decoder once before any
21    /// `Samples`. Re-emitted only when the playlist's `EXT-X-MAP` changes
22    /// (e.g. across an `EXT-X-DISCONTINUITY`).
23    Init(Vec<u8>),
24    /// Newly available coded samples (access units) for one track, in decode
25    /// order, demuxed from a fetched Part or Segment resource via
26    /// `transmux::Fmp4Demux`.
27    Samples {
28        /// Track ID, matching the `moov`'s `trak.tkhd.track_ID` (ISO/IEC
29        /// 14496-12 §8.3.2) carried by the preceding [`Output::Init`].
30        track_id: u32,
31        /// The samples, in decode order.
32        samples: Vec<Sample>,
33    },
34    /// `EXT-X-DISCONTINUITY` (RFC 8216 §4.3.4.3): the encoding, timestamps,
35    /// tracks, or codec parameters may have changed between the previously
36    /// emitted samples and the ones that follow this marker. Forwarded
37    /// verbatim so the sink can flush/reset its decoder pipeline.
38    Discontinuity,
39    /// The playlist reached `#EXT-X-ENDLIST` (RFC 8216 §4.3.3.4) with no
40    /// further open segment or preload hint outstanding — playback is
41    /// complete, no more output will ever be produced.
42    EndOfStream,
43}