From 5109753b965e4de016954b1199ea056d9600f993 Mon Sep 17 00:00:00 2001 From: Rutger Schoorstra Date: Fri, 26 Jan 2024 18:54:23 +0100 Subject: [PATCH] #EXT-X-TARGETDURATION: is supposed to be a decimal-integer https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.3.1 --- src/lib.rs | 2 +- src/parser.rs | 4 ++-- src/playlist.rs | 2 +- tests/lib.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c22f723..1b740c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,7 +42,7 @@ //! //! let playlist = MediaPlaylist { //! version: Some(6), -//! target_duration: 3.0, +//! target_duration: 3, //! media_sequence: 338559, //! discontinuity_sequence: 1234, //! end_list: true, diff --git a/src/parser.rs b/src/parser.rs index cfbe9a5..10344ac 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -344,7 +344,7 @@ fn parse_media_playlist_tags(i: &[u8]) -> IResult<&[u8], Vec> enum MediaPlaylistTag { Version(usize), Segment(SegmentTag), - TargetDuration(f32), + TargetDuration(u64), MediaSequence(u64), DiscontinuitySequence(u64), EndList, @@ -361,7 +361,7 @@ fn media_playlist_tag(i: &[u8]) -> IResult<&[u8], MediaPlaylistTag> { alt(( map(version_tag, MediaPlaylistTag::Version), map( - pair(tag("#EXT-X-TARGETDURATION:"), float), + pair(tag("#EXT-X-TARGETDURATION:"), number), |(_, duration)| MediaPlaylistTag::TargetDuration(duration), ), map( diff --git a/src/playlist.rs b/src/playlist.rs index 5e9f112..8ba747b 100644 --- a/src/playlist.rs +++ b/src/playlist.rs @@ -713,7 +713,7 @@ impl SessionData { pub struct MediaPlaylist { pub version: Option, /// `#EXT-X-TARGETDURATION:` - pub target_duration: f32, + pub target_duration: u64, /// `#EXT-X-MEDIA-SEQUENCE:` pub media_sequence: u64, pub segments: Vec, diff --git a/tests/lib.rs b/tests/lib.rs index a3d594a..3b95f2d 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -304,7 +304,7 @@ fn create_and_parse_media_playlist_empty() { #[test] fn create_and_parse_media_playlist_single_segment() { let mut playlist_original = Playlist::MediaPlaylist(MediaPlaylist { - target_duration: 2.0, + target_duration: 2, segments: vec![MediaSegment { uri: "20140311T113819-01-338559live.ts".into(), duration: 2.002, @@ -321,7 +321,7 @@ fn create_and_parse_media_playlist_single_segment() { fn create_and_parse_media_playlist_full() { let mut playlist_original = Playlist::MediaPlaylist(MediaPlaylist { version: Some(4), - target_duration: 3.0, + target_duration: 3, media_sequence: 338559, discontinuity_sequence: 1234, end_list: true,