#[non_exhaustive]pub struct Mpd {Show 23 fields
pub id: Option<String>,
pub profiles: Vec<String>,
pub kind: PresentationType,
pub availability_start_time_us: Option<i64>,
pub availability_end_time_us: Option<i64>,
pub publish_time_us: Option<i64>,
pub media_presentation_duration: Option<Duration>,
pub minimum_update_period: Option<Duration>,
pub min_buffer_time: Option<Duration>,
pub time_shift_buffer_depth: Option<Duration>,
pub suggested_presentation_delay: Option<Duration>,
pub max_segment_duration: Option<Duration>,
pub max_subsegment_duration: Option<Duration>,
pub base_urls: Vec<BaseUrl>,
pub locations: Vec<String>,
pub patch_locations: Vec<PatchLocation>,
pub service_descriptions: Vec<ServiceDescription>,
pub utc_timings: Vec<UtcTiming>,
pub essential_properties: Vec<Descriptor>,
pub supplemental_properties: Vec<Descriptor>,
pub content_steering: Option<ContentSteering>,
pub periods: Vec<Period>,
pub features: MpdFeatures,
}Expand description
An MPD (5.3.1).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: Option<String>@id.
profiles: Vec<String>@profiles, split on ,.
kind: PresentationType@type.
availability_start_time_us: Option<i64>@availabilityStartTime, Unix microseconds.
availability_end_time_us: Option<i64>@availabilityEndTime, Unix microseconds.
publish_time_us: Option<i64>@publishTime, Unix microseconds.
media_presentation_duration: Option<Duration>@mediaPresentationDuration.
minimum_update_period: Option<Duration>@minimumUpdatePeriod.
min_buffer_time: Option<Duration>@minBufferTime.
time_shift_buffer_depth: Option<Duration>@timeShiftBufferDepth.
suggested_presentation_delay: Option<Duration>@suggestedPresentationDelay.
max_segment_duration: Option<Duration>@maxSegmentDuration.
max_subsegment_duration: Option<Duration>@maxSubsegmentDuration.
base_urls: Vec<BaseUrl>BaseURL alternates.
locations: Vec<String>Location texts.
patch_locations: Vec<PatchLocation>PatchLocation.
service_descriptions: Vec<ServiceDescription>ServiceDescription.
utc_timings: Vec<UtcTiming>UTCTiming elements in document order (alternatives, in preference
order).
essential_properties: Vec<Descriptor>EssentialProperty.
supplemental_properties: Vec<Descriptor>SupplementalProperty.
content_steering: Option<ContentSteering>ContentSteering.
periods: Vec<Period>The Periods.
features: MpdFeaturesConstructs seen but not acted on.
Implementations§
Source§impl Mpd
impl Mpd
Sourcepub fn has_event_streams(&self) -> bool
pub fn has_event_streams(&self) -> bool
Whether the MPD declares an EventStream in a Period or an
InbandEventStream anywhere.
Sourcepub fn has_preselections(&self) -> bool
pub fn has_preselections(&self) -> bool
Whether any Period declares a Preselection.
Sourcepub fn has_patch_location(&self) -> bool
pub fn has_patch_location(&self) -> bool
Whether the MPD declares a PatchLocation.
Source§impl Mpd
impl Mpd
Sourcepub fn parse(bytes: &[u8]) -> Result<Self, MpdError>
pub fn parse(bytes: &[u8]) -> Result<Self, MpdError>
Parse an MPD document with the default Limits.
§Errors
MpdError for malformed XML, a non-MPD root, a schema violation the
core relies on, an exceeded bound, or an out-of-scope presentation type.
Examples found in repository?
10fn main() {
11 let mut video = Representation::default();
12 video.id = "v0".to_string();
13 video.bandwidth = 2_000_000;
14 let mut vc = CommonAttributes::default();
15 vc.codecs = Some("avc1.42E01E".to_string());
16 vc.mime_type = Some("video/mp4".to_string());
17 vc.width = Some(1280);
18 vc.height = Some(720);
19 vc.frame_rate = Some("30".to_string());
20 video.common = vc;
21 let mut tmpl = SegmentTemplate::default();
22 tmpl.media = Some("chunk-$Number$.m4s".to_string());
23 tmpl.initialization = Some("init.mp4".to_string());
24 tmpl.multi.base.timescale = Some(90000);
25 tmpl.multi.duration = Some(90000);
26 tmpl.multi.start_number = Some(1);
27 video.segment.template = Some(tmpl);
28
29 let mut audio = Representation::default();
30 audio.id = "a0".to_string();
31 audio.bandwidth = 128_000;
32 let mut ac = CommonAttributes::default();
33 ac.codecs = Some("mp4a.40.2".to_string());
34 ac.mime_type = Some("audio/mp4".to_string());
35 ac.audio_sampling_rate = Some("48000".to_string());
36 audio.common = ac;
37 let mut atmpl = SegmentTemplate::default();
38 atmpl.media = Some("audio-chunk-$Number$.m4s".to_string());
39 atmpl.initialization = Some("audio-init.mp4".to_string());
40 atmpl.multi.base.timescale = Some(48000);
41 atmpl.multi.duration = Some(48000);
42 atmpl.multi.start_number = Some(1);
43 audio.segment.template = Some(atmpl);
44
45 let mut video_set = AdaptationSet::default();
46 video_set.id = Some(0);
47 video_set.content_type = Some("video".to_string());
48 video_set.representations.push(video);
49
50 let mut audio_set = AdaptationSet::default();
51 audio_set.id = Some(1);
52 audio_set.content_type = Some("audio".to_string());
53 audio_set.representations.push(audio);
54
55 let mut period = Period::default();
56 period.id = Some("p0".to_string());
57 period.adaptation_sets.push(video_set);
58 period.adaptation_sets.push(audio_set);
59
60 let mut mpd = Mpd::default();
61 mpd.id = Some("demo".to_string());
62 mpd.profiles = vec!["urn:mpeg:dash:profile:isoff-on-demand:2011".to_string()];
63 mpd.kind = PresentationType::Static;
64 mpd.media_presentation_duration = Some(std::time::Duration::from_secs(60));
65 mpd.min_buffer_time = Some(std::time::Duration::from_secs(2));
66 mpd.periods.push(period);
67
68 let xml = mpd.to_xml().expect("render");
69 print!("{xml}");
70 assert_eq!(Mpd::parse(xml.as_bytes()).expect("re-parse"), mpd);
71}Source§impl Mpd
impl Mpd
Sourcepub fn to_xml(&self) -> Result<String, MpdError>
pub fn to_xml(&self) -> Result<String, MpdError>
Render the model as an MPD XML document.
§Errors
MpdError::Write if the in-memory writer fails (it cannot in
practice) and MpdError::Invalid if a stored instant cannot be
formatted.
Examples found in repository?
10fn main() {
11 let mut video = Representation::default();
12 video.id = "v0".to_string();
13 video.bandwidth = 2_000_000;
14 let mut vc = CommonAttributes::default();
15 vc.codecs = Some("avc1.42E01E".to_string());
16 vc.mime_type = Some("video/mp4".to_string());
17 vc.width = Some(1280);
18 vc.height = Some(720);
19 vc.frame_rate = Some("30".to_string());
20 video.common = vc;
21 let mut tmpl = SegmentTemplate::default();
22 tmpl.media = Some("chunk-$Number$.m4s".to_string());
23 tmpl.initialization = Some("init.mp4".to_string());
24 tmpl.multi.base.timescale = Some(90000);
25 tmpl.multi.duration = Some(90000);
26 tmpl.multi.start_number = Some(1);
27 video.segment.template = Some(tmpl);
28
29 let mut audio = Representation::default();
30 audio.id = "a0".to_string();
31 audio.bandwidth = 128_000;
32 let mut ac = CommonAttributes::default();
33 ac.codecs = Some("mp4a.40.2".to_string());
34 ac.mime_type = Some("audio/mp4".to_string());
35 ac.audio_sampling_rate = Some("48000".to_string());
36 audio.common = ac;
37 let mut atmpl = SegmentTemplate::default();
38 atmpl.media = Some("audio-chunk-$Number$.m4s".to_string());
39 atmpl.initialization = Some("audio-init.mp4".to_string());
40 atmpl.multi.base.timescale = Some(48000);
41 atmpl.multi.duration = Some(48000);
42 atmpl.multi.start_number = Some(1);
43 audio.segment.template = Some(atmpl);
44
45 let mut video_set = AdaptationSet::default();
46 video_set.id = Some(0);
47 video_set.content_type = Some("video".to_string());
48 video_set.representations.push(video);
49
50 let mut audio_set = AdaptationSet::default();
51 audio_set.id = Some(1);
52 audio_set.content_type = Some("audio".to_string());
53 audio_set.representations.push(audio);
54
55 let mut period = Period::default();
56 period.id = Some("p0".to_string());
57 period.adaptation_sets.push(video_set);
58 period.adaptation_sets.push(audio_set);
59
60 let mut mpd = Mpd::default();
61 mpd.id = Some("demo".to_string());
62 mpd.profiles = vec!["urn:mpeg:dash:profile:isoff-on-demand:2011".to_string()];
63 mpd.kind = PresentationType::Static;
64 mpd.media_presentation_duration = Some(std::time::Duration::from_secs(60));
65 mpd.min_buffer_time = Some(std::time::Duration::from_secs(2));
66 mpd.periods.push(period);
67
68 let xml = mpd.to_xml().expect("render");
69 print!("{xml}");
70 assert_eq!(Mpd::parse(xml.as_bytes()).expect("re-parse"), mpd);
71}