From 5fe3fc309c1c1d11296421702a6c9ce712f5cba6 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Wed, 20 Jan 2021 21:25:52 +1100 Subject: [PATCH] Add HDCP-LEVEL and CHANNELS fields. Add support for parsing / generating HDCP-LEVEL in a VariantStream and CHANNELS in AlternativeMedia. The fields were added after draft-pantos-http-live-streaming-19.txt and brings things up to date with RFC 8216. --- src/playlist.rs | 6 ++++++ tests/lib.rs | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/playlist.rs b/src/playlist.rs index 0ee58e7..a085e0f 100644 --- a/src/playlist.rs +++ b/src/playlist.rs @@ -179,6 +179,7 @@ pub struct VariantStream { pub codecs: Option, pub resolution: Option, pub frame_rate: Option, + pub hdcp_level: Option, pub audio: Option, pub video: Option, pub subtitles: Option, @@ -197,6 +198,7 @@ impl VariantStream { codecs: attrs.remove("CODECS"), resolution: attrs.remove("RESOLUTION"), frame_rate: attrs.remove("FRAME-RATE"), + hdcp_level: attrs.remove("HDCP-LEVEL"), audio: attrs.remove("AUDIO"), video: attrs.remove("VIDEO"), subtitles: attrs.remove("SUBTITLES"), @@ -229,6 +231,7 @@ impl VariantStream { write_some_attribute_quoted!(w, ",CODECS", &self.codecs)?; write_some_attribute!(w, ",RESOLUTION", &self.resolution)?; write_some_attribute!(w, ",FRAME-RATE", &self.frame_rate)?; + write_some_attribute!(w, ",HDCP-LEVEL", &self.hdcp_level)?; write_some_attribute_quoted!(w, ",VIDEO", &self.video) } } @@ -256,6 +259,7 @@ pub struct AlternativeMedia { pub forced: bool, // Its absence indicates an implicit value of NO pub instream_id: Option, pub characteristics: Option, + pub channels: Option, } impl AlternativeMedia { @@ -275,6 +279,7 @@ impl AlternativeMedia { forced: bool_default_false!(attrs.remove("FORCED")), instream_id: attrs.remove("INSTREAM-ID"), characteristics: attrs.remove("CHARACTERISTICS"), + channels: attrs.remove("CHANNELS"), } } @@ -291,6 +296,7 @@ impl AlternativeMedia { if self.forced { write!(w, ",FORCED=YES")?; } write_some_attribute_quoted!(w, ",INSTREAM-ID", &self.instream_id)?; write_some_attribute_quoted!(w, ",CHARACTERISTICS", &self.characteristics)?; + write_some_attribute_quoted!(w, ",CHANNELS", &self.channels)?; write!(w, "\n") } } diff --git a/tests/lib.rs b/tests/lib.rs index bf88f21..41cb456 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -314,6 +314,7 @@ fn create_and_parse_master_playlist_full() { forced: true, // Its absence indicates an implicit value of NO instream_id: Some("instream_id".into()), characteristics: Some("characteristics".into()), + channels: Some("channels".into()), } ], variants: vec![ @@ -325,11 +326,11 @@ fn create_and_parse_master_playlist_full() { codecs: Some("TheCODEC".into()), resolution: Some("1000x3000".into()), frame_rate: Some("60".into()), + hdcp_level: Some("NONE".into()), audio: Some("audio".into()), video: Some("video".into()), subtitles: Some("subtitles".into()), closed_captions: Some("closed_captions".into()), - } ], session_data: Some(SessionData {