Skip to content

Commit

Permalink
Serialize multivariant playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
VixieTSQ committed Jun 26, 2024
1 parent 2a6dac1 commit a5fe68f
Show file tree
Hide file tree
Showing 5 changed files with 969 additions and 530 deletions.
44 changes: 40 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,43 @@ As specified by [this updated version of RFC 8216](https://datatracker.ietf.org/

## Usage

### Playlists

```rust
use hls_playlist::playlist::{MediaPlaylist, MediaSegment};
use hls_playlist::{FloatOrInteger};

let playlist = MediaPlaylist {
segments: vec![
MediaSegment {
uri: "https://example.com/1.mp4".into(),
duration_seconds: FloatOrInteger::Float(5.5),
title: String::new(),
byte_range_or_bitrate: None,
is_discontinuity: false,
encryption: None,
media_initialization_section: None,
absolute_time: None,
is_gap: false,
parts: vec![]
}
],
..MediaPlaylist::default()
};

let mut output = Vec::new();
playlist.serialize(&mut output).unwrap();

assert_eq!(String::from_utf8(output).unwrap(), "#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:0
#EXTINF:5.5
https://example.com/1.mp4
");
```

### Tags

```rust
use hls_playlist::tags::Tag;

Expand All @@ -14,8 +51,7 @@ let mut output = vec![];
Tag::M3u.serialize(&mut output).unwrap();
Tag::XStart { offset_seconds: 10.0, is_precise: false }.serialize(&mut output).unwrap();

assert_eq!(String::from_utf8(output).unwrap(), "\
#EXTM3U
assert_eq!(String::from_utf8(output).unwrap(), "#EXTM3U
#EXT-X-START:TIME-OFFSET=10
");
```
Expand All @@ -26,11 +62,11 @@ assert_eq!(String::from_utf8(output).unwrap(), "\

## Roadmap

This library is 100% finished and feature-complete as far as serializing tags goes, but I'd like to eventually implement a serializer for the higher level playlist representation, and also deserialization.
This library is 100% finished and feature-complete as far as serialization goes. I'd like to implement deserialization sometime in the future.

- [x] Serialize steering manifest
- [x] Serialize tags
- [ ] Serialize playlist
- [x] Serialize playlist
- [ ] Deserialize steering manifest
- [ ] Deserialize tags
- [ ] Deserialize playlist
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ pub struct DeltaUpdateInfo {
pub can_skip_dateranges: bool,
}

// TODO: Can we fill in these fields when deserializing a playlist?
/// Information about an associated Rendition that is as up-to-date as
/// the Playlist that contains the report.
#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
Loading

0 comments on commit a5fe68f

Please sign in to comment.