1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-05-18 16:28:20 +00:00

various improvements to InStreamId

This commit is contained in:
Luro02 2020-02-21 20:41:31 +01:00
parent c39d104137
commit 86bb573c97
No known key found for this signature in database
GPG key ID: B66FD4F74501A9CF
2 changed files with 33 additions and 6 deletions

View file

@ -111,10 +111,17 @@ pub struct ExtXMedia {
/// essential to play.
#[builder(default)]
is_forced: bool,
/// An [`InStreamId`] specifies a rendition within the
/// segments in the [`MediaPlaylist`].
/// An [`InStreamId`] identifies a rendition within the
/// [`MediaSegment`]s in a [`MediaPlaylist`].
///
/// # Note
///
/// This attribute is required, if the [`ExtXMedia::media_type`] is
/// [`MediaType::ClosedCaptions`]. For all other [`ExtXMedia::media_type`]
/// the [`InStreamId`] must not be specified!
///
/// [`MediaPlaylist`]: crate::MediaPlaylist
/// [`MediaSegment`]: crate::MediaSegment
#[builder(setter(strip_option), default)]
#[shorthand(enable(copy))]
instream_id: Option<InStreamId>,

View file

@ -1,15 +1,26 @@
use strum::{Display, EnumString};
/// Identifier of a rendition within the segments in a media playlist.
use crate::traits::RequiredVersion;
use crate::types::ProtocolVersion;
/// Identifier of a rendition within the [`MediaSegment`]s in a
/// [`MediaPlaylist`].
///
/// See: [4.3.4.1. EXT-X-MEDIA]
/// The variants [`InStreamId::Cc1`], [`InStreamId::Cc2`], [`InStreamId::Cc3`],
/// and [`InStreamId::Cc4`] identify a Line 21 Data Services channel ([CEA608]).
///
/// [4.3.4.1. EXT-X-MEDIA]: https://tools.ietf.org/html/rfc8216#section-4.3.4.1
/// The `Service` variants identify a Digital Television Closed Captioning
/// ([CEA708]) service block number. The `Service` variants range from
/// [`InStreamId::Service1`] to [`InStreamId::Service63`].
///
/// [CEA608]: https://tools.ietf.org/html/rfc8216#ref-CEA608
/// [CEA708]: https://tools.ietf.org/html/rfc8216#ref-CEA708
/// [`MediaSegment`]: crate::MediaSegment
/// [`MediaPlaylist`]: crate::MediaPlaylist
#[non_exhaustive]
#[allow(missing_docs)]
#[strum(serialize_all = "UPPERCASE")]
#[derive(Ord, PartialOrd, Debug, Clone, Copy, PartialEq, Eq, Hash, Display, EnumString)]
#[non_exhaustive]
pub enum InStreamId {
Cc1,
Cc2,
@ -80,6 +91,15 @@ pub enum InStreamId {
Service63,
}
impl RequiredVersion for InStreamId {
fn required_version(&self) -> ProtocolVersion {
match &self {
Self::Cc1 | Self::Cc2 | Self::Cc3 | Self::Cc4 => ProtocolVersion::V1,
_ => ProtocolVersion::V7,
}
}
}
#[cfg(test)]
mod tests {
use super::*;