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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//! Errors returned by DASH parsing and fragment streaming.
/// Errors that can occur when parsing a DASH manifest or streaming fragments.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// Manifest was not a base64-encoded `data:` URL
#[error("Invalid DASH manifest data URL")]
InvalidDataUrl,
/// Base64-encoded data URL could not be decoded
#[error("DASH manifest base64 decoding failed: {0}")]
DataUrlBase64(#[from] base64::DecodeError),
/// Decoded data URL payload was not valid UTF-8
#[error("DASH manifest UTF-8 decoding failed: {0}")]
DataUrlUtf8(#[from] std::string::FromUtf8Error),
/// MPEG-DASH manifest XML could not be parsed
#[error("MPEG-DASH manifest parsing failed: {0}")]
DashManifestParse(#[from] crate::vendor::dash_mpd_core::DashMpdError),
/// An MPEG-DASH representation did not include an initialization URL
#[error("MPEG-DASH representation is missing an initialization URL")]
DashManifestMissingUrls,
/// MPEG-DASH manifest did not contain any representations
#[error("MPEG-DASH manifest contains no representations")]
DashManifestMissingRepresentations,
/// An MPEG-DASH representation did not have an ID
#[error("MPEG-DASH representation is missing its ID")]
DashManifestMissingRepresentationId,
/// No MPEG-DASH representation matched the requested ID or format token
#[error("MPEG-DASH representation not found: {0}")]
DashManifestMissingRepresentation(String),
/// A MPEG-DASH representation had neither a SegmentTimeline nor a
/// SegmentTemplate@duration, or its SegmentTimeline was empty
#[error(
"MPEG-DASH representation has neither a SegmentTimeline nor a SegmentTemplate@duration"
)]
DashManifestMissingTimeline,
/// The segment count depends on the Period length, but the manifest gives
/// no Period@duration, next Period@start, MPD@mediaPresentationDuration or
/// SegmentTemplate@endNumber
#[error("MPEG-DASH segment count needs a Period duration, presentation duration or endNumber")]
DashManifestMissingDuration,
/// A MPEG-DASH SegmentTemplate or SegmentList could not be expanded into segments
#[error("Invalid MPEG-DASH segment addressing: {0}")]
DashManifestInvalidSegments(String),
/// A representation's `SegmentBase` index could not be fetched or parsed
/// when the manifest was loaded
#[error(
"MPEG-DASH SegmentBase index for representation {representation} failed to load: {reason}"
)]
DashManifestSegmentIndex {
/// The representation ID
representation: String,
/// Why the index failed to load
reason: String,
},
/// A MPEG-DASH URL could not be parsed or resolved against its BaseURL chain
#[error("Cannot resolve MPEG-DASH URL {0}: {1}")]
DashManifestUrl(String, #[source] url::ParseError),
/// HTTP request for the MPEG-DASH manifest failed
#[error("Fetching MPEG-DASH manifest failed: {0}")]
DashManifestFetch(#[source] ureq::Error),
/// An MPEG-DASH representation did not include a media URL template
#[error("MPEG-DASH representation is missing a media URL template")]
DashManifestMissingMediaTemplate,
/// A MPEG-DASH representation had a zero or out-of-range timescale
#[error("MPEG-DASH representation has an invalid timescale")]
DashManifestMissingTimescale,
/// A byte range was not in `first-last` form with `first <= last`
#[error("Invalid byte range: {0}")]
InvalidByteRange(String),
/// A ranged fragment's body did not match the length of its range
#[error("Fragment {fragment} returned {actual} bytes, expected {expected}")]
FragmentLength {
/// The fragment URL and range
fragment: String,
/// Bytes covered by the range
expected: u64,
/// Bytes received
actual: u64,
},
/// Failed to initialize audio stream
#[error("Stream initialization error: {0}")]
StreamInitializationError(String),
/// IO error while reading a media fragment body
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
/// HTTP request for a media fragment failed
#[error("Stream HTTP request failed: {0}")]
StreamHttp(#[from] ureq::Error),
/// Rodio could not initialize a decoder for the selected representation.
#[cfg(feature = "rodio")]
#[error("Audio decoder initialization failed: {0}")]
RodioDecoder(#[from] ::rodio::decoder::DecoderError),
/// The rodio adapter was asked to decode a protected representation
/// without content keys.
#[cfg(feature = "rodio")]
#[error("Rodio playback of {0}-protected MPEG-DASH content needs content keys")]
RodioProtectedContent(String),
/// A content key or key ID was not 32 hexadecimal digits
#[cfg(feature = "encryption")]
#[error("Invalid content key or KID: {0}")]
InvalidContentKey(String),
/// Protected media needs a key for this KID (hexadecimal) that was not supplied
#[cfg(feature = "encryption")]
#[error("No content key for KID {0}")]
MissingContentKey(String),
/// A fragment uses Common Encryption features this crate does not decrypt
#[cfg(feature = "encryption")]
#[error("Fragment {fragment} uses unsupported content protection: {reason}")]
UnsupportedProtection {
/// The fragment URL and range
fragment: String,
/// What is unsupported
reason: String,
},
/// A fragment's Common Encryption boxes are truncated or inconsistent
#[cfg(feature = "encryption")]
#[error("Fragment {fragment} has malformed content protection: {reason}")]
MalformedProtection {
/// The fragment URL and range
fragment: String,
/// What is malformed
reason: String,
},
}