Class: shaka.util.StreamUtils

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

Methods

(static) applyRestrictions(period, restrictions, maxHwRes) → {boolean}

Parameters:
Name Type Description
period shakaExtern.Period
restrictions shakaExtern.Restrictions
maxHwRes {width: number, height: number}
Source:
Returns:
Whether the tracks changed.
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 shakaExtern.Stream <nullable>
activeVideo shakaExtern.Stream <nullable>
period shakaExtern.Period
Source:

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

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

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

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

(static) filterVariantsByAudioChannelCount(variantsnon-null, preferredAudioChannelCount) → (non-null) {Array.<!shakaExtern.Variant>}

Filters variants according to the given audio channel count config.
Parameters:
Name Type Description
variants Array.<shakaExtern.Variant>
preferredAudioChannelCount number
Source:
Returns:
Type
Array.<!shakaExtern.Variant>

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

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

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

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

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

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

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

Parameters:
Name Type Description
manifest shakaExtern.Manifest
stream shakaExtern.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 shakaExtern.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 shakaExtern.Manifest
variant shakaExtern.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) {shakaExtern.Stream}

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

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

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

(static) getPlayableVariants(variantsnon-null) → (non-null) {Array.<!shakaExtern.Variant>}

Filters out unplayable variants.
Parameters:
Name Type Description
variants Array.<!shakaExtern.Variant>
Source:
Returns:
Type
Array.<!shakaExtern.Variant>

(static) getRebufferingGoal(manifest, config, scaleFactor) → {number}

Gets the rebuffering goal from the manifest and configuration.
Parameters:
Name Type Description
manifest shakaExtern.Manifest
config shakaExtern.StreamingConfiguration
scaleFactor number
Source:
Returns:
Type
number

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

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

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

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

(static) getVariantByStreamIds(audioIdnullable, videoIdnullable, variantsnon-null) → (nullable) {shakaExtern.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.<shakaExtern.Variant>
Source:
Returns:
Type
shakaExtern.Variant

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

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

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

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

(static) isAudio(stream) → {boolean}

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

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

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

(private, static) isStreamCompatible_(streamnullable, drmEngine, activeStreamnullable) → {boolean}

Checks if a stream is compatible with the key system, platform, and active stream. This does not check if the stream is supported by the chosen key system.
Parameters:
Name Type Attributes Description
stream shakaExtern.Stream <nullable>
A non-text stream to check.
drmEngine shaka.media.DrmEngine
activeStream shakaExtern.Stream <nullable>
Source:
Returns:
Type
boolean

(private, static) isVariantCompatible_(variantnon-null, drmEngine, activeAudionullable, activeVideonullable) → {boolean}

Checks if a variant is compatible with the key system, platform, and active stream.
Parameters:
Name Type Attributes Description
variant shakaExtern.Variant
drmEngine shaka.media.DrmEngine
activeAudio shakaExtern.Stream <nullable>
activeVideo shakaExtern.Stream <nullable>
Source:
Returns:
Type
boolean

(static) isVideo(stream) → {boolean}

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

(static) meetsRestrictions(variant, restrictions, maxHwRes) → {boolean}

Parameters:
Name Type Description
variant shakaExtern.Variant
restrictions shakaExtern.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) → {shakaExtern.Track}

Parameters:
Name Type Description
stream shakaExtern.Stream
Source:
Returns:
Type
shakaExtern.Track

(static) variantToTrack(variant) → {shakaExtern.Track}

Parameters:
Name Type Description
variant shakaExtern.Variant
Source:
Returns:
Type
shakaExtern.Track