Constructor
new StreamUtils()
A set of utility functions for dealing with Streams and Manifests.
- Source:
Members
DecodingAttributes :string
Type:
- string
Properties:
Name | Value | Type | Description |
---|---|---|---|
SMOOTH |
smooth | string | |
POWER |
powerEfficient | string | |
BANDWIDTH |
bandwidth | string |
- Source:
decodingConfigCache_ :Object.<(!string), (!MediaCapabilitiesDecodingInfo)>
A cache of results from mediaCapabilities.decodingInfo, indexed by the
(stringified) decodingConfig.
Type:
- Object.<(!string), (!MediaCapabilitiesDecodingInfo)>
- Source:
minImage_ :Map.<string, string>
Type:
- Map.<string, string>
- Source:
supportedImageMimeTypes_ :Map.<string, boolean>
Type:
- Map.<string, boolean>
- 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:
Name | Type | Description |
---|---|---|
variants |
Array.<shaka.extern.Variant> | |
restrictions |
shaka.extern.Restrictions | |
maxHwRes |
{width: number, height: number} |
- Source:
Returns:
Whether the tracks changed.
- Type
- boolean
areStreamsCompatible_(s0, s1) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
s0 |
shaka.extern.Stream | |
s1 |
shaka.extern.Stream |
- Source:
Returns:
- Type
- boolean
chooseCodecsAndFilterManifest(manifestnon-null, preferredVideoCodecsnon-null, preferredAudioCodecsnon-null, preferredAudioChannelCount, 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> | |
preferredAudioChannelCount |
number | |
preferredDecodingAttributes |
Array.<string> |
- Source:
chooseCodecsByDecodingAttributes_(variantsByCodecsnon-null, attributesnon-null) → {string}
Choose the codecs by configured preferred decoding attributes.
Parameters:
Name | Type | Description |
---|---|---|
variantsByCodecs |
shaka.util.MultiMap.<shaka.extern.Variant> | |
attributes |
Array.<string> |
- Source:
Returns:
- Type
- string
chooseCodecsByMediaCapabilitiesInfo_(variantsByCodecsnon-null, attribute) → {shaka.util.MultiMap.<shaka.extern.Variant>}
Choose the best codecs by configured preferred MediaCapabilitiesInfo
attributes.
Parameters:
Name | Type | Description |
---|---|---|
variantsByCodecs |
shaka.util.MultiMap.<shaka.extern.Variant> | |
attribute |
string |
- Source:
Returns:
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>
filterByRestrictions(manifestnon-null, restrictions, maxHwResolution)
Filter the variants in |manifest| to only include the variants that meet
the given restrictions.
Parameters:
Name | Type | Description |
---|---|---|
manifest |
shaka.extern.Manifest | |
restrictions |
shaka.extern.Restrictions | |
maxHwResolution |
{width: number, height:number} |
- Source:
filterImageStreams_(manifest)
Alters the given Manifest to filter out any unsupported image streams.
Parameters:
Name | Type | Description |
---|---|---|
manifest |
shaka.extern.Manifest |
- Source:
filterManifest(drmEngine, currentVariantnullable, manifest)
Alters the given Manifest to filter out any unplayable streams.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
drmEngine |
shaka.media.DrmEngine | ||
currentVariant |
shaka.extern.Variant |
<nullable> |
|
manifest |
shaka.extern.Manifest |
- Source:
filterManifestByCurrentVariant(currentVariantnullable, manifest)
Alters the given Manifest to filter out any streams uncompatible with the
current variant.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
currentVariant |
shaka.extern.Variant |
<nullable> |
|
manifest |
shaka.extern.Manifest |
- Source:
filterManifestByMediaCapabilities(manifest, usePersistentLicenses)
Alters the given Manifest to filter out any streams unsupported by the
platform via MediaCapabilities.decodingInfo() API.
Parameters:
Name | Type | Description |
---|---|---|
manifest |
shaka.extern.Manifest | |
usePersistentLicenses |
boolean |
- Source:
filterStreamsByLanguageAndRole(streams, preferredLanguage, preferredRole, preferredForced) → {!Array.<!shaka.extern.Stream>|!Array.<!shaka.extern.Track>}
Chooses streams according to the given config.
Works both for Stream and Track types due to their similarities.
Parameters:
Name | Type | Description |
---|---|---|
streams |
!Array.<!shaka.extern.Stream> | !Array.<!shaka.extern.Track> | |
preferredLanguage |
string | |
preferredRole |
string | |
preferredForced |
boolean |
- Source:
Returns:
- Type
- !Array.<!shaka.extern.Stream> | !Array.<!shaka.extern.Track>
filterStreamsByRole_(streams, preferredRole) → {!Array.<!shaka.extern.Stream>|!Array.<!shaka.extern.Track>}
Filter Streams by role.
Works both for Stream and Track types due to their similarities.
Parameters:
Name | Type | Description |
---|---|---|
streams |
!Array.<!shaka.extern.Stream> | !Array.<!shaka.extern.Track> | |
preferredRole |
string |
- Source:
Returns:
- Type
- !Array.<!shaka.extern.Stream> | !Array.<!shaka.extern.Track>
filterTextStreams_(manifest)
Alters the given Manifest to filter out any unsupported text streams.
Parameters:
Name | Type | Description |
---|---|---|
manifest |
shaka.extern.Manifest |
- Source:
filterVariantsByAudioChannelCount(variantsnon-null, preferredAudioChannelCount) → {Array.<!shaka.extern.Variant>}
Filters variants according to the given audio channel count config.
Parameters:
Name | Type | Description |
---|---|---|
variants |
Array.<shaka.extern.Variant> | |
preferredAudioChannelCount |
number |
- Source:
Returns:
- Type
- Array.<!shaka.extern.Variant>
filterVariantsByDensity_(variantsByCodecsnon-null) → {shaka.util.MultiMap.<shaka.extern.Variant>}
Filters variants by density.
Get variants by codecs map with the max density where all codecs are
present.
Parameters:
Name | Type | Description |
---|---|---|
variantsByCodecs |
shaka.util.MultiMap.<shaka.extern.Variant> |
- Source:
Returns:
findCodecsByLowestBandwidth_(variantsByCodecsnon-null) → {string}
Find the lowest-bandwidth (best) codecs.
Compute the average bandwidth for each group of variants.
Parameters:
Name | Type | Description |
---|---|---|
variantsByCodecs |
shaka.util.MultiMap.<shaka.extern.Variant> |
- Source:
Returns:
- Type
- string
getCorrectAudioCodecs_(codecs) → {string}
Generates the correct audio codec for MediaDecodingConfiguration and
for MediaSource.isTypeSupported.
Parameters:
Name | Type | Description |
---|---|---|
codecs |
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.<!MediaDecodingConfiguration>}
Generate a MediaDecodingConfiguration object to get the decodingInfo
results for each variant.
Parameters:
Name | Type | Description |
---|---|---|
variant |
shaka.extern.Variant | |
usePersistentLicenses |
boolean | |
srcEquals |
boolean |
- Source:
Returns:
- Type
- Array.<!MediaDecodingConfiguration>
getDecodingInfosForVariant_(variantnon-null, decodingConfignon-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 | |
decodingConfig |
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:
getPlayableVariants(variantsnon-null) → {Array.<!shaka.extern.Variant>}
Filters out unplayable variants.
Parameters:
Name | Type | Description |
---|---|---|
variants |
Array.<!shaka.extern.Variant> |
- Source:
Returns:
- Type
- Array.<!shaka.extern.Variant>
getStreamSummaryString_(stream) → {string}
Returns a string of an audio or video stream for log printing.
Parameters:
Name | Type | Description |
---|---|---|
stream |
shaka.extern.Stream |
- Source:
Returns:
- Type
- string
getVariantCodecs_(variantnon-null) → {string}
Get a string representing all codecs used in a variant.
Parameters:
Name | Type | Description |
---|---|---|
variant |
shaka.extern.Variant |
- Source:
Returns:
- Type
- string
getVariantsByCodecs_(variantsnon-null) → {shaka.util.MultiMap.<shaka.extern.Variant>}
Get variants by codecs.
Parameters:
Name | Type | Description |
---|---|---|
variants |
Array.<shaka.extern.Variant> |
- Source:
Returns:
getVariantStreams(variant) → {Array.<shaka.extern.Stream>}
Get all non-null streams in the variant as an array.
Parameters:
Name | Type | Description |
---|---|---|
variant |
shaka.extern.Variant |
- Source:
Returns:
- Type
- Array.<shaka.extern.Stream>
getVariantSummaryString_(variant) → {string}
Returns a string of a variant, with the attribute values of its audio
and/or video streams for log printing.
Parameters:
Name | Type | Description |
---|---|---|
variant |
shaka.extern.Variant |
- Source:
Returns:
- Type
- string
html5AudioTrackToTrack(audioTrack) → {shaka.extern.Track}
Parameters:
Name | Type | Description |
---|---|---|
audioTrack |
AudioTrack |
- Source:
Returns:
- Type
- shaka.extern.Track
html5TextTrackToTrack(textTrack) → {shaka.extern.Track}
Parameters:
Name | Type | Description |
---|---|---|
textTrack |
TextTrack |
- Source:
Returns:
- Type
- shaka.extern.Track
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
imageStreamToTrack(stream) → {shaka.extern.Track}
Parameters:
Name | Type | Description |
---|---|---|
stream |
shaka.extern.Stream |
- Source:
Returns:
- Type
- shaka.extern.Track
isAudio(stream) → {boolean}
Checks if the given stream is an audio stream.
Parameters:
Name | Type | Description |
---|---|---|
stream |
shaka.extern.Stream |
- 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:
Name | Type | Description |
---|---|---|
variant |
shaka.extern.Variant |
- Source:
Returns:
- Type
- boolean
isVideo(stream) → {boolean}
Checks if the given stream is a video stream.
Parameters:
Name | Type | Description |
---|---|---|
stream |
shaka.extern.Stream |
- Source:
Returns:
- Type
- boolean
meetsRestrictions(variant, restrictions, maxHwRes) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
variant |
shaka.extern.Variant | |
restrictions |
shaka.extern.Restrictions | Configured restrictions from the user. |
maxHwRes |
{width: number, height: number} | The maximum resolution the hardware can handle. This is applied separately from user restrictions because the setting should not be easily replaced by the user's configuration. |
- Source:
Returns:
- Type
- boolean
textStreamToTrack(stream) → {shaka.extern.Track}
Parameters:
Name | Type | Description |
---|---|---|
stream |
shaka.extern.Stream |
- Source:
Returns:
- Type
- shaka.extern.Track
variantToTrack(variant) → {shaka.extern.Track}
Parameters:
Name | Type | Description |
---|---|---|
variant |
shaka.extern.Variant |
- Source:
Returns:
- Type
- shaka.extern.Track