@UnstableApi
interface DashSegmentIndex

Known direct subclasses
DashWrappingSegmentIndex

An implementation of DashSegmentIndex that wraps a ChunkIndex parsed from a media stream.

Representation.MultiSegmentRepresentation

A DASH representation consisting of multiple segments.


Indexes the segments within a media stream.

Summary

Constants

const Int

Public functions

Long
getAvailableSegmentCount(periodDurationUs: Long, nowUnixTimeUs: Long)

Returns the number of available segments in the index.

Long
getDurationUs(segmentNum: Long, periodDurationUs: Long)

Returns the duration of a segment.

Long
getFirstAvailableSegmentNum(periodDurationUs: Long, nowUnixTimeUs: Long)

Returns the segment number of the first available segment in the index.

Long

Returns the segment number of the first defined segment in the index.

Long
getNextSegmentAvailableTimeUs(
    periodDurationUs: Long,
    nowUnixTimeUs: Long
)

Returns the time, in microseconds, at which a new segment becomes available, or TIME_UNSET if not applicable.

Long
getSegmentCount(periodDurationUs: Long)

Returns the number of segments defined in the index, or INDEX_UNBOUNDED.

Long
getSegmentNum(timeUs: Long, periodDurationUs: Long)

Returns getFirstSegmentNum() if the index has no segments or if the given media time is earlier than the start of the first segment.

RangedUri!
getSegmentUrl(segmentNum: Long)

Returns a RangedUri defining the location of a segment.

Long
getTimeUs(segmentNum: Long)

Returns the start time of a segment.

Boolean

Returns true if segments are defined explicitly by the index.

Constants

INDEX_UNBOUNDED

const val INDEX_UNBOUNDED = -1: Int

Public functions

getAvailableSegmentCount

fun getAvailableSegmentCount(periodDurationUs: Long, nowUnixTimeUs: Long): Long

Returns the number of available segments in the index.

Parameters
periodDurationUs: Long

The duration of the enclosing period in microseconds, or TIME_UNSET if the period's duration is not yet known.

nowUnixTimeUs: Long

The current time in milliseconds since the Unix epoch.

Returns
Long

The number of available segments in the index.

getDurationUs

fun getDurationUs(segmentNum: Long, periodDurationUs: Long): Long

Returns the duration of a segment.

Parameters
segmentNum: Long

The segment number.

periodDurationUs: Long

The duration of the enclosing period in microseconds, or TIME_UNSET if the period's duration is not yet known.

Returns
Long

The duration of the segment, in microseconds.

getFirstAvailableSegmentNum

fun getFirstAvailableSegmentNum(periodDurationUs: Long, nowUnixTimeUs: Long): Long

Returns the segment number of the first available segment in the index.

Parameters
periodDurationUs: Long

The duration of the enclosing period in microseconds, or TIME_UNSET if the period's duration is not yet known.

nowUnixTimeUs: Long

The current time in milliseconds since the Unix epoch.

Returns
Long

The number of the first available segment.

getFirstSegmentNum

fun getFirstSegmentNum(): Long

Returns the segment number of the first defined segment in the index.

getNextSegmentAvailableTimeUs

fun getNextSegmentAvailableTimeUs(
    periodDurationUs: Long,
    nowUnixTimeUs: Long
): Long

Returns the time, in microseconds, at which a new segment becomes available, or TIME_UNSET if not applicable.

Parameters
periodDurationUs: Long

The duration of the enclosing period in microseconds, or TIME_UNSET if the period's duration is not yet known.

nowUnixTimeUs: Long

The current time in milliseconds since the Unix epoch.

Returns
Long

The time, in microseconds, at which a new segment becomes available, or TIME_UNSET if not applicable.

getSegmentCount

fun getSegmentCount(periodDurationUs: Long): Long

Returns the number of segments defined in the index, or INDEX_UNBOUNDED.

An unbounded index occurs if a dynamic manifest uses SegmentTemplate elements without a SegmentTimeline element, and if the period duration is not yet known. In this case the caller can query the available segment using getFirstAvailableSegmentNum and getAvailableSegmentCount.

Parameters
periodDurationUs: Long

The duration of the enclosing period in microseconds, or TIME_UNSET if the period's duration is not yet known.

Returns
Long

The number of segments in the index, or INDEX_UNBOUNDED.

getSegmentNum

fun getSegmentNum(timeUs: Long, periodDurationUs: Long): Long

Returns getFirstSegmentNum() if the index has no segments or if the given media time is earlier than the start of the first segment. Returns getFirstSegmentNum() + getSegmentCount() - 1 if the given media time is later than the end of the last segment. Otherwise, returns the segment number of the segment containing the given media time.

Parameters
timeUs: Long

The time in microseconds.

periodDurationUs: Long

The duration of the enclosing period in microseconds, or TIME_UNSET if the period's duration is not yet known.

Returns
Long

The segment number of the corresponding segment.

getSegmentUrl

fun getSegmentUrl(segmentNum: Long): RangedUri!

Returns a RangedUri defining the location of a segment.

Parameters
segmentNum: Long

The segment number.

Returns
RangedUri!

The RangedUri defining the location of the data.

getTimeUs

fun getTimeUs(segmentNum: Long): Long

Returns the start time of a segment.

Parameters
segmentNum: Long

The segment number.

Returns
Long

The corresponding start time in microseconds.

isExplicit

fun isExplicit(): Boolean

Returns true if segments are defined explicitly by the index.

If true is returned, each segment is defined explicitly by the index data, and all of the listed segments are guaranteed to be available at the time when the index was obtained.

If false is returned then segment information was derived from properties such as a fixed segment duration. If the presentation is dynamic, it's possible that only a subset of the segments are available.

Returns
Boolean

Whether segments are defined explicitly by the index.