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
//! Lossless conversion of DPI / timed-metadata signalling between SCTE-35,
//! HLS `#EXT-X-DATERANGE` and DASH `emsg` (ISO/IEC 23009-1 §5.10.3.3,
//! ANSI/SCTE 214-1:2024 §7.7). `no_std` + `alloc`; it depends on
//! `broadcast-common`, `broadcast-core`, `broadcast-hls`, `isobmff`, `jiff`
//! and `scte35-splice`. `caption-convert`, `transmux`, `hls-runtime`,
//! `media-plane`, `multimux`, `media-doctor` and `compliance-probe` use it.
//! The original `splice_info_section` bytes are carried verbatim, so an
//! event can always be rendered back to its source form.
//!
//! # Quickstart
//!
//! Take one real SCTE-35 cue, render it as an HLS date range and a DASH
//! `emsg`, then recover the original bytes from the `emsg`.
//!
//! ```rust
//! use broadcast_core::timescale::Timescale;
//! use isobmff::emsg::PresentationTime;
//! use timed_metadata::convert::{EmsgConfig, emsg_to_scte35};
//! use timed_metadata::{TimeAnchor, Timeline};
//!
//! let hex = "FC302100000000000000FFF01005000007D27FEF7F7E0020F580C0000000000088B9661D";
//! let raw: Vec<u8> = (0..hex.len())
//! .step_by(2)
//! .map(|index| u8::from_str_radix(&hex[index..index + 2], 16).unwrap())
//! .collect();
//! let anchor = TimeAnchor { pts_90k: 0, utc_epoch_ms: 1_705_320_000_000 };
//! let mut timeline = Timeline::new(anchor);
//! let event = timeline.push_scte35(&raw).unwrap();
//!
//! let line = timeline.to_daterange(&event).unwrap().to_tag_line().unwrap();
//! assert!(line.starts_with("#EXT-X-DATERANGE:"));
//!
//! let config = EmsgConfig::new(
//! Timescale::try_new(90_000).expect("a non-zero timescale"),
//! PresentationTime::Absolute(90_000),
//! Some(24 * 90_000),
//! "34".to_string(),
//! event.id.unwrap_or(0),
//! );
//! let emsg = timeline.to_emsg(&event, &config).unwrap();
//! assert_eq!(emsg_to_scte35(&emsg).unwrap(), raw);
//! ```
//!
//! # How do I...
//!
//! - Convert SCTE-35 to a date range: [`convert::scte35_to_daterange`] or
//! [`Timeline::to_daterange`], `examples/scte35_to_hls.rs`.
//! - Convert SCTE-35 to a DASH `emsg`: [`convert::scte35_to_emsg`] or
//! [`Timeline::to_emsg`], `examples/scte35_to_dash.rs`.
//! - Recover SCTE-35 bytes from an `emsg`: [`convert::emsg_to_scte35`],
//! `examples/scte35_to_dash.rs`.
//! - Re-time an `emsg` between versions 0 and 1: [`convert::emsg_to_v0`] and
//! [`convert::emsg_to_v1`], `examples/scte35_to_dash.rs`.
//! - Map PTS to UTC and unwrap 33-bit timestamps: [`Timeline`] and
//! [`TimeAnchor`], `examples/scte35_to_hls.rs`.
//! - Unroll PTS outside a session: [`PtsUnroller`], `examples/scte35_to_hls.rs`.
//! - Read a neutral event's id, kind and source: [`TimedEvent`] and
//! [`SourcePayload`], `examples/scte35_to_hls.rs`.
//! - Handle typed conversion failures: [`Error`], `examples/scte35_to_hls.rs`.
//!
//! # Modules
//!
//! Session: [`timeline`] (PTS/UTC timeline and event session), [`anchor`]
//! (PTS-to-wall-clock anchor).
//!
//! Conversion: [`convert`] (pure format conversions and their configuration),
//! [`event`] (neutral event model).
//!
//! Shared vocabulary: [`error`] (typed conversion failures).
//!
//! # Feature flags
//!
//! - `std` (default): `std::error::Error` impls and `std` in dependencies.
//! - `serde`: `Serialize`/`Deserialize` on supported public types.
//!
//! # Spec citations
//!
//! ANSI/SCTE 35 §7.7 (`splice_info_section`), ANSI/SCTE 214-1:2024 §7.7.1(2),
//! §7.7.3 (`private/specs-verified/scte/dash/scte-214-1-2024.md`); RFC 8216bis
//! §4.4.5.1 (`EXT-X-DATERANGE`); ISO/IEC 23009-1 §5.10.3.3 (`emsg`).
extern crate alloc;
;
pub use TimeAnchor;
pub use ;
pub use ;
pub use ;