Constructor
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 VODVOD string EVENTEVENT string LIVELIVE 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_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, nullable) config_ :shakaExtern.ManifestConfiguration
-
Type:
- Source:
-
(private) globalId_ :number
-
Type:
- number
- Source:
-
(private, nullable) manifest_ :shakaExtern.Manifest
-
Type:
- Source:
-
(private) manifestTextParser_ :shaka.hls.ManifestTextParser
-
Type:
- Source:
-
(private) manifestUri_ :string
-
TODO: should be resolved, post-redirect URI, so that media playlist URIs respect master playlist redirects
Type:
- string
- Source:
-
(private) maxTargetDuration_ :number
-
Type:
- number
- Source:
-
(private, non-null) mediaTagsToStreamInfosMap_ :Object.<number, shaka.hls.HlsParser.StreamInfo>
-
TODO: this is now only used for text codec detection, try to remove
Type:
- Object.<number, shaka.hls.HlsParser.StreamInfo>
- Source:
-
(private) minTargetDuration_ :number
-
Type:
- number
- Source:
-
(private, nullable) playerInterface_ :shakaExtern.ManifestParser.PlayerInterface
-
Type:
- Source:
-
(private, nullable) presentationTimeline_ :shaka.media.PresentationTimeline
-
Type:
- Source:
-
(private) presentationType_ :shaka.hls.HlsParser.PresentationType_
-
Type:
- Source:
-
(private, non-null) streamsToIndexMap_ :Object.<number, !shaka.media.SegmentIndex>
-
Type:
- Object.<number, !shaka.media.SegmentIndex>
- Source:
-
(private, nullable) updatePeriod_ :number
-
The update period in seconds; or null for no updates.
Type:
- number
- Source:
-
(private, nullable) updateTimer_ :number
-
Type:
- number
- Source:
-
(private, non-null) urisToVariantsMap_ :Object.<string, shakaExtern.Variant>
-
The key is a string of the form "
Type:
- Object.<string, shakaExtern.Variant>
- Source:
-
(private, non-null) uriToStreamInfosMap_ :Object.<string, shaka.hls.HlsParser.StreamInfo>
-
A map from media playlists' uris to stream infos representing the playlists. TODO: should use original, resolved URIs, before redirects
Type:
- Object.<string, shaka.hls.HlsParser.StreamInfo>
- 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 tagshaka.hls.Tag attributeNamestring - Source:
Throws:
Returns:
- Type
- string
-
(private, static) widevineDrmParser_(drmTagnon-null) → (nullable) {shakaExtern.DrmInfo}
-
Parameters:
Name Type Description drmTagshaka.hls.Tag - Source:
Returns:
- Type
- shakaExtern.DrmInfo
-
(private) addVideoAttributes_(stream, widthnullable, heightnullable, frameRatenullable)
-
Parameters:
Name Type Attributes Description streamshakaExtern.Stream widthstring <nullable>
heightstring <nullable>
frameRatestring <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 configshakaExtern.ManifestConfiguration - Implements:
- Source:
-
(private) createInitSegmentReference_(playlistnon-null) → {shaka.media.InitSegmentReference}
-
Parameters:
Name Type Description playlistshaka.hls.Playlist - Source:
Throws:
Returns:
-
(private) createPeriod_(playlistnon-null) → (non-null) {Promise.<!shakaExtern.Period>}
-
Parses a playlist into a Period object.
Parameters:
Name Type Description playlistshaka.hls.Playlist - Source:
Returns:
- Type
- Promise.<!shakaExtern.Period>
-
(private) createPresentationTimeline_(endTime)
-
Parameters:
Name Type Description endTimenumber - 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 playlistshaka.hls.Playlist previousReferenceshaka.media.SegmentReference hlsSegmentshaka.hls.Segment positionnumber startTimenumber - Source:
Returns:
-
(private) createSegments_(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 playlistshaka.hls.Playlist startPositionnumber mimeTypestring codecsstring - Source:
Returns:
- Type
- Promise.<!Array.<!shaka.media.SegmentReference>>
-
(private) createStreamInfo_(urinon-null, allCodecsnon-null, typenon-null, languagenon-null, primary, labelnullable, channelsCountnullable) → (non-null) {Promise.<shaka.hls.HlsParser.StreamInfo>}
-
Parameters:
Name Type Attributes Description uristring allCodecsArray.<!string> typestring languagestring primaryboolean labelstring <nullable>
channelsCountnumber <nullable>
- Source:
Throws:
shaka.util.ErrorReturns:
- 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 tagshaka.hls.Tag allCodecsArray.<!string> - Source:
Returns:
- Type
- Promise.<shaka.hls.HlsParser.StreamInfo>
-
(private) createStreamInfoFromVariantTag_(tagnon-null, allCodecsnon-null, typenon-null) → (non-null) {Promise.<shaka.hls.HlsParser.StreamInfo>}
-
Parse EXT-X-STREAM-INF media tag into a Stream object.
Parameters:
Name Type Description tagshaka.hls.Tag allCodecsArray.<!string> typestring - 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 tagshaka.hls.Tag playlistshaka.hls.Playlist - Source:
Returns:
- Type
- Promise.<?shakaExtern.Stream>
-
(private) createVariant_(audio, video, bandwidth, drmInfosnon-null) → (non-null) {shakaExtern.Variant}
-
Parameters:
Name Type Description audioshakaExtern.Stream videoshakaExtern.Stream bandwidthnumber drmInfosArray.<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 audioInfosArray.<!shaka.hls.HlsParser.StreamInfo> videoInfosArray.<!shaka.hls.HlsParser.StreamInfo> bandwidthnumber widthstring <nullable>
heightstring <nullable>
frameRatestring <nullable>
- Source:
Returns:
- Type
- Array.<!shakaExtern.Variant>
-
(private) createVariantsForTag_(tagnon-null, playlistnon-null) → (non-null) {Promise.<!Array.<!shakaExtern.Variant>>}
-
Parameters:
Name Type Description tagshaka.hls.Tag playlistshaka.hls.Playlist - Source:
Returns:
- Type
- Promise.<!Array.<!shakaExtern.Variant>>
-
(private) determinePresentationType_(playlistnon-null)
-
Parameters:
Name Type Description playlistshaka.hls.Playlist - Source:
-
(private) fetchPartialSegment_(segmentRefnon-null) → (non-null) {Promise.<shakaExtern.Response>}
-
Try to fetch a partial segment, and fall back to a full segment if we have to.
Parameters:
Name Type Description segmentRefshaka.media.SegmentReference - Source:
Throws:
Returns:
- Type
- Promise.<shakaExtern.Response>
-
(private) getChannelsCount_(channelsnullable) → (nullable) {number}
-
Get the channels count information for HLS audio track. The channels value is a string that specifies an ordered, "/" separated list of parameters. If the type is audio, the first parameter will be a decimal integer, as the number of independent, simultaneous audio channels. No other channels parameters are currently defined.
Parameters:
Name Type Attributes Description channelsstring <nullable>
- Source:
Returns:
channelcount- Type
- number
-
(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 tagsArray.<shaka.hls.Tag> tagNamestring - Source:
Throws:
Returns:
- Type
- shaka.hls.Tag
-
(private) getStartTime_(playlistUri, segmentRefnon-null, mimeType, codecs) → (non-null) {Promise.<number>}
-
Gets start time of a segment from the existing manifest (if possible) or by downloading it and parsing it otherwise.
Parameters:
Name Type Description playlistUristring segmentRefshaka.media.SegmentReference mimeTypestring codecsstring - Source:
Throws:
Returns:
- Type
- Promise.<number>
-
(private) getStartTimeFromMp4Segment_(datanon-null) → {number}
-
Parses an mp4 segment to get its start time.
Parameters:
Name Type Description dataArrayBuffer - 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 mimeTypestring codecsstring dataArrayBuffer - Source:
Throws:
Returns:
- Type
- number
-
(private) getStartTimeFromTsSegment_(datanon-null) → {number}
-
Parses a TS segment to get its start time.
Parameters:
Name Type Description dataArrayBuffer - Source:
Throws:
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. Assumes a single codec is correct, and throws if not found.
Parameters:
Name Type Description contentTypestring codecsArray.<!string> - Source:
Throws:
Returns:
- Type
- string
-
(private) guessCodecsSafe_(contentTypenon-null, 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 contentTypestring codecsArray.<!string> - Source:
Returns:
or null if no match is found- Type
- string
-
(private) guessMimeType_(contentTypenon-null, codecsnon-null, playlistnon-null) → (non-null) {Promise.<!string>}
-
Attempts to guess stream's mime type based on content type and uri.
Parameters:
Name Type Description contentTypestring codecsstring playlistshaka.hls.Playlist - Source:
Throws:
Returns:
- Type
- Promise.<!string>
-
(private) isLive_() → {boolean}
-
- Source:
Returns:
- Type
- boolean
-
onExpirationUpdated(sessionId, expiration)
-
Tells the parser that the expiration time of an EME session has changed. Implementing this is optional.
Parameters:
Name Type Description sessionIdstring expirationnumber - Implements:
- Source:
-
(private) onUpdate_()
-
Called when the update timer ticks.
- Source:
-
(private) parseManifest_(datanon-null, uri) → (non-null) {Promise}
-
Parses the manifest.
Parameters:
Name Type Description dataArrayBuffer uristring - Source:
Throws:
shaka.util.Error When there is a parsing error.Returns:
- Type
- Promise
-
(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 uristring - Source:
Returns:
- Type
- Promise.<!shakaExtern.Response>
-
(private) setPresentationType_(type)
-
Parameters:
Name Type Description typeshaka.hls.HlsParser.PresentationType_ - Source:
-
(private) setUpdateTimer_(timenullable)
-
Sets the update timer.
Parameters:
Name Type Attributes Description timenumber <nullable>
in seconds - Source:
-
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 uristring The URI of the manifest. playerInterfaceshakaExtern.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:
-
(private) updateStream_(streamInfonon-null, uri)
-
Updates a stream.
Parameters:
Name Type Description streamInfoshaka.hls.HlsParser.StreamInfo uristring - Source:
Throws:
shaka.util.Error
Type Definitions
-
DrmParser_
-
Type:
- function(!shaka.hls.Tag): ?shakaExtern.DrmInfo
- Source:
-
StreamInfo
-
Contains a stream and information about it.
Type:
- {stream: !shakaExtern.Stream, segmentIndex: !shaka.media.SegmentIndex, drmInfos: !Array.<shakaExtern.DrmInfo>, relativeUri: string, minTimestamp: number, duration: number}
Properties:
Name Type Description streamshakaExtern.Stream The Stream itself. segmentIndexshaka.media.SegmentIndex SegmentIndex of the stream. drmInfosArray.<shakaExtern.DrmInfo> DrmInfos of the stream. There may be multiple for multi-DRM content. relativeUristring The uri associated with the stream, relative to the manifest. minTimestampnumber The minimum timestamp found in the stream. Used for VOD only. durationnumber The duration of the playlist. Used for VOD only. - Source: