ConstantBitrateSeekMap


@UnstableApi
class ConstantBitrateSeekMap : SeekMap


A SeekMap implementation that assumes the stream has a constant bitrate and consists of multiple independent frames of the same size. Seek points are calculated to be at frame boundaries.

Summary

Public constructors

ConstantBitrateSeekMap(
    inputLength: Long,
    firstFrameBytePosition: Long,
    bitrate: Int,
    frameSize: Int
)

Creates an instance with allowSeeksIfLengthUnknown set to false.

ConstantBitrateSeekMap(
    inputLength: Long,
    firstFrameBytePosition: Long,
    bitrate: Int,
    frameSize: Int,
    allowSeeksIfLengthUnknown: Boolean
)

Creates an instance.

Protected constructors

ConstantBitrateSeekMap(
    inputLength: Long,
    firstFrameBytePosition: Long,
    bitrate: Int,
    frameSize: Int,
    allowSeeksIfLengthUnknown: Boolean,
    isEstimated: Boolean
)

Creates an instance.

Public functions

SeekMap.SeekPoints!

Obtains seek points for the specified seek time in microseconds.

Long

Returns the stream time in microseconds for a given position.

Boolean

Returns whether seeking is supported.

Protected functions

Long

Returns the byte position of the first frame in the stream (as passed to the constructor).

Boolean

Returns whether seeking is permitted if the stream length is unknown (as passed to the constructor).

Public properties

Long
Boolean

Protected properties

Int
Int

Public constructors

ConstantBitrateSeekMap

ConstantBitrateSeekMap(
    inputLength: Long,
    firstFrameBytePosition: Long,
    bitrate: Int,
    frameSize: Int
)

Creates an instance with allowSeeksIfLengthUnknown set to false.

Parameters
inputLength: Long

The length of the stream in bytes, or LENGTH_UNSET if unknown.

firstFrameBytePosition: Long

The byte-position of the first frame in the stream.

bitrate: Int

The bitrate (which is assumed to be constant in the stream).

frameSize: Int

The size of each frame in the stream in bytes. May be LENGTH_UNSET if unknown.

ConstantBitrateSeekMap

ConstantBitrateSeekMap(
    inputLength: Long,
    firstFrameBytePosition: Long,
    bitrate: Int,
    frameSize: Int,
    allowSeeksIfLengthUnknown: Boolean
)

Creates an instance.

Parameters
inputLength: Long

The length of the stream in bytes, or LENGTH_UNSET if unknown.

firstFrameBytePosition: Long

The byte-position of the first frame in the stream.

bitrate: Int

The bitrate (which is assumed to be constant in the stream).

frameSize: Int

The size of each frame in the stream in bytes. May be LENGTH_UNSET if unknown.

allowSeeksIfLengthUnknown: Boolean

Whether to allow seeking even if the length of the content is unknown.

Protected constructors

ConstantBitrateSeekMap

protected ConstantBitrateSeekMap(
    inputLength: Long,
    firstFrameBytePosition: Long,
    bitrate: Int,
    frameSize: Int,
    allowSeeksIfLengthUnknown: Boolean,
    isEstimated: Boolean
)

Creates an instance.

Parameters
inputLength: Long

The length of the stream in bytes, or LENGTH_UNSET if unknown.

firstFrameBytePosition: Long

The byte-position of the first frame in the stream.

bitrate: Int

The bitrate (which is assumed to be constant in the stream).

frameSize: Int

The size of each frame in the stream in bytes. May be LENGTH_UNSET if unknown.

allowSeeksIfLengthUnknown: Boolean

Whether to allow seeking even if the length of the content is unknown.

isEstimated: Boolean

Whether this ConstantBitrateSeekMap is based on estimations.

Public functions

getSeekPoints

fun getSeekPoints(timeUs: Long): SeekMap.SeekPoints!

Obtains seek points for the specified seek time in microseconds. The returned SeekPoints will contain one or two distinct seek points.

Two seek points [A, B] are returned in the case that seeking can only be performed to discrete points in time, there does not exist a seek point at exactly the requested time, and there exist seek points on both sides of it. In this case A and B are the closest seek points before and after the requested time. A single seek point is returned in all other cases.

Parameters
timeUs: Long

A seek time in microseconds.

Returns
SeekMap.SeekPoints!

The corresponding seek points.

getTimeUsAtPosition

fun getTimeUsAtPosition(position: Long): Long

Returns the stream time in microseconds for a given position.

Parameters
position: Long

The stream byte-position.

Returns
Long

The stream time in microseconds for the given position.

isSeekable

fun isSeekable(): Boolean

Returns whether seeking is supported.

Returns
Boolean

Whether seeking is supported.

Protected functions

getFirstFramePosition

protected fun getFirstFramePosition(): Long

Returns the byte position of the first frame in the stream (as passed to the constructor).

shouldAllowSeeksIfLengthUnknown

protected fun shouldAllowSeeksIfLengthUnknown(): Boolean

Returns whether seeking is permitted if the stream length is unknown (as passed to the constructor).

Public properties

durationUs

val durationUsLong

isEstimated

val isEstimatedBoolean

Protected properties

bitrate

protected val bitrateInt

frameSize

protected val frameSizeInt