mirror of
https://github.com/sile/hls_m3u8.git
synced 2025-01-09 19:55:25 +00:00
minor code improvements
This commit is contained in:
parent
9eccea8a7f
commit
969e5bae9a
2 changed files with 5 additions and 16 deletions
|
@ -115,14 +115,11 @@ impl<'a> TryFrom<&'a str> for Tag<'a> {
|
||||||
} else if input.starts_with(tags::ExtXIFramesOnly::PREFIX) {
|
} else if input.starts_with(tags::ExtXIFramesOnly::PREFIX) {
|
||||||
input.parse().map(Self::ExtXIFramesOnly)
|
input.parse().map(Self::ExtXIFramesOnly)
|
||||||
} else if input.starts_with(tags::ExtXMedia::PREFIX) {
|
} else if input.starts_with(tags::ExtXMedia::PREFIX) {
|
||||||
input.parse().map(Self::ExtXMedia).map_err(Error::custom)
|
input.parse().map(Self::ExtXMedia)
|
||||||
} else if input.starts_with(tags::VariantStream::PREFIX_EXTXIFRAME)
|
} else if input.starts_with(tags::VariantStream::PREFIX_EXTXIFRAME)
|
||||||
|| input.starts_with(tags::VariantStream::PREFIX_EXTXSTREAMINF)
|
|| input.starts_with(tags::VariantStream::PREFIX_EXTXSTREAMINF)
|
||||||
{
|
{
|
||||||
input
|
input.parse().map(Self::VariantStream)
|
||||||
.parse()
|
|
||||||
.map(Self::VariantStream)
|
|
||||||
.map_err(Error::custom)
|
|
||||||
} else if input.starts_with(tags::ExtXSessionData::PREFIX) {
|
} else if input.starts_with(tags::ExtXSessionData::PREFIX) {
|
||||||
input.parse().map(Self::ExtXSessionData)
|
input.parse().map(Self::ExtXSessionData)
|
||||||
} else if input.starts_with(tags::ExtXSessionKey::PREFIX) {
|
} else if input.starts_with(tags::ExtXSessionKey::PREFIX) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ use crate::{Decryptable, RequiredVersion};
|
||||||
/// [`MediaPlaylist`]: crate::MediaPlaylist
|
/// [`MediaPlaylist`]: crate::MediaPlaylist
|
||||||
#[derive(ShortHand, Debug, Clone, Builder, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(ShortHand, Debug, Clone, Builder, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[builder(setter(strip_option))]
|
#[builder(setter(strip_option))]
|
||||||
#[shorthand(enable(must_use))]
|
#[shorthand(enable(must_use, skip))]
|
||||||
pub struct MediaSegment {
|
pub struct MediaSegment {
|
||||||
/// Each [`MediaSegment`] has a number, which allows synchronization between
|
/// Each [`MediaSegment`] has a number, which allows synchronization between
|
||||||
/// different variants.
|
/// different variants.
|
||||||
|
@ -53,10 +53,9 @@ pub struct MediaSegment {
|
||||||
/// [`ExtXMediaSequence`]: crate::tags::ExtXMediaSequence
|
/// [`ExtXMediaSequence`]: crate::tags::ExtXMediaSequence
|
||||||
/// [`ExtXDiscontinuitySequence`]: crate::tags::ExtXDiscontinuitySequence
|
/// [`ExtXDiscontinuitySequence`]: crate::tags::ExtXDiscontinuitySequence
|
||||||
#[builder(default, setter(custom))]
|
#[builder(default, setter(custom))]
|
||||||
#[shorthand(disable(set))]
|
#[shorthand(disable(set, skip))]
|
||||||
pub(crate) number: usize,
|
pub(crate) number: usize,
|
||||||
#[builder(default, setter(custom))]
|
#[builder(default, setter(custom))]
|
||||||
#[shorthand(enable(skip))]
|
|
||||||
pub(crate) explicit_number: bool,
|
pub(crate) explicit_number: bool,
|
||||||
/// This field specifies how to decrypt a [`MediaSegment`], which can only
|
/// This field specifies how to decrypt a [`MediaSegment`], which can only
|
||||||
/// be encrypted with one [`EncryptionMethod`], using one [`DecryptionKey`]
|
/// be encrypted with one [`EncryptionMethod`], using one [`DecryptionKey`]
|
||||||
|
@ -81,7 +80,6 @@ pub struct MediaSegment {
|
||||||
/// [`KeyFormat`]: crate::types::KeyFormat
|
/// [`KeyFormat`]: crate::types::KeyFormat
|
||||||
/// [`EncryptionMethod`]: crate::types::EncryptionMethod
|
/// [`EncryptionMethod`]: crate::types::EncryptionMethod
|
||||||
#[builder(default, setter(into))]
|
#[builder(default, setter(into))]
|
||||||
#[shorthand(enable(skip))]
|
|
||||||
pub keys: Vec<ExtXKey>,
|
pub keys: Vec<ExtXKey>,
|
||||||
/// This field specifies how to obtain the Media Initialization Section
|
/// This field specifies how to obtain the Media Initialization Section
|
||||||
/// required to parse the applicable `MediaSegment`s.
|
/// required to parse the applicable `MediaSegment`s.
|
||||||
|
@ -96,7 +94,6 @@ pub struct MediaSegment {
|
||||||
///
|
///
|
||||||
/// [`ExtXIFramesOnly`]: crate::tags::ExtXIFramesOnly
|
/// [`ExtXIFramesOnly`]: crate::tags::ExtXIFramesOnly
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
#[shorthand(enable(skip))]
|
|
||||||
pub map: Option<ExtXMap>,
|
pub map: Option<ExtXMap>,
|
||||||
/// This field indicates that a `MediaSegment` is a sub-range of the
|
/// This field indicates that a `MediaSegment` is a sub-range of the
|
||||||
/// resource identified by its URI.
|
/// resource identified by its URI.
|
||||||
|
@ -105,7 +102,6 @@ pub struct MediaSegment {
|
||||||
///
|
///
|
||||||
/// This field is optional.
|
/// This field is optional.
|
||||||
#[builder(default, setter(into))]
|
#[builder(default, setter(into))]
|
||||||
#[shorthand(enable(skip))]
|
|
||||||
pub byte_range: Option<ExtXByteRange>,
|
pub byte_range: Option<ExtXByteRange>,
|
||||||
/// This field associates a date-range (i.e., a range of time defined by a
|
/// 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.
|
/// starting and ending date) with a set of attribute/value pairs.
|
||||||
|
@ -114,7 +110,6 @@ pub struct MediaSegment {
|
||||||
///
|
///
|
||||||
/// This field is optional.
|
/// This field is optional.
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
#[shorthand(enable(skip))]
|
|
||||||
pub date_range: Option<ExtXDateRange>,
|
pub date_range: Option<ExtXDateRange>,
|
||||||
/// This field indicates a discontinuity between the `MediaSegment` that
|
/// This field indicates a discontinuity between the `MediaSegment` that
|
||||||
/// follows it and the one that preceded it.
|
/// follows it and the one that preceded it.
|
||||||
|
@ -131,7 +126,6 @@ pub struct MediaSegment {
|
||||||
/// - encoding parameters
|
/// - encoding parameters
|
||||||
/// - encoding sequence
|
/// - encoding sequence
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
#[shorthand(enable(skip))]
|
|
||||||
pub has_discontinuity: bool,
|
pub has_discontinuity: bool,
|
||||||
/// This field associates the first sample of a media segment with an
|
/// This field associates the first sample of a media segment with an
|
||||||
/// absolute date and/or time.
|
/// absolute date and/or time.
|
||||||
|
@ -140,14 +134,12 @@ pub struct MediaSegment {
|
||||||
///
|
///
|
||||||
/// This field is optional.
|
/// This field is optional.
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
#[shorthand(enable(skip))]
|
|
||||||
pub program_date_time: Option<ExtXProgramDateTime>,
|
pub program_date_time: Option<ExtXProgramDateTime>,
|
||||||
/// This field indicates the duration of a media segment.
|
/// This field indicates the duration of a media segment.
|
||||||
///
|
///
|
||||||
/// ## Note
|
/// ## Note
|
||||||
///
|
///
|
||||||
/// This field is required.
|
/// This field is required.
|
||||||
#[shorthand(enable(skip))]
|
|
||||||
#[builder(setter(into))]
|
#[builder(setter(into))]
|
||||||
pub duration: ExtInf,
|
pub duration: ExtInf,
|
||||||
/// The URI of a media segment.
|
/// The URI of a media segment.
|
||||||
|
@ -156,7 +148,7 @@ pub struct MediaSegment {
|
||||||
///
|
///
|
||||||
/// This field is required.
|
/// This field is required.
|
||||||
#[builder(setter(into))]
|
#[builder(setter(into))]
|
||||||
#[shorthand(enable(into))]
|
#[shorthand(enable(into), disable(skip))]
|
||||||
uri: String,
|
uri: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue