use broadcast_common::impl_spec_display;
use thiserror::Error;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum Limit {
InputBytes,
Depth,
Elements,
AttributeBytes,
Attributes,
Periods,
AdaptationSets,
Representations,
TimelineEntries,
BaseUrls,
SegmentUrls,
}
impl Limit {
#[must_use]
pub fn name(&self) -> &'static str {
match self {
Self::InputBytes => "input_bytes",
Self::Depth => "depth",
Self::Elements => "elements",
Self::AttributeBytes => "attribute_bytes",
Self::Attributes => "attributes",
Self::Periods => "periods",
Self::AdaptationSets => "adaptation_sets",
Self::Representations => "representations",
Self::TimelineEntries => "timeline_entries",
Self::BaseUrls => "base_urls",
Self::SegmentUrls => "segment_urls",
}
}
}
impl_spec_display!(Limit);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum Unsupported {
PresentationTypeList,
SegmentSequence,
DataUrl,
OpenEndedRange,
HierarchicalSidx,
}
impl Unsupported {
#[must_use]
pub fn name(&self) -> &'static str {
match self {
Self::PresentationTypeList => "presentation_type_list",
Self::SegmentSequence => "segment_sequence",
Self::DataUrl => "data_url",
Self::OpenEndedRange => "open_ended_range",
Self::HierarchicalSidx => "hierarchical_sidx",
}
}
}
impl_spec_display!(Unsupported);
#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum MpdError {
#[error("MPD is not valid UTF-8 (valid up to byte {valid_up_to})")]
InvalidUtf8 {
valid_up_to: usize,
},
#[error("XML error at byte {pos}: {message}")]
Xml {
pos: usize,
message: String,
},
#[error("document root is not an MPD in the MPD namespace (found `{found}`)")]
NotMpd {
found: String,
},
#[error("invalid MPD: {what}: {detail}")]
Invalid {
what: &'static str,
detail: String,
},
#[error("MPD exceeds the {limit} limit of {max}")]
TooLarge {
limit: Limit,
max: usize,
},
#[error("unsupported: {0}")]
Unsupported(Unsupported),
}