Class: shaka.dash.DashParser

Constructor

new DashParser()

Creates a new DASH parser.
Implements:
Source:

Members

(private, static, constant) DEFAULT_SUGGESTED_PRESENTATION_DELAY_ :number

The default MPD@suggestedPresentationDelay in seconds.
Type:
  • number
Source:

(private, static, constant) MIN_UPDATE_PERIOD_ :number

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

(private, nullable) config_ :shakaExtern.ManifestConfiguration

Type:
Source:

(private, nullable) filterPeriod_ :?function(shakaExtern.Period)

Type:
Source:

(private) globalId_ :number

Type:
  • number
Source:

(private, nullable) manifest_ :shakaExtern.Manifest

Type:
Source:

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

Type:
  • Array.<string>
Source:

(private) networkingEngine_ :shaka.net.NetworkingEngine

Type:
Source:

(private, nullable) onError_ :?function(!shaka.util.Error)

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, nullable) updateTimer_ :number

Type:
  • number
Source:

Methods

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) 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) createStreamSets_(adaptationSetsnon-null) → (non-null) {Array.<shakaExtern.StreamSet>}

Creates the StreamSet objects for the given AdaptationSets. This will group stream sets according to which streams it can switch to. If AdaptationSet A can switch to B, it is assumed that B can switch to A (as well as any stream that A can switch to).
Parameters:
Name Type Description
adaptationSets Array.<shaka.dash.DashParser.AdaptationInfo>
Source:
Returns:
Type
Array.<shakaExtern.StreamSet>

(private) onUpdate_()

Called when the update timer ticks.
Source:

(private) parseAdaptationSet_(context, elemnon-null) → {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) parseManifest_(datanon-null, 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) → {shakaExtern.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
shakaExtern.Period

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

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.<shakaExtern.Period>, duration: ?number}

(private) parseRepresentation_(context, contentProtection, kind, nodenon-null) → {shakaExtern.Stream}

Parses a Representation XML element.
Parameters:
Name Type Description
context shaka.dash.DashParser.Context
contentProtection shaka.dash.ContentProtection.Context
kind string | undefined
node Element
Source:
Throws:
shaka.util.Error When there is a parsing error.
Returns:
Type
shakaExtern.Stream

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

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

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

Makes a request to the given URI and calculates the clock offset.
Parameters:
Name Type Description
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}

Makes a network request for the manifest and parses the resulting data.
Source:
Returns:
Type
Promise

(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:

start(uri, networkingEnginenon-null, filterPeriod, onError) → (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.
networkingEngine shaka.net.NetworkingEngine The networking engine to use for network requests.
filterPeriod function(shakaExtern.Period) A callback to be invoked on all new Periods so that they can be filtered.
onError function(!shaka.util.Error) A callback to be invoked on errors.
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

(private) verifyRepresentation_(frame)

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:
Throws:
shaka.util.Error If there is no segment info.

Type Definitions

AdaptationInfo

Contains information about an AdaptationSet element.
Type:
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.<shakaExtern.Stream> The streams this AdaptationSet contains.
drmInfos Array.<shakaExtern.DrmInfo> The DRM info for the AdaptationSet.
switchableIds Array.<string> An array of the IDs of the AdaptationSets it can switch to.
Source:

Context

Contains context data for the streams.
Type:
Properties:
Name Type Attributes Description
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 | undefined The bandwidth of the Representation.
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, codec: string, id: string}
Properties:
Name Type 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.
codec string The inherited codec value.
id string The ID of the element.
Source:

PeriodInfo

Contains information about a Period element.
Type:
  • {start: number, duration: ?number, node: !Element}
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.
Source:

RequestInitSegmentCallback

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

SegmentIndexFunctions

Contains functions used to create and find segment references.
Type:
Properties:
Name Type Description
createSegmentIndex shakaExtern.CreateSegmentIndexFunction The createSegmentIndex function.
findSegmentPosition shakaExtern.FindSegmentPositionFunction The findSegmentPosition function.
getSegmentReference shakaExtern.GetSegmentReferenceFunction The getSegmentReference function.
Source:

StreamInfo

Contains information about a Stream. This is passed from the createStream methods.
Type:
Properties:
Name Type Description
createSegmentIndex shakaExtern.CreateSegmentIndexFunction The createSegmentIndex function for the stream.
findSegmentPosition shakaExtern.FindSegmentPositionFunction The findSegmentPosition function for the stream.
getSegmentReference shakaExtern.GetSegmentReferenceFunction The getSegmentReference function for the stream.
initSegmentReference shaka.media.InitSegmentReference The init segment for the stream.
presentationTimeOffset number | undefined The presentationTimeOffset for the stream.
Source: