Constructor
new SegmentIndex(referencesnon-null)
Creates a SegmentIndex, which maintains a set of SegmentReferences sorted by
their start times.
Parameters:
Name | Type | Description |
---|---|---|
references |
Array.<!shaka.media.SegmentReference> | The set of SegmentReferences, which must be sorted by their start times. |
- Source:
Members
-
(protected, non-null) references :Array.<!shaka.media.SegmentReference>
-
Type:
- Array.<!shaka.media.SegmentReference>
- Source:
-
(protected) timestampCorrection :number
-
Type:
- number
- Source:
Methods
-
(protected) assertCorrectReferences()
-
Asserts that the SegmentReferences meet all requirements. For debugging purposes.
- Source:
-
correct(timestampCorrection) → {number}
-
Corrects each SegmentReference by the given timestamp correction. The previous timestamp correction, if it exists, is replaced.
Parameters:
Name Type Description timestampCorrection
number - Source:
Returns:
The amount the SegmentReferences were shifted by.- Type
- number
-
destroy()
-
Destroys this SegmentIndex.
- Source:
-
find(time) → {shaka.media.SegmentReference}
-
Finds a SegmentReference for the specified time. This function can trigger an update, which may add or remove SegmentReferences.
Parameters:
Name Type Description time
number The time in seconds. - Source:
Returns:
The SegmentReference for the specified time, or null if no such SegmentReference exists. -
first() → (non-null) {shaka.media.SegmentReference}
-
Gets the first SegmentReference.
- Source:
Throws:
-
when there are no SegmentReferences.
- Type
- RangeError
Returns:
The first SegmentReference. -
get(index) → (non-null) {shaka.media.SegmentReference}
-
Gets the SegmentReference at the given index.
Parameters:
Name Type Description index
number - Source:
Throws:
-
when |index| is out of range.
- Type
- RangeError
Returns:
-
getSeekRange() → {{start: number, end: ?number}}
-
Gets the SegmentIndex's seek range. By default the SegmentIndex's entire span is seekable.
- Source:
Returns:
The seek range. If |end| is null then the seek end time continues to the end of the stream.- Type
- {start: number, end: ?number}
-
integrate(segmentIndexnon-null) → {boolean}
-
Integrates |segmentIndex| into this SegmentIndex. "Integration" is implementation dependent, but can be assumed to combine the two SegmentIndexes somehow. Assumes that both SegmentIndexes correspond to the same stream (e.g., the same Representation). This function can trigger an update, which may add or remove SegmentReferences independent of integration. The default implementation merges |segmentIndex| into this SegmentIndex if it covers times greater than or equal to times that this SegmentIndex covers.
Parameters:
Name Type Description segmentIndex
shaka.media.SegmentIndex - Source:
Returns:
True on success; otherwise, return false.- Type
- boolean
-
last() → (non-null) {shaka.media.SegmentReference}
-
Gets the last SegmentReference.
- Source:
Throws:
-
when there are no SegmentReferences.
- Type
- RangeError
Returns:
The last SegmentReference. -
length() → {number}
-
Gets the number of SegmentReferences.
- Source:
Returns:
- Type
- number
-
(protected) merge(segmentIndexnon-null)
-
Merges |segmentIndex| into this SegmentIndex, but only if it covers times greater than or equal to times that this SegmentIndex covers. Takes into account timestamp corrections.
Parameters:
Name Type Description segmentIndex
shaka.media.SegmentIndex - Source: