[−][src]Struct hls_m3u8::MediaSegment
A video is split into smaller chunks called MediaSegment
s, which are
specified by a uri and optionally a byte range.
Each MediaSegment
must carry the continuation of the encoded bitstream
from the end of the segment with the previous MediaSegment::number
,
where values in a series such as timestamps and continuity counters must
continue uninterrupted. The only exceptions are the first MediaSegment
ever to appear in a MediaPlaylist
and MediaSegment
s that are
explicitly signaled as discontinuities.
Unmarked media discontinuities can trigger playback errors.
Any MediaSegment
that contains video should include enough information
to initialize a video decoder and decode a continuous set of frames that
includes the final frame in the segment; network efficiency is optimized if
there is enough information in the segment to decode all frames in the
segment.
For example, any MediaSegment
containing H.264 video should
contain an Instantaneous Decoding Refresh (IDR); frames prior to the first
IDR will be downloaded but possibly discarded.
Fields
keys: Vec<ExtXKey>
This field specifies how to decrypt a MediaSegment
, which can only
be encrypted with one EncryptionMethod
, using one DecryptionKey
and DecryptionKey::iv
.
However, a server may offer multiple ways to retrieve that key by
providing multiple keys with different DecryptionKey::format
s.
Any unencrypted segment that is preceded by an encrypted segment must
have an ExtXKey::empty
. Otherwise, the client will misinterpret
those segments as encrypted.
The server may set the HTTP Expires header in the key response to indicate the duration for which the key can be cached.
Note
This field is optional and a missing value or an ExtXKey::empty()
indicates an unencrypted media segment.
map: Option<ExtXMap>
This field specifies how to obtain the Media Initialization Section
required to parse the applicable MediaSegment
s.
Note
This field is optional, but should be specified for media segments in
playlists with an ExtXIFramesOnly
tag when the first MediaSegment
in the playlist (or the first segment following a segment marked with
MediaSegment::has_discontinuity
) does not immediately follow the
Media Initialization Section at the beginning of its resource.
byte_range: Option<ExtXByteRange>
This field indicates that a MediaSegment
is a sub-range of the
resource identified by its URI.
Note
This field is optional.
date_range: Option<ExtXDateRange>
This field associates a date-range (i.e., a range of time defined by a starting and ending date) with a set of attribute/value pairs.
Note
This field is optional.
has_discontinuity: bool
This field indicates a discontinuity between the MediaSegment
that
follows it and the one that preceded it.
Note
This field is required if any of the following characteristics change:
- file format
- number, type, and identifiers of tracks
- timestamp, sequence
This field should be present if any of the following characteristics change:
- encoding parameters
- encoding sequence
program_date_time: Option<ExtXProgramDateTime>
This field associates the first sample of a media segment with an absolute date and/or time.
Note
This field is optional.
duration: ExtInf
Methods
impl MediaSegment
[src]
#[must_use]pub fn number(&self) -> usize
[src]
Each MediaSegment
has a number, which allows synchronization between
different variants.
Note
This number must not be specified, because it will be assigned
automatically by MediaPlaylistBuilder::segments
. The first
MediaSegment::number
in a MediaPlaylist
will either be 0 or the
number returned by the ExtXDiscontinuitySequence
if one is
provided.
The following segments will be the previous segment number + 1.
#[must_use]pub fn uri(&self) -> &String
[src]
pub fn set_uri<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self
[src]
impl MediaSegment
[src]
#[must_use]pub fn builder() -> MediaSegmentBuilder
[src]
Returns a builder for a MediaSegment
.
Example
use hls_m3u8::tags::ExtXMap; use std::time::Duration; let segment = MediaSegment::builder() .map(ExtXMap::new("https://www.example.com/")) .byte_range(5..25) .has_discontinuity(true) .duration(Duration::from_secs(4)) .uri("http://www.uri.com/") .build()?;
Trait Implementations
impl Clone for MediaSegment
[src]
fn clone(&self) -> MediaSegment
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for MediaSegment
[src]
impl Decryptable for MediaSegment
[src]
fn keys(&self) -> Vec<&DecryptionKey>
[src]
#[must_use]fn first_key(&self) -> Option<&DecryptionKey>
[src]
#[must_use]fn len(&self) -> usize
[src]
#[must_use]fn is_empty(&self) -> bool
[src]
impl Display for MediaSegment
[src]
impl Eq for MediaSegment
[src]
impl Hash for MediaSegment
[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 MediaSegment
[src]
fn cmp(&self, other: &MediaSegment) -> 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<MediaSegment> for MediaSegment
[src]
fn eq(&self, other: &MediaSegment) -> bool
[src]
fn ne(&self, other: &MediaSegment) -> bool
[src]
impl PartialOrd<MediaSegment> for MediaSegment
[src]
fn partial_cmp(&self, other: &MediaSegment) -> Option<Ordering>
[src]
fn lt(&self, other: &MediaSegment) -> bool
[src]
fn le(&self, other: &MediaSegment) -> bool
[src]
fn gt(&self, other: &MediaSegment) -> bool
[src]
fn ge(&self, other: &MediaSegment) -> bool
[src]
impl StructuralEq for MediaSegment
[src]
impl StructuralPartialEq for MediaSegment
[src]
Auto Trait Implementations
impl RefUnwindSafe for MediaSegment
impl Send for MediaSegment
impl Sync for MediaSegment
impl Unpin for MediaSegment
impl UnwindSafe for MediaSegment
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>,