1use broadcast_common::impl_spec_display;
4use thiserror::Error;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8#[non_exhaustive]
9pub enum Limit {
10 InputBytes,
12 Depth,
14 Elements,
16 AttributeBytes,
18 Attributes,
20 Periods,
22 AdaptationSets,
24 Representations,
26 TimelineEntries,
28 BaseUrls,
30 SegmentUrls,
32}
33
34impl Limit {
35 #[must_use]
37 pub fn name(&self) -> &'static str {
38 match self {
39 Self::InputBytes => "input_bytes",
40 Self::Depth => "depth",
41 Self::Elements => "elements",
42 Self::AttributeBytes => "attribute_bytes",
43 Self::Attributes => "attributes",
44 Self::Periods => "periods",
45 Self::AdaptationSets => "adaptation_sets",
46 Self::Representations => "representations",
47 Self::TimelineEntries => "timeline_entries",
48 Self::BaseUrls => "base_urls",
49 Self::SegmentUrls => "segment_urls",
50 }
51 }
52}
53impl_spec_display!(Limit);
54
55impl From<broadcast_common::xml_chars::XmlLimit> for Limit {
56 fn from(limit: broadcast_common::xml_chars::XmlLimit) -> Self {
57 use broadcast_common::xml_chars::XmlLimit;
58 match limit {
59 XmlLimit::Depth => Self::Depth,
60 XmlLimit::Elements => Self::Elements,
61 XmlLimit::AttributeBytes => Self::AttributeBytes,
62 XmlLimit::Attributes => Self::Attributes,
63 _ => Self::InputBytes,
64 }
65 }
66}
67
68#[derive(Debug, Clone, Copy, PartialEq, Eq)]
70#[non_exhaustive]
71pub enum Unsupported {
72 PresentationTypeList,
74 SegmentSequence,
76 DataUrl,
78 OpenEndedRange,
80 HierarchicalSidx,
82}
83
84impl Unsupported {
85 #[must_use]
87 pub fn name(&self) -> &'static str {
88 match self {
89 Self::PresentationTypeList => "presentation_type_list",
90 Self::SegmentSequence => "segment_sequence",
91 Self::DataUrl => "data_url",
92 Self::OpenEndedRange => "open_ended_range",
93 Self::HierarchicalSidx => "hierarchical_sidx",
94 }
95 }
96}
97impl_spec_display!(Unsupported);
98
99#[derive(Debug, Clone, PartialEq, Eq, Error)]
101#[non_exhaustive]
102pub enum MpdError {
103 #[error("MPD is not valid UTF-8 (valid up to byte {valid_up_to})")]
105 InvalidUtf8 {
106 valid_up_to: usize,
108 },
109 #[error("XML error at byte {pos}: {message}")]
112 Xml {
113 pos: usize,
115 message: String,
117 },
118 #[error("document root is not an MPD in the MPD namespace (found `{found}`)")]
120 NotMpd {
121 found: String,
123 },
124 #[error("invalid MPD: {what}: {detail}")]
126 Invalid {
127 what: &'static str,
129 detail: String,
131 },
132 #[error("MPD exceeds the {limit} limit of {max}")]
134 TooLarge {
135 limit: Limit,
137 max: usize,
139 },
140 #[error("unsupported: {0}")]
142 Unsupported(Unsupported),
143}