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
55#[derive(Debug, Clone, Copy, PartialEq, Eq)]
57#[non_exhaustive]
58pub enum Unsupported {
59 PresentationTypeList,
61 SegmentSequence,
63 DataUrl,
65 OpenEndedRange,
67 HierarchicalSidx,
69}
70
71impl Unsupported {
72 #[must_use]
74 pub fn name(&self) -> &'static str {
75 match self {
76 Self::PresentationTypeList => "presentation_type_list",
77 Self::SegmentSequence => "segment_sequence",
78 Self::DataUrl => "data_url",
79 Self::OpenEndedRange => "open_ended_range",
80 Self::HierarchicalSidx => "hierarchical_sidx",
81 }
82 }
83}
84impl_spec_display!(Unsupported);
85
86#[derive(Debug, Clone, PartialEq, Eq, Error)]
88#[non_exhaustive]
89pub enum MpdError {
90 #[error("MPD is not valid UTF-8 (valid up to byte {valid_up_to})")]
92 InvalidUtf8 {
93 valid_up_to: usize,
95 },
96 #[error("XML error at byte {pos}: {message}")]
99 Xml {
100 pos: usize,
102 message: String,
104 },
105 #[error("document root is not an MPD in the MPD namespace (found `{found}`)")]
107 NotMpd {
108 found: String,
110 },
111 #[error("invalid MPD: {what}: {detail}")]
113 Invalid {
114 what: &'static str,
116 detail: String,
118 },
119 #[error("MPD exceeds the {limit} limit of {max}")]
121 TooLarge {
122 limit: Limit,
124 max: usize,
126 },
127 #[error("unsupported: {0}")]
129 Unsupported(Unsupported),
130}