Class: shaka.dash.TimelineSegmentIndex

Constructor

new TimelineSegmentIndex(templateInfonon-null, representationIdnullable, bandwidth, getBaseUris, urlParams, periodStart, periodEnd, initSegmentReference, shouldFit, aesKey, segmentSequenceCadence)

Parameters:
Name Type Attributes Description
templateInfo shaka.dash.SegmentTemplate.SegmentTemplateInfo
representationId string <nullable>
bandwidth number
getBaseUris function
urlParams function
periodStart number
periodEnd number
initSegmentReference shaka.media.InitSegmentReference
shouldFit boolean
aesKey shaka.extern.aesKey | undefined
segmentSequenceCadence number
Implements:
Extends:
Source:

Extends

Members

aesKey_ :shaka.extern.aesKey|undefined

Type:
Source:

bandwidth_ :number

Type:
  • number
Source:

getBaseUris_ :function(): Array.<string>

Type:
  • function(): Array.<string>
Source:

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:

periodEnd_ :number

Type:
  • number
Source:

periodStart_ :number

Type:
  • number
Source:

representationId_ :string

Type:
  • string
Source:

segmentSequenceCadence_ :number

Type:
  • number
Source:

urlParams_ :function():string

Type:
  • function():string
Source:

Methods

createUris_() → {Array.<string>}

Fill in a specific template with values to get the segment uris
Source:
Returns:
Type
Array.<string>

appendTemplateInfo(info, periodStart, periodEnd, shouldFit, initSegmentReference)

Merge new template info
Parameters:
Name Type Description
info shaka.dash.SegmentTemplate.SegmentTemplateInfo
periodStart number
periodEnd number
shouldFit boolean
initSegmentReference shaka.media.InitSegmentReference
Source:

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:

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:

fitTimeline()

Fit timeline entries to period boundaries
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

isBeforeFirstEntry(time)

Parameters:
Name Type Description
time number
Source:

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:

updateInitSegmentReference(initSegmentReference)

Updates the init segment reference and propagates the update to all references.
Parameters:
Name Type Description
initSegmentReference shaka.media.InitSegmentReference
Source: