TSDuck v3.40-4033
MPEG Transport Stream Toolkit
|
Playlist for HTTP Live Streaming (HLS). More...
#include <tshlsPlayList.h>
Public Member Functions | |
PlayList ()=default | |
Constructor. | |
bool | addAltPlayList (const AltPlayList &pl, Report &report=(ts::CerrReport::Instance())) |
Add an alternative rendition media playlist in a master playlist. | |
void | addCustomTag (const UString &tag) |
Add a custom tag in the playlist. | |
bool | addPlayList (const MediaPlayList &pl, Report &report=(ts::CerrReport::Instance())) |
Add a media playlist in a master playlist. | |
bool | addSegment (const MediaSegment &seg, Report &report=(ts::CerrReport::Instance())) |
Add a segment in a media playlist. | |
const AltPlayList & | altPlayList (size_t index) const |
Get a constant reference to an alternative rendition playlist description (in master playlist). | |
size_t | altPlayListCount () const |
Get the number of altenative rendition playlists (in master playlist). | |
void | buildURL (MediaElement &media, const UString &uri) const |
Build an URL for a media segment or sub-playlist. | |
void | clear () |
Clear the content of the playlist. | |
void | clearCustomTags () |
Clear all application-specific custom tags. | |
void | deleteAltPlayList (size_t index) |
Delete an alternative rendition playlist description from a master playlist. | |
void | deletePlayList (size_t index) |
Delete a media playlist description from a master playlist. | |
Time | downloadUTC () const |
Get the download UTC time of the playlist. | |
bool | endList () const |
Get the end of list indicator (in media playlist). | |
bool | isMaster () const |
Check if the playlist is a master playlist (contains references to media playlists). | |
bool | isMedia () const |
Check if the playlist is a media playlist (contains references to media segments). | |
bool | isUpdatable () const |
Check if the playlist can be updated (and must be reloaded later). | |
bool | isValid () const |
Check if the playlist has been successfully loaded. | |
bool | loadFile (const UString &filename, bool strict=false, PlayListType type=PlayListType::UNKNOWN, Report &report=(ts::CerrReport::Instance())) |
Load the playlist from a text file. | |
bool | loadText (const UString &text, bool strict=false, PlayListType type=PlayListType::UNKNOWN, Report &report=(ts::CerrReport::Instance())) |
Load the playlist from its text content. | |
bool | loadURL (const URL &url, bool strict=false, const WebRequestArgs &args=WebRequestArgs(), PlayListType type=PlayListType::UNKNOWN, Report &report=(ts::CerrReport::Instance())) |
Load the playlist from a URL. | |
bool | loadURL (const UString &url, bool strict=false, const WebRequestArgs &args=WebRequestArgs(), PlayListType type=PlayListType::UNKNOWN, Report &report=(ts::CerrReport::Instance())) |
Load the playlist from a URL. | |
size_t | mediaSequence () const |
Get the sequence number of first segment (in media playlist). | |
const UStringList & | originalLoadedContent () const |
Get the orginal loaded text content of the playlist. | |
const MediaPlayList & | playList (size_t index) const |
Get a constant reference to a media playlist description (in master playlist). | |
size_t | playListCount () const |
Get the number of media playlists (in master playlist). | |
bool | popFirstSegment () |
Remove the first media segment and do not even return it (in media playlist). | |
bool | popFirstSegment (MediaSegment &seg) |
Remove the first media segment (in media playlist). | |
bool | reload (bool strict=false, const WebRequestArgs &args=WebRequestArgs(), Report &report=(ts::CerrReport::Instance())) |
Reload a media playlist with updated content. | |
void | reset (PlayListType type, const UString &filename, int version=3) |
Reset the content of a playlist. | |
bool | saveFile (const UString &filename=UString(), Report &report=(ts::CerrReport::Instance())) const |
Save the playlist to a text file. | |
const MediaSegment & | segment (size_t index) const |
Get a constant reference to a media segment (in media playlist). | |
size_t | segmentCount () const |
Get the number of media segments (in media playlist). | |
size_t | selectAltPlayList (const UString &type=UString(), const UString &name=UString(), const UString &groupId=UString(), const UString &language=UString()) const |
Select the first alternative rendition playlist with specific criteria. | |
size_t | selectPlayList (const BitRate &minBitrate, const BitRate &maxBitrate, size_t minWidth, size_t maxWidth, size_t minHeight, size_t maxHeight) const |
Select the first media playlist with specific constraints. | |
size_t | selectPlayListHighestBitRate () const |
Select the media playlist with the highest bitrate. | |
size_t | selectPlayListHighestResolution () const |
Select the media playlist with the highest resolution. | |
size_t | selectPlayListLowestBitRate () const |
Select the media playlist with the lowest bitrate. | |
size_t | selectPlayListLowestResolution () const |
Select the media playlist with the lowest resolution. | |
void | setAutoSaveDirectory (const UString &dir) |
Set a directory name where all loaded files or URL are automatically saved. | |
bool | setEndList (bool end, Report &report=(ts::CerrReport::Instance())) |
Set the end of list indicator in a media playlist. | |
bool | setMediaSequence (size_t seq, Report &report=(ts::CerrReport::Instance())) |
Set the sequence number of first segment in a media playlist. | |
bool | setTargetDuration (cn::seconds duration, Report &report=(ts::CerrReport::Instance())) |
Set the segment target duration in a media playlist. | |
bool | setType (PlayListType type, Report &report=(ts::CerrReport::Instance()), bool forced=false) |
Set the playlist type. | |
bool | setTypeMedia (Report &report=(ts::CerrReport::Instance())) |
Set the playlist type as media playlist. | |
cn::seconds | targetDuration () const |
Get the segment target duration (informative, in media playlist). | |
Time | terminationUTC () const |
Get the playout estimated termination UTC time of the playlist (in media playlist). | |
UString | textContent (Report &report=(ts::CerrReport::Instance())) const |
Build the text content of the playlist. | |
virtual UString | toString () const override |
Convert to a string object. | |
PlayListType | type () const |
Get the playlist type. | |
UString | url () const |
Get the original URL. | |
int | version () const |
Get the playlist version (EXT-X-VERSION). | |
Playlist for HTTP Live Streaming (HLS).
void ts::hls::PlayList::reset | ( | PlayListType | type, |
const UString & | filename, | ||
int | version = 3 |
||
) |
Reset the content of a playlist.
Should be used before rebuilding a new playlist.
[in] | type | Playlist type. |
[in] | filename | File path where the playlist will be saved. This required to build relative paths for sub-playlists or media segments. |
[in] | version | Playlist format version. The default is 3, the minimum level which is required for playlists which are supported here. |
bool ts::hls::PlayList::loadURL | ( | const UString & | url, |
bool | strict = false , |
||
const WebRequestArgs & | args = WebRequestArgs() , |
||
PlayListType | type = PlayListType::UNKNOWN , |
||
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Load the playlist from a URL.
[in] | url | URL from which to load the playlist. |
[in] | strict | If true, perform strict conformance checking. By default, relaxed as long as we can understand the content. |
[in] | args | Web request arguments from command line. |
[in] | type | Expected playlist type, unknown by default. |
[in,out] | report | Where to report errors. |
bool ts::hls::PlayList::loadURL | ( | const URL & | url, |
bool | strict = false , |
||
const WebRequestArgs & | args = WebRequestArgs() , |
||
PlayListType | type = PlayListType::UNKNOWN , |
||
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Load the playlist from a URL.
[in] | url | URL from which to load the playlist. |
[in] | strict | If true, perform strict conformance checking. By default, relaxed as long as we can understand the content. |
[in] | args | Web request arguments from command line. |
[in] | type | Expected playlist type, unknown by default. |
[in,out] | report | Where to report errors. |
bool ts::hls::PlayList::loadFile | ( | const UString & | filename, |
bool | strict = false , |
||
PlayListType | type = PlayListType::UNKNOWN , |
||
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Load the playlist from a text file.
[in] | filename | File from which to load the playlist. |
[in] | strict | If true, perform strict conformance checking. By default, relaxed as long as we can understand the content. |
[in] | type | Expected playlist type, unknown by default. |
[in,out] | report | Where to report errors. |
bool ts::hls::PlayList::loadText | ( | const UString & | text, |
bool | strict = false , |
||
PlayListType | type = PlayListType::UNKNOWN , |
||
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Load the playlist from its text content.
[in] | text | Text of the playlist (multi-lines). |
[in] | strict | If true, perform strict conformance checking. By default, relaxed as long as we can understand the content. |
[in] | type | Expected playlist type, unknown by default. |
[in,out] | report | Where to report errors. |
bool ts::hls::PlayList::reload | ( | bool | strict = false , |
const WebRequestArgs & | args = WebRequestArgs() , |
||
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Reload a media playlist with updated content.
Master playlists or media playlists for which endList() is true are never reloaded. Live playlists (media playlists for which endList() is false) are reloaded from the same URL. New segments are added. If a segment hole is found, all previous content is replaced.
[in] | strict | If true, perform strict conformance checking. By default, relaxed as long as we can understand the content. |
[in] | args | Web request arguments from command line. |
[in,out] | report | Where to report errors. |
|
inline |
Set a directory name where all loaded files or URL are automatically saved.
[in] | dir | A directory name. |
|
inline |
Check if the playlist has been successfully loaded.
bool ts::hls::PlayList::saveFile | ( | const UString & | filename = UString() , |
Report & | report = (ts::CerrReport::Instance()) |
||
) | const |
Save the playlist to a text file.
[in] | filename | File where to save the playlist. By default, use the same file from loadFile() or reset(). |
[in,out] | report | Where to report errors. |
UString ts::hls::PlayList::textContent | ( | Report & | report = (ts::CerrReport::Instance()) | ) | const |
Build the text content of the playlist.
[in,out] | report | Where to report errors. |
|
inline |
Get the orginal loaded text content of the playlist.
This can be different from the current content of the playlist if the object has been modified.
void ts::hls::PlayList::buildURL | ( | MediaElement & | media, |
const UString & | uri | ||
) | const |
Build an URL for a media segment or sub-playlist.
[out] | media | A media element with all fields filled in. |
[in] | uri | An URI, typically extracted from the playlist. |
|
inline |
Get the playlist type.
bool ts::hls::PlayList::setType | ( | PlayListType | type, |
Report & | report = (ts::CerrReport::Instance()) , |
||
bool | forced = false |
||
) |
Set the playlist type.
[in] | type | The playlist type. |
[in,out] | report | Where to report errors. |
[in] | forced | When true, unconditionally set the playlist type. When false (the default), check that the playlist type does not change in an inconsistent way. Allowed changes are UNKNOWN to anything and LIVE to VOD or EVENT. The latter case is a playlist which is known to be a media playlist but for which no EXT-X-PLAYLIST-TYPE tag was found so far. |
bool ts::hls::PlayList::setTypeMedia | ( | Report & | report = (ts::CerrReport::Instance()) | ) |
Set the playlist type as media playlist.
If the type is already known and already a media playlist, do nothing. If the type is unknown, set it as LIVE which is a media playlist type without EXT-X-PLAYLIST-TYPE tag and which can be later turned into a VOD or EVENT playlist.
[in,out] | report | Where to report errors. |
|
inline |
Add a custom tag in the playlist.
[in] | tag | A custom tag line to add in the playlist. If does not start with a '#' , it will be automatically added. |
|
inline |
Clear all application-specific custom tags.
|
inline |
Check if the playlist can be updated (and must be reloaded later).
|
inline |
Check if the playlist is a media playlist (contains references to media segments).
|
inline |
Check if the playlist is a master playlist (contains references to media playlists).
|
inline |
Get the playlist version (EXT-X-VERSION).
|
inline |
Get the segment target duration (informative, in media playlist).
bool ts::hls::PlayList::setTargetDuration | ( | cn::seconds | duration, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Set the segment target duration in a media playlist.
[in] | duration | The segment target duration in seconds. |
[in,out] | report | Where to report errors. |
|
inline |
Get the sequence number of first segment (in media playlist).
bool ts::hls::PlayList::setMediaSequence | ( | size_t | seq, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Set the sequence number of first segment in a media playlist.
[in] | seq | The sequence number of first segment. |
[in,out] | report | Where to report errors. |
|
inline |
Get the end of list indicator (in media playlist).
bool ts::hls::PlayList::setEndList | ( | bool | end, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Set the end of list indicator in a media playlist.
[in] | end | The end of list indicator. |
[in,out] | report | Where to report errors. |
|
inline |
Get the number of media segments (in media playlist).
|
inline |
Get the number of media playlists (in master playlist).
|
inline |
Get the number of altenative rendition playlists (in master playlist).
const MediaSegment & ts::hls::PlayList::segment | ( | size_t | index | ) | const |
Get a constant reference to a media segment (in media playlist).
[in] | index | Index of the segment, from 0 to segmentCount(). |
bool ts::hls::PlayList::popFirstSegment | ( | MediaSegment & | seg | ) |
Remove the first media segment (in media playlist).
[out] | seg | Characteristics of the first segment. |
bool ts::hls::PlayList::popFirstSegment | ( | ) |
Remove the first media segment and do not even return it (in media playlist).
bool ts::hls::PlayList::addSegment | ( | const MediaSegment & | seg, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Add a segment in a media playlist.
[in] | seg | The new media segment to append. If the playlist's URI is a file name, the URI of the segment is transformed into a relative URI from the playlist's path. |
[in,out] | report | Where to report errors. |
|
inline |
Get the download UTC time of the playlist.
|
inline |
Get the playout estimated termination UTC time of the playlist (in media playlist).
const MediaPlayList & ts::hls::PlayList::playList | ( | size_t | index | ) | const |
Get a constant reference to a media playlist description (in master playlist).
[in] | index | Index of the playlist, from 0 to playListCount()-1. |
void ts::hls::PlayList::deletePlayList | ( | size_t | index | ) |
Delete a media playlist description from a master playlist.
[in] | index | Index of the media playlist to delete, from 0 to playListCount()-1. |
bool ts::hls::PlayList::addPlayList | ( | const MediaPlayList & | pl, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Add a media playlist in a master playlist.
[in] | pl | The new media playlist to append. If the master playlist's URI is a file name, the URI of the media playlist is transformed into a relative URI from the master playlist's path. |
[in,out] | report | Where to report errors. |
size_t ts::hls::PlayList::selectPlayList | ( | const BitRate & | minBitrate, |
const BitRate & | maxBitrate, | ||
size_t | minWidth, | ||
size_t | maxWidth, | ||
size_t | minHeight, | ||
size_t | maxHeight | ||
) | const |
Select the first media playlist with specific constraints.
[in] | minBitrate | Minimum bitrate. Zero means no minimum. |
[in] | maxBitrate | Maximum bitrate. Zero means no maximum. |
[in] | minWidth | Minimum width. Zero means no minimum. |
[in] | maxWidth | Maximum width. Zero means no maximum. |
[in] | minHeight | Minimum height. Zero means no minimum. |
[in] | maxHeight | Maximum height. Zero means no maximum. |
size_t ts::hls::PlayList::selectPlayListLowestBitRate | ( | ) | const |
Select the media playlist with the lowest bitrate.
size_t ts::hls::PlayList::selectPlayListHighestBitRate | ( | ) | const |
Select the media playlist with the highest bitrate.
size_t ts::hls::PlayList::selectPlayListLowestResolution | ( | ) | const |
Select the media playlist with the lowest resolution.
size_t ts::hls::PlayList::selectPlayListHighestResolution | ( | ) | const |
Select the media playlist with the highest resolution.
const AltPlayList & ts::hls::PlayList::altPlayList | ( | size_t | index | ) | const |
Get a constant reference to an alternative rendition playlist description (in master playlist).
[in] | index | Index of the playlist, from 0 to altPlayListCount()-1. |
void ts::hls::PlayList::deleteAltPlayList | ( | size_t | index | ) |
Delete an alternative rendition playlist description from a master playlist.
[in] | index | Index of the alternative rendition playlist to delete, from 0 to altPlayListCount()-1. |
bool ts::hls::PlayList::addAltPlayList | ( | const AltPlayList & | pl, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Add an alternative rendition media playlist in a master playlist.
[in] | pl | The new alternative rendition playlist to append. If the master playlist's URI is a file name, the URI of the media playlist is transformed into a relative URI from the master playlist's path. |
[in,out] | report | Where to report errors. |
size_t ts::hls::PlayList::selectAltPlayList | ( | const UString & | type = UString() , |
const UString & | name = UString() , |
||
const UString & | groupId = UString() , |
||
const UString & | language = UString() |
||
) | const |
Select the first alternative rendition playlist with specific criteria.
[in] | type | The type to match. Ignored if empty. |
[in] | name | The name to match. Ignored if empty. |
[in] | groupId | The group-id to match. Ignored if empty. |
[in] | language | The language to match. Ignored if empty. |
|
overridevirtual |
Convert to a string object.
Implements ts::StringifyInterface.