Constructor
new TimelineSegmentIndex(templateInfonon-null, representationIdnullable, bandwidth, getBaseUris, periodStart, periodEnd, initSegmentReference, shouldFit, aes128Key, segmentSequenceCadence)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
templateInfo |
shaka.dash.SegmentTemplate.SegmentTemplateInfo | ||
representationId |
string |
<nullable> |
|
bandwidth |
number | ||
getBaseUris |
function | ||
periodStart |
number | ||
periodEnd |
number | ||
initSegmentReference |
shaka.media.InitSegmentReference | ||
shouldFit |
boolean | ||
aes128Key |
shaka.extern.aes128Key | undefined | ||
segmentSequenceCadence |
number |
- Implements:
- shaka.util.IReleasable
- Iterable.<!shaka.media.SegmentReference>
- Extends:
- Source:
Extends
Members
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:
references :Array.<!shaka.media.SegmentReference>
Type:
- Array.<!shaka.media.SegmentReference>
- Overrides:
- 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)
Merge new template info
Parameters:
Name | Type | Description |
---|---|---|
info |
shaka.dash.SegmentTemplate.SegmentTemplateInfo | |
periodStart |
number | |
periodEnd |
number | |
shouldFit |
boolean |
- 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:
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:
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:
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.
getIsImmutable() → {boolean}
Get immutability
- Overrides:
- Source:
Returns:
- Type
- boolean
getIteratorForTime(time) → {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 | Description |
---|---|---|
time |
number |
- Overrides:
- Source:
Returns:
getNumReferences() → {number}
Get number of references
- Overrides:
- Source:
Returns:
- Type
- number
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: