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[] adaptationSetIndices,
TrackSelection trackSelection,
int trackType,
DataSource dataSource,
long elapsedRealtimeOffsetMs,
int maxSegmentsPerLoad,
boolean enableEventMessageTrack,
boolean enableCea608Track) |
| 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
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)
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[] adaptationSetIndices, TrackSelection trackSelection, int trackType, DataSource dataSource, long elapsedRealtimeOffsetMs, int maxSegmentsPerLoad, boolean enableEventMessageTrack, boolean enableCea608Track)
manifestLoaderErrorThrower - Throws errors affecting loading of manifests.manifest - The initial manifest.periodIndex - The index of the period in the manifest.adaptationSetIndices - The indices of the adaptation sets in the period.trackSelection - The track selection.trackType - The type of the tracks in the 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.maxSegmentsPerLoad - The maximum number of segments to combine into a single request.
Note that segments will only be combined if their Uris are the same and if their
data ranges are adjacent.enableEventMessageTrack - Whether the chunks generated by the source may output an event
message track.enableCea608Track - Whether the chunks generated by the source may output a CEA-608 track.public void updateManifest(DashManifest newManifest, int newPeriodIndex)
updateManifest in interface DashChunkSourcepublic void maybeThrowError()
throws IOException
ChunkSourceThis method should only be called after the source has been prepared.
maybeThrowError in interface ChunkSourceIOException - The underlying error.public 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).
getPreferredQueueSize in interface ChunkSourceplaybackPositionUs - The current playback position.queue - The queue of buffered MediaChunks.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 ChunkSourceprevious - 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)
ChunkSourceChunkSampleStream has finished loading a chunk obtained from this
source.
This method should only be called when the source is enabled.
onChunkLoadCompleted in interface ChunkSourcechunk - The chunk whose load has been completed.public boolean onChunkLoadError(Chunk chunk, boolean cancelable, Exception e)
ChunkSourceChunkSampleStream encounters an error loading a chunk obtained from
this source.
This method should only be called when the source is enabled.
onChunkLoadError in interface ChunkSourcechunk - The chunk whose load encountered the error.cancelable - Whether the load can be canceled.e - The error.