Crate hls_playlist

Source
Expand description

§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

Modules§

playlist
High level representations of extended M3U playlists.
steering_manifeststeering-manifest
A representation of a HLS steering manifest.
tags
Representations of extended M3U playlist tags.

Structs§

ByteRange
Represents a range of bytes in a given resource.
ByteRangeWithOffset
Represents a range of bytes in a given resource.
ContentProtectionConfiguration
Represents required content protection robustness for a given key_format
ContentSteering
Identifies a steering_manifest::SteeringManifest.
DateRange
A duration of time with specific attributes.
DateRangeCue
When to trigger an action associated with a given DateRange.
DeltaUpdateInfo
Information about the server’s playlist delta update capabilities.
PreloadHint
A hint that the client should request a resource before it is available to be delivered.
RenditionReport
Information about an associated Rendition that is as up-to-date as the Playlist that contains the report.
Resolution
A video resolution in pixels.
SessionData
Arbitrary session data.
StreamInf
Metadata for a given stream.
SupplementalCodec
Describes media samples with both a backward-compatible base layer and a newer enhancement layer.

Enums§

AttributeValue
AudioChannelInformation
Information about the audio channels in a given rendition.
DateRangeCuePosition
The relative time at which a given DateRange action is to be triggered.
DefinitionType
EncryptionMethod
Information about the encryption method of a given MediaSegment.
FloatOrInteger
HdcpLevel
The High-bandwidth Digital Content Protection level.
InStreamId
Specifies a Rendition within the segments in the MediaPlaylist.
KeyFormat
Specifies how a given encryption key is represented.
PlaylistType
If Event, Media Segments can only be added to the end of the Media Playlist. If Vod, the Media Playlist cannot change.
PreloadHintType
Whether a given resource is a PartialSegment or a MediaInitializationSection.
RenditionPlaybackPriority
The priority in which a given rendition should be chosen over another rendition.
SessionDataValue
Whether the data is stored inline or identified by a URI.
UriFormat
The format of the data value.
VideoChannelSpecifier
Indicates whether some video content is stereoscopic or not.
VideoRange