1use std::num::ParseIntError;
2
3use thiserror::Error;
4
5use crate::SegmentId;
6
7#[derive(Error, Debug)]
8pub enum Error {
9 #[error("Scale must be strictly positive")]
10 NullScale(),
11 #[error("activePresentation references unknown id {0}")]
12 InvalidActivePresentationId(String),
13 #[error("'{0}' is not a valid audio MIME Type")]
14 InvalidAudioMime(String),
15 #[error("'{0}' is not a valid video MIME Type")]
16 InvalidVideoMime(String),
17 #[error("Presentation with id {0} is active but has no currentTime")]
18 MissingCurrentTime(String),
19 #[error("Presentation with id {0} is active but has no startTime")]
20 MissingStartTime(String),
21 #[error(
22 "Presentation with id {0} is active but its currentTime is earlier than its startTime"
23 )]
24 ImpossibleCurrentTime(String),
25 #[error("segment id's must be incremented by one: {1} must not follow {0}")]
26 InvalidSegmentIds(SegmentId, SegmentId),
27 #[error("SwitchingSetProtection must contain at least one system")]
28 EmptySwitchingSetProtectionSystems,
29 #[error("TimeBounds must have a start- or end-time")]
30 EmptyTimeBounds,
31 #[error("startTime {start} must be before endTime {end}")]
32 ReverseTimeBounds { start: u64, end: u64 },
33 #[error(
34 "Track {0} has no segmentDuration therefore each segment must have timeBounds without gaps"
35 )]
36 MissingSegmentDuration(String),
37 #[error("Track {0} is active so it must have an active sequence number")]
38 MissingActiveSequenceNumber(String),
39 #[error("Track {0} must have codecs")]
40 MissingCodecs(String),
41 #[error("Track {0} must have a continuation pattern")]
42 MissingContinuationPattern(String),
43 #[error("Track {0} must have a framerate")]
44 MissingFrameRate(String),
45 #[error("Track {0} must have a sample rate")]
46 MissingSampleRate(String),
47 #[error("Track {0} must have an initialization pattern")]
48 MissingInitializationPattern(String),
49 #[error("Ids must be unique (found duplicate: {0})")]
50 DuplicateId(String),
51 #[error("Pattern '{0}' must contain {1}")]
52 InvalidPattern(String, &'static str),
53 #[error("Track path '{0}' must contain exactly 3 forward slashes")]
54 InvalidTrackPath(String),
55 #[error("'{0}' is not a valid MediaType")]
56 InvalidMediaType(String),
57 #[error("'{0}' cannot be converted to a float (f64's mantissa is only 52 bits wide)")]
58 FloatOverflow(String),
59 #[error("Illegal key format version: {0}")]
60 KeyFormatVersion(ParseIntError),
61 #[error("Missing fairplay attribute: {0}")]
62 MissingFairplayAttribute(&'static str),
63 #[error("Invalid Fairplay scheme ID")]
64 FairplaySchemeId,
65 #[error(transparent)]
66 UrlParseError(#[from] url::ParseError),
67 #[error(transparent)]
68 InvalidJson(#[from] serde_path_to_error::Error<serde_json::Error>),
69}
70
71pub type Result<T> = std::result::Result<T, Error>;