1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-11-29 02:00:59 +00:00

collect unsupported tags #36

closes #36
This commit is contained in:
Luro02 2020-02-02 13:50:56 +01:00
parent 27d94faec4
commit 006f36ff47
No known key found for this signature in database
GPG key ID: B66FD4F74501A9CF
2 changed files with 30 additions and 2 deletions

View file

@ -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)
}

View file

@ -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)
}