public class DefaultDashChunkSource extends Object implements DashChunkSource
DashChunkSource
implementation.Modifier and Type | Class and Description |
---|---|
static class |
DefaultDashChunkSource.Factory |
protected static class |
DefaultDashChunkSource.RepresentationHolder |
Constructor and Description |
---|
DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
DashManifest manifest,
int periodIndex,
int adaptationSetIndex,
TrackSelection trackSelection,
DataSource dataSource,
long elapsedRealtimeOffsetMs) |
Modifier and Type | Method and Description |
---|---|
void |
getNextChunk(MediaChunk previous,
long playbackPositionUs,
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)
Called when the
ChunkSampleStream encounters an error loading a chunk obtained from
this source. |
void |
updateManifest(DashManifest newManifest,
int newPeriodIndex) |
public DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower, DashManifest manifest, int periodIndex, int adaptationSetIndex, TrackSelection trackSelection, DataSource dataSource, long elapsedRealtimeOffsetMs)
manifestLoaderErrorThrower
- Throws errors affecting loading of manifests.manifest
- The initial manifest.periodIndex
- The index of the period in the manifest.adaptationSetIndex
- The index of the adaptation set in the period.trackSelection
- The track selection.dataSource
- A DataSource
suitable for loading the media data.elapsedRealtimeOffsetMs
- If known, an estimate of the instantaneous difference between
server-side unix time and SystemClock.elapsedRealtime()
in milliseconds, specified
as the server's unix time minus the local elapsed time. If unknown, set to 0.public void updateManifest(DashManifest newManifest, int newPeriodIndex)
updateManifest
in interface DashChunkSource
public void maybeThrowError() throws IOException
ChunkSource
This method should only be called after the source has been prepared.
maybeThrowError
in interface ChunkSource
IOException
- The underlying error.public int getPreferredQueueSize(long playbackPositionUs, List<? extends MediaChunk> queue)
ChunkSource
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).
getPreferredQueueSize
in interface ChunkSource
playbackPositionUs
- The current playback position.queue
- The queue of buffered MediaChunk
s.public final void getNextChunk(MediaChunk previous, long playbackPositionUs, ChunkHolder out)
ChunkSource
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.
getNextChunk
in interface ChunkSource
previous
- The most recently loaded media chunk.playbackPositionUs
- The current playback position. If previous
is null 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 to populate.public void onChunkLoadCompleted(Chunk chunk)
ChunkSource
ChunkSampleStream
has finished loading a chunk obtained from this
source.
This method should only be called when the source is enabled.
onChunkLoadCompleted
in interface ChunkSource
chunk
- The chunk whose load has been completed.public boolean onChunkLoadError(Chunk chunk, boolean cancelable, Exception e)
ChunkSource
ChunkSampleStream
encounters an error loading a chunk obtained from
this source.
This method should only be called when the source is enabled.
onChunkLoadError
in interface ChunkSource
chunk
- The chunk whose load encountered the error.cancelable
- Whether the load can be canceled.e
- The error.