Class: shaka.dash.DashParser

Constructor

(export) new DashParser()

Creates a new DASH parser.
Implements:
Source:

Members

(private, static, constant) MIN_UPDATE_PERIOD_ :number

Contains the minimum amount of time, in seconds, between manifest update requests.
Type:
  • number
Source:

(private, non-null) averageUpdateDuration_ :shaka.abr.Ewma

An ewma that tracks how long updates take. This is to mitigate issues caused by slow parsing on embedded devices.
Type:
Source:

(private) globalId_ :number

Type:
  • number
Source:

(private, nullable) manifest_ :shaka.extern.Manifest

Type:
Source:

(private, non-null) manifestUris_ :Array.<string>

Type:
  • Array.<string>
Source:

(private, non-null) operationManager_ :shaka.util.OperationManager

Type:
Source:

(private, non-null) periodIds_ :Array.<string>

Type:
  • Array.<string>
Source:

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

A map of IDs to SegmentIndex objects. ID: Period@id,AdaptationSet@id,@Representation@id e.g.: '1,5,23'
Type:
Source:

(private) updatePeriod_ :number

The update period in seconds, or 0 for no updates.
Type:
  • number
Source:

(private) updateTimer_ :shaka.util.Timer

Type:
Source:

Methods

(private, static) guessContentType_(mimeType, codecs) → {string}

Guess the content type based on MIME type and codecs.
Parameters:
Name Type Description
mimeType string
codecs string
Source:
Returns:
Type
string

(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) createFrame_(elemnon-null, parentnullable, baseUris) → {shaka.dash.DashParser.InheritanceFrame}

Creates a new inheritance frame for the given element.
Parameters:
Name Type Attributes Description
elem Element
parent shaka.dash.DashParser.InheritanceFrame <nullable>
baseUris Array.<string>
Source:
Returns:
Type
shaka.dash.DashParser.InheritanceFrame

(private) createVariants_(audionullable, videonullable, variantsnon-null)

Combines Streams into Variants
Parameters:
Name Type Attributes Description
audio shaka.dash.DashParser.AdaptationInfo <nullable>
video shaka.dash.DashParser.AdaptationInfo <nullable>
variants Array.<shaka.extern.Variant> New variants are pushed onto this array.
Source:

(private) emsgSchemeIdUris_(inBandEventStreamsnon-null, emsgSchemeIdUrisnon-null) → (non-null) {Array.<string>}

Returns a new array of InbandEventStream schemeIdUri containing the union of the ones parsed from inBandEventStreams and the ones provided in emsgSchemeIdUris.
Parameters:
Name Type Description
inBandEventStreams Array.<!Element> Array of InbandEventStream elements to parse and add to the returned array.
emsgSchemeIdUris Array.<string> Array of parsed InbandEventStream schemeIdUri attributes to add to the returned array.
Source:
Returns:
schemeIdUris Array of parsed InbandEventStream schemeIdUri attributes.
Type
Array.<string>

(private) getSetsOfType_(adaptationSetsnon-null, type) → (non-null) {Array.<!shaka.dash.DashParser.AdaptationInfo>}

Parameters:
Name Type Description
adaptationSets Array.<!shaka.dash.DashParser.AdaptationInfo>
type string
Source:
Returns:
Type
Array.<!shaka.dash.DashParser.AdaptationInfo>

(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.
Source:
Returns:
Type
Promise

(private) parseAdaptationSet_(context, elemnon-null) → (nullable) {shaka.dash.DashParser.AdaptationInfo}

Parses an AdaptationSet XML element.
Parameters:
Name Type Description
context shaka.dash.DashParser.Context
elem Element The AdaptationSet element.
Source:
Throws:
shaka.util.Error When there is a parsing error.
Returns:
Type
shaka.dash.DashParser.AdaptationInfo

(private) parseAudioChannels_(audioChannelConfigsnon-null) → (nullable) {number}

Parameters:
Name Type Description
audioChannelConfigs Array.<!Element> An array of AudioChannelConfiguration elements.
Source:
Returns:
The number of audio channels, or null if unknown.
Type
number

(private) parseEventStream_(periodStart, periodDurationnullable, elemnon-null)

Parses an EventStream element.
Parameters:
Name Type Attributes Description
periodStart number
periodDuration number <nullable>
elem Element
Source:

(private) parseManifest_(data, finalManifestUri) → (non-null) {Promise}

Parses the manifest XML. This also handles updates and will update the stored manifest.
Parameters:
Name Type Description
data ArrayBuffer
finalManifestUri string The final manifest URI, which may differ from this.manifestUri_ if there has been a redirect.
Source:
Throws:
shaka.util.Error When there is a parsing error.
Returns:
Type
Promise

(private) parsePeriod_(context, baseUrisnon-null, periodInfo) → {shaka.extern.Period}

Parses a Period XML element. Unlike the other parse methods, this is not given the Node; it is given a PeriodInfo structure. Also, partial parsing was done before this was called so start and duration are valid.
Parameters:
Name Type Description
context shaka.dash.DashParser.Context
baseUris Array.<string>
periodInfo shaka.dash.DashParser.PeriodInfo
Source:
Throws:
shaka.util.Error When there is a parsing error.
Returns:
Type
shaka.extern.Period

(private) parsePeriods_(context, baseUrisnon-null, mpdnon-null) → {{periods: !Array.<shaka.extern.Period>, duration: ?number, durationDerivedFromPeriods: boolean}}

Reads and parses the periods from the manifest. This first does some partial parsing so the start and duration is available when parsing children.
Parameters:
Name Type Description
context shaka.dash.DashParser.Context
baseUris Array.<string>
mpd Element
Source:
Returns:
Type
{periods: !Array.<shaka.extern.Period>, duration: ?number, durationDerivedFromPeriods: boolean}

(private) parseRepresentation_(context, contentProtection, kind, language, label, isPrimary, rolesnon-null, closedCaptions, nodenon-null) → (nullable) {shaka.extern.Stream}

Parses a Representation XML element.
Parameters:
Name Type Description
context shaka.dash.DashParser.Context
contentProtection shaka.dash.ContentProtection.Context
kind string | undefined
language string
label string
isPrimary boolean
roles Array.<string>
closedCaptions Map.<string, string>
node Element
Source:
Throws:
shaka.util.Error When there is a parsing error.
Returns:
The Stream, or null when there is a non-critical parsing error.
Type
shaka.extern.Stream

(private) parseUtcTiming_(baseUrisnon-null, elemsnon-null) → (non-null) {Promise.<number>}

Parses an array of UTCTiming elements.
Parameters:
Name Type Description
baseUris Array.<string>
elems Array.<!Element>
Source:
Returns:
Type
Promise.<number>

(private) processManifest_(mpdnon-null, finalManifestUri) → (non-null) {Promise}

Takes a formatted MPD and converts it into a manifest.
Parameters:
Name Type Description
mpd Element
finalManifestUri string The final manifest URI, which may differ from this.manifestUri_ if there has been a redirect.
Source:
Throws:
shaka.util.Error When there is a parsing error.
Returns:
Type
Promise

(private) requestForTiming_(baseUrisnon-null, uri, method) → (non-null) {Promise.<number>}

Makes a request to the given URI and calculates the clock offset.
Parameters:
Name Type Description
baseUris Array.<string>
uri string
method string
Source:
Returns:
Type
Promise.<number>

(private) requestInitSegment_(urisnon-null, startBytenullable, endBytenullable) → (non-null) {Promise.<!ArrayBuffer>}

Makes a network request on behalf of SegmentBase.createStream.
Parameters:
Name Type Attributes Description
uris Array.<string>
startByte number <nullable>
endByte number <nullable>
Source:
Returns:
Type
Promise.<!ArrayBuffer>

(private) requestManifest_() → (non-null) {Promise.<number>}

Makes a network request for the manifest and parses the resulting data.
Source:
Returns:
Resolves with the time it took, in seconds, to fulfill the request and parse the data.
Type
Promise.<number>

(private) setUpdateTimer_(offset)

Sets the update timer. Does nothing if the manifest does not specify an update period.
Parameters:
Name Type Description
offset number An offset, in seconds, to apply to the manifest's update period.
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) verifyRepresentation_(frame) → {boolean}

Verifies that a Representation has exactly one Segment* element. Prints warnings if there is a problem.
Parameters:
Name Type Description
frame shaka.dash.DashParser.InheritanceFrame
Source:
Returns:
True if the Representation is usable; otherwise return false.
Type
boolean

Type Definitions

AdaptationInfo

Contains information about an AdaptationSet element.
Type:
  • {id: string, contentType: ?string, language: string, main: boolean, streams: !Array.<shaka.extern.Stream>, drmInfos: !Array.<shaka.extern.DrmInfo>, trickModeFor: ?string, representationIds: !Array.<string>}
Properties:
Name Type Attributes Description
id string The unique ID of the adaptation set.
contentType string <nullable>
The content type of the AdaptationSet.
language string The language of the AdaptationSet.
main boolean Whether the AdaptationSet has the 'main' type.
streams Array.<shaka.extern.Stream> The streams this AdaptationSet contains.
drmInfos Array.<shaka.extern.DrmInfo> The DRM info for the AdaptationSet.
trickModeFor string <nullable>
If non-null, this AdaptationInfo represents trick mode tracks. This property is the ID of the normal AdaptationSet these tracks should be associated with.
representationIds Array.<string> An array of the IDs of the Representations this AdaptationSet contains.
Source:

Context

Contains context data for the streams.
Type:
Properties:
Name Type Attributes Description
dynamic boolean True if the MPD is dynamic (not all segments available at once)
presentationTimeline shaka.media.PresentationTimeline The PresentationTimeline.
period shaka.dash.DashParser.InheritanceFrame <nullable>
The inheritance from the Period element.
periodInfo shaka.dash.DashParser.PeriodInfo <nullable>
The Period info for the current Period.
adaptationSet shaka.dash.DashParser.InheritanceFrame <nullable>
The inheritance from the AdaptationSet element.
representation shaka.dash.DashParser.InheritanceFrame <nullable>
The inheritance from the Representation element.
bandwidth number The bandwidth of the Representation, or zero if missing.
indexRangeWarningGiven boolean True if the warning about SegmentURL@indexRange has been printed.
Source:

InheritanceFrame

A collection of elements and properties which are inherited across levels of a DASH manifest.
Type:
  • {segmentBase: Element, segmentList: Element, segmentTemplate: Element, baseUris: !Array.<string>, width: (number|undefined), height: (number|undefined), contentType: string, mimeType: string, codecs: string, frameRate: (number|undefined), pixelAspectRatio: (string|undefined), emsgSchemeIdUris: !Array.<string>, id: ?string, numChannels: ?number, audioSamplingRate: ?number}
Properties:
Name Type Attributes Description
segmentBase Element The XML node for SegmentBase.
segmentList Element The XML node for SegmentList.
segmentTemplate Element The XML node for SegmentTemplate.
baseUris Array.<string> An array of absolute base URIs for the frame.
width number | undefined The inherited width value.
height number | undefined The inherited height value.
contentType string The inherited media type.
mimeType string The inherited MIME type value.
codecs string The inherited codecs value.
frameRate number | undefined The inherited framerate value.
pixelAspectRatio string | undefined The inherited pixel aspect ratio value.
emsgSchemeIdUris Array.<string> emsg registered schemeIdUris.
id string <nullable>
The ID of the element.
numChannels number <nullable>
The number of audio channels, or null if unknown.
audioSamplingRate number <nullable>
Specifies the maximum sampling rate of the content, or null if unknown.
Source:

PeriodInfo

Contains information about a Period element.
Type:
  • {start: number, duration: ?number, node: !Element, isLastPeriod: boolean}
Properties:
Name Type Attributes Description
start number The start time of the period.
duration number <nullable>
The duration of the period; or null if the duration is not given. This will be non-null for all periods except the last.
node Element The XML Node for the Period.
isLastPeriod boolean Whether this Period is the last one in the manifest.
Source:

RequestInitSegmentCallback

Type:
  • function(!Array.<string>, ?number, ?number): !Promise.<!ArrayBuffer>
Source:

SegmentIndexFunctions

Contains functions used to create and find segment references. Used as a return value, to temporarily store them before StreamInfo is created.
Type:
Properties:
Name Type Description
createSegmentIndex shaka.extern.CreateSegmentIndexFunction The createSegmentIndex function.
findSegmentPosition shaka.extern.FindSegmentPositionFunction The findSegmentPosition function.
getSegmentReference shaka.extern.GetSegmentReferenceFunction The getSegmentReference function.
Source:

StreamInfo

Contains information about a Stream. This is passed from the createStream methods.
Type:
Properties:
Name Type Description
createSegmentIndex shaka.extern.CreateSegmentIndexFunction The createSegmentIndex function for the stream.
findSegmentPosition shaka.extern.FindSegmentPositionFunction The findSegmentPosition function for the stream.
getSegmentReference shaka.extern.GetSegmentReferenceFunction The getSegmentReference function for the stream.
initSegmentReference shaka.media.InitSegmentReference The init segment for the stream.
scaledPresentationTimeOffset number The presentation time offset for the stream, in seconds.
Source: