2 unstable releases
0.2.0 | Jun 26, 2024 |
---|---|
0.1.0 | May 21, 2024 |
#846 in Parser implementations
93 downloads per month
150KB
3K
SLoC
HLS Playlist
A library for serializing and deserializing HLS playlists (aka extended M3U playlists).
As specified by this updated version of RFC 8216.
Usage
Playlists
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
use hls_playlist::tags::Tag;
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
#EXT-X-START:TIME-OFFSET=10
");
Features
steering-manifest
: Enables support for serializing and deserializing steering manifests.
Roadmap
This library is 100% finished and feature-complete as far as serialization goes. I'd like to implement deserialization sometime in the future.
- Serialize steering manifest
- Serialize tags
- Serialize playlist
- Deserialize steering manifest
- Deserialize tags
- Deserialize playlist
Dependencies
~1–1.5MB
~25K SLoC