Class: shaka.media.MetaSegmentIndex

Constructor

new MetaSegmentIndex()

Implements:
Extends:
Source:

Extends

Members

immutable_ :boolean

Type:
  • boolean
Overrides:
Source:

numEvicted :number

The number of references that have been removed from the front of the array. Used to create stable positions in the find/get APIs.
Type:
  • number
Overrides:
Source:

Methods

appendSegmentIndex(segmentIndexnon-null)

Append a SegmentIndex to this MetaSegmentIndex. This effectively stitches the underlying Stream onto the end of the multi-Period Stream represented by this MetaSegmentIndex.
Parameters:
Name Type Description
segmentIndex shaka.media.SegmentIndex
Source:

clone() → {shaka.media.MetaSegmentIndex}

Create a clone of this MetaSegmentIndex containing all the same indexes.
Source:
Returns:
Type
shaka.media.MetaSegmentIndex

destroy() → {Promise}

SegmentIndex used to be an IDestroyable. Now it is an IReleasable. This method is provided for backward compatibility.
Overrides:
Deprecated:
  • Yes
Source:
Returns:
Type
Promise

evict(time)

Removes all SegmentReferences that end before the given time.
Parameters:
Name Type Description
time number The time in seconds.
Overrides:
Source:

find(time) → {number}

Finds the position of the segment for the given time, in seconds, relative to the start of the presentation. Returns the position of the segment with the largest end time if more than one segment is known for the given time.
Parameters:
Name Type Description
time number
Overrides:
Source:
Returns:
The position of the segment, or null if the position of the segment could not be determined.
Type
number

fit(windowStart, windowEndnullable, isNewopt)

Drops references that start after windowEnd, or end before windowStart, and contracts the last reference so that it ends at windowEnd. Do not call on the last period of a live presentation (unknown duration). It is okay to call on the other periods of a live presentation, where the duration is known and another period has been added.
Parameters:
Name Type Attributes Default Description
windowStart number
windowEnd number <nullable>
isNew boolean <optional>
false Whether this is a new SegmentIndex and we shouldn't update the number of evicted elements.
Overrides:
Source:

get(position) → {shaka.media.SegmentReference}

Gets the SegmentReference for the segment at the given position.
Parameters:
Name Type Description
position number The position of the segment as returned by find().
Overrides:
Source:
Returns:
The SegmentReference, or null if no such SegmentReference exists.
Type
shaka.media.SegmentReference

getIteratorForTime(time) → {shaka.media.SegmentIterator}

Returns a new iterator that initially points to the segment that contains the given time. Like the normal iterator, next() must be called first to get to the first element.
Parameters:
Name Type Description
time number
Overrides:
Source:
Returns:
Type
shaka.media.SegmentIterator

markImmutable()

Marks the index as immutable. Segments cannot be added or removed after this point. This doesn't affect the references themselves. This also makes the destroy/release methods do nothing. This is mainly for testing.
Overrides:
Source:

merge(referencesnon-null)

Merges the given SegmentReferences. Supports extending the original references only. Will not replace old references or interleave new ones. Used, for example, by the DASH and HLS parser, where manifests may not list all available references, so we must keep available references in memory to fill the availability window.
Parameters:
Name Type Description
references Array.<!shaka.media.SegmentReference> The list of SegmentReferences, which must be sorted first by their start times (ascending) and second by their end times (ascending).
Overrides:
Source:

offset(offset)

Offset all segment references by a fixed amount.
Parameters:
Name Type Description
offset number The amount to add to each segment's start and end times.
Overrides:
Source:

updateEvery(interval, updateCallback)

Updates the references every so often. Stops when the references list returned by the callback is null.
Parameters:
Name Type Description
interval number The interval in seconds.
updateCallback function
Overrides:
Source: