Class: shaka.hls.HlsParser

Constructor

new HlsParser()

Creates an Hls Parser object.
Implements:
Source:

Members

AUDIO_EXTENSIONS_TO_MIME_TYPES_ :Object.<string, string>

Type:
  • Object.<string, string>
Source:

EXTENSION_MAP_BY_CONTENT_TYPE_ :Object.<string, !Object.<string, string>>

Type:
  • Object.<string, !Object.<string, string>>
Source:

IMAGE_EXTENSIONS_TO_MIME_TYPES_ :Object.<string, string>

Type:
  • Object.<string, string>
Source:

KEYFORMATS_TO_DRM_PARSERS_ :Object.<string, shaka.hls.HlsParser.DrmParser_>

Type:
Source:

PresentationType_ :string

Type:
  • string
Properties:
Name Value Type Description
VOD VOD string
EVENT EVENT string
LIVE LIVE string
Source:

RAW_FORMATS_TO_MIME_TYPES_ :Object.<string, string>

Type:
  • Object.<string, string>
Source:

TEXT_EXTENSIONS_TO_MIME_TYPES_ :Object.<string, string>

Type:
  • Object.<string, string>
Source:

VIDEO_EXTENSIONS_TO_MIME_TYPES_ :Object.<string, string>

Type:
  • Object.<string, string>
Source:

globalId_ :number

Type:
  • number
Source:

globalVariables_ :Map.<string, string>

Type:
  • Map.<string, string>
Source:

groupIdToClosedCaptionsMap_ :Map.<string, Map.<string, string>>

A map from closed captions' group id, to a map of closed captions info. {group id -> {closed captions channel id -> language}}
Type:
  • Map.<string, Map.<string, string>>
Source:

groupIdToCodecsMap_ :Map.<string, string>

Type:
  • Map.<string, string>
Source:

groupIdToStreamInfosMap_ :Map.<string, !Array.<?shaka.hls.HlsParser.StreamInfo>>

A map from group id to stream infos created from the media tags.
Type:
Source:

lowestSyncTime_ :number

The lowest time value for any of the streams, as defined by the EXT-X-PROGRAM-DATE-TIME value. Measured in seconds since January 1, 1970.
Type:
  • number
Source:

lowLatencyMode_ :boolean

Type:
  • boolean
Source:

lowLatencyPresentationDelay_ :number

Type:
  • number
Source:

mapTagToInitSegmentRefMap_

A cache mapping EXT-X-MAP tag info to the InitSegmentReference created from the tag. The key is a string combining the EXT-X-MAP tag's absolute uri, and its BYTERANGE if available. {!Map.}
Source:

masterPlaylistUri_ :string

The master playlist URI, after redirects.
Type:
  • string
Source:

maxTargetDuration_ :number

Type:
  • number
Source:

minSequenceNumber_ :number

The minimum sequence number for generated segments, when ignoring EXT-X-PROGRAM-DATE-TIME.
Type:
  • number
Source:

minTargetDuration_ :number

Type:
  • number
Source:

partialTargetDuration_ :number

Partial segments target duration.
Type:
  • number
Source:

segmentsToNotifyByStream_ :Array.<!Array.<!shaka.media.SegmentReference>>

Type:
Source:

streamsSynced_ :boolean

If true, we have already calculated offsets to synchronize streams. Offsets are computed in syncStreams*_().
Type:
  • boolean
Source:

updatePlaylistDelay_ :number

This is the number of seconds we want to wait between finishing a manifest update and starting the next one. This will be set when we parse the manifest.
Type:
  • number
Source:

updatePlaylistTimer_ :shaka.util.Timer

This timer is used to trigger the start of a manifest update. A manifest update is async. Once the update is finished, the timer will be restarted to trigger the next update. The timer will only be started if the content is live content.
Type:
Source:

uriToStreamInfosMap_ :Map.<string, shaka.hls.HlsParser.StreamInfo>

A map from (verbatim) media playlist URI to stream infos representing the playlists. On update, used to iterate through and update from media playlists. On initial parse, used to iterate through and determine minimum timestamps, offsets, and to handle TS rollover. During parsing, used to avoid duplicates in the async methods createStreamInfoFromMediaTag_, createStreamInfoFromImageTag_ and createStreamInfoFromVariantTag_.
Type:
Source:

variantUriSet_ :Set.<string>

The values are strings of the form "
Type:
  • Set.<string>
Source:

Methods

fairplayDrmParser_(drmTagnon-null, mimeType) → {shaka.extern.DrmInfo}

Parameters:
Name Type Description
drmTag shaka.hls.Tag
mimeType string
Source:
Returns:
Type
shaka.extern.DrmInfo

playreadyDrmParser_(drmTagnon-null) → {shaka.extern.DrmInfo}

See: https://docs.microsoft.com/en-us/playready/packaging/mp4-based-formats-supported-by-playready-clients?tabs=case4
Parameters:
Name Type Description
drmTag shaka.hls.Tag
Source:
Returns:
Type
shaka.extern.DrmInfo

widevineDrmParser_(drmTagnon-null) → {shaka.extern.DrmInfo}

Parameters:
Name Type Description
drmTag shaka.hls.Tag
Source:
Returns:
Type
shaka.extern.DrmInfo

addVideoAttributes_(stream, widthnullable, heightnullable, frameRatenullable, videoRangenullable)

Parameters:
Name Type Attributes Description
stream shaka.extern.Stream
width string <nullable>
height string <nullable>
frameRate string <nullable>
videoRange string <nullable>
Source:

configure(config)

Called by the Player to provide an updated configuration any time the configuration changes. Will be called at least once before start().
Parameters:
Name Type Description
config shaka.extern.ManifestConfiguration
Implements:
Source:

convertParsedPlaylistIntoStreamInfo_(playlistnon-null, verbatimMediaPlaylistUri, absoluteMediaPlaylistUri, codecs, type, language, primary, namenullable, channelsCountnullable, closedCaptions, characteristicsnullable, forced, spatialAudio, mimeType) → {Promise.<!shaka.hls.HlsParser.StreamInfo>}

Parameters:
Name Type Attributes Description
playlist shaka.hls.Playlist
verbatimMediaPlaylistUri string
absoluteMediaPlaylistUri string
codecs string
type string
language string
primary boolean
name string <nullable>
channelsCount number <nullable>
closedCaptions Map.<string, string>
characteristics string <nullable>
forced boolean
spatialAudio boolean
mimeType string | undefined
Source:
Returns:
Type
Promise.<!shaka.hls.HlsParser.StreamInfo>

createInitSegmentReference_(absoluteInitSegmentUri, mapTagnon-null) → {shaka.media.InitSegmentReference}

Create an InitSegmentReference object for the EXT-X-MAP tag in the media playlist.
Parameters:
Name Type Description
absoluteInitSegmentUri string
mapTag shaka.hls.Tag EXT-X-MAP
Source:
Returns:
Type
shaka.media.InitSegmentReference

createPresentationTimeline_()

Source:

createSegmentReference_(initSegmentReference, previousReference, hlsSegmentnon-null, startTime, variablesnon-null, absoluteMediaPlaylistUri, type, hlsAes128Keyopt) → {shaka.media.SegmentReference}

Parses one shaka.hls.Segment object into a shaka.media.SegmentReference.
Parameters:
Name Type Attributes Description
initSegmentReference shaka.media.InitSegmentReference
previousReference shaka.media.SegmentReference
hlsSegment shaka.hls.Segment
startTime number
variables Map.<string, string>
absoluteMediaPlaylistUri string
type string
hlsAes128Key shaka.extern.HlsAes128Key <optional>
Source:
Returns:
Type
shaka.media.SegmentReference

createSegments_(verbatimMediaPlaylistUri, playlistnon-null, type, mimeType, mediaSequenceToStartTimenon-null, variablesnon-null, codecs) → {Array.<!shaka.media.SegmentReference>}

Parses shaka.hls.Segment objects into shaka.media.SegmentReferences.
Parameters:
Name Type Description
verbatimMediaPlaylistUri string
playlist shaka.hls.Playlist
type string
mimeType string
mediaSequenceToStartTime Map.<number, number>
variables Map.<string, string>
codecs string
Source:
Returns:
Type
Array.<!shaka.media.SegmentReference>

createStreamInfo_(verbatimMediaPlaylistUri, codecs, type, language, primary, namenullable, channelsCountnullable, closedCaptions, characteristicsnullable, forced, spatialAudio) → {Promise.<!shaka.hls.HlsParser.StreamInfo>}

Parameters:
Name Type Attributes Description
verbatimMediaPlaylistUri string
codecs string
type string
language string
primary boolean
name string <nullable>
channelsCount number <nullable>
closedCaptions Map.<string, string>
characteristics string <nullable>
forced boolean
spatialAudio boolean
Source:
Returns:
Type
Promise.<!shaka.hls.HlsParser.StreamInfo>

createStreamInfoFromImageTag_(tag) → {Promise.<!shaka.hls.HlsParser.StreamInfo>}

Parse EXT-X-MEDIA media tag into a Stream object.
Parameters:
Name Type Description
tag shaka.hls.Tag
Source:
Returns:
Type
Promise.<!shaka.hls.HlsParser.StreamInfo>

createStreamInfoFromMediaTag_(tag) → {Promise.<!shaka.hls.HlsParser.StreamInfo>}

Parse EXT-X-MEDIA media tag into a Stream object.
Parameters:
Name Type Description
tag shaka.hls.Tag
Source:
Returns:
Type
Promise.<!shaka.hls.HlsParser.StreamInfo>

createStreamInfoFromVariantTag_(tagnon-null, allCodecsnon-null, type) → {Promise.<!shaka.hls.HlsParser.StreamInfo>}

Parse an EXT-X-STREAM-INF media tag into a Stream object.
Parameters:
Name Type Description
tag shaka.hls.Tag
allCodecs Array.<string>
type string
Source:
Returns:
Type
Promise.<!shaka.hls.HlsParser.StreamInfo>

createStreamInfosForVariantTag_(tagnon-null, resolutionnullable, frameRatenullable) → {Promise.<!shaka.hls.HlsParser.StreamInfos>}

Create audio and video streamInfos from an 'EXT-X-STREAM-INF' tag and its related media tags.
Parameters:
Name Type Attributes Description
tag shaka.hls.Tag
resolution string <nullable>
frameRate string <nullable>
Source:
Returns:
Type
Promise.<!shaka.hls.HlsParser.StreamInfos>

createStreamInfosFromMediaTags_(mediaTagsnon-null)

Parameters:
Name Type Description
mediaTags Array.<!shaka.hls.Tag> Media tags from the playlist.
Source:

createVariants_(audioInfosnon-null, videoInfosnon-null, bandwidth, widthnullable, heightnullable, frameRatenullable, videoRangenullable) → {Array.<!shaka.extern.Variant>}

Parameters:
Name Type Attributes Description
audioInfos Array.<shaka.hls.HlsParser.StreamInfo>
videoInfos Array.<shaka.hls.HlsParser.StreamInfo>
bandwidth number
width string <nullable>
height string <nullable>
frameRate string <nullable>
videoRange string <nullable>
Source:
Returns:
Type
Array.<!shaka.extern.Variant>

createVariantsForTags_(tagsnon-null) → {Promise.<!Array.<!shaka.extern.Variant>>}

Parameters:
Name Type Description
tags Array.<!shaka.hls.Tag> Variant tags from the playlist.
Source:
Returns:
Type
Promise.<!Array.<!shaka.extern.Variant>>

determinePresentationType_(playlistnon-null)

Parameters:
Name Type Description
playlist shaka.hls.Playlist
Source:

filterLegacyCodecs_(streamInfos)

Filters out unsupported codec strings from an array of stream infos.
Parameters:
Name Type Description
streamInfos shaka.hls.HlsParser.StreamInfos
Source:

getChannelsCount_(tagnon-null) → {number}

Get the channel count information for an HLS audio track. CHANNELS specifies an ordered, "/" separated list of parameters. If the type is audio, the first parameter will be a decimal integer specifying the number of independent, simultaneous audio channels. No other channels parameters are currently defined.
Parameters:
Name Type Description
tag shaka.hls.Tag
Source:
Returns:
Type
number

getClosedCaptions_(tagnon-null, type) → {Map.<string, string>}

Get the closed captions map information for the EXT-X-STREAM-INF tag, to create the stream info.
Parameters:
Name Type Description
tag shaka.hls.Tag
type string
Source:
Returns:
closedCaptions
Type
Map.<string, string>

getCodecsForVariantTag_(tagnon-null) → {Array.<string>}

Get the codecs from the 'EXT-X-STREAM-INF' tag.
Parameters:
Name Type Description
tag shaka.hls.Tag
Source:
Returns:
codecs
Type
Array.<string>

getInitSegmentReference_(playlistUri, tagsnon-null, variablesnon-null) → {shaka.media.InitSegmentReference}

Get the InitSegmentReference for a segment if it has a EXT-X-MAP tag.
Parameters:
Name Type Description
playlistUri string The absolute uri of the media playlist.
tags Array.<!shaka.hls.Tag> Segment tags
variables Map.<string, string>
Source:
Returns:
Type
shaka.media.InitSegmentReference

getLanguage_(tagnon-null) → {string}

Get the language value.
Parameters:
Name Type Description
tag shaka.hls.Tag
Source:
Returns:
Type
string

getRequiredTag_(tagsnon-null, tagName) → {shaka.hls.Tag}

Returns a tag with a given name. Throws an error if tag was not found.
Parameters:
Name Type Description
tags Array.<shaka.hls.Tag>
tagName string
Source:
Returns:
Type
shaka.hls.Tag

getType_(tagnon-null) → {string}

Get the type value. Shaka recognizes the content types 'audio', 'video' and 'text'. The HLS 'subtitles' type needs to be mapped to 'text'.
Parameters:
Name Type Description
tag shaka.hls.Tag
Source:
Returns:
Type
string

guessMimeType_(contentType, codecs, playlistnon-null, variablesnon-null) → {Promise.<string>}

Attempts to guess stream's mime type based on content type and URI.
Parameters:
Name Type Description
contentType string
codecs string
playlist shaka.hls.Playlist
variables Map.<string, string>
Source:
Returns:
Type
Promise.<string>

isLive_() → {boolean}

Source:
Returns:
Type
boolean

isSpatialAudio_(tagnon-null) → {boolean}

Get the spatial audio information for an HLS audio track. In HLS the channels field indicates the number of audio channels that the stream has (eg: 2). In the case of Dolby Atmos, the complexity is expressed with the number of channels followed by the word JOC (eg: 16/JOC), so 16 would be the number of channels (eg: 7.3.6 layout), and JOC indicates that the stream has spatial audio.
Parameters:
Name Type Description
tag shaka.hls.Tag
Source:
See:
Returns:
Type
boolean

makeNetworkRequest_(request, type) → {Promise.<shaka.extern.Response>}

Create a networking request. This will manage the request using the parser's operation manager. If the parser has already been stopped, the request will not be made.
Parameters:
Name Type Description
request shaka.extern.Request
type shaka.net.NetworkingEngine.RequestType
Source:
Returns:
Type
Promise.<shaka.extern.Response>

notifySegments_()

Source:

offsetStreamInfo_(streamInfonon-null, offset)

Parameters:
Name Type Description
streamInfo shaka.hls.HlsParser.StreamInfo
offset number
Source:

onExpirationUpdated(sessionId, expiration)

Tells the parser that the expiration time of an EME session has changed. Implementing this is optional.
Parameters:
Name Type Description
sessionId string
expiration number
Implements:
Source:

onUpdate_() → {Promise}

Called when the update timer ticks. Because parsing a manifest is async, this method is async. To work with this, this method will schedule the next update when it finished instead of using a repeating-start.
Source:
Returns:
Type
Promise

parseAES128DrmTag_(drmTagnon-null, playlistnon-null) → {shaka.extern.HlsAes128Key}

Parameters:
Name Type Description
drmTag shaka.hls.Tag
playlist shaka.hls.Playlist
Source:
Returns:
Type
shaka.extern.HlsAes128Key

parseByteRange_(previousReference, byterangenullable) → {Array.<number>}

Parse the startByte and endByte.
Parameters:
Name Type Attributes Description
previousReference shaka.media.SegmentReference
byterange string <nullable>
Source:
Returns:
An array with the start byte and end byte.
Type
Array.<number>

parseClosedCaptions_(mediaTagsnon-null)

Parses an array of EXT-X-MEDIA tags, then stores the values of all tags with TYPE="CLOSED-CAPTIONS" into a map of group id to closed captions.
Parameters:
Name Type Description
mediaTags Array.<!shaka.hls.Tag>
Source:

parseCodecs_(tagsnon-null)

Get the codecs of each variant tag, and store in a map from audio/video/subtitle group id to the codecs arraylist.
Parameters:
Name Type Description
tags Array.<!shaka.hls.Tag> Variant tags from the playlist.
Source:

parseImages_(imageTagsnon-null) → {Promise.<!Array.<!shaka.extern.Stream>>}

Parameters:
Name Type Description
imageTags Array.<!shaka.hls.Tag> from the playlist.
Source:
Returns:
Type
Promise.<!Array.<!shaka.extern.Stream>>

parseManifest_(data, uri) → {Promise}

Parses the manifest.
Parameters:
Name Type Description
data BufferSource
uri string
Source:
Returns:
Type
Promise

parseMasterVariables_(tagsnon-null)

Get the variables of each variant tag, and store in a map.
Parameters:
Name Type Description
tags Array.<!shaka.hls.Tag> Variant tags from the playlist.
Source:

parseMediaVariables_(tagsnon-null) → {Map.<string, string>}

Get the variables of each variant tag, and store in a map.
Parameters:
Name Type Description
tags Array.<!shaka.hls.Tag> Variant tags from the playlist.
Source:
Returns:
Type
Map.<string, string>

parseTexts_(mediaTagsnon-null) → {Promise.<!Array.<!shaka.extern.Stream>>}

Parse Subtitles and Closed Captions from 'EXT-X-MEDIA' tags. Create text streams for Subtitles, but not Closed Captions.
Parameters:
Name Type Description
mediaTags Array.<!shaka.hls.Tag> Media tags from the playlist.
Source:
Returns:
Type
Promise.<!Array.<!shaka.extern.Stream>>

requestManifest_(absoluteUri) → {Promise.<!shaka.extern.Response>}

Makes a network request for the manifest and returns a Promise with the resulting data.
Parameters:
Name Type Description
absoluteUri string
Source:
Returns:
Type
Promise.<!shaka.extern.Response>

setPresentationType_(type)

Parameters:
Name Type Description
type shaka.hls.HlsParser.PresentationType_
Source:

start(uri, playerInterface) → {Promise.<shaka.extern.Manifest>}

Initialize and start the parser. When |start| resolves, it should return the initial version of the manifest. |start| will only be called once. If |stop| is called while |start| is pending, |start| should reject.
Parameters:
Name Type Description
uri string The URI of the manifest.
playerInterface shaka.extern.ManifestParser.PlayerInterface The player interface contains the callbacks and members that the parser can use to communicate with the player and outside world.
Implements:
Source:
Returns:
Type
Promise.<shaka.extern.Manifest>

stop() → {Promise}

Tell the parser that it must stop and free all internal resources as soon as possible. Only once all internal resources are stopped and freed will the promise resolve. Once stopped a parser will not be started again. The parser should support having |stop| called multiple times and the promise should always resolve.
Implements:
Source:
Returns:
Type
Promise

syncStreamsWithProgramDateTime_()

Synchronize streams by the EXT-X-PROGRAM-DATE-TIME tags attached to their segments. Also normalizes segment times so that the earliest segment in any stream is at time 0.
Source:

syncStreamsWithSequenceNumber_()

Align all streams by sequence number by dropping early segments. Then offset all streams to begin at presentation time 0.
Source:

update()

Tells the parser to do a manual manifest update. Implementing this is optional. This is only called when 'emsg' boxes are present.
Implements:
Source:

updateStream_(streamInfonon-null) → {Promise}

Updates a stream.
Parameters:
Name Type Description
streamInfo shaka.hls.HlsParser.StreamInfo
Source:
Returns:
Type
Promise

variableSubstitution_(uri, variablesnon-null) → {string}

Replaces the variables of a given URI.
Parameters:
Name Type Description
uri string
variables Map.<string, string>
Source:
Returns:
Type
string

Type Definitions

DrmParser_

Type:
  • function(!shaka.hls.Tag, string):?shaka.extern.DrmInfo
Source:

StreamInfo

Contains a stream and information about it.
Type:
  • {stream: !shaka.extern.Stream, verbatimMediaPlaylistUri: string, absoluteMediaPlaylistUri: string, maxTimestamp: number, mediaSequenceToStartTime: !Map.<number, number>, canSkipSegments: boolean, hasEndList: boolean}
Properties:
Name Type Description
stream shaka.extern.Stream The Stream itself.
verbatimMediaPlaylistUri string The verbatim media playlist URI, as it appeared in the master playlist. This has not been canonicalized into an absolute URI. This gives us a consistent key for this playlist, even if redirects cause us to update from different origins each time.
absoluteMediaPlaylistUri string The absolute media playlist URI, resolved relative to the master playlist and updated to reflect any redirects.
maxTimestamp number The maximum timestamp found in the stream.
mediaSequenceToStartTime Map.<number, number> A map of media sequence numbers to media start times.
canSkipSegments boolean True if the server supports delta playlist updates, and we can send a request for a playlist that can skip older media segments.
hasEndList boolean True if the stream has an EXT-X-ENDLIST tag.
Source:

StreamInfos

Audio and video stream infos.
Type:
Properties:
Name Type Description
audio Array.<shaka.hls.HlsParser.StreamInfo>
video Array.<shaka.hls.HlsParser.StreamInfo>
Source: