Class: shaka.dash.MpdUtils

MPD processing utility functions.

Constructor

new MpdUtils()

MPD processing utility functions.

Source:

Members

XlinkNamespaceUri_ :string

Type:
  • string
Source:

Methods

createTimeline(timePoints, timescale, unscaledPresentationTimeOffset, periodDuration, startNumber) → {Array<shaka.media.PresentationTimeline.TimeRange>}

Expands a SegmentTimeline into an array-based timeline. The results are in seconds.
Parameters:
Name Type Description
timePoints Array<!shaka.extern.xml.Node>
timescale number
unscaledPresentationTimeOffset number
periodDuration number The Period's duration in seconds. Infinity indicates that the Period continues indefinitely.
startNumber number
Source:
Returns:
Type
Array<shaka.media.PresentationTimeline.TimeRange>

expandSWithPattern_(sNodenon-null, patternsnon-null) → {Array<!shaka.extern.xml.Node>}

Expands an element that references a Pattern into one or more plain elements without pattern usage.
Parameters:
Name Type Description
sNode shaka.extern.xml.Node
patterns Map<string, !shaka.extern.xml.Node>
Source:
Returns:
Type
Array<!shaka.extern.xml.Node>

fallbackLinkedPeriod_(mpdnon-null, periodnon-null, importedMpdElemnon-null)

Handles a failed Linked Period resolution (§5.3.2.6.3 step 2): the ImportedMPD element is removed so the Linked Period becomes a regular Period. If the resulting Period has no valid content, the Period itself is removed from the MPD.
Parameters:
Name Type Description
mpd shaka.extern.xml.Node
period shaka.extern.xml.Node
importedMpdElem shaka.extern.xml.Node
Source:

fillUriTemplate(uriTemplate, representationIdnullable, numbernullable, subNumbernullable, bandwidthnullable, timenullable) → {string}

Fills a SegmentTemplate URI template. This function does not validate the resulting URI.
Parameters:
Name Type Attributes Description
uriTemplate string
representationId string <nullable>
number number <nullable>
subNumber number <nullable>
bandwidth number <nullable>
time number | bigint <nullable>
Source:
See:
  • ISO/IEC 23009-1:2014 section 5.3.9.4.4
Returns:
A URI string.
Type
string

getDescriptor(descriptorsnon-null, schemeIdUri, valueopt) → {shaka.dash.MpdUtils.Descriptor}

Returns the first descriptor in the list matching the given scheme (and, when provided, value), or null if there is none.
Parameters:
Name Type Attributes Description
descriptors Array<shaka.dash.MpdUtils.Descriptor>
schemeIdUri string
value string <optional>
Source:
Returns:
Type
shaka.dash.MpdUtils.Descriptor

getNodes(context, callback) → {Array<!shaka.extern.xml.Node>}

Parses common attributes for Representation, AdaptationSet, and Period.
Parameters:
Name Type Description
context shaka.dash.DashParser.Context
callback function(?shaka.dash.DashParser.InheritanceFrame): ?shaka.extern.xml.Node
Source:
Returns:
Type
Array<!shaka.extern.xml.Node>

handleXlinkInElement_(elementnon-null, retryParametersnon-null, failGracefully, baseUri, networkingEnginenon-null, linkDepth) → {shaka.util.AbortableOperation<!shaka.extern.xml.Node>}

Follow the xlink link contained in the given element. It also strips the xlink properties off of the element, even if the process fails.
Parameters:
Name Type Description
element shaka.extern.xml.Node
retryParameters shaka.extern.RetryParameters
failGracefully boolean
baseUri string
networkingEngine shaka.net.NetworkingEngine
linkDepth number
Source:
Returns:
Type
shaka.util.AbortableOperation<!shaka.extern.xml.Node>

hasDescriptor(descriptorsnon-null, schemeIdUri, valueopt) → {boolean}

Returns true if the list contains a descriptor matching the given scheme (and, when provided, value).
Parameters:
Name Type Attributes Description
descriptors Array<shaka.dash.MpdUtils.Descriptor>
schemeIdUri string
value string <optional>
Source:
Returns:
Type
boolean

hasLinkedPeriods(mpdnon-null) → {boolean}

Checks whether the MPD has any Linked Periods (Periods with ImportedMPD children, as defined in DASH 6th edition §5.3.2.6).
Parameters:
Name Type Description
mpd shaka.extern.xml.Node
Source:
Returns:
Type
boolean
Fast detection of whether the MPD contains XLinks worth resolving. The DASH spec only allows XLink on the following elements: - Period - AdaptationSet - SegmentList We also avoid descending into SegmentTimeline for performance and because XLink is not valid there.
Parameters:
Name Type Description
root shaka.extern.xml.Node
Source:
Returns:
Type
boolean

importedMpdResolutionFails_(importedMpdnon-null) → {boolean}

Checks whether a retrieved imported MPD must be rejected per §5.3.2.6.3: - step 1.b: it does not conform to the imported MPD restrictions. The Single-Period Static Profile (clause 8.15.2) requires MPD@type="static" (the default when the attribute is absent) — so a live/dynamic, or a "list", imported MPD is rejected — and exactly one Period element. - step 1.c: @availabilityEndTime is present and earlier than now.
Parameters:
Name Type Description
importedMpd shaka.extern.xml.Node
Source:
Returns:
Type
boolean

inheritAttribute(context, callback, attribute) → {string}

Searches the inheritance for a Segment* with the given attribute.
Parameters:
Name Type Description
context shaka.dash.DashParser.Context
callback function(?shaka.dash.DashParser.InheritanceFrame): ?shaka.extern.xml.Node Gets the Element that contains the attribute to inherit.
attribute string
Source:
Returns:
Type
string

inheritChild(context, callback, child) → {shaka.extern.xml.Node}

Searches the inheritance for a Segment* with the given child.
Parameters:
Name Type Description
context shaka.dash.DashParser.Context
callback function(?shaka.dash.DashParser.InheritanceFrame): ?shaka.extern.xml.Node Gets the Element that contains the child to inherit.
child string
Source:
Returns:
Type
shaka.extern.xml.Node

isValidRegularPeriod_(periodnon-null) → {boolean}

A regular Period is valid if it contains at least one Adaptation Set, or if its @duration is zero (see DASH 6th ed. Table 4, AdaptationSet semantics).
Parameters:
Name Type Description
period shaka.extern.xml.Node
Source:
Returns:
Type
boolean

linkedPeriodMergeKey_(nodenon-null) → {string}

Returns the equivalence key used by §5.3.2.6.3 step 3.c to decide whether two elements are "the same" (so the imported one overrides the Linked Period one), or null if the element is not subject to override.
Parameters:
Name Type Description
node shaka.extern.xml.Node
Source:
Returns:
Type
string

mergeImportedPeriod_(periodnon-null, importedMpdnon-null, importedPeriodnon-null, importedMpdUri)

Integrates the content of an imported single-period MPD into a Linked Period, following DASH 6th ed. §5.3.2.6.3 step 3.
Parameters:
Name Type Description
period shaka.extern.xml.Node The Linked Period.
importedMpd shaka.extern.xml.Node
importedPeriod shaka.extern.xml.Node
importedMpdUri string The absolute URL of the imported MPD.
Source:

normalizeDescriptor_(elementnon-null) → {shaka.dash.MpdUtils.Descriptor}

Normalizes a single EssentialProperty/SupplementalProperty element into a Descriptor, keeping a reference to the underlying XML element for access to scheme-specific attributes.
Parameters:
Name Type Description
element shaka.extern.xml.Node
Source:
Returns:
Type
shaka.dash.MpdUtils.Descriptor

parseDescriptorsByTag_(nodenon-null, tagName) → {Array<shaka.dash.MpdUtils.Descriptor>}

Extracts and normalizes the descriptor elements with the given tag name that are direct children of the given element.
Parameters:
Name Type Description
node shaka.extern.xml.Node
tagName string
Source:
Returns:
Type
Array<shaka.dash.MpdUtils.Descriptor>

parseEssentialProperties(nodenon-null) → {Array<shaka.dash.MpdUtils.Descriptor>}

Extracts and normalizes the EssentialProperty descriptors that are direct children of the given element.
Parameters:
Name Type Description
node shaka.extern.xml.Node
Source:
See:
  • ISO/IEC 23009-1:2022 clause 5.8.4.8
Returns:
Type
Array<shaka.dash.MpdUtils.Descriptor>

parsePatterns_(segmentTimelineNodenon-null) → {Map<string, !shaka.extern.xml.Node>}

Parameters:
Name Type Description
segmentTimelineNode shaka.extern.xml.Node
Source:
Returns:
Type
Map<string, !shaka.extern.xml.Node>

parseSegmentInfo(context, callback) → {shaka.dash.MpdUtils.SegmentInfo}

Parses common segment info for SegmentList and SegmentTemplate.
Parameters:
Name Type Description
context shaka.dash.DashParser.Context
callback function(?shaka.dash.DashParser.InheritanceFrame): ?shaka.extern.xml.Node Gets the element that contains the segment info.
Source:
Returns:
Type
shaka.dash.MpdUtils.SegmentInfo

parseSupplementalProperties(nodenon-null) → {Array<shaka.dash.MpdUtils.Descriptor>}

Extracts and normalizes the SupplementalProperty descriptors that are direct children of the given element.
Parameters:
Name Type Description
node shaka.extern.xml.Node
Source:
See:
  • ISO/IEC 23009-1:2022 clause 5.8.4.9
Returns:
Type
Array<shaka.dash.MpdUtils.Descriptor>

processLinkedPeriods(mpdnon-null, baseUri, retryParametersnon-null, networkingEnginenon-null) → {shaka.util.AbortableOperation<!shaka.extern.xml.Node>}

Resolves Linked Periods (ImportedMPD elements, DASH 6th ed. §5.3.2.6). For each Period with an ImportedMPD child, fetches the referenced single-period MPD and integrates its content into the Linked Period following the reference processing model of §5.3.2.6.3. When the resolution fails, the Linked Period falls back to a regular Period, or is removed if it has no valid content (step 2).
Parameters:
Name Type Description
mpd shaka.extern.xml.Node
baseUri string
retryParameters shaka.extern.RetryParameters
networkingEngine shaka.net.NetworkingEngine
Source:
Returns:
Type
shaka.util.AbortableOperation<!shaka.extern.xml.Node>
Filter the contents of a node recursively, replacing xlink links with their associated online data.
Parameters:
Name Type Attributes Default Description
element shaka.extern.xml.Node
retryParameters shaka.extern.RetryParameters
failGracefully boolean
baseUri string
networkingEngine shaka.net.NetworkingEngine
linkDepth number <optional>
0 default set to 0
Source:
Returns:
Type
shaka.util.AbortableOperation<!shaka.extern.xml.Node>

resolveImportedBaseUrls_(importedMpdnon-null, importedPeriodnon-null, importedMpdUri) → {Array<string>}

Resolves the Base URLs of an imported MPD into absolute URLs, following the Base URL resolution of clause 5.6 (§5.3.2.6.3 step 3.e). The imported MPD URL is the root, against which the imported MPD-level BaseURL elements are resolved, against which in turn the imported Period-level BaseURL elements are resolved.
Parameters:
Name Type Description
importedMpd shaka.extern.xml.Node
importedPeriod shaka.extern.xml.Node
importedMpdUri string
Source:
Returns:
Type
Array<string>

Type Definitions

Descriptor

A normalized DASH property descriptor, as carried by EssentialProperty and SupplementalProperty elements.
Type:
Properties:
Name Type Description
schemeIdUri string The @schemeIdUri attribute identifying the descriptor scheme.
value string The @value attribute, or undefined if not present.
id string The @id attribute, or undefined if not present.
element shaka.extern.xml.Node The underlying XML element, for access to scheme-specific attributes.
Source:

SegmentInfo

Contains common information between SegmentList and SegmentTemplate items.
Type:
  • {timescale: number, unscaledSegmentDuration: ?number, segmentDuration: ?number, startNumber: number, scaledPresentationTimeOffset: number, unscaledPresentationTimeOffset: number, timeline: Array<shaka.media.PresentationTimeline.TimeRange>}
Properties:
Name Type Attributes Description
timescale number The time-scale of the representation.
unscaledSegmentDuration number <nullable>
The duration of the segments in timescale units, if given.
segmentDuration number <nullable>
The duration of the segments in seconds, if given.
startNumber number The start number of the segments; 1 or greater.
scaledPresentationTimeOffset number The presentation time offset of the representation, in seconds.
unscaledPresentationTimeOffset number The presentation time offset of the representation, in timescale units.
timeline Array<shaka.media.PresentationTimeline.TimeRange> The timeline of the representation, if given. Times in seconds.
Source:

Documentation generated by JSDoc 3.6.10 on Thu Jul 09 2026 15:26:34 GMT+0000 (Coordinated Universal Time)