Class: shaka.hls.HlsParser

Constructor

new HlsParser()

Creates a new HLS parser.
Implements:
Source:

Members

(private, static, constant, non-null) AUDIO_CODEC_FORMATS_ :Array.<!RegExp>

A list of well-known audio codecs formats.
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) KEYFORMATS_TO_DRM_PARSERS_ :Object.<string, shaka.hls.HlsParser.DrmParser_>

Type:
Source:

(private, static, constant, non-null) VIDEO_CODEC_FORMATS_ :Array.<!RegExp>

A list of well-known video codecs formats.
Type:
  • Array.<!RegExp>
Source:

(private, static, constant, non-null) VIDEO_EXTENSIONS_TO_MIME_TYPES_ :Object.<string, string>

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

(private, nullable) config_ :shakaExtern.ManifestConfiguration

Type:
Source:

(private) globalId_ :number

Type:
  • number
Source:

(private) manifestTextParser_ :shaka.hls.ManifestTextParser

Type:
Source:

(private) manifestUri_ :string

Type:
  • string
Source:

(private, non-null) mediaTagsToStreamInfosMap_ :Object.<number, shaka.hls.HlsParser.StreamInfo>

Type:
Source:

(private, nullable) playerInterface_ :shakaExtern.ManifestParser.PlayerInterface

Type:
Source:

(private, nullable) presentationTimeline_ :shaka.media.PresentationTimeline

Type:
Source:

(private, non-null) streamsToIndexMap_ :Object.<number, !shaka.media.SegmentIndex>

Type:
Source:

Methods

(private, static) getRequiredAttributeValue_(tag, attributeNamenon-null) → (non-null) {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) {shakaExtern.DrmInfo}

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

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

Parameters:
Name Type Attributes Description
stream shakaExtern.Stream
width string <nullable>
height string <nullable>
frameRate 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 shakaExtern.ManifestConfiguration
Implements:
Source:

(private) createInitSegmentReference_(playlistnon-null) → {shaka.media.InitSegmentReference}

Parameters:
Name Type Description
playlist shaka.hls.Playlist
Source:
Throws:
Returns:
Type
shaka.media.InitSegmentReference

(private) createPeriod_(playlistnon-null) → (non-null) {Promise.<!shakaExtern.Period>}

Parses a playlist into a Period object.
Parameters:
Name Type Description
playlist shaka.hls.Playlist
Source:
Returns:
Type
Promise.<!shakaExtern.Period>

(private) createSegments_(playlistnon-null, startPosition) → (non-null) {Array.<!shaka.media.SegmentReference>}

Parses shaka.hls.Segment objects into shaka.media.SegmentReferences.
Parameters:
Name Type Description
playlist shaka.hls.Playlist
startPosition number
Source:
Returns:
Type
Array.<!shaka.media.SegmentReference>

(private) createStreamInfo_(urinon-null, allCodecsnon-null, typenon-null, timeOffsetnullable, languagenon-null, primary, labelnullable) → (non-null) {Promise.<shaka.hls.HlsParser.StreamInfo>}

Parameters:
Name Type Attributes Description
uri string
allCodecs Array.<!string>
type string
timeOffset number <nullable>
language string
primary boolean
label string <nullable>
Source:
Throws:
shaka.util.Error
Returns:
Type
Promise.<shaka.hls.HlsParser.StreamInfo>

(private) createStreamInfoFromMediaTag_(tag, allCodecsnon-null, timeOffsetnullable) → (non-null) {Promise.<shaka.hls.HlsParser.StreamInfo>}

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

(private) createStreamInfoFromVariantTag_(tagnon-null, allCodecsnon-null, typenon-null, timeOffsetnullable) → (non-null) {Promise.<shaka.hls.HlsParser.StreamInfo>}

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

(private) createTextStream_(tagnon-null, playlistnon-null) → (non-null) {Promise.<?shakaExtern.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.<?shakaExtern.Stream>

(private) createVariant_(audio, video, bandwidth, drmInfosnon-null) → (non-null) {shakaExtern.Variant}

Parameters:
Name Type Description
audio shakaExtern.Stream
video shakaExtern.Stream
bandwidth number
drmInfos Array.<shakaExtern.DrmInfo>
Source:
Returns:
Type
shakaExtern.Variant

(private) createVariants_(audioInfosnon-null, videoInfosnon-null, bandwidth, widthnullable, heightnullable, frameRatenullable) → (non-null) {Array.<!shakaExtern.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.<!shakaExtern.Variant>

(private) createVariantsForTag_(tagnon-null, playlistnon-null) → (non-null) {Promise.<!Array.<!shakaExtern.Variant>>}

Parameters:
Name Type Description
tag shaka.hls.Tag
playlist shaka.hls.Playlist
Source:
Returns:
Type
Promise.<!Array.<!shakaExtern.Variant>>

(private) fitSegments_(variantsnon-null)

Adjusts segment references of every stream of every variant to the timeline of the presentation.
Parameters:
Name Type Description
variants Array.<!shakaExtern.Variant>
Source:

(private) getRequiredTag_(tagsnon-null, tagNamenon-null) → (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) getTimeOffset_(playlistnon-null) → (nullable) {number}

Get presentation time offset of the playlist if it has been specified. Return null otherwise.
Parameters:
Name Type Description
playlist shaka.hls.Playlist
Source:
Returns:
Type
number

(private) guessCodecs_(contentTypenon-null, codecsnon-null) → {string}

Attempts to guess which codecs from the codecs list belong to a given content type.
Parameters:
Name Type Description
contentType string
codecs Array.<!string>
Source:
Throws:
Returns:
Type
string

(private) guessMimeType_(contentTypenon-null, urinon-null) → (non-null) {Promise.<!string>}

Attempts to guess stream's mime type based on content type and uri.
Parameters:
Name Type Description
contentType string
uri string
Source:
Throws:
Returns:
Type
Promise.<!string>

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) parseManifest_(datanon-null, uri) → (non-null) {Promise.<!shakaExtern.Manifest>}

Parses the manifest.
Parameters:
Name Type Description
data ArrayBuffer
uri string
Source:
Throws:
shaka.util.Error When there is a parsing error.
Returns:
Type
Promise.<!shakaExtern.Manifest>

(private) requestManifest_(urinon-null) → (non-null) {Promise.<!shakaExtern.Response>}

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

start(uri, playerInterface) → (non-null) {Promise.<shakaExtern.Manifest>}

Parses the given manifest data into a Manifest object and starts any background timers that are needed. This will only be called once.
Parameters:
Name Type Description
uri string The URI of the manifest.
playerInterface shakaExtern.ManifestParser.PlayerInterface Contains the interface to the Player.
Implements:
Source:
Returns:
Type
Promise.<shakaExtern.Manifest>

stop() → (non-null) {Promise}

Stops any background timers and frees any objects held by this instance. This will only be called after a successful call to start. This will only be called once.
Implements:
Source:
Returns:
Type
Promise

update()

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

Type Definitions

DrmParser_

Type:
Source:

StreamInfo

Contains a stream and information about it.
Type:
Properties:
Name Type Description
stream shakaExtern.Stream The Stream itself.
segmentIndex shaka.media.SegmentIndex SegmentIndex of the stream.
drmInfos Array.<shakaExtern.DrmInfo> DrmInfos of the stream. There may be multiple for multi-DRM content.
relativeUri string The uri associated with the stream, relative to the manifest.
Source: