Class: shaka.util.StreamUtils

A set of utility functions for dealing with Streams and Manifests.

Methods

(static) 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

(private, static) areStreamsCompatible_(s0, s1) → {boolean}

Parameters:
Name Type Description
s0 shaka.extern.Stream
s1 shaka.extern.Stream
Source:
Returns:
Type
boolean

(static) filterNewPeriod(drmEngine, activeAudionullable, activeVideonullable, period)

Alters the given Period to filter out any unplayable streams.
Parameters:
Name Type Attributes Description
drmEngine shaka.media.DrmEngine
activeAudio shaka.extern.Stream <nullable>
activeVideo shaka.extern.Stream <nullable>
period shaka.extern.Period
Source:

(static) filterStreamsByLanguageAndRole(streamsnon-null, preferredLanguage, preferredRole, languageMatchesopt, non-null) → (non-null) {Array.<!shaka.extern.Stream>}

Chooses streams according to the given config.
Parameters:
Name Type Attributes Description
streams Array.<shaka.extern.Stream>
preferredLanguage string
preferredRole string
languageMatches Object <optional>
Source:
Returns:
Type
Array.<!shaka.extern.Stream>

(private, static) filterTextStreamsByRole_(textStreamsnon-null, preferredRole) → (non-null) {Array.<shaka.extern.Stream>}

Filter text Streams by role.
Parameters:
Name Type Description
textStreams Array.<shaka.extern.Stream>
preferredRole string
Source:
Returns:
Type
Array.<shaka.extern.Stream>

(static) filterVariantsByAudioChannelCount(variantsnon-null, preferredAudioChannelCount) → (non-null) {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>

(static) filterVariantsByConfig(variantsnon-null, preferredLanguage, preferredRole, preferredAudioChannelCount, languageMatchesopt, non-null) → (non-null) {Array.<!shaka.extern.Variant>}

Chooses variants according to the given config.
Parameters:
Name Type Attributes Description
variants Array.<shaka.extern.Variant>
preferredLanguage string
preferredRole string
preferredAudioChannelCount number
languageMatches Object <optional>
Source:
Returns:
Type
Array.<!shaka.extern.Variant>

(static) filterVariantsByLanguageAndRole(variantsnon-null, preferredLanguage, preferredRole, languageMatchesopt, non-null) → (non-null) {Array.<!shaka.extern.Variant>}

Chooses variants according to the given config.
Parameters:
Name Type Attributes Description
variants Array.<shaka.extern.Variant>
preferredLanguage string
preferredRole string
languageMatches Object <optional>
Source:
Returns:
Type
Array.<!shaka.extern.Variant>

(private, static) filterVariantsByRole_(variantsnon-null, preferredRole) → (non-null) {Array.<shaka.extern.Variant>}

Filter Variants by role.
Parameters:
Name Type Description
variants Array.<shaka.extern.Variant>
preferredRole string
Source:
Returns:
Type
Array.<shaka.extern.Variant>

(static) findPeriodContainingStream(manifest, stream) → {number}

Parameters:
Name Type Description
manifest shaka.extern.Manifest
stream shaka.extern.Stream
Source:
Returns:
The index of the Period which contains |stream|, or -1 if no Period contains |stream|.
Type
number

(static) findPeriodContainingTime(manifest, time) → {number}

Gets the index of the Period that contains the given time.
Parameters:
Name Type Description
manifest shaka.extern.Manifest
time number The time in seconds from the start of the presentation.
Source:
Returns:
Type
number

(static) findPeriodContainingVariant(manifest, variant) → {number}

Parameters:
Name Type Description
manifest shaka.extern.Manifest
variant shaka.extern.Variant
Source:
Returns:
The index of the Period which contains |stream|, or -1 if no Period contains |stream|.
Type
number

(static) findTextStreamForTrack(period, track) → (nullable) {shaka.extern.Stream}

Finds the text stream for the given track.
Parameters:
Name Type Description
period shaka.extern.Period
track shaka.extern.Track
Source:
Returns:
Type
shaka.extern.Stream

(static) findVariantForTrack(period, track) → (nullable) {shaka.extern.Variant}

Finds the Variant for the given track.
Parameters:
Name Type Description
period shaka.extern.Period
track shaka.extern.Track
Source:
Returns:
Type
shaka.extern.Variant

(static) getAllVariants(manifest) → (non-null) {Array.<shaka.extern.Variant>}

Get all the variants from all the periods in the manifest.
Parameters:
Name Type Description
manifest shaka.extern.Manifest
Source:
Returns:
Type
Array.<shaka.extern.Variant>

(static) getPlayableVariants(variantsnon-null) → (non-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>

(private, static) getStreamSummaryString_(stream) → {string}

Parameters:
Name Type Description
stream shaka.extern.Stream
Source:
Returns:
Type
string

(static) getTextTracks(period, activeStreamIdnullable) → (non-null) {Array.<shaka.extern.Track>}

Gets an array of text Track objects for the given Period.
Parameters:
Name Type Attributes Description
period shaka.extern.Period
activeStreamId number <nullable>
Source:
Returns:
Type
Array.<shaka.extern.Track>

(static) getTracks(period) → (non-null) {Array.<shaka.extern.Track>}

Gets track representations of all playable variants and all text streams.
Parameters:
Name Type Description
period shaka.extern.Period
Source:
Returns:
Type
Array.<shaka.extern.Track>

(static) getVariantByStreamIds(audioIdnullable, videoIdnullable, variantsnon-null) → (nullable) {shaka.extern.Variant}

Finds a Variant with the given video and audio streams, by stream ID. Returns null if no such Variant was found.
Parameters:
Name Type Attributes Description
audioId number <nullable>
videoId number <nullable>
variants Array.<shaka.extern.Variant>
Source:
Returns:
Type
shaka.extern.Variant

(static) getVariantByStreams(audionullable, videonullable, variantsnon-null) → (nullable) {shaka.extern.Variant}

Finds a Variant with given audio and video streams. Returns null if no such Variant was found.
Parameters:
Name Type Attributes Description
audio shaka.extern.Stream <nullable>
video shaka.extern.Stream <nullable>
variants Array.<!shaka.extern.Variant>
Source:
Returns:
Type
shaka.extern.Variant

(static) getVariantStreams(variant) → (non-null) {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>

(static) getVariantTracks(period, activeAudioIdnullable, activeVideoIdnullable) → (non-null) {Array.<shaka.extern.Track>}

Gets an array of Track objects for the given Period.
Parameters:
Name Type Attributes Description
period shaka.extern.Period
activeAudioId number <nullable>
activeVideoId number <nullable>
Source:
Returns:
Type
Array.<shaka.extern.Track>

(static) isAudio(stream) → {boolean}

Checks if the given stream is an audio stream.
Parameters:
Name Type Description
stream shaka.extern.Stream
Source:
Returns:
Type
boolean

(static) isPlayable(variantnon-null) → {boolean}

Determines if the given variant is playable.
Parameters:
Name Type Description
variant shaka.extern.Variant
Source:
Returns:
Type
boolean

(static) isVideo(stream) → {boolean}

Checks if the given stream is a video stream.
Parameters:
Name Type Description
stream shaka.extern.Stream
Source:
Returns:
Type
boolean

(static) 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

(static) textStreamToTrack(stream) → {shaka.extern.Track}

Parameters:
Name Type Description
stream shaka.extern.Stream
Source:
Returns:
Type
shaka.extern.Track

(static) variantToTrack(variant) → {shaka.extern.Track}

Parameters:
Name Type Description
variant shaka.extern.Variant
Source:
Returns:
Type
shaka.extern.Track