ChunkSource
@UnstableApi
interface ChunkSource
DashChunkSource |
A |
FakeChunkSource |
Fake |
SsChunkSource |
A |
DefaultDashChunkSource |
A default |
DefaultSsChunkSource |
A default |
A provider of Chunks for a ChunkSampleStream to load.
Summary
Public functions |
|
|---|---|
Long |
getAdjustedSeekPositionUs(Adjusts a seek position given the specified |
Unit |
getNextChunk(Returns the next chunk to load. |
Int |
getPreferredQueueSize(Evaluates whether |
Unit |
If the source is currently having difficulty providing chunks, then this method throws the underlying error. |
Unit |
onChunkLoadCompleted(chunk: Chunk!)Called when the |
Boolean |
onChunkLoadError(Called when the |
Unit |
release()Releases any held resources. |
Boolean |
shouldCancelLoad(Returns whether an ongoing load of a chunk should be canceled. |
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 |
loadPositionUs: Long |
The current load position in microseconds. If |
queue: (Mutable)List<MediaChunk!>! |
The queue of buffered |
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 |
| 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 |
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 |
queue: (Mutable)List<MediaChunk!>! |
The queue of buffered |
| Returns | |
|---|---|
Boolean |
Whether the ongoing load of |