Constructor
(export) new HlsParser()
Creates a new HLS parser.
- Implements:
- Source:
Members
(private, static, constant, non-null) AUDIO_CODEC_REGEXPS_ :Array.<!RegExp>
A list of regexps to detect well-known audio codecs.
Type:
- Array.<!RegExp>
- Source:
(private, static, constant, non-null) AUDIO_EXTENSIONS_TO_MIME_TYPES_ :Object.<string, string>
Type:
- Object.<string, string>
- Source:
(private, static, constant, non-null) CODEC_REGEXPS_BY_CONTENT_TYPE_ :Object.<string, !Array.<!RegExp>>
Type:
- Object.<string, !Array.<!RegExp>>
- Source:
(private, static, constant, non-null) EXTENSION_MAP_BY_CONTENT_TYPE_ :Object.<string, !Object.<string, string>>
Type:
- Object.<string, !Object.<string, string>>
- Source:
(private, static, constant, non-null) KEYFORMATS_TO_DRM_PARSERS_ :Object.<string, shaka.hls.HlsParser.DrmParser_>
Type:
- Object.<string, shaka.hls.HlsParser.DrmParser_>
- Source:
(private, static, constant) PARTIAL_SEGMENT_SIZE_ :number
The amount of data from the start of a segment we will try to fetch when we
need to know the segment start time. This allows us to avoid fetching the
entire segment in many cases.
Type:
- number
- Source:
(private, static) PresentationType_ :string
Type:
- string
Properties:
Name | Value | Type | Description |
---|---|---|---|
VOD |
VOD | string | |
EVENT |
EVENT | string | |
LIVE |
LIVE | string |
- Source:
(private, static, constant, non-null) TEXT_CODEC_REGEXPS_ :Array.<!RegExp>
A list of regexps to detect well-known text codecs.
Type:
- Array.<!RegExp>
- Source:
(private, static, constant, non-null) TEXT_EXTENSIONS_TO_MIME_TYPES_ :Object.<string, string>
Type:
- Object.<string, string>
- Source:
(private, static, constant) TS_ROLLOVER_ :number
At this value, timestamps roll over in TS content.
Type:
- number
- Source:
(private, static, constant) TS_TIMESCALE_ :number
Type:
- number
- Source:
(private, static, constant, non-null) VIDEO_CODEC_REGEXPS_ :Array.<!RegExp>
A list of regexps to detect well-known video codecs.
Type:
- Array.<!RegExp>
- Source:
(private, static, constant, non-null) VIDEO_EXTENSIONS_TO_MIME_TYPES_ :Object.<string, string>
Type:
- Object.<string, string>
- Source:
(private) aesEncrypted_ :boolean
True if some of the variants in the playlist is encrypted with AES-128.
Type:
- boolean
- Source:
(private) 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:
(private) masterPlaylistUri_ :string
The master playlist URI, after redirects.
Type:
- string
- Source:
(private, non-null) mediaTagsToStreamInfosMap_ :Map.<number, shaka.hls.HlsParser.StreamInfo>
Type:
- Map.<number, shaka.hls.HlsParser.StreamInfo>
- Source:
(private, non-null) segmentsToNotifyByStream_ :Array.<!Array.<!shaka.media.SegmentReference>>
Type:
- Array.<!Array.<!shaka.media.SegmentReference>>
- Source:
(private) 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:
(private) 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:
(private, non-null) 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_ and createStreamInfoFromVariantTag_.
During parsing of updates, used by getStartTime_ to determine the start
time of the first segment from existing segment references.
Type:
- Map.<string, shaka.hls.HlsParser.StreamInfo>
- Source:
(private, non-null) variantUriSet_ :Set.<string>
The values are strings of the form "
Type:
- Set.<string>
- Source:
Methods
(private, static) filterDuplicateCodecs_(codecsnon-null) → (non-null) {Array.<string>}
Filters out duplicate codecs from the codec list.
Parameters:
Name | Type | Description |
---|---|---|
codecs |
Array.<string> |
- Source:
Returns:
- Type
- Array.<string>
(private, static) getRequiredAttributeValue_(tag, attributeName) → {string}
Find the attribute and returns its value.
Throws an error if attribute was not found.
Parameters:
Name | Type | Description |
---|---|---|
tag |
shaka.hls.Tag | |
attributeName |
string |
- Source:
Throws:
Returns:
- Type
- string
(private, static) widevineDrmParser_(drmTagnon-null) → (nullable) {shaka.extern.DrmInfo}
Parameters:
Name | Type | Description |
---|---|---|
drmTag |
shaka.hls.Tag |
- Source:
Returns:
- Type
- shaka.extern.DrmInfo
(private) addVideoAttributes_(stream, widthnullable, heightnullable, frameRatenullable)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
stream |
shaka.extern.Stream | ||
width |
string |
<nullable> |
|
height |
string |
<nullable> |
|
frameRate |
string |
<nullable> |
- Source:
(export) 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:
(private) createInitSegmentReference_(playlistnon-null) → {shaka.media.InitSegmentReference}
Parameters:
Name | Type | Description |
---|---|---|
playlist |
shaka.hls.Playlist |
- Source:
Throws:
Returns:
(private) createPeriod_(playlistnon-null) → (non-null) {Promise.<!shaka.extern.Period>}
Parses a playlist into a Period object.
Parameters:
Name | Type | Description |
---|---|---|
playlist |
shaka.hls.Playlist |
- Source:
Returns:
- Type
- Promise.<!shaka.extern.Period>
(private) createPresentationTimeline_(lastTimestamp)
Parameters:
Name | Type | Description |
---|---|---|
lastTimestamp |
number |
- Source:
Throws:
shaka.util.Error
(private) createSegmentReference_(playlistnon-null, previousReference, hlsSegmentnon-null, position, startTime) → (non-null) {shaka.media.SegmentReference}
Parses one shaka.hls.Segment object into a shaka.media.SegmentReference.
Parameters:
Name | Type | Description |
---|---|---|
playlist |
shaka.hls.Playlist | |
previousReference |
shaka.media.SegmentReference | |
hlsSegment |
shaka.hls.Segment | |
position |
number | |
startTime |
number |
- Source:
Returns:
(private) createSegments_(verbatimMediaPlaylistUri, playlistnon-null, startPosition, mimeType, codecs) → (non-null) {Promise.<!Array.<!shaka.media.SegmentReference>>}
Parses shaka.hls.Segment objects into shaka.media.SegmentReferences.
Parameters:
Name | Type | Description |
---|---|---|
verbatimMediaPlaylistUri |
string | |
playlist |
shaka.hls.Playlist | |
startPosition |
number | |
mimeType |
string | |
codecs |
string |
- Source:
Returns:
- Type
- Promise.<!Array.<!shaka.media.SegmentReference>>
(private) createStreamInfo_(verbatimMediaPlaylistUri, allCodecsnon-null, type, language, primary, namenullable, channelsCountnullable, closedCaptions) → (non-null) {Promise.<?shaka.hls.HlsParser.StreamInfo>}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
verbatimMediaPlaylistUri |
string | ||
allCodecs |
Array.<string> | ||
type |
string | ||
language |
string | ||
primary |
boolean | ||
name |
string |
<nullable> |
|
channelsCount |
number |
<nullable> |
|
closedCaptions |
Map.<string, string> |
- Source:
Throws:
shaka.util.Error
Returns:
- Type
- Promise.<?shaka.hls.HlsParser.StreamInfo>
(private) createStreamInfoFromMediaTag_(tag, allCodecsnon-null) → (non-null) {Promise.<?shaka.hls.HlsParser.StreamInfo>}
Parse EXT-X-MEDIA media tag into a Stream object.
Parameters:
Name | Type | Description |
---|---|---|
tag |
shaka.hls.Tag | |
allCodecs |
Array.<string> |
- Source:
Returns:
- Type
- Promise.<?shaka.hls.HlsParser.StreamInfo>
(private) createStreamInfoFromVariantTag_(tagnon-null, allCodecsnon-null, type) → (non-null) {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>
(private) createTextStream_(tagnon-null, playlistnon-null) → (non-null) {Promise.<?shaka.extern.Stream>}
Parses an EXT-X-MEDIA tag with TYPE="SUBTITLES" into a text stream.
Parameters:
Name | Type | Description |
---|---|---|
tag |
shaka.hls.Tag | |
playlist |
shaka.hls.Playlist |
- Source:
Returns:
- Type
- Promise.<?shaka.extern.Stream>
(private) createVariant_(audio, video, bandwidth, drmInfosnon-null) → (non-null) {shaka.extern.Variant}
Parameters:
Name | Type | Description |
---|---|---|
audio |
shaka.extern.Stream | |
video |
shaka.extern.Stream | |
bandwidth |
number | |
drmInfos |
Array.<shaka.extern.DrmInfo> |
- Source:
Returns:
- Type
- shaka.extern.Variant
(private) createVariants_(audioInfosnon-null, videoInfosnon-null, bandwidth, widthnullable, heightnullable, frameRatenullable) → (non-null) {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> |
- Source:
Returns:
- Type
- Array.<!shaka.extern.Variant>
(private) createVariantsForTag_(tagnon-null, playlistnon-null) → (non-null) {Promise.<!Array.<!shaka.extern.Variant>>}
Parameters:
Name | Type | Description |
---|---|---|
tag |
shaka.hls.Tag | |
playlist |
shaka.hls.Playlist |
- Source:
Returns:
- Type
- Promise.<!Array.<!shaka.extern.Variant>>
(private) determinePresentationType_(playlistnon-null)
Parameters:
Name | Type | Description |
---|---|---|
playlist |
shaka.hls.Playlist |
- Source:
(private) fetchPartialSegment_(referencenon-null) → (non-null) {Promise.<shaka.extern.Response>}
Try to fetch a partial segment, and fall back to a full segment if we have
to.
Parameters:
Name | Type | Description |
---|---|---|
reference |
shaka.media.AnySegmentReference |
- Source:
Throws:
Returns:
- Type
- Promise.<shaka.extern.Response>
(private) filterLegacyCodecs_(streamInfosnon-null)
Filters out unsupported codec strings from an array of stream infos.
Parameters:
Name | Type | Description |
---|---|---|
streamInfos |
Array.<shaka.hls.HlsParser.StreamInfo> |
- Source:
(private) getChannelCount_(channelsnullable) → (nullable) {number}
Get the channel count information for an HLS audio track.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
channels |
string |
<nullable> |
A string that 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. |
- Source:
Returns:
channelcount
- Type
- number
(private) getRequiredTag_(tagsnon-null, tagName) → (non-null) {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:
Throws:
Returns:
- Type
- shaka.hls.Tag
(private) getStartTime_(verbatimMediaPlaylistUri, initSegmentRef, segmentRefnon-null, mimeType, codecs) → (non-null) {Promise.<number>}
Gets the start time of a segment from the existing manifest (if possible) or
by downloading it and parsing it otherwise.
Parameters:
Name | Type | Description |
---|---|---|
verbatimMediaPlaylistUri |
string | |
initSegmentRef |
shaka.media.InitSegmentReference | |
segmentRef |
shaka.media.SegmentReference | |
mimeType |
string | |
codecs |
string |
- Source:
Throws:
Returns:
- Type
- Promise.<number>
(private) getStartTimeFromMp4Segment_(mediaDatanon-null, initDatanon-null) → {number}
Parses an mp4 segment to get its start time.
Parameters:
Name | Type | Description |
---|---|---|
mediaData |
ArrayBuffer | |
initData |
ArrayBuffer |
- Source:
Throws:
Returns:
- Type
- number
(private) getStartTimeFromTextSegment_(mimeType, codecs, datanon-null) → {number}
Parses a text segment to get its start time.
Parameters:
Name | Type | Description |
---|---|---|
mimeType |
string | |
codecs |
string | |
data |
ArrayBuffer |
- Source:
Throws:
Returns:
- Type
- number
(private) getStartTimeFromTsSegment_(datanon-null) → {number}
Parses a TS segment to get its start time.
Parameters:
Name | Type | Description |
---|---|---|
data |
ArrayBuffer |
- Source:
Throws:
Returns:
- Type
- number
(private) guessCodecs_(contentType, codecsnon-null) → {string}
Attempts to guess which codecs from the codecs list belong to a given content
type. Assumes that at least one codec is correct, and throws if none are.
Parameters:
Name | Type | Description |
---|---|---|
contentType |
string | |
codecs |
Array.<string> |
- Source:
Throws:
Returns:
- Type
- string
(private) guessCodecsSafe_(contentType, codecsnon-null) → (nullable) {string}
Attempts to guess which codecs from the codecs list belong to a given content
type. Does not assume a single codec is anything special, and does not throw
if it fails to match.
Parameters:
Name | Type | Description |
---|---|---|
contentType |
string | |
codecs |
Array.<string> |
- Source:
Returns:
or null if no match is found
- Type
- string
(private) guessMimeType_(contentType, codecs, playlistnon-null) → (non-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 |
- Source:
Throws:
Returns:
- Type
- Promise.<string>
(private) makeNetworkRequest_(request, type) → (non-null) {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>
(private) notifySegments_()
- Source:
(export) 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:
(private) onUpdate_() → (non-null) {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
(private) parseClosedCaptions_(tagsnon-null)
Parses an EXT-X-MEDIA tag with TYPE="CLOSED-CAPTIONS", add store the values
into the map of group id to closed captions.
Parameters:
Name | Type | Description |
---|---|---|
tags |
Array.<shaka.hls.Tag> |
- Source:
(private) parseManifest_(datanon-null) → (non-null) {Promise}
Parses the manifest.
Parameters:
Name | Type | Description |
---|---|---|
data |
ArrayBuffer |
- Source:
Throws:
shaka.util.Error When there is a parsing error.
Returns:
- Type
- Promise
(private) requestManifest_(absoluteUri) → (non-null) {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>
(private) setPresentationType_(type)
Parameters:
Name | Type | Description |
---|---|---|
type |
shaka.hls.HlsParser.PresentationType_ |
- Source:
(export) start(uri, playerInterface) → (non-null) {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>
(export) stop() → (non-null) {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
(export) 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:
(private) updateStream_(streamInfonon-null) → (non-null) {Promise}
Updates a stream.
Parameters:
Name | Type | Description |
---|---|---|
streamInfo |
shaka.hls.HlsParser.StreamInfo |
- Source:
Throws:
shaka.util.Error
Returns:
- Type
- Promise
Type Definitions
DrmParser_
Type:
- function(!shaka.hls.Tag):?shaka.extern.DrmInfo
- Source:
StreamInfo
Contains a stream and information about it.
Type:
- {stream: !shaka.extern.Stream, segmentIndex: !shaka.media.SegmentIndex, drmInfos: !Array.<shaka.extern.DrmInfo>, verbatimMediaPlaylistUri: string, absoluteMediaPlaylistUri: string, minTimestamp: number, maxTimestamp: number, duration: number}
Properties:
Name | Type | Description |
---|---|---|
stream |
shaka.extern.Stream | The Stream itself. |
segmentIndex |
shaka.media.SegmentIndex | SegmentIndex of the stream. |
drmInfos |
Array.<shaka.extern.DrmInfo> | DrmInfos of the stream. There may be multiple for multi-DRM content. |
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. |
minTimestamp |
number | The minimum timestamp found in the stream. |
maxTimestamp |
number | The maximum timestamp found in the stream. |
duration |
number | The duration of the playlist. Used for VOD only. |
- Source: