@UnstableApi
class FakeChunkSource : ChunkSource


Fake ChunkSource with adaptive media chunks of a given duration.

Summary

Nested types

Factory for a FakeChunkSource.

Public constructors

FakeChunkSource(
    trackSelection: ExoTrackSelection!,
    dataSource: DataSource!,
    dataSet: FakeAdaptiveDataSet!
)

Public functions

Long
getAdjustedSeekPositionUs(
    positionUs: Long,
    seekParameters: SeekParameters!
)

Adjusts a seek position given the specified SeekParameters.

Unit
getNextChunk(
    loadingInfo: LoadingInfo!,
    loadPositionUs: Long,
    queue: (Mutable)List<MediaChunk!>!,
    out: ChunkHolder!
)

Returns the next chunk to load.

Int
getPreferredQueueSize(
    playbackPositionUs: Long,
    queue: (Mutable)List<MediaChunk!>!
)

Evaluates whether MediaChunks should be removed from the back of the queue.

Unit

If the source is currently having difficulty providing chunks, then this method throws the underlying error.

Unit

Called when the ChunkSampleStream has finished loading a chunk obtained from this source.

Boolean
onChunkLoadError(
    chunk: Chunk!,
    cancelable: Boolean,
    loadErrorInfo: LoadErrorHandlingPolicy.LoadErrorInfo!,
    loadErrorHandlingPolicy: LoadErrorHandlingPolicy!
)

Called when the ChunkSampleStream encounters an error loading a chunk obtained from this source.

Unit

Releases any held resources.

Boolean
shouldCancelLoad(
    playbackPositionUs: Long,
    loadingChunk: Chunk!,
    queue: (Mutable)List<MediaChunk!>!
)

Returns whether an ongoing load of a chunk should be canceled.

Public constructors

FakeChunkSource

FakeChunkSource(
    trackSelection: ExoTrackSelection!,
    dataSource: DataSource!,
    dataSet: FakeAdaptiveDataSet!
)

Public functions

getAdjustedSeekPositionUs

fun getAdjustedSeekPositionUs(
    positionUs: Long,
    seekParameters: SeekParameters!
): Long

Adjusts a seek position given the specified SeekParameters. Chunk boundaries are used as sync points.

Parameters
positionUs: Long

The seek position in microseconds.

seekParameters: SeekParameters!

Parameters that control how the seek is performed.

Returns
Long

The adjusted seek position, in microseconds.

getNextChunk

fun getNextChunk(
    loadingInfo: LoadingInfo!,
    loadPositionUs: Long,
    queue: (Mutable)List<MediaChunk!>!,
    out: ChunkHolder!
): Unit

Returns the next chunk to load.

If a chunk is available then chunk is set. If the end of the stream has been reached then endOfStream is set. If a chunk is not available but the end of the stream has not been reached, the ChunkHolder is not modified.

Parameters
loadingInfo: LoadingInfo!

The LoadingInfo when loading request is made.

loadPositionUs: Long

The current load position in microseconds. If queue is empty, this is the starting position from which chunks should be provided. Else it's equal to endTimeUs of the last chunk in the queue.

queue: (Mutable)List<MediaChunk!>!

The queue of buffered MediaChunks.

out: ChunkHolder!

A holder to populate.

getPreferredQueueSize

fun getPreferredQueueSize(
    playbackPositionUs: Long,
    queue: (Mutable)List<MediaChunk!>!
): Int

Evaluates whether MediaChunks should be removed from the back of the queue.

Removing MediaChunks from the back of the queue can be useful if they could be replaced with chunks of a significantly higher quality (e.g. because the available bandwidth has substantially increased).

Will only be called if no MediaChunk in the queue is currently loading.

Parameters
playbackPositionUs: Long

The current playback position, in microseconds.

queue: (Mutable)List<MediaChunk!>!

The queue of buffered MediaChunks.

Returns
Int

The preferred queue size.

maybeThrowError

fun maybeThrowError(): Unit

If the source is currently having difficulty providing chunks, then this method throws the underlying error. Otherwise does nothing.

Throws
java.io.IOException

The underlying error.

onChunkLoadCompleted

fun onChunkLoadCompleted(chunk: Chunk!): Unit

Called when the ChunkSampleStream has finished loading a chunk obtained from this source.

Parameters
chunk: Chunk!

The chunk whose load has been completed.

onChunkLoadError

fun onChunkLoadError(
    chunk: Chunk!,
    cancelable: Boolean,
    loadErrorInfo: LoadErrorHandlingPolicy.LoadErrorInfo!,
    loadErrorHandlingPolicy: LoadErrorHandlingPolicy!
): Boolean

Called when the ChunkSampleStream encounters an error loading a chunk obtained from this source.

Parameters
chunk: Chunk!

The chunk whose load encountered the error.

cancelable: Boolean

Whether the load can be canceled.

loadErrorInfo: LoadErrorHandlingPolicy.LoadErrorInfo!

The load error info.

loadErrorHandlingPolicy: LoadErrorHandlingPolicy!

The load error handling policy to customize the behaviour of handling the load error.

Returns
Boolean

Whether the load should be canceled so that a replacement chunk can be loaded instead. Must be false if cancelable is false. If true, getNextChunk will be called to obtain the replacement chunk.

release

fun release(): Unit

Releases any held resources.

shouldCancelLoad

fun shouldCancelLoad(
    playbackPositionUs: Long,
    loadingChunk: Chunk!,
    queue: (Mutable)List<MediaChunk!>!
): Boolean

Returns whether an ongoing load of a chunk should be canceled.

Parameters
playbackPositionUs: Long

The current playback position, in microseconds.

loadingChunk: Chunk!

The currently loading Chunk.

queue: (Mutable)List<MediaChunk!>!

The queue of buffered MediaChunks.

Returns
Boolean

Whether the ongoing load of loadingChunk should be canceled.