public interface ChunkSource
Chunk
s for a ChunkSampleSource
to load.Modifier and Type | Method and Description |
---|---|
void |
continueBuffering(long playbackPositionUs)
Indicates to the source that it should still be checking for updates to the stream.
|
void |
disable(List<? extends MediaChunk> queue)
Disables the source.
|
void |
enable(int track)
Enable the source for the specified track.
|
void |
getChunkOperation(List<? extends MediaChunk> queue,
long playbackPositionUs,
ChunkOperationHolder out)
Updates the provided
ChunkOperationHolder to contain the next operation that should
be performed by the calling ChunkSampleSource . |
MediaFormat |
getFormat(int track)
Gets the format of the specified track.
|
int |
getTrackCount()
Returns the number of tracks exposed by the source.
|
void |
maybeThrowError()
If the source is currently having difficulty preparing or providing chunks, then this method
throws the underlying error.
|
void |
onChunkLoadCompleted(Chunk chunk)
Invoked when the
ChunkSampleSource has finished loading a chunk obtained from this
source. |
void |
onChunkLoadError(Chunk chunk,
Exception e)
Invoked when the
ChunkSampleSource encounters an error loading a chunk obtained from
this source. |
boolean |
prepare()
Prepares the source.
|
void maybeThrowError() throws IOException
IOException
- The underlying error.boolean prepare()
The method can be called repeatedly until the return value indicates success.
int getTrackCount()
This method should only be called after the source has been prepared.
MediaFormat getFormat(int track)
This method should only be called after the source has been prepared.
track
- The track index.void enable(int track)
This method should only be called after the source has been prepared, and when the source is disabled.
track
- The track index.void continueBuffering(long playbackPositionUs)
This method should only be called when the source is enabled.
playbackPositionUs
- The current playback position.void getChunkOperation(List<? extends MediaChunk> queue, long playbackPositionUs, ChunkOperationHolder out)
ChunkOperationHolder
to contain the next operation that should
be performed by the calling ChunkSampleSource
.
This method should only be called when the source is enabled.
queue
- A representation of the currently buffered MediaChunk
s.playbackPositionUs
- The current playback position. If the queue is empty then this
parameter is the position from which playback is expected to start (or restart) and hence
should be interpreted as a seek position.out
- A holder for the next operation, whose ChunkOperationHolder.endOfStream
is
initially set to false, whose ChunkOperationHolder.queueSize
is initially equal to
the length of the queue, and whose ChunkOperationHolder.chunk
is initially equal to
null or a Chunk
previously supplied by the ChunkSource
that the caller has
not yet finished loading. In the latter case the chunk can either be replaced or left
unchanged. Note that leaving the chunk unchanged is both preferred and more efficient than
replacing it with a new but identical chunk.void onChunkLoadCompleted(Chunk chunk)
ChunkSampleSource
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.void onChunkLoadError(Chunk chunk, Exception e)
ChunkSampleSource
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.e
- The error.void disable(List<? extends MediaChunk> queue)
This method should only be called when the source is enabled.
queue
- A representation of the currently buffered MediaChunk
s.