public class DefaultDashChunkSource extends Object implements DashChunkSource
DashChunkSource
implementation.Modifier and Type | Class and Description |
---|---|
static class |
DefaultDashChunkSource.Factory |
protected static class |
DefaultDashChunkSource.RepresentationHolder
Holds information about a snapshot of a single
Representation . |
protected static class |
DefaultDashChunkSource.RepresentationSegmentIterator
|
Modifier and Type | Field and Description |
---|---|
protected DefaultDashChunkSource.RepresentationHolder[] |
representationHolders |
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,
PlayerEmsgHandler.PlayerTrackEmsgHandler playerTrackEmsgHandler) |
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.
|
protected Chunk |
newInitializationChunk(DefaultDashChunkSource.RepresentationHolder representationHolder,
DataSource dataSource,
Format trackFormat,
int trackSelectionReason,
Object trackSelectionData,
RangedUri initializationUri,
RangedUri indexUri) |
protected Chunk |
newMediaChunk(DefaultDashChunkSource.RepresentationHolder representationHolder,
DataSource dataSource,
int trackType,
Format trackFormat,
int trackSelectionReason,
Object trackSelectionData,
long firstSegmentNum,
int maxSegmentCount,
long seekTimeUs) |
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. |
void |
updateManifest(DashManifest newManifest,
int newPeriodIndex)
Updates the manifest.
|
protected final DefaultDashChunkSource.RepresentationHolder[] representationHolders
public DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower, DashManifest manifest, int periodIndex, int[] adaptationSetIndices, TrackSelection trackSelection, int trackType, DataSource dataSource, long elapsedRealtimeOffsetMs, int maxSegmentsPerLoad, boolean enableEventMessageTrack, boolean enableCea608Track, @Nullable PlayerEmsgHandler.PlayerTrackEmsgHandler playerTrackEmsgHandler)
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 Uri
s 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.playerTrackEmsgHandler
- The PlayerEmsgHandler.PlayerTrackEmsgHandler
instance to handle emsg
messages targeting the player. Maybe null if this is not necessary.public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters)
ChunkSource
SeekParameters
. Chunk boundaries are used
as sync points.getAdjustedSeekPositionUs
in interface ChunkSource
positionUs
- The seek position in microseconds.seekParameters
- Parameters that control how the seek is performed.public void updateManifest(DashManifest newManifest, int newPeriodIndex)
DashChunkSource
updateManifest
in interface DashChunkSource
newManifest
- The new manifest.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 void getNextChunk(long playbackPositionUs, long loadPositionUs, List<? extends MediaChunk> queue, 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
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.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, long blacklistDurationMs)
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.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.protected Chunk newInitializationChunk(DefaultDashChunkSource.RepresentationHolder representationHolder, DataSource dataSource, Format trackFormat, int trackSelectionReason, Object trackSelectionData, RangedUri initializationUri, RangedUri indexUri)
protected Chunk newMediaChunk(DefaultDashChunkSource.RepresentationHolder representationHolder, DataSource dataSource, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long firstSegmentNum, int maxSegmentCount, long seekTimeUs)