mirror of
https://github.com/rutgersc/m3u8-rs.git
synced 2024-12-22 06:26:28 +00:00
Support multiple session data and key tags.
Collect Vecs of session_data and session_key tags to allow for multiples of each. Doesn't do any validation as to disallowed duplicated values. Fixes #20
This commit is contained in:
parent
870ca830d3
commit
05669cab68
2 changed files with 17 additions and 16 deletions
|
@ -65,8 +65,8 @@ impl Playlist {
|
|||
pub struct MasterPlaylist {
|
||||
pub version: usize,
|
||||
pub variants: Vec<VariantStream>,
|
||||
pub session_data: Option<SessionData>,
|
||||
pub session_key: Option<SessionKey>,
|
||||
pub session_data: Vec<SessionData>,
|
||||
pub session_key: Vec<SessionKey>,
|
||||
pub start: Option<Start>,
|
||||
pub independent_segments: bool,
|
||||
pub alternatives: Vec<AlternativeMedia>, // EXT-X-MEDIA tags
|
||||
|
@ -74,7 +74,6 @@ pub struct MasterPlaylist {
|
|||
}
|
||||
|
||||
impl MasterPlaylist {
|
||||
|
||||
pub fn from_tags(mut tags: Vec<MasterPlaylistTag>) -> MasterPlaylist {
|
||||
let mut master_playlist = MasterPlaylist::default();
|
||||
|
||||
|
@ -95,10 +94,10 @@ impl MasterPlaylist {
|
|||
}
|
||||
}
|
||||
MasterPlaylistTag::SessionData(data) => {
|
||||
master_playlist.session_data = Some(data);
|
||||
master_playlist.session_data.push(data);
|
||||
}
|
||||
MasterPlaylistTag::SessionKey(key) => {
|
||||
master_playlist.session_key = Some(key);
|
||||
master_playlist.session_key.push(key);
|
||||
}
|
||||
MasterPlaylistTag::Start(s) => {
|
||||
master_playlist.start = Some(s);
|
||||
|
@ -131,10 +130,10 @@ impl MasterPlaylist {
|
|||
for variant in &self.variants {
|
||||
variant.write_to(w)?;
|
||||
}
|
||||
if let Some(ref session_data) = self.session_data {
|
||||
for session_data in &self.session_data {
|
||||
session_data.write_to(w)?;
|
||||
}
|
||||
if let Some(ref session_key) = self.session_key {
|
||||
for session_key in &self.session_key {
|
||||
session_key.write_to(w)?;
|
||||
}
|
||||
if let Some(ref start) = self.start {
|
||||
|
|
20
tests/lib.rs
20
tests/lib.rs
|
@ -333,20 +333,22 @@ fn create_and_parse_master_playlist_full() {
|
|||
closed_captions: Some("closed_captions".into()),
|
||||
}
|
||||
],
|
||||
session_data: Some(
|
||||
session_data: vec![
|
||||
SessionData {
|
||||
data_id: "****".into(),
|
||||
field: SessionDataField::Value("%%%%".to_string()),
|
||||
language: Some("SessionDataLanguage".into()),
|
||||
}
|
||||
),
|
||||
session_key: Some(SessionKey(Key {
|
||||
method: "AES-128".into(),
|
||||
uri: Some("https://secure.domain.com".into()),
|
||||
iv: Some("0xb059217aa2649ce170b734".into()),
|
||||
keyformat: Some("xXkeyformatXx".into()),
|
||||
keyformatversions: Some("xXFormatVers".into()),
|
||||
})),
|
||||
],
|
||||
session_key: vec![
|
||||
SessionKey(Key {
|
||||
method: "AES-128".into(),
|
||||
uri: Some("https://secure.domain.com".into()),
|
||||
iv: Some("0xb059217aa2649ce170b734".into()),
|
||||
keyformat: Some("xXkeyformatXx".into()),
|
||||
keyformatversions: Some("xXFormatVers".into()),
|
||||
})
|
||||
],
|
||||
start: Some(Start {
|
||||
time_offset: "123123123".into(),
|
||||
precise: Some("YES".into()),
|
||||
|
|
Loading…
Reference in a new issue