ChunkSourcepublic final class FakeChunkSource extends Object implements ChunkSource
ChunkSource with adaptive media chunks of a given duration.| Modifier and Type | Class | Description |
|---|---|---|
static class |
FakeChunkSource.Factory |
Factory for a
FakeChunkSource. |
| Constructor | Description |
|---|---|
FakeChunkSource(ExoTrackSelection trackSelection,
DataSource dataSource,
FakeAdaptiveDataSet dataSet) |
| Modifier and Type | Method | 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
MediaChunks 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 exclusionDurationMs) |
Called when the
ChunkSampleStream encounters an error loading a chunk obtained from
this source. |
void |
release() |
Releases any held resources.
|
boolean |
shouldCancelLoad(long playbackPositionUs,
Chunk loadingChunk,
List<? extends MediaChunk> queue) |
Returns whether an ongoing load of a chunk should be canceled.
|
public FakeChunkSource(ExoTrackSelection trackSelection, DataSource dataSource, FakeAdaptiveDataSet dataSet)
public long getAdjustedSeekPositionUs(long positionUs,
SeekParameters seekParameters)
ChunkSourceSeekParameters. Chunk boundaries are used
as sync points.getAdjustedSeekPositionUs in interface ChunkSourcepositionUs - The seek position in microseconds.seekParameters - Parameters that control how the seek is performed.public void maybeThrowError()
ChunkSourcemaybeThrowError in interface ChunkSourcepublic int getPreferredQueueSize(long playbackPositionUs,
List<? extends MediaChunk> queue)
ChunkSourceMediaChunks 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.
getPreferredQueueSize in interface ChunkSourceplaybackPositionUs - The current playback position, in microseconds.queue - The queue of buffered MediaChunks.public boolean shouldCancelLoad(long playbackPositionUs,
Chunk loadingChunk,
List<? extends MediaChunk> queue)
ChunkSourceshouldCancelLoad in interface ChunkSourceplaybackPositionUs - The current playback position, in microseconds.loadingChunk - The currently loading Chunk.queue - The queue of buffered MediaChunks.loadingChunk should be canceled.public void getNextChunk(long playbackPositionUs,
long loadPositionUs,
List<? extends MediaChunk> queue,
ChunkHolder out)
ChunkSourceIf 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.
getNextChunk in interface ChunkSourceplaybackPositionUs - 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 MediaChunks.out - A holder to populate.public void onChunkLoadCompleted(Chunk chunk)
ChunkSourceChunkSampleStream has finished loading a chunk obtained from this
source.onChunkLoadCompleted in interface ChunkSourcechunk - The chunk whose load has been completed.public boolean onChunkLoadError(Chunk chunk, boolean cancelable, Exception e, long exclusionDurationMs)
ChunkSourceChunkSampleStream encounters an error loading a chunk obtained from
this source.onChunkLoadError in interface ChunkSourcechunk - The chunk whose load encountered the error.cancelable - Whether the load can be canceled.e - The error.exclusionDurationMs - The duration for which the associated track may be excluded, or
C.TIME_UNSET if the track may not be excluded.false if cancelable is false. If true, ChunkSource.getNextChunk(long, long, List, ChunkHolder) will be called to obtain the replacement
chunk.public void release()
ChunkSourcerelease in interface ChunkSource