mirror of
https://github.com/sile/hls_m3u8.git
synced 2024-11-22 15:21:01 +00:00
46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
//! Credits go to
|
|
//! - https://github.com/globocom/m3u8/blob/master/tests/playlists.py
|
|
use hls_m3u8::tags::*;
|
|
use hls_m3u8::MediaPlaylist;
|
|
|
|
use std::time::Duration;
|
|
|
|
#[test]
|
|
fn test_simple_playlist() {
|
|
let playlist = r#"
|
|
#EXTM3U
|
|
#EXT-X-TARGETDURATION:5220
|
|
#EXTINF:0,
|
|
http://media.example.com/entire1.ts
|
|
#EXTINF:5220,
|
|
http://media.example.com/entire2.ts
|
|
#EXT-X-ENDLIST"#;
|
|
|
|
let media_playlist = playlist.parse::<MediaPlaylist>().unwrap();
|
|
assert_eq!(
|
|
media_playlist.target_duration_tag(),
|
|
ExtXTargetDuration::new(Duration::from_secs(5220))
|
|
);
|
|
|
|
assert_eq!(media_playlist.segments().len(), 2);
|
|
|
|
assert_eq!(
|
|
media_playlist.segments()[0].inf_tag(),
|
|
&ExtInf::new(Duration::from_secs(0))
|
|
);
|
|
|
|
assert_eq!(
|
|
media_playlist.segments()[1].inf_tag(),
|
|
&ExtInf::new(Duration::from_secs(5220))
|
|
);
|
|
|
|
assert_eq!(
|
|
media_playlist.segments()[0].uri(),
|
|
&"http://media.example.com/entire1.ts".parse().unwrap()
|
|
);
|
|
|
|
assert_eq!(
|
|
media_playlist.segments()[1].uri(),
|
|
&"http://media.example.com/entire2.ts".parse().unwrap()
|
|
);
|
|
}
|