Constructor
new DashParser()
Creates a new DASH parser.
- Implements:
- Source:
Members
-
(static, constant) BOX_TYPE_EMSG :number
-
Type:
- number
- Source:
-
(static, constant) DASH_EMSG_SCHEME_ID_URI :string
-
Type:
- string
- Source:
-
(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, non-null) emsgResponseFilter_ :shaka.net.NetworkingEngine.ResponseFilter
-
Type:
- Source:
-
(private, nullable) filterPeriod_ :?function(shakaExtern.Period)
-
Type:
- ?function(shakaExtern.Period)
- 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:
- ?function(!shaka.util.Error)
- Source:
-
(private, nullable) onEvent_ :?function(!shaka.util.FakeEvent)
-
Type:
- ?function(!shaka.util.FakeEvent)
- 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:
- Object.<string, !shaka.media.SegmentIndex>
- 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 configshakaExtern.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 elemElement parentshaka.dash.DashParser.InheritanceFrame <nullable>
baseUrisArray.<string> - Source:
Returns:
-
(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 adaptationSetsArray.<shaka.dash.DashParser.AdaptationInfo> - Source:
Returns:
- Type
- Array.<shakaExtern.StreamSet>
-
(private) emsgResponseFilter_(type, responsenon-null)
-
Response filter that looks for presence of EMSG boxes in segments. If a box is found, depending on the content it either triggers the manifest update or dispatches an event with the box content to the application.
Parameters:
Name Type Description typeshaka.net.NetworkingEngine.RequestType responseshakaExtern.Response - Source:
-
(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 contextshaka.dash.DashParser.Context elemElement The AdaptationSet element. - Source:
Throws:
shaka.util.Error When there is a parsing error.Returns:
-
(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 dataArrayBuffer finalManifestUristring 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 contextshaka.dash.DashParser.Context baseUrisArray.<string> periodInfoshaka.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, containsInband: 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 contextshaka.dash.DashParser.Context baseUrisArray.<string> mpdElement - Source:
Returns:
- Type
- {periods: !Array.<shakaExtern.Period>, duration: ?number, containsInband: boolean}
-
(private) parseRepresentation_(context, contentProtection, kind, language, nodenon-null) → (nullable) {shakaExtern.Stream}
-
Parses a Representation XML element.
Parameters:
Name Type Description contextshaka.dash.DashParser.Context contentProtectionshaka.dash.ContentProtection.Context kindstring | undefined languagestring nodeElement - 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
- shakaExtern.Stream
-
(private) parseUtcTiming_(baseUrisnon-null, elemsnon-null, isLive) → (non-null) {Promise.<number>}
-
Parses an array of UTCTiming elements.
Parameters:
Name Type Description baseUrisArray.<string> elemsArray.<!Element> isLiveboolean - Source:
Returns:
- Type
- Promise.<number>
-
(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 baseUrisArray.<string> uristring methodstring - 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 urisArray.<string> startBytenumber <nullable>
endBytenumber <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 offsetnumber An offset, in seconds, to apply to the manifest's update period. - Source:
-
start(uri, networkingEnginenon-null, filterPeriod, onError, onEvent) → (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. networkingEngineshaka.net.NetworkingEngine The networking engine to use for network requests. filterPeriodfunction(shakaExtern.Period) A callback to be invoked on all new Periods so that they can be filtered. onErrorfunction(!shaka.util.Error) A callback to be invoked on errors. onEventfunction(!shaka.util.FakeEvent) A callback to be invoked to dispatch events to application. - 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) → {boolean}
-
Verifies that a Representation has exactly one Segment* element. Prints warnings if there is a problem.
Parameters:
Name Type Description frameshaka.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.<shakaExtern.Stream>, drmInfos: !Array.<shakaExtern.DrmInfo>, switchableIds: !Array.<string>, containsInband: boolean}
Properties:
Name Type Attributes Description idstring The unique ID of the adaptation set. contentTypestring <nullable>
The content type of the AdaptationSet. languagestring The language of the AdaptationSet. mainboolean Whether the AdaptationSet has the 'main' type. streamsArray.<shakaExtern.Stream> The streams this AdaptationSet contains. drmInfosArray.<shakaExtern.DrmInfo> The DRM info for the AdaptationSet. switchableIdsArray.<string> An array of the IDs of the AdaptationSets it can switch to. containsInbandboolean Signals whether AdaptationSet has inband content indicator on it. - Source:
-
Context
-
Contains context data for the streams.
Type:
- {dynamic: boolean, presentationTimeline: !shaka.media.PresentationTimeline, period: ?shaka.dash.DashParser.InheritanceFrame, periodInfo: ?shaka.dash.DashParser.PeriodInfo, adaptationSet: ?shaka.dash.DashParser.InheritanceFrame, representation: ?shaka.dash.DashParser.InheritanceFrame, bandwidth: (number|undefined)}
Properties:
Name Type Attributes Description dynamicboolean True if the MPD is dynamic (not all segments available at once) presentationTimelineshaka.media.PresentationTimeline The PresentationTimeline. periodshaka.dash.DashParser.InheritanceFrame <nullable>
The inheritance from the Period element. periodInfoshaka.dash.DashParser.PeriodInfo <nullable>
The Period info for the current Period. adaptationSetshaka.dash.DashParser.InheritanceFrame <nullable>
The inheritance from the AdaptationSet element. representationshaka.dash.DashParser.InheritanceFrame <nullable>
The inheritance from the Representation element. bandwidthnumber | undefined The bandwidth of the Representation. - Source:
-
EmsgInfo
-
Contains information about an EMSG MP4 box.
Type:
- {schemeIdUri: string, value: string, timescale: number, presentationTimeDelta: number, eventDuration: number, id: number, messageData: Uint8Array}
Properties:
Name Type Description schemeIdUristring Identifies the message scheme. valuestring Specifies the value for the event. timescalenumber Provides the timescale, in ticks per second, for the time and duration fields within this box. presentationTimeDeltanumber Provides the Media Presentation time delta of the media presentation time of the event and the earliest presentation time in this segment. eventDurationnumber Provides the duration of event in media presentation time. idnumber A field identifying this instance of the message. messageDataUint8Array Body of the message. - 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, id: string}
Properties:
Name Type Description segmentBaseElement The XML node for SegmentBase. segmentListElement The XML node for SegmentList. segmentTemplateElement The XML node for SegmentTemplate. baseUrisArray.<string> An array of absolute base URIs for the frame. widthnumber | undefined The inherited width value. heightnumber | undefined The inherited height value. contentTypestring The inherited media type. mimeTypestring The inherited MIME type value. codecsstring The inherited codecs value. idstring The ID of the element. - Source:
-
PeriodInfo
-
Contains information about a Period element.
Type:
- {start: number, duration: ?number, node: !Element, containsInband: boolean}
Properties:
Name Type Attributes Description startnumber The start time of the period. durationnumber <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. nodeElement The XML Node for the Period. containsInbandboolean Indicates whether a period contains inband information. - Source:
-
RequestInitSegmentCallback
-
Type:
- !function(!Array.<string>, ?number, ?number): !Promise.<!ArrayBuffer>
- Source:
-
SegmentIndexFunctions
-
Contains functions used to create and find segment references.
Type:
- {createSegmentIndex: shakaExtern.CreateSegmentIndexFunction, findSegmentPosition: shakaExtern.FindSegmentPositionFunction, getSegmentReference: shakaExtern.GetSegmentReferenceFunction}
Properties:
Name Type Description createSegmentIndexshakaExtern.CreateSegmentIndexFunction The createSegmentIndex function. findSegmentPositionshakaExtern.FindSegmentPositionFunction The findSegmentPosition function. getSegmentReferenceshakaExtern.GetSegmentReferenceFunction The getSegmentReference function. - Source:
-
StreamInfo
-
Contains information about a Stream. This is passed from the createStream methods.
Type:
- {createSegmentIndex: shakaExtern.CreateSegmentIndexFunction, findSegmentPosition: shakaExtern.FindSegmentPositionFunction, getSegmentReference: shakaExtern.GetSegmentReferenceFunction, initSegmentReference: shaka.media.InitSegmentReference, presentationTimeOffset: (number|undefined)}
Properties:
Name Type Description createSegmentIndexshakaExtern.CreateSegmentIndexFunction The createSegmentIndex function for the stream. findSegmentPositionshakaExtern.FindSegmentPositionFunction The findSegmentPosition function for the stream. getSegmentReferenceshakaExtern.GetSegmentReferenceFunction The getSegmentReference function for the stream. initSegmentReferenceshaka.media.InitSegmentReference The init segment for the stream. presentationTimeOffsetnumber | undefined The presentationTimeOffset for the stream. - Source: