AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Namespaces | Classes | Typedefs | Functions | Variables
alexaClientSDK::playlistParser Namespace Reference

Namespaces

 test
 

Classes

class  ContentDecrypter
 
struct  EVP_CIPHER_CTX_Deleter
 Unique ptr to auto release EVP_CIPHER_CTX. More...
 
class  FFMpegInputBuffer
 
class  Id3TagsRemover
 
class  IterativePlaylistParser
 
struct  M3UContent
 A struct used to encapsulate information retrieved from an M3U playlist. More...
 
struct  PlayItem
 
class  PlaylistParser
 
class  UrlContentToAttachmentConverter
 Class that handles the streaming of urls containing media into Attachments. More...
 

Typedefs

typedef std::vector< unsigned char > ByteVector
 Alias for bytes. More...
 
using EVP_CIPHER_CTX_free_ptr = std::unique_ptr< EVP_CIPHER_CTX, EVP_CIPHER_CTX_Deleter >
 

Functions

bool isPlaylistExtendedM3U (const std::string &playlistContent)
 
M3UContent parseM3UContent (const std::string &playlistURL, const std::string &content)
 
avsCommon::utils::playlistParser::EncryptionInfo parseHLSEncryptionLine (const std::string &line, const std::string &baseURL)
 
long parsePlaylistMediaSequence (const std::string &line)
 
avsCommon::utils::playlistParser::ByteRange parseHLSByteRangeLine (const std::string &line)
 
avsCommon::utils::playlistParser::PlaylistEntry parseHLSMapLine (const std::string &line, const std::string &baseURL)
 
std::vector< std::string > parsePLSContent (const std::string &playlistURL, const std::string &content)
 
void removeCarriageReturnFromLine (std::string *line)
 
bool readFromContentFetcher (std::unique_ptr< avsCommon::sdkInterfaces::HTTPContentFetcherInterface > contentFetcher, std::string *content, std::atomic< bool > *shouldShutDown, std::string *playlistURL)
 
bool isURLAbsolute (const std::string &url)
 
bool getAbsoluteURLFromRelativePathToURL (std::string baseURL, std::string relativePath, std::string *absoluteURL)
 
static const std::string TAG ("ContentDecrypter")
 String to identify log entries originating from this file. More...
 
static const std::chrono::milliseconds WRITE_TO_STREAM_TIMEOUT (100)
 Timeout for write to stream. More...
 
static const std::string TAG ("Id3TagsRemover")
 
static const std::size_t CHUNK_SIZE (1024)
 The number of bytes read from the attachment with each read in the read loop. More...
 
static const std::string TAG ("IterativePlaylistParser")
 String to identify log entries originating from this file. More...
 
static const std::string TAG ("M3UParser")
 String to identify log entries originating from this file. More...
 
std::chrono::milliseconds parseRuntime (const std::string &line)
 
bool getAbsoluteURL (const std::string &baseURL, const std::string &url, std::string *absoluteURL)
 
bool hasPrefix (const std::string &line, const std::string &prefix)
 
static std::string to16ByteHexString (int number)
 
std::string parseURIAttribute (const std::string &line, const std::string &baseURL)
 
ByteRange parseByteRange (const std::string &byteRange)
 
static const std::string TAG ("PlaylistParser")
 String to identify log entries originating from this file. More...
 
static const std::string TAG ("PlaylistUtils")
 String to identify log entries originating from this file. More...
 
static const size_t CHUNK_SIZE (1024)
 The number of bytes read from the attachment with each read in the read loop. More...
 
bool readFromContentFetcher (std::unique_ptr< HTTPContentFetcherInterface > contentFetcher, std::string *content, std::atomic< bool > *shouldShutDown, std::string *playlistURL)
 
static const std::string TAG ("UrlContentToAttachmentConverter")
 String to identify log entries originating from this file. More...
 
static const size_t CHUNK_SIZE (1024)
 The number of bytes read from the attachment with each read in the read loop. More...
 

Variables

static constexpr long INVALID_MEDIA_SEQUENCE = -1
 An invalid media sequence number. More...
 
static const int AES_BLOCK_SIZE = 16
 Block size of AES encrypted content. More...
 
static const int IV_HEX_STRING_LENGTH = 2 * AES_BLOCK_SIZE
 Length of initilization vector as hex string. More...
 
static const std::chrono::milliseconds WAIT_FOR_ACTIVITY_TIMEOUT {100}
 Timeout for polling loops that check activity between read or write. More...
 
static const std::string M3U_CONTENT_TYPE = "mpegurl"
 The HTML content-type of an M3U playlist. More...
 
static const std::string PLS_CONTENT_TYPE = "scpls"
 The HTML content-type of a PLS playlist. More...
 
static const auto INVALID_DURATION = std::chrono::milliseconds(-1)
 An invalid duration. More...
 
static const std::string EXT_M3U_PLAYLIST_HEADER = "#EXTM3U"
 The first line of an Extended M3U playlist. More...
 
static const std::string EXTXMEDIASEQUENCE = "#EXT-X-MEDIA-SEQUENCE:"
 The key to identify the media sequence tag. More...
 
static const std::string EXTINF = "#EXTINF"
 HLS EXTINF tag. More...
 
static const std::string EXTSTREAMINF = "#EXT-X-STREAM-INF"
 
static const std::string ENDLIST = "#EXT-X-ENDLIST"
 
static const std::string EXT_KEY = "#EXT-X-KEY:"
 EXT-X-KEY HLS tag. More...
 
static const std::string EXT_MAP = "#EXT-X-MAP:"
 EXT-X-MAP HLS tag. More...
 
static const std::string EXT_BYTERANGE = "#EXT-X-BYTERANGE:"
 EXT-X-BYTERANGE HLS tag. More...
 
static const std::string METHOD_ATTR = "METHOD="
 Method encryption attribute. More...
 
static const std::string URI_ATTR = "URI=\""
 HLS tag attribute for URI. More...
 
static const std::string IV_ATTR = "IV="
 Initialization Vector encryption attribute. More...
 
static const std::string BYTERANGE_ATTR = "BYTERANGE=\""
 Byte range encryption attribute. More...
 
static const std::string ENCRYPTION_METHOD_NONE = "NONE"
 Encryption method: NONE. More...
 
static const std::string ENCRYPTION_METHOD_AES_128 = "AES-128"
 Encryption method: AES-128. More...
 
static const std::string ENCRYPTION_METHOD_SAMPLE_AES = "SAMPLE-AES"
 Encryption method: SAMPLE-AES. More...
 
static const auto INVALID_DURATION = std::chrono::milliseconds(-1)
 An invalid duration. More...
 
static const int IV_HEX_STRING_LENGTH = 32
 Length of initialization vector as hex string. More...
 
static const std::string M3U_CONTENT_TYPE = "mpegurl"
 The HTML content-type of an M3U playlist. More...
 
static const std::string PLS_CONTENT_TYPE = "scpls"
 The HTML content-type of a PLS playlist. More...
 
static int g_id = 0
 The id of each request. More...
 
static const auto INVALID_DURATION = std::chrono::milliseconds(-1)
 An invalid duration. More...
 
static const std::string PLS_FILE = "File"
 The beginning of a line in a PLS file indicating a URL. More...
 
static const std::string URL_END_SCHEME_PATTERN = "://"
 url scheme pattern. More...
 
static const std::chrono::milliseconds WAIT_FOR_ACTIVITY_TIMEOUT {100}
 A wait period for a polling loop that constantly check if a content fetcher finished fetching the payload or failed. More...
 
static const std::string PROCESS_ATTACHMENT_ID = "download:"
 Process attachment ID. More...
 
static const std::chrono::minutes PLAYLIST_FETCH_TIMEOUT {5}
 Timeout to wait for a playlist to arrive from the content fetcher. More...
 
static const std::chrono::milliseconds INVALID_DURATION = std::chrono::milliseconds(-1)
 An invalid duration. More...
 
static const std::chrono::milliseconds WAIT_FOR_ACTIVITY_TIMEOUT {100}
 Timeout for polling loops that check activities running on separate threads. More...
 

Typedef Documentation

◆ ByteVector

typedef std::vector<unsigned char> alexaClientSDK::playlistParser::ByteVector

Alias for bytes.

◆ EVP_CIPHER_CTX_free_ptr

using alexaClientSDK::playlistParser::EVP_CIPHER_CTX_free_ptr = typedef std::unique_ptr<EVP_CIPHER_CTX, EVP_CIPHER_CTX_Deleter>

Function Documentation

◆ CHUNK_SIZE() [1/3]

static const std::size_t alexaClientSDK::playlistParser::CHUNK_SIZE ( 1024  )
static

The number of bytes read from the attachment with each read in the read loop.

◆ CHUNK_SIZE() [2/3]

static const size_t alexaClientSDK::playlistParser::CHUNK_SIZE ( 1024  )
static

The number of bytes read from the attachment with each read in the read loop.

◆ CHUNK_SIZE() [3/3]

static const size_t alexaClientSDK::playlistParser::CHUNK_SIZE ( 1024  )
static

The number of bytes read from the attachment with each read in the read loop.

◆ getAbsoluteURL()

bool alexaClientSDK::playlistParser::getAbsoluteURL ( const std::string &  baseURL,
const std::string &  url,
std::string *  absoluteURL 
)

Helper method to convert a line in HLS playlist to absolute URL.

Parameters
baseURLThe URL of the HLS playlist.
urlThe URL found in HLS playlist.
[out]absoluteURLAbsolute URL parsed from line and converted to an absolute URL.
Returns
true if method is successful or false otherwise.

◆ getAbsoluteURLFromRelativePathToURL()

bool alexaClientSDK::playlistParser::getAbsoluteURLFromRelativePathToURL ( std::string  baseURL,
std::string  relativePath,
std::string *  absoluteURL 
)

Creates an absolute url, given a base url and a relative path from that url. For example, if "www.awesomewebsite.com/music/test.m3u" was the base url and the relative path was "music.mp3", "www.awesomewebsite.com/music/music.mp3" would be returned.

Parameters
baseURLThe base url to add the relative path to.
relativePathThe relative path to add to the base url.
[out]absoluteURLThe absolute url generated
Returns
true If everything was successful and false otherwise.

◆ hasPrefix()

bool alexaClientSDK::playlistParser::hasPrefix ( const std::string &  line,
const std::string &  prefix 
)
inline

Helper method to check if line starts with prefix.

Parameters
lineA HLS line.
prefixThe prefix to check.
Returns
true if line starts with prefix, false otherwise.

◆ isPlaylistExtendedM3U()

bool alexaClientSDK::playlistParser::isPlaylistExtendedM3U ( const std::string &  playlistContent)

Determines the playlist type of an M3U playlist.

Parameters
playlistContentThe M3U playlist in std::string format.
Returns
true if the playlist is extended M3U or false otherwise

◆ isURLAbsolute()

bool alexaClientSDK::playlistParser::isURLAbsolute ( const std::string &  url)

Determines whether the provided url is an absolute url as opposed to a relative url. This is done by simply checking to see if the string contains the substring "://".

Parameters
urlThe url to check.
Returns
true if the url is an absolute url and false otherwise.

◆ parseByteRange()

ByteRange alexaClientSDK::playlistParser::parseByteRange ( const std::string &  byteRange)

◆ parseHLSByteRangeLine()

ByteRange alexaClientSDK::playlistParser::parseHLSByteRangeLine ( const std::string &  line)

Parses #EXT-X-BYTERANGE line of HLS playlist and returns ByteRange.

Parameters
lineThe line to parse.
Returns
Returns ByteRange - {start, end}.

◆ parseHLSEncryptionLine()

EncryptionInfo alexaClientSDK::playlistParser::parseHLSEncryptionLine ( const std::string &  line,
const std::string &  baseURL 
)

Parses #EXT-X-KEY line of HLS playlist and returns EncryptionInfo.

Parameters
lineThe line to parse.
baseURLThe URL of the playlist.
Returns
Returns EncryptionInfo.

◆ parseHLSMapLine()

PlaylistEntry alexaClientSDK::playlistParser::parseHLSMapLine ( const std::string &  line,
const std::string &  baseURL 
)

Parses #EXT-X-MAP line of HLS playlist and returns PlaylistEntry.

Parameters
lineThe line to parse.
baseURLThe url of the playlist.
Returns
Returns PlaylistEntry.

◆ parseM3UContent()

M3UContent alexaClientSDK::playlistParser::parseM3UContent ( const std::string &  playlistURL,
const std::string &  content 
)

Parses an M3U playlist and returns the "children" URLs in the order they appeared in the playlist.

Parameters
playlistURLThe URL of the M3U playlist that needs to be parsed.
contentText content of the downloaded M3U playlist to parse.
Returns
M3UContent which contains parsed list of variant URLs (for master playlist) OR list of @ Playlist (for media playlist).

◆ parsePlaylistMediaSequence()

long alexaClientSDK::playlistParser::parsePlaylistMediaSequence ( const std::string &  line)

Helper method that parses the media sequence field. This method assumes that the line passed begins with the media sequence tag.

Parameters
lineThe line to be parsed.
Returns
The media sequence value or INVALID_MEDIA_SEQUENCE if any issue happened during parsing.

◆ parsePLSContent()

std::vector< std::string > alexaClientSDK::playlistParser::parsePLSContent ( const std::string &  playlistURL,
const std::string &  content 
)

Parses an PLS playlist and returns the "children" URLs in the order they appeared in the playlist.

Parameters
contentThe content to parse.
Returns
A vector of URLs in the order they appeared in the playlist.

◆ parseRuntime()

std::chrono::milliseconds alexaClientSDK::playlistParser::parseRuntime ( const std::string &  line)

Helper method to parse runtime from EXTINF tag.

Parameters
lineThe EXTINF line in HLS playlist.
Returns
parsed runtime in milliseconds from line.

◆ parseURIAttribute()

std::string alexaClientSDK::playlistParser::parseURIAttribute ( const std::string &  line,
const std::string &  baseURL 
)

◆ readFromContentFetcher() [1/2]

bool alexaClientSDK::playlistParser::readFromContentFetcher ( std::unique_ptr< avsCommon::sdkInterfaces::HTTPContentFetcherInterface contentFetcher,
std::string *  content,
std::atomic< bool > *  shouldShutDown,
std::string *  playlistURL 
)

Retrieves playlist content and stores it into a string.

Parameters
contentFetcherObject used to retrieve url content.
[out]contentThe playlist content.
shouldShutDownA pointer to allow for the caller to cancel the content retrieval asynchronously
[out]playlistURLA pointer to the playlist url. This will be updated in case the last used URL to fetch the content is different.
Returns
true if no error occured or false otherwise.
Note
This function should be used to retrieve content specifically from playlist URLs. Attempting to use this on a media URL could be blocking forever as the URL might point to a live stream.

◆ readFromContentFetcher() [2/2]

bool alexaClientSDK::playlistParser::readFromContentFetcher ( std::unique_ptr< HTTPContentFetcherInterface contentFetcher,
std::string *  content,
std::atomic< bool > *  shouldShutDown,
std::string *  playlistURL 
)

◆ removeCarriageReturnFromLine()

void alexaClientSDK::playlistParser::removeCarriageReturnFromLine ( std::string *  line)

Removes a carriage return from the end of a line. This is required to handle Windows style line breaks ('
'). std::getline reads by default up to '
' so at times, the '' may be included when readinglines.

Parameters
lineThe line to parse

◆ TAG() [1/7]

static const std::string alexaClientSDK::playlistParser::TAG ( "UrlContentToAttachmentConverter"  )
static

String to identify log entries originating from this file.

◆ TAG() [2/7]

static const std::string alexaClientSDK::playlistParser::TAG ( "Id3TagsRemover"  )
static

◆ TAG() [3/7]

static const std::string alexaClientSDK::playlistParser::TAG ( "M3UParser"  )
static

String to identify log entries originating from this file.

◆ TAG() [4/7]

static const std::string alexaClientSDK::playlistParser::TAG ( "PlaylistUtils"  )
static

String to identify log entries originating from this file.

◆ TAG() [5/7]

static const std::string alexaClientSDK::playlistParser::TAG ( "IterativePlaylistParser"  )
static

String to identify log entries originating from this file.

◆ TAG() [6/7]

static const std::string alexaClientSDK::playlistParser::TAG ( "PlaylistParser"  )
static

String to identify log entries originating from this file.

◆ TAG() [7/7]

static const std::string alexaClientSDK::playlistParser::TAG ( "ContentDecrypter"  )
static

String to identify log entries originating from this file.

◆ to16ByteHexString()

static std::string alexaClientSDK::playlistParser::to16ByteHexString ( int  number)
static

◆ WRITE_TO_STREAM_TIMEOUT()

static const std::chrono::milliseconds alexaClientSDK::playlistParser::WRITE_TO_STREAM_TIMEOUT ( 100  )
static

Timeout for write to stream.

Variable Documentation

◆ AES_BLOCK_SIZE

const int alexaClientSDK::playlistParser::AES_BLOCK_SIZE = 16
static

Block size of AES encrypted content.

◆ BYTERANGE_ATTR

const std::string alexaClientSDK::playlistParser::BYTERANGE_ATTR = "BYTERANGE=\""
static

Byte range encryption attribute.

◆ ENCRYPTION_METHOD_AES_128

const std::string alexaClientSDK::playlistParser::ENCRYPTION_METHOD_AES_128 = "AES-128"
static

Encryption method: AES-128.

◆ ENCRYPTION_METHOD_NONE

const std::string alexaClientSDK::playlistParser::ENCRYPTION_METHOD_NONE = "NONE"
static

Encryption method: NONE.

◆ ENCRYPTION_METHOD_SAMPLE_AES

const std::string alexaClientSDK::playlistParser::ENCRYPTION_METHOD_SAMPLE_AES = "SAMPLE-AES"
static

Encryption method: SAMPLE-AES.

◆ ENDLIST

const std::string alexaClientSDK::playlistParser::ENDLIST = "#EXT-X-ENDLIST"
static

A tag present in a live stream playlist indicating that no more URLs will be added to the playlist on subsequent requests.

◆ EXT_BYTERANGE

const std::string alexaClientSDK::playlistParser::EXT_BYTERANGE = "#EXT-X-BYTERANGE:"
static

EXT-X-BYTERANGE HLS tag.

◆ EXT_KEY

const std::string alexaClientSDK::playlistParser::EXT_KEY = "#EXT-X-KEY:"
static

EXT-X-KEY HLS tag.

◆ EXT_M3U_PLAYLIST_HEADER

const std::string alexaClientSDK::playlistParser::EXT_M3U_PLAYLIST_HEADER = "#EXTM3U"
static

The first line of an Extended M3U playlist.

◆ EXT_MAP

const std::string alexaClientSDK::playlistParser::EXT_MAP = "#EXT-X-MAP:"
static

EXT-X-MAP HLS tag.

◆ EXTINF

const std::string alexaClientSDK::playlistParser::EXTINF = "#EXTINF"
static

HLS EXTINF tag.

◆ EXTSTREAMINF

const std::string alexaClientSDK::playlistParser::EXTSTREAMINF = "#EXT-X-STREAM-INF"
static

A tag present in a live stream playlist that indicates that the next URL points to a playlist. Attributes of this tag include information such as bitrate, codecs, and others.

◆ EXTXMEDIASEQUENCE

const std::string alexaClientSDK::playlistParser::EXTXMEDIASEQUENCE = "#EXT-X-MEDIA-SEQUENCE:"
static

The key to identify the media sequence tag.

◆ g_id

int alexaClientSDK::playlistParser::g_id = 0
static

The id of each request.

◆ INVALID_DURATION [1/4]

const std::chrono::milliseconds alexaClientSDK::playlistParser::INVALID_DURATION = std::chrono::milliseconds(-1)
static

An invalid duration.

◆ INVALID_DURATION [2/4]

const auto alexaClientSDK::playlistParser::INVALID_DURATION = std::chrono::milliseconds(-1)
static

An invalid duration.

◆ INVALID_DURATION [3/4]

const auto alexaClientSDK::playlistParser::INVALID_DURATION = std::chrono::milliseconds(-1)
static

An invalid duration.

◆ INVALID_DURATION [4/4]

const auto alexaClientSDK::playlistParser::INVALID_DURATION = std::chrono::milliseconds(-1)
static

An invalid duration.

◆ INVALID_MEDIA_SEQUENCE

constexpr long alexaClientSDK::playlistParser::INVALID_MEDIA_SEQUENCE = -1
static

An invalid media sequence number.

◆ IV_ATTR

const std::string alexaClientSDK::playlistParser::IV_ATTR = "IV="
static

Initialization Vector encryption attribute.

◆ IV_HEX_STRING_LENGTH [1/2]

const int alexaClientSDK::playlistParser::IV_HEX_STRING_LENGTH = 2 * AES_BLOCK_SIZE
static

Length of initilization vector as hex string.

◆ IV_HEX_STRING_LENGTH [2/2]

const int alexaClientSDK::playlistParser::IV_HEX_STRING_LENGTH = 32
static

Length of initialization vector as hex string.

◆ M3U_CONTENT_TYPE [1/2]

const std::string alexaClientSDK::playlistParser::M3U_CONTENT_TYPE = "mpegurl"
static

The HTML content-type of an M3U playlist.

◆ M3U_CONTENT_TYPE [2/2]

const std::string alexaClientSDK::playlistParser::M3U_CONTENT_TYPE = "mpegurl"
static

The HTML content-type of an M3U playlist.

◆ METHOD_ATTR

const std::string alexaClientSDK::playlistParser::METHOD_ATTR = "METHOD="
static

Method encryption attribute.

◆ PLAYLIST_FETCH_TIMEOUT

const std::chrono::minutes alexaClientSDK::playlistParser::PLAYLIST_FETCH_TIMEOUT {5}
static

Timeout to wait for a playlist to arrive from the content fetcher.

◆ PLS_CONTENT_TYPE [1/2]

const std::string alexaClientSDK::playlistParser::PLS_CONTENT_TYPE = "scpls"
static

The HTML content-type of a PLS playlist.

◆ PLS_CONTENT_TYPE [2/2]

const std::string alexaClientSDK::playlistParser::PLS_CONTENT_TYPE = "scpls"
static

The HTML content-type of a PLS playlist.

◆ PLS_FILE

const std::string alexaClientSDK::playlistParser::PLS_FILE = "File"
static

The beginning of a line in a PLS file indicating a URL.

◆ PROCESS_ATTACHMENT_ID

const std::string alexaClientSDK::playlistParser::PROCESS_ATTACHMENT_ID = "download:"
static

Process attachment ID.

◆ URI_ATTR

const std::string alexaClientSDK::playlistParser::URI_ATTR = "URI=\""
static

HLS tag attribute for URI.

◆ URL_END_SCHEME_PATTERN

const std::string alexaClientSDK::playlistParser::URL_END_SCHEME_PATTERN = "://"
static

url scheme pattern.

◆ WAIT_FOR_ACTIVITY_TIMEOUT [1/3]

const std::chrono::milliseconds alexaClientSDK::playlistParser::WAIT_FOR_ACTIVITY_TIMEOUT {100}
static

Timeout for polling loops that check activity between read or write.

◆ WAIT_FOR_ACTIVITY_TIMEOUT [2/3]

const std::chrono::milliseconds alexaClientSDK::playlistParser::WAIT_FOR_ACTIVITY_TIMEOUT {100}
static

Timeout for polling loops that check activities running on separate threads.

◆ WAIT_FOR_ACTIVITY_TIMEOUT [3/3]

const std::chrono::milliseconds alexaClientSDK::playlistParser::WAIT_FOR_ACTIVITY_TIMEOUT {100}
static

A wait period for a polling loop that constantly check if a content fetcher finished fetching the payload or failed.

AlexaClientSDK 1.25.0 - Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0