[−][src]Enum hls_m3u8::tags::VariantStream
A server may offer multiple MediaPlaylist
files to provide different
encodings of the same presentation.
If it does so, it should provide
a MasterPlaylist
that lists each VariantStream
to allow
clients to switch between encodings dynamically.
The server must meet the following constraints when producing
VariantStream
s in order to allow clients to switch between them
seamlessly:
-
Each
VariantStream
must present the same content. -
Matching content in
VariantStream
s must have matching timestamps. This allows clients to synchronize the media. -
Matching content in
VariantStream
s must have matchingExtXDiscontinuitySequence
. -
Each
MediaPlaylist
in eachVariantStream
must have the same target duration. The only exceptions are subtitle renditions andMediaPlaylist
s containing anExtXIFramesOnly
tag, which may have different target durations if they havePlaylistType::Vod
. -
Content that appears in a
MediaPlaylist
of oneVariantStream
but not in another must appear either at the beginning or at the end of theMediaPlaylist
and must not be longer than the target duration. -
If any
MediaPlaylist
s have anPlaylistType
tag, allMediaPlaylist
s must have anPlaylistType
tag with the same value. -
If the Playlist contains an
PlaylistType
tag with the value of VOD, the first segment of everyMediaPlaylist
in everyVariantStream
must start at the same media timestamp. -
If any
MediaPlaylist
in aMasterPlaylist
contains anExtXProgramDateTime
tag, then allMediaPlaylist
s in thatMasterPlaylist
must containExtXProgramDateTime
tags with consistent mappings of date and time to media timestamps. -
Each
VariantStream
must contain the same set of Date Ranges, each one identified by anExtXDateRange
tag(s) with the same ID attribute value and containing the same set of attribute/value pairs.
In addition, for broadest compatibility, VariantStream
s should
contain the same encoded audio bitstream. This allows clients to
switch between VariantStream
s without audible glitching.
Variants
The VariantStream::ExtXIFrame
variant identifies a MediaPlaylist
file containing the I-frames of a multimedia presentation.
It stands alone, in that it does not apply to a particular URI in the
MasterPlaylist
.
Fields of ExtXIFrame
uri: String
The URI identifies the I-frame MediaPlaylist
file.
That Playlist file must contain an ExtXIFramesOnly
tag.
Note
This field is required.
stream_data: StreamData
Some fields are shared between VariantStream::ExtXStreamInf
and
VariantStream::ExtXIFrame
.
Note
This field is optional.
VariantStream::ExtXStreamInf
specifies a VariantStream
, which is
a set of renditions that can be combined to play the presentation.
Fields of ExtXStreamInf
uri: String
The URI specifies a MediaPlaylist
that carries a rendition of
the VariantStream
. Clients that do not support multiple video
renditions should play this rendition.
Note
This field is required.
frame_rate: Option<UFloat>
The value is an unsigned float describing the maximum frame
rate for all the video in the VariantStream
.
Note
Specifying the frame rate is optional, but is recommended if the
VariantStream
includes video. It should be specified if any
video exceeds 30 frames per second.
audio: Option<String>
It indicates the set of audio renditions that should be used when playing the presentation.
It must match the value of the ExtXMedia::group_id
of an
ExtXMedia
tag elsewhere in the MasterPlaylist
whose
ExtXMedia::media_type
is MediaType::Audio
.
Note
This field is optional.
subtitles: Option<String>
It indicates the set of subtitle renditions that can be used when playing the presentation.
It must match the value of the ExtXMedia::group_id
of an
ExtXMedia
tag elsewhere in the MasterPlaylist
whose
ExtXMedia::media_type
is MediaType::Subtitles
.
Note
This field is optional.
It indicates the set of closed-caption renditions that can be used when playing the presentation.
Note
This field is optional.
stream_data: StreamData
Some fields are shared between VariantStream::ExtXStreamInf
and
VariantStream::ExtXIFrame
.
Note
This field is optional.
Methods
impl VariantStream
[src]
#[must_use]pub fn is_associated(&self, media: &ExtXMedia) -> bool
[src]
Checks if a VariantStream
and an ExtXMedia
element are
associated.
Example
use hls_m3u8::tags::{ExtXMedia, VariantStream}; use hls_m3u8::types::{ClosedCaptions, MediaType, StreamData}; let variant_stream = VariantStream::ExtXStreamInf { uri: "https://www.example.com/init.bin".into(), frame_rate: None, audio: Some("ag1".into()), subtitles: Some("sg1".into()), closed_captions: Some(ClosedCaptions::group_id("cc1")), stream_data: StreamData::builder() .bandwidth(1_110_000) .video("vg1") .build() .unwrap(), }; assert!(variant_stream.is_associated( &ExtXMedia::builder() .media_type(MediaType::Audio) .group_id("ag1") .name("audio example") .build() .unwrap(), ));
Methods from Deref<Target = StreamData>
#[must_use]pub fn bandwidth(&self) -> u64
[src]
The peak segment bitrate of the VariantStream
in bits per second.
If all the MediaSegment
s in a VariantStream
have already been
created, the bandwidth value must be the largest sum of peak segment
bitrates that is produced by any playable combination of renditions.
(For a VariantStream
with a single MediaPlaylist
, this is just
the peak segment bit rate of that MediaPlaylist
.)
An inaccurate value can cause playback stalls or prevent clients from
playing the variant. If the MasterPlaylist
is to be made available
before all MediaSegment
s in the presentation have been encoded, the
bandwidth value should be the bandwidth value of a representative
period of similar content, encoded using the same settings.
Example
let mut stream = StreamData::new(20); stream.set_bandwidth(5); assert_eq!(stream.bandwidth(), 5);
Note
This field is required.
#[must_use]pub fn average_bandwidth(&self) -> Option<u64>
[src]
The average bandwidth of the stream in bits per second.
It represents the average segment bitrate of the VariantStream
. If
all the MediaSegment
s in a VariantStream
have already been
created, the average bandwidth must be the largest sum of average
segment bitrates that is produced by any playable combination of
renditions.
(For a VariantStream
with a single MediaPlaylist
, this is just
the average segment bitrate of that MediaPlaylist
.)
An inaccurate value can cause playback stalls or prevent clients from
playing the variant. If the MasterPlaylist
is to be made available
before all MediaSegment
s in the presentation have been encoded, the
average bandwidth should be the average bandwidth of a representative
period of similar content, encoded using the same settings.
Example
let mut stream = StreamData::new(20); stream.set_average_bandwidth(Some(300)); assert_eq!(stream.average_bandwidth(), Some(300));
Note
This field is optional.
#[must_use]pub fn codecs(&self) -> Option<&Codecs>
[src]
A list of formats, where each format specifies a media sample type that
is present in one or more renditions specified by the VariantStream
.
Valid format identifiers are those in the ISO Base Media File Format Name Space defined by "The 'Codecs' and 'Profiles' Parameters for "Bucket" Media Types" (RFC6381).
For example, a stream containing AAC low complexity (AAC-LC) audio and H.264 Main Profile Level 3.0 video would be
let codecs = Codecs::from(&["mp4a.40.2", "avc1.4d401e"]);
Example
use hls_m3u8::types::Codecs; let mut stream = StreamData::new(20); stream.set_codecs(Some(&["mp4a.40.2", "avc1.4d401e"])); assert_eq!( stream.codecs(), Some(&Codecs::from(&["mp4a.40.2", "avc1.4d401e"])) );
Note
This field is optional, but every instance of
VariantStream::ExtXStreamInf
should include a codecs attribute.
#[must_use]pub fn resolution(&self) -> Option<Resolution>
[src]
The resolution of the stream.
Example
use hls_m3u8::types::Resolution; let mut stream = StreamData::new(20); stream.set_resolution(Some((1920, 1080))); assert_eq!(stream.resolution(), Some(Resolution::new(1920, 1080)));
Note
This field is optional, but it is recommended if the VariantStream
includes video.
#[must_use]pub fn hdcp_level(&self) -> Option<HdcpLevel>
[src]
High-bandwidth Digital Content Protection level of the
VariantStream
.
Example
use hls_m3u8::types::HdcpLevel; let mut stream = StreamData::new(20); stream.set_hdcp_level(Some(HdcpLevel::None)); assert_eq!(stream.hdcp_level(), Some(HdcpLevel::None));
Note
This field is optional.
#[must_use]pub fn video(&self) -> Option<&String>
[src]
It indicates the set of video renditions, that should be used when playing the presentation.
It must match the value of the ExtXMedia::group_id
attribute
ExtXMedia
tag elsewhere in the MasterPlaylist
whose
ExtXMedia::media_type
attribute is video. It indicates the set of
video renditions that should be used when playing the presentation.
Example
let mut stream = StreamData::new(20); stream.set_video(Some("video_01")); assert_eq!(stream.video(), Some(&"video_01".to_string()));
Note
This field is optional.
Trait Implementations
impl Clone for VariantStream
[src]
fn clone(&self) -> VariantStream
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for VariantStream
[src]
impl Deref for VariantStream
[src]
type Target = StreamData
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl Display for VariantStream
[src]
impl Eq for VariantStream
[src]
impl FromStr for VariantStream
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(input: &str) -> Result<Self, Self::Err>
[src]
impl Hash for VariantStream
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for VariantStream
[src]
fn cmp(&self, other: &VariantStream) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'_> PartialEq<&'_ VariantStream> for VariantStream
[src]
impl PartialEq<VariantStream> for VariantStream
[src]
fn eq(&self, other: &VariantStream) -> bool
[src]
fn ne(&self, other: &VariantStream) -> bool
[src]
impl PartialOrd<VariantStream> for VariantStream
[src]
fn partial_cmp(&self, other: &VariantStream) -> Option<Ordering>
[src]
fn lt(&self, other: &VariantStream) -> bool
[src]
fn le(&self, other: &VariantStream) -> bool
[src]
fn gt(&self, other: &VariantStream) -> bool
[src]
fn ge(&self, other: &VariantStream) -> bool
[src]
impl StructuralEq for VariantStream
[src]
impl StructuralPartialEq for VariantStream
[src]
Auto Trait Implementations
impl RefUnwindSafe for VariantStream
impl Send for VariantStream
impl Sync for VariantStream
impl Unpin for VariantStream
impl UnwindSafe for VariantStream
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,