Struct hls_m3u8::MasterPlaylist [−][src]
#[non_exhaustive]pub struct MasterPlaylist<'a> { pub has_independent_segments: bool, pub start: Option<ExtXStart>, pub media: Vec<ExtXMedia<'a>>, pub variant_streams: Vec<VariantStream<'a>>, pub session_data: Vec<ExtXSessionData<'a>>, pub session_keys: Vec<ExtXSessionKey<'a>>, pub unknown_tags: Vec<Cow<'a, str>>, }
Expand description
The master playlist describes all of the available variants for your content.
Each variant is a version of the stream at a particular bitrate and is
contained in a separate playlist called MediaPlaylist
.
Examples
A MasterPlaylist
can be parsed from a str
:
use core::convert::TryFrom; use hls_m3u8::MasterPlaylist; // the concat! macro joins multiple `&'static str`. let master_playlist = MasterPlaylist::try_from(concat!( "#EXTM3U\n", "#EXT-X-STREAM-INF:", "BANDWIDTH=150000,CODECS=\"avc1.42e00a,mp4a.40.2\",RESOLUTION=416x234\n", "http://example.com/low/index.m3u8\n", "#EXT-X-STREAM-INF:", "BANDWIDTH=240000,CODECS=\"avc1.42e00a,mp4a.40.2\",RESOLUTION=416x234\n", "http://example.com/lo_mid/index.m3u8\n", "#EXT-X-STREAM-INF:", "BANDWIDTH=440000,CODECS=\"avc1.42e00a,mp4a.40.2\",RESOLUTION=416x234\n", "http://example.com/hi_mid/index.m3u8\n", "#EXT-X-STREAM-INF:", "BANDWIDTH=640000,CODECS=\"avc1.42e00a,mp4a.40.2\",RESOLUTION=640x360\n", "http://example.com/high/index.m3u8\n", "#EXT-X-STREAM-INF:BANDWIDTH=64000,CODECS=\"mp4a.40.5\"\n", "http://example.com/audio/index.m3u8\n" ))?; println!("{}", master_playlist.has_independent_segments);
or it can be constructed through a builder
use hls_m3u8::tags::{ExtXStart, VariantStream}; use hls_m3u8::types::{Float, StreamData}; MasterPlaylist::builder() .variant_streams(vec![ VariantStream::ExtXStreamInf { uri: "http://example.com/low/index.m3u8".into(), frame_rate: None, audio: None, subtitles: None, closed_captions: None, stream_data: StreamData::builder() .bandwidth(150000) .codecs(&["avc1.42e00a", "mp4a.40.2"]) .resolution((416, 234)) .build() .unwrap(), }, VariantStream::ExtXStreamInf { uri: "http://example.com/lo_mid/index.m3u8".into(), frame_rate: None, audio: None, subtitles: None, closed_captions: None, stream_data: StreamData::builder() .bandwidth(240000) .codecs(&["avc1.42e00a", "mp4a.40.2"]) .resolution((416, 234)) .build() .unwrap(), }, ]) .has_independent_segments(true) .start(ExtXStart::new(Float::new(1.23))) .build()?;
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.has_independent_segments: bool
Indicates that all media samples in a MediaSegment
can be
decoded without information from other segments.
Note
This field is optional and by default false
. If the field is true
,
it applies to every MediaSegment
in every MediaPlaylist
of this
MasterPlaylist
.
start: Option<ExtXStart>
A preferred point at which to start playing a playlist.
Note
This field is optional and by default the playlist should be played from the start.
media: Vec<ExtXMedia<'a>>
A list of all ExtXMedia
tags, which describe an alternative
rendition.
For example, three ExtXMedia
tags can be used to identify audio-only
MediaPlaylist
s, that contain English, French, and Spanish
renditions of the same presentation. Or, two ExtXMedia
tags can
be used to identify video-only MediaPlaylist
s that show two
different camera angles.
Note
This field is optional.
variant_streams: Vec<VariantStream<'a>>
session_data: Vec<ExtXSessionData<'a>>
The ExtXSessionData
tag allows arbitrary session data to be
carried in a MasterPlaylist
.
Note
This field is optional.
session_keys: Vec<ExtXSessionKey<'a>>
A list of ExtXSessionKey
s, that allows the client to preload
these keys without having to read the MediaPlaylist
s first.
Note
This field is optional.
A list of all tags that could not be identified while parsing the input.
Note
This field is optional.
Implementations
Returns a builder for a MasterPlaylist
.
Example
use hls_m3u8::tags::{ExtXStart, VariantStream}; use hls_m3u8::types::{Float, StreamData}; MasterPlaylist::builder() .variant_streams(vec![ VariantStream::ExtXStreamInf { uri: "http://example.com/low/index.m3u8".into(), frame_rate: None, audio: None, subtitles: None, closed_captions: None, stream_data: StreamData::builder() .bandwidth(150000) .codecs(&["avc1.42e00a", "mp4a.40.2"]) .resolution((416, 234)) .build() .unwrap(), }, VariantStream::ExtXStreamInf { uri: "http://example.com/lo_mid/index.m3u8".into(), frame_rate: None, audio: None, subtitles: None, closed_captions: None, stream_data: StreamData::builder() .bandwidth(240000) .codecs(&["avc1.42e00a", "mp4a.40.2"]) .resolution((416, 234)) .build() .unwrap(), }, ]) .has_independent_segments(true) .start(ExtXStart::new(Float::new(1.23))) .build()?;
Returns all streams, which have an audio group id.
Returns all streams, which have a video group id.
Returns all streams, which have no group id.
pub fn associated_with<'b>(
&'b self,
stream: &'b VariantStream<'_>
) -> impl Iterator<Item = &ExtXMedia<'a>> + 'b
pub fn associated_with<'b>(
&'b self,
stream: &'b VariantStream<'_>
) -> impl Iterator<Item = &ExtXMedia<'a>> + 'b
Returns all ExtXMedia
tags, associated with the provided stream.
Trait Implementations
Returns the “default value” for a type. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl<'a> RefUnwindSafe for MasterPlaylist<'a>
impl<'a> Send for MasterPlaylist<'a>
impl<'a> Sync for MasterPlaylist<'a>
impl<'a> Unpin for MasterPlaylist<'a>
impl<'a> UnwindSafe for MasterPlaylist<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more