Class: shaka.util.PeriodCombiner

Constructor

new PeriodCombiner()

Implements:
Source:

Members

BetterOrWorse :number

Type:
  • number
Properties:
Name Value Type Description
BETTER 1 number
EQUAL 0 number
WORSE -1 number
Source:

memoizedCodecs :Map.<string, string>

Type:
  • Map.<string, string>
Source:

audioStreams_ :Array.<shaka.extern.Stream>

Type:
Source:

imageStreams_ :Array.<shaka.extern.Stream>

Type:
Source:

multiTypeVariantsAllowed_ :boolean

Type:
  • boolean
Source:

textStreams_ :Array.<shaka.extern.Stream>

Type:
Source:

usedPeriodIds_ :Set.<string>

The IDs of the periods we have already used to generate streams. This helps us identify the periods which have been added when a live stream is updated.
Type:
  • Set.<string>
Source:

useStreamOnce_ :boolean

Type:
  • boolean
Source:

variants_ :Array.<shaka.extern.Variant>

Type:
Source:

videoStreams_ :Array.<shaka.extern.Stream>

Type:
Source:

Methods

areAVStreamsExactMatch_(a, b) → {boolean}

Parameters:
Name Type Description
a T
b T
Source:
Returns:
Type
boolean

areImageStreamsCompatible_(outputStream, candidate) → {boolean}

Parameters:
Name Type Description
outputStream T A image output stream
candidate T A candidate stream to be combined with the output
Source:
Returns:
True if the candidate could be combined with the output
Type
boolean

areTextStreamsCompatible_(outputStream, candidate) → {boolean}

Parameters:
Name Type Description
outputStream T A text output stream
candidate T A candidate stream to be combined with the output
Source:
Returns:
True if the candidate could be combined with the output
Type
boolean

cloneStream_(stream) → {shaka.extern.Stream}

Clone a Stream to make an output Stream for combining others across periods.
Parameters:
Name Type Description
stream shaka.extern.Stream
Source:
Returns:
Type
shaka.extern.Stream

cloneStreamDB_(streamDb) → {shaka.extern.StreamDB}

Clone a StreamDB to make an output stream for combining others across periods.
Parameters:
Name Type Description
streamDb shaka.extern.StreamDB
Source:
Returns:
Type
shaka.extern.StreamDB

combineDbStreams(streamDbsPerPeriodnon-null) → {Promise.<!Array.<shaka.extern.StreamDB>>}

Stitch together DB streams across periods, taking a mix of stream types. The offline database does not separate these by type. Unlike the DASH case, this does not need to maintain any state for manifest updates.
Parameters:
Name Type Description
streamDbsPerPeriod Array.<!Array.<shaka.extern.StreamDB>>
Source:
Returns:
Type
Promise.<!Array.<shaka.extern.StreamDB>>

compareClosestPreferLower(outputValue, bestValue, candidateValue) → {shaka.util.PeriodCombiner.BetterOrWorse}

Compare the best value so far with the candidate value and the output value. Decide if the candidate is better, equal, or worse than the best so far. Any value less than or equal to the output is preferred over a larger value, and closer to the output is better than farther. This provides us a generic way to choose things that should match as closely as possible, like resolution, frame rate, audio channels, or sample rate. If we have to go higher to make a match, we will. But if the user selects 480p, for example, we don't want to surprise them with 720p and waste bandwidth if there's another choice available to us.
Parameters:
Name Type Description
outputValue number
bestValue number
candidateValue number
Source:
Returns:
Type
shaka.util.PeriodCombiner.BetterOrWorse

compareClosestPreferMinimalAbsDiff_(outputValue, bestValue, candidateValue) → {shaka.util.PeriodCombiner.BetterOrWorse}

Parameters:
Name Type Description
outputValue number
bestValue number
candidateValue number
Source:
Returns:
Type
shaka.util.PeriodCombiner.BetterOrWorse

concatenateStreamDBs_(output, input)

Combine the various fields of the input StreamDB into the output.
Parameters:
Name Type Description
output shaka.extern.StreamDB
input shaka.extern.StreamDB
Source:

concatenateStreams_(output, input)

Combine the various fields of the input Stream into the output.
Parameters:
Name Type Description
output shaka.extern.Stream
input shaka.extern.Stream
Source:

dummyStream_(type) → {shaka.extern.Stream}

Create a dummy Stream to fill in periods that are missing a certain type, to avoid failing the general flattening algorithm. This won't be used for audio or video, since those are strictly required in all periods if they exist in any period.
Parameters:
Name Type Description
type shaka.util.ManifestParserUtils.ContentType
Source:
Returns:
Type
shaka.extern.Stream

dummyStreamDB_(type) → {shaka.extern.StreamDB}

Create a dummy StreamDB to fill in periods that are missing a certain type, to avoid failing the general flattening algorithm. This won't be used for audio or video, since those are strictly required in all periods if they exist in any period.
Parameters:
Name Type Description
type shaka.util.ManifestParserUtils.ContentType
Source:
Returns:
Type
shaka.extern.StreamDB

extendOutputSegmentIndex_(outputStream, firstNewPeriodIndex)

Creates the segment indexes for an array of input streams, and append them to the output stream's segment index.
Parameters:
Name Type Description
outputStream shaka.extern.Stream
firstNewPeriodIndex number An index into streamsPerPeriod which represents the first new period that hasn't been processed yet.
Source:

extendOutputStream_(outputStream, firstNewPeriodIndex, concat, unusedStreamsPerPeriodnon-null, periodsMissing)

Parameters:
Name Type Description
outputStream T An existing output stream which needs to be extended into new periods.
firstNewPeriodIndex number An index into streamsPerPeriod which represents the first new period that hasn't been processed yet.
concat function(T, T) Concatenate the second stream onto the end of the first.
unusedStreamsPerPeriod Array.<!Set.<T>> An array of sets of unused streams from each period.
periodsMissing number How many periods are missing in this update
Source:

generateAudioKey_(a) → {string}

Parameters:
Name Type Description
a T
Source:
Returns:
Type
string

generateImageKey_(i) → {string}

Parameters:
Name Type Description
i T
Source:
Returns:
Type
string

generateKey_(valuesnon-null) → {string}

Parameters:
Name Type Description
values Array.<*>
Source:
Returns:
Type
string

generateTextKey_(t) → {string}

Parameters:
Name Type Description
t T
Source:
Returns:
Type
string

generateVideoKey_(v) → {string}

Parameters:
Name Type Description
v T
Source:
Returns:
Type
string

getCodec_(codecs) → {string}

Parameters:
Name Type Description
codecs string
Source:
Returns:
Type
string

isAudioStreamBetterMatch_(outputStream, best, candidate) → {boolean}

Parameters:
Name Type Description
outputStream T An audio output stream
best T The best match so far for this period
candidate T A candidate stream which might be better
Source:
Returns:
True if the candidate is a better match
Type
boolean

isDummy_(stream) → {boolean}

Parameters:
Name Type Description
stream T
Source:
Returns:
Type
boolean

isImageStreamBetterMatch_(outputStream, best, candidate) → {boolean}

Parameters:
Name Type Description
outputStream T A image output stream
best T The best match so far for this period
candidate T A candidate stream which might be better
Source:
Returns:
True if the candidate is a better match
Type
boolean

isTextStreamBetterMatch_(outputStream, best, candidate) → {boolean}

Parameters:
Name Type Description
outputStream T A text output stream
best T The best match so far for this period
candidate T A candidate stream which might be better
Source:
Returns:
True if the candidate is a better match
Type
boolean

isVideoStreamBetterMatch_(outputStream, best, candidate) → {boolean}

Parameters:
Name Type Description
outputStream T A video output stream
best T The best match so far for this period
candidate T A candidate stream which might be better
Source:
Returns:
True if the candidate is a better match
Type
boolean

areAVStreamsCompatible_(outputStream, candidate) → {boolean}

Parameters:
Name Type Description
outputStream T An audio or video output stream
candidate T A candidate stream to be combined with the output
Source:
Returns:
True if the candidate could be combined with the output stream
Type
boolean

combine_(outputStreamsnon-null, streamsPerPeriodnon-null, firstNewPeriodIndex, clone, concat, periodsMissing) → {Promise.<!Array.<T>>}

Combine input Streams per period into flat output Streams. Templatized to handle both DASH Streams and offline StreamDBs.
Parameters:
Name Type Description
outputStreams Array.<T> A list of existing output streams, to facilitate updates for live DASH content. Will be modified and returned.
streamsPerPeriod Array.<!Map.<string, T>> A list of maps of Streams from each period.
firstNewPeriodIndex number An index into streamsPerPeriod which represents the first new period that hasn't been processed yet.
clone function(T):T Make a clone of an input stream.
concat function(T, T) Concatenate the second stream onto the end of the first.
periodsMissing number The number of periods missing
Source:
Returns:
The same array passed to outputStreams, modified to include any newly-created streams.
Type
Promise.<!Array.<T>>

combinePeriods(periodsnon-null, isDynamic, isPatchUpdateopt) → {Promise}

Parameters:
Name Type Attributes Default Description
periods Array.<shaka.extern.Period>
isDynamic boolean
isPatchUpdate boolean <optional>
false
Source:
Returns:
Type
Promise

createNewOutputStream_(stream, streamsPerPeriodnon-null, clone, concat, unusedStreamsPerPeriodnon-null) → {T}

Create a new output Stream based on a particular input Stream. Locates matching Streams in all other periods and combines them into an output Stream. Templatized to handle both DASH Streams and offline StreamDBs.
Parameters:
Name Type Description
stream T An input stream on which to base the output stream.
streamsPerPeriod Array.<!Map.<string, T>> A list of maps of Streams from each period.
clone function(T):T Make a clone of an input stream.
concat function(T, T) Concatenate the second stream onto the end of the first.
unusedStreamsPerPeriod Array.<!Set.<T>> An array of sets of unused streams from each period.
Source:
Returns:
A newly-created output Stream, or null if matches could not be found.`
Type
T

extendExistingOutputStream_(outputStream, streamsPerPeriodnon-null, firstNewPeriodIndex, concat, unusedStreamsPerPeriodnon-null, periodsMissing) → {Promise.<boolean>}

Parameters:
Name Type Description
outputStream T An existing output stream which needs to be extended into new periods.
streamsPerPeriod Array.<!Map.<string, T>> A list of maps of Streams from each period.
firstNewPeriodIndex number An index into streamsPerPeriod which represents the first new period that hasn't been processed yet.
concat function(T, T) Concatenate the second stream onto the end of the first.
unusedStreamsPerPeriod Array.<!Set.<T>> An array of sets of unused streams from each period.
periodsMissing number How many periods are missing in this update.
Source:
Returns:
Type
Promise.<boolean>

findBestMatchInPeriod_(streamsnon-null, outputStream) → {T}

Find the best match for the output stream.
Parameters:
Name Type Description
streams Map.<string, T>
outputStream T
Source:
Returns:
Returns null if no match can be found.
Type
T

findMatchesInAllPeriods_(streamsPerPeriodnon-null, outputStream, shouldAppendopt)

Finds streams in all periods which match the output stream.
Parameters:
Name Type Attributes Default Description
streamsPerPeriod Array.<!Map.<string, T>>
outputStream T
shouldAppend boolean <optional>
false
Source:

getImageStreams() → {Array.<shaka.extern.Stream>}

Source:
Returns:
Type
Array.<shaka.extern.Stream>

getStreamsPerPeriod_(periodsnon-null, addDummy) → {{audioStreamsPerPeriod: !Array.<!Map.<string, shaka.extern.Stream>>, videoStreamsPerPeriod: !Array.<!Map.<string, shaka.extern.Stream>>, textStreamsPerPeriod: !Array.<!Map.<string, shaka.extern.Stream>>, imageStreamsPerPeriod: !Array.<!Map.<string, shaka.extern.Stream>>}}

Returns an object that contains arrays of streams by type
Parameters:
Name Type Description
periods Array.<shaka.extern.Period>
addDummy boolean
Source:
Returns:
Type
{audioStreamsPerPeriod: !Array.<!Map.<string, shaka.extern.Stream>>, videoStreamsPerPeriod: !Array.<!Map.<string, shaka.extern.Stream>>, textStreamsPerPeriod: !Array.<!Map.<string, shaka.extern.Stream>>, imageStreamsPerPeriod: !Array.<!Map.<string, shaka.extern.Stream>>}

getTextStreams() → {Array.<shaka.extern.Stream>}

Source:
Returns:
Type
Array.<shaka.extern.Stream>

getVariants() → {Array.<shaka.extern.Variant>}

Source:
Returns:
Type
Array.<shaka.extern.Variant>

release()

Request that this object release all internal references.
Implements:
Source:

setAllowMultiTypeVariants(allowed)

Parameters:
Name Type Description
allowed boolean If set to true, multi-mimeType or multi-codec variants will be allowed.
Source:

setUseStreamOnce(useOnce)

Parameters:
Name Type Description
useOnce boolean if true, stream will be used only once in period flattening algoritnm.
Source: