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

dropFirstReferences(n)

Drop the first N references. Used in early HLS synchronization, and does not count as eviction.
Parameters:
Name Type Description
n number
Overrides:
Source:

earliestReference() → {shaka.media.SegmentReference}

Return the earliest reference, or null if empty.
Overrides:
Source:
Returns:
Type
shaka.media.SegmentReference

evict(time)

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

evictEmpty()

Evicts all old SegmentIndexes in this MetaSegmentIndex that are empty.
Source:

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:

forEachTopLevelReference(fn)

Iterates over all top-level segment references in this segment index.
Parameters:
Name Type Description
fn function
Overrides:
Source:

getIsImmutable() → {boolean}

Get immutability
Overrides:
Source:
Returns:
Type
boolean

getIteratorForTime(time, allowNonIndepedentopt, reverseopt) → {shaka.media.SegmentIterator}

Returns a new iterator that initially points to the segment that contains the given time, or the nearest independent segment before it. Like the normal iterator, next() must be called first to get to the first element. Returns null if we do not find a segment at the requested time. The first segment returned by the iterator _MUST_ be an independent segment. Assumes that only partial references can be dependent, based on RFC 8216 rev 13, section 8.1: "Each (non-Partial) Media Segment in a Media Playlist will contain at least one independent frame."
Parameters:
Name Type Attributes Default Description
time number
allowNonIndepedent boolean <optional>
false
reverse boolean <optional>
false
Overrides:
Source:
Returns:
Type
shaka.media.SegmentIterator

isEmpty() → {boolean}

Overrides:
Source:
Returns:
Type
boolean

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 replace old references with equivalent new ones, and keep any unique old 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:

mergeAndEvict(referencesnon-null, windowStart)

Merges the given SegmentReferences and evicts the ones that end before the given time. 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).
windowStart number The start of the availability window to filter out the references that are no longer available.
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: