1#[derive(Debug, Clone, thiserror::Error)]
8#[non_exhaustive]
9pub enum Error {
10 #[error("moq: {0}")]
12 Moq(#[from] moq_net::Error),
13
14 #[error("hang: {0}")]
16 Hang(#[from] hang::Error),
17
18 #[error("json: {0}")]
20 Json(#[from] moq_json::Error),
21
22 #[error("cmaf: {0}")]
24 Cmaf(#[from] crate::container::fmp4::Error),
25
26 #[error("mkv: {0}")]
28 Mkv(#[from] crate::container::mkv::Error),
29
30 #[error("msf: {0}")]
32 Msf(#[from] crate::catalog::msf::Error),
33
34 #[error("loc: {0}")]
36 Loc(#[from] moq_loc::Error),
37
38 #[error("annexb: {0}")]
40 Annexb(#[from] crate::codec::annexb::Error),
41
42 #[error("aac: {0}")]
44 Aac(#[from] crate::codec::aac::Error),
45
46 #[error("opus: {0}")]
48 Opus(#[from] crate::codec::opus::Error),
49
50 #[error("flac: {0}")]
52 Flac(#[from] crate::codec::flac::Error),
53
54 #[error("mp3: {0}")]
56 Mp3(#[from] crate::codec::mp3::Error),
57
58 #[error("h264: {0}")]
60 H264(#[from] crate::codec::h264::Error),
61
62 #[error("h265: {0}")]
64 H265(#[from] crate::codec::h265::Error),
65
66 #[error("av1: {0}")]
68 Av1(#[from] crate::codec::av1::Error),
69
70 #[error("vp8: {0}")]
72 Vp8(#[from] crate::codec::vp8::Error),
73
74 #[error("vp9: {0}")]
76 Vp9(#[from] crate::codec::vp9::Error),
77
78 #[error("legacy: {0}")]
80 Legacy(#[from] crate::codec::legacy::Error),
81
82 #[error("timestamp overflow")]
84 TimestampOverflow(#[from] moq_net::TimeOverflow),
85
86 #[error("mp4: {0}")]
88 Mp4(std::sync::Arc<mp4_atom::Error>),
89
90 #[error("io: {0}")]
92 Io(std::sync::Arc<std::io::Error>),
93
94 #[error("url: {0}")]
96 Url(#[from] url::ParseError),
97
98 #[error("unknown format: {0}")]
100 UnknownFormat(String),
101
102 #[error("{0}")]
105 MissingKeyframe(#[from] crate::container::MissingKeyframe),
106
107 #[error("negative FLV video presentation timestamp: dts={dts_ms}ms composition_time={composition_time_ms}ms")]
109 NegativeFlvPts {
110 dts_ms: u64,
112 composition_time_ms: i32,
114 },
115
116 #[error("{0}")]
119 Other(std::sync::Arc<anyhow::Error>),
120
121 #[error("invalid timeline timescale: {0}")]
124 InvalidTimescale(u32),
125
126 #[error("reserved catalog section: {0}")]
129 ReservedSection(String),
130
131 #[error("unsupported container: {0}")]
134 UnsupportedContainer(String),
135}
136
137impl Error {
138 pub(crate) fn unsupported_container(container: &hang::catalog::UnknownContainer) -> Self {
140 Self::UnsupportedContainer(container.kind().unwrap_or("<missing>").to_string())
141 }
142}
143
144impl From<anyhow::Error> for Error {
145 fn from(err: anyhow::Error) -> Self {
146 Error::Other(std::sync::Arc::new(err))
147 }
148}
149
150impl From<mp4_atom::Error> for Error {
151 fn from(err: mp4_atom::Error) -> Self {
152 Error::Mp4(std::sync::Arc::new(err))
153 }
154}
155
156impl From<std::io::Error> for Error {
157 fn from(err: std::io::Error) -> Self {
158 Error::Io(std::sync::Arc::new(err))
159 }
160}
161
162pub type Result<T> = std::result::Result<T, Error>;