public interface ChunkSource
Chunk
s for a ChunkSampleStream
to load.Modifier and Type | Method and Description |
---|---|
long |
getAdjustedSeekPositionUs(long positionUs,
SeekParameters seekParameters)
Adjusts a seek position given the specified
SeekParameters . |
void |
getNextChunk(long playbackPositionUs,
long loadPositionUs,
List<? extends MediaChunk> queue,
ChunkHolder out)
Returns the next chunk to load.
|
int |
getPreferredQueueSize(long playbackPositionUs,
List<? extends MediaChunk> queue)
Evaluates whether
MediaChunk s should be removed from the back of the queue. |
void |
maybeThrowError()
If the source is currently having difficulty providing chunks, then this method throws the
underlying error.
|
void |
onChunkLoadCompleted(Chunk chunk)
Called when the
ChunkSampleStream has finished loading a chunk obtained from this
source. |
boolean |
onChunkLoadError(Chunk chunk,
boolean cancelable,
Exception e,
long blacklistDurationMs)
Called when the
ChunkSampleStream encounters an error loading a chunk obtained from
this source. |
long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters)
SeekParameters
. Chunk boundaries are used
as sync points.positionUs
- The seek position in microseconds.seekParameters
- Parameters that control how the seek is performed.void maybeThrowError() throws IOException
This method should only be called after the source has been prepared.
IOException
- The underlying error.int getPreferredQueueSize(long playbackPositionUs, List<? extends MediaChunk> queue)
MediaChunk
s should be removed from the back of the queue.
Removing MediaChunk
s 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).
playbackPositionUs
- The current playback position.queue
- The queue of buffered MediaChunk
s.void getNextChunk(long playbackPositionUs, long loadPositionUs, List<? extends MediaChunk> queue, ChunkHolder out)
If a chunk is available then ChunkHolder.chunk
is set. If the end of the stream has
been reached then ChunkHolder.endOfStream
is set. If a chunk is not available but the
end of the stream has not been reached, the ChunkHolder
is not modified.
playbackPositionUs
- The current playback position in microseconds. If playback of the
period to which this chunk source belongs has not yet started, the value will be the
starting position in the period minus the duration of any media in previous periods still
to be played.loadPositionUs
- 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
Chunk.endTimeUs
of the last chunk in the queue
.queue
- The queue of buffered MediaChunk
s.out
- A holder to populate.void onChunkLoadCompleted(Chunk chunk)
ChunkSampleStream
has finished loading a chunk obtained from this
source.
This method should only be called when the source is enabled.
chunk
- The chunk whose load has been completed.boolean onChunkLoadError(Chunk chunk, boolean cancelable, Exception e, long blacklistDurationMs)
ChunkSampleStream
encounters an error loading a chunk obtained from
this source.
This method should only be called when the source is enabled.
chunk
- The chunk whose load encountered the error.cancelable
- Whether the load can be canceled.e
- The error.blacklistDurationMs
- The duration for which the associated track may be blacklisted, or
C.TIME_UNSET
if the track may not be blacklisted.cancelable
is false.