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
//! Crate error type.
use alloc::string::String;
use broadcast_core::timescale::Timescale;
/// Errors produced by conversions and the [`crate::Timeline`] session.
#[derive(Debug, thiserror::Error, Clone, PartialEq)]
#[non_exhaustive]
pub enum Error {
/// A wall-clock conversion was attempted without a [`crate::TimeAnchor`].
#[error("wall-clock conversion requires a TimeAnchor, but none was set")]
MissingAnchor,
/// SCTE 35 `emsg` cannot be version 0: ANSI/SCTE 214-1:2024 §7.7.1(2),
/// `private/specs-verified/scte/dash/scte-214-1-2024.md`.
#[error("SCTE 35 emsg version 0 is not allowed; supply a version 1 presentation_time")]
Scte35EmsgVersionZero,
/// `emsg_to_v0` was asked to write a SCTE 35 `emsg`, which 214-1 2024 §7.7.1(2) forbids.
#[error("SCTE 35 emsg cannot be converted to version 0 (ANSI/SCTE 214-1:2024 §7.7.1(2))")]
Scte35EmsgVersionZeroConversion,
/// An emsg presented to [`crate::convert::emsg_to_scte35`] is not a
/// SCTE-35 carriage scheme.
#[error("emsg scheme {scheme:?} is not a SCTE-35 carriage scheme")]
#[non_exhaustive]
UnsupportedScheme {
/// The `emsg` `scheme_id_uri` that was rejected, verbatim.
scheme: String,
},
/// SCTE-35 parse failure.
#[error("SCTE-35: {0}")]
Scte35(#[from] scte35_splice::Error),
/// emsg parse/serialize failure.
#[error("emsg: {0}")]
Emsg(#[from] isobmff::Error),
/// `EXT-X-DATERANGE` tag could not be parsed.
#[error("DATERANGE parse: {0}")]
AttrParse(String),
/// A SCTE-35-sourced event has no `id` (e.g. a `time_signal` cue with no
/// `segmentation_descriptor`), so it cannot be given a `DATERANGE` `ID`
/// (RFC 8216bis §4.4.5.1 requires unique IDs; emitting `ID=""` would
/// silently collide across cues).
#[error("SCTE-35 event has no id; cannot produce a DATERANGE ID")]
MissingEventId,
/// emsg ↔ SegmentTiming `timescale` mismatch.
#[error("emsg timescale ({emsg}) does not match SegmentTiming timescale ({timing})")]
#[non_exhaustive]
EmsgTimescaleMismatch {
/// The `timescale` declared by the `emsg` box.
emsg: Timescale,
/// The `timescale` declared by the DASH `SegmentTiming`.
timing: Timescale,
},
/// The emsg states a `timescale` of 0, which no time can be read in.
#[error("emsg timescale is 0")]
EmsgZeroTimescale,
/// v0 emsg cannot carry an event starting before the segment EPT.
#[error("presentation time precedes earliest presentation time; cannot express as v0 delta")]
EmsgPresentationTimeBeforeEpt,
/// v0 `presentation_time_delta` overflowed u32.
#[error("presentation_time_delta value {0} exceeds u32 max")]
EmsgDeltaOverflow(u64),
/// A v0 emsg's `earliest_presentation_time + presentation_time_delta`
/// overflowed `u64` (ISO/IEC 23009-1 §5.10.3.3); a wrapped value would
/// silently place the event near time zero.
#[error("earliest presentation time + presentation_time_delta overflows u64")]
EmsgPresentationTimeOverflow,
/// The emsg carries a `PresentationTime` variant this crate does not
/// know how to convert (the enum is `#[non_exhaustive]` upstream).
#[error("unsupported emsg PresentationTime variant")]
UnsupportedPresentationTime,
/// A `DATERANGE` attribute value (`ID`, `CLASS`, or a `SCTE35-*` hex
/// token) could not be represented as an RFC 8216 §4.2 quoted-string —
/// contains `"`, CR or LF (issue #1140 / audit r12-TM-W4): these values
/// are frequently sourced from an upstream SCTE-35 segmentation
/// descriptor's `segmentation_upid`, which is caller/network data, not
/// this crate's own.
#[error(transparent)]
HlsAttrValue(#[from] broadcast_hls::Error),
/// `DURATION`/`PLANNED-DURATION` was NaN, infinite, or negative (issue
/// #1140 / audit r13-BH-W4-class). RFC 8216 decimal-floating-point is
/// non-negative and finite.
#[error("{what} must be a finite, non-negative number of seconds, got {value}")]
#[non_exhaustive]
InvalidDuration {
/// Which attribute failed (`"DURATION"` or `"PLANNED-DURATION"`).
what: &'static str,
/// The offending value.
value: f64,
},
/// A wall-clock instant is outside the range RFC 3339 formatting supports
/// (years -9999..=9999).
#[error(
"epoch milliseconds {0} are outside the representable RFC 3339 range (years -9999..=9999)"
)]
TimestampOutOfRange(i64),
}
/// Crate result alias.
pub type Result<T> = core::result::Result<T, Error>;