A set of utility functions for dealing with Streams and Manifests.
Constructor
new StreamUtils()
A set of utility functions for dealing with Streams and Manifests.
- Source:
Members
DecodingAttributes :string
Type:
Properties:
Name |
Value |
Type |
Description |
SMOOTH |
smooth
|
string
|
|
POWER |
powerEfficient
|
string
|
|
- Source:
decodingConfigCache_ :Object.<(!string), (!MediaCapabilitiesDecodingInfo)>
A cache of results from mediaCapabilities.decodingInfo, indexed by the
(stringified) decodingConfig.
Type:
-
Object.<(!string), (!MediaCapabilitiesDecodingInfo)>
- Source:
minAvifImage_ :string
Type:
- Source:
minImage_ :Map.<string, string>
Type:
- Source:
minWebPImage_ :string
Type:
- Source:
nextTrackId_ :number
Type:
- Source:
supportedImageMimeTypes_ :Map.<string, boolean>
Type:
- Source:
Methods
alphabeticalKeyOrderStringify_(objnon-null) → {string}
Constructs a string out of an object, similar to the JSON.stringify method.
Unlike that method, this guarantees that the order of the keys is
alphabetical, so it can be used as a way to reliably compare two objects.
Parameters:
Name |
Type |
Description |
obj |
Object
|
|
- Source:
Returns:
-
Type
-
string
applyRestrictions(variantsnon-null, restrictions, maxHwRes) → {boolean}
Parameters:
- Source:
Returns:
Whether the tracks changed.
-
Type
-
boolean
areStreamsCompatible_(s0, s1) → {boolean}
Parameters:
- Source:
Returns:
-
Type
-
boolean
checkEachDecodingConfigCombination_(decodingConfignon-null) → {Promise.<?Array.<!MediaCapabilitiesDecodingInfo>>}
Parameters:
Name |
Type |
Description |
decodingConfig |
MediaDecodingConfiguration
|
|
- Source:
Returns:
-
Type
-
Promise.<?Array.<!MediaCapabilitiesDecodingInfo>>
checkVariantSupported_(variantnon-null, keySystemnullable) → {boolean}
Parameters:
- Source:
Returns:
-
Type
-
boolean
chooseCodecsAndFilterManifest(manifestnon-null, preferredVideoCodecsnon-null, preferredAudioCodecsnon-null, preferredDecodingAttributesnon-null)
In case of multiple usable codecs, choose one based on lowest average
bandwidth and filter out the rest.
Also filters out variants that have too many audio channels.
Parameters:
Name |
Type |
Description |
manifest |
shaka.extern.Manifest
|
|
preferredVideoCodecs |
Array.<string>
|
|
preferredAudioCodecs |
Array.<string>
|
|
preferredDecodingAttributes |
Array.<string>
|
|
- Source:
choosePreferredCodecs(variantsnon-null, preferredVideoCodecsnon-null, preferredAudioCodecsnon-null) → {Array.<shaka.extern.Variant>}
Choose the codecs by configured preferred audio and video codecs.
Parameters:
Name |
Type |
Description |
variants |
Array.<shaka.extern.Variant>
|
|
preferredVideoCodecs |
Array.<string>
|
|
preferredAudioCodecs |
Array.<string>
|
|
- Source:
Returns:
-
Type
-
Array.<shaka.extern.Variant>
clearDecodingConfigCache()
Clears underlying decoding config cache.
- Source:
filterByRestrictions(manifestnon-null, restrictions, maxHwResolution)
Filter the variants in |manifest| to only include the variants that meet
the given restrictions.
Parameters:
- Source:
filterImageStreams_(manifest)
Alters the given Manifest to filter out any unsupported image streams.
Parameters:
- Source:
filterManifest(drmEngine, manifest, preferredKeySystemsopt, non-null)
Alters the given Manifest to filter out any unplayable streams.
Parameters:
- Source:
filterManifestByCurrentVariant(currentVariantnullable, manifest)
Alters the given Manifest to filter out any streams uncompatible with the
current variant.
Parameters:
- Source:
Alters the given Manifest to filter out any streams unsupported by the
platform via MediaCapabilities.decodingInfo() API.
Parameters:
- Source:
filterTextStreams_(manifest)
Alters the given Manifest to filter out any unsupported text streams.
Parameters:
- Source:
getCorrectAudioCodecs(codecs, mimeType) → {string}
Generates the correct audio codec for MediaDecodingConfiguration and
for MediaSource.isTypeSupported.
Parameters:
Name |
Type |
Description |
codecs |
string
|
|
mimeType |
string
|
|
- Source:
Returns:
-
Type
-
string
getCorrectVideoCodecs(codec) → {string}
Generates the correct video codec for MediaDecodingConfiguration and
for MediaSource.isTypeSupported.
Parameters:
Name |
Type |
Description |
codec |
string
|
|
- Source:
Returns:
-
Type
-
string
getDecodingConfigs_(variantnon-null, usePersistentLicenses, srcEquals) → {Array.<!Array.<!MediaDecodingConfiguration>>}
Generate a batch of MediaDecodingConfiguration objects to get the
decodingInfo results for each variant.
Each batch shares the same DRM information, and represents the various
fullMimeType combinations of the streams.
Parameters:
- Source:
Returns:
-
Type
-
Array.<!Array.<!MediaDecodingConfiguration>>
getDecodingInfosForVariant_(variantnon-null, decodingConfigsnon-null)
Queries mediaCapabilities for the decoding info for that decoding config,
and assigns it to the given variant.
If that query has been done before, instead return a cached result.
Parameters:
Name |
Type |
Description |
variant |
shaka.extern.Variant
|
|
decodingConfigs |
Array.<!MediaDecodingConfiguration>
|
|
- Source:
getDecodingInfosForVariants(variantsnon-null, usePersistentLicenses, srcEquals, preferredKeySystemsnon-null)
Get the decodingInfo results of the variants via MediaCapabilities.
This should be called after the DrmEngine is created and configured, and
before DrmEngine sets the mediaKeys.
Parameters:
Name |
Type |
Description |
variants |
Array.<shaka.extern.Variant>
|
|
usePersistentLicenses |
boolean
|
|
srcEquals |
boolean
|
|
preferredKeySystems |
Array.<string>
|
|
- Source:
getStreamSummaryString_(stream) → {string}
Returns a string of an audio or video stream for log printing.
Parameters:
- Source:
Returns:
-
Type
-
string
getVariantSummaryString_(variant) → {string}
Returns a string of a variant, with the attribute values of its audio
and/or video streams for log printing.
Parameters:
- Source:
Returns:
-
Type
-
string
html5TrackId(html5Track) → {number}
Generate and return an ID for this track, since the ID field is optional.
Parameters:
Name |
Type |
Description |
html5Track |
TextTrack
|
AudioTrack
|
|
- Source:
Returns:
The generated ID.
-
Type
-
number
html5TrackToGenericShakaTrack_(html5Track) → {shaka.extern.Track}
Creates a Track object with non-type specific fields filled out. The
caller is responsible for completing the Track object with any
type-specific information (audio or text).
Parameters:
Name |
Type |
Description |
html5Track |
TextTrack
|
AudioTrack
|
|
- Source:
Returns:
-
Type
-
shaka.extern.Track
isAudio(stream) → {boolean}
Checks if the given stream is an audio stream.
Parameters:
- Source:
Returns:
-
Type
-
boolean
isFastSwitching(variant) → {boolean}
Indicates if some of the variant's streams are fastSwitching.
Parameters:
- Source:
Returns:
-
Type
-
boolean
isImageSupported_(minImage) → {Promise.<boolean>}
Parameters:
Name |
Type |
Description |
minImage |
string
|
|
- Source:
Returns:
-
Type
-
Promise.<boolean>
isPlayable(variantnon-null) → {boolean}
Determines if the given variant is playable.
Parameters:
- Source:
Returns:
-
Type
-
boolean
isVideo(stream) → {boolean}
Checks if the given stream is a video stream.
Parameters:
- Source:
Returns:
-
Type
-
boolean
meetsRestrictions(variant, restrictions, maxHwRes) → {boolean}
Parameters:
- Source:
Returns:
-
Type
-
boolean
overrideDolbyVisionCodecs(variantsnon-null)
Maps Dolby Vision codecs to H.264 and H.265 equivalents as a workaround
to make Dolby Vision playback work on some platforms.
Mapping is done according to the relevant Dolby documentation found here:
https://professionalsupport.dolby.com/s/article/How-to-signal-Dolby-Vision-in-MPEG-DASH?language=en_US
Parameters:
- Source:
setBetterIFrameStream(streamnon-null, iFrameStreamsnon-null)
Set the best iframe stream to the original stream.
Parameters:
- Source: