mirror of
https://github.com/sile/hls_m3u8.git
synced 2024-11-25 08:31:00 +00:00
parent
27d94faec4
commit
006f36ff47
2 changed files with 30 additions and 2 deletions
|
@ -68,6 +68,13 @@ pub struct MasterPlaylist {
|
|||
/// This tag is optional.
|
||||
#[builder(default)]
|
||||
session_key_tags: Vec<ExtXSessionKey>,
|
||||
/// A list of tags that are unknown.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This tag is optional.
|
||||
#[builder(default)]
|
||||
unknown_tags: Vec<String>,
|
||||
}
|
||||
|
||||
impl MasterPlaylist {
|
||||
|
@ -244,6 +251,10 @@ impl fmt::Display for MasterPlaylist {
|
|||
writeln!(f, "{}", value)?;
|
||||
}
|
||||
|
||||
for t in &self.unknown_tags {
|
||||
writeln!(f, "{}", t)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -259,6 +270,7 @@ impl FromStr for MasterPlaylist {
|
|||
let mut i_frame_stream_inf_tags = vec![];
|
||||
let mut session_data_tags = vec![];
|
||||
let mut session_key_tags = vec![];
|
||||
let mut unknown_tags = vec![];
|
||||
|
||||
for (i, line) in input.parse::<Lines>()?.into_iter().enumerate() {
|
||||
match line {
|
||||
|
@ -320,7 +332,7 @@ impl FromStr for MasterPlaylist {
|
|||
_ => {
|
||||
// [6.3.1. General Client Responsibilities]
|
||||
// > ignore any unrecognized tags.
|
||||
// TODO: collect custom tags
|
||||
unknown_tags.push(tag.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -335,6 +347,7 @@ impl FromStr for MasterPlaylist {
|
|||
builder.i_frame_stream_inf_tags(i_frame_stream_inf_tags);
|
||||
builder.session_data_tags(session_data_tags);
|
||||
builder.session_key_tags(session_key_tags);
|
||||
builder.unknown_tags(unknown_tags);
|
||||
|
||||
builder.build().map_err(Error::builder)
|
||||
}
|
||||
|
|
|
@ -98,6 +98,13 @@ pub struct MediaPlaylist {
|
|||
/// `Duration::from_secs(0)`.
|
||||
#[builder(default = "Duration::from_secs(0)")]
|
||||
allowable_excess_duration: Duration,
|
||||
/// A list of unknown tags.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This field is optional.
|
||||
#[builder(default)]
|
||||
unknown_tags: Vec<String>,
|
||||
}
|
||||
|
||||
impl MediaPlaylistBuilder {
|
||||
|
@ -257,6 +264,10 @@ impl fmt::Display for MediaPlaylist {
|
|||
writeln!(f, "{}", value)?;
|
||||
}
|
||||
|
||||
for value in &self.unknown_tags {
|
||||
writeln!(f, "{}", value)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -270,6 +281,7 @@ fn parse_media_playlist(
|
|||
|
||||
let mut has_partial_segment = false;
|
||||
let mut has_discontinuity_tag = false;
|
||||
let mut unknown_tags = vec![];
|
||||
|
||||
let mut available_key_tags: Vec<crate::tags::ExtXKey> = vec![];
|
||||
|
||||
|
@ -369,9 +381,11 @@ fn parse_media_playlist(
|
|||
Tag::ExtXStart(t) => {
|
||||
builder.start_tag(t);
|
||||
}
|
||||
Tag::Unknown(_) | Tag::ExtXVersion(_) => {
|
||||
Tag::ExtXVersion(_) => {}
|
||||
Tag::Unknown(_) => {
|
||||
// [6.3.1. General Client Responsibilities]
|
||||
// > ignore any unrecognized tags.
|
||||
unknown_tags.push(tag.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -389,6 +403,7 @@ fn parse_media_playlist(
|
|||
return Err(Error::invalid_input());
|
||||
}
|
||||
|
||||
builder.unknown_tags(unknown_tags);
|
||||
builder.segments(segments);
|
||||
builder.build().map_err(Error::builder)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue