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