DefaultDashChunkSource
@UnstableApi
public class DefaultDashChunkSource implements DashChunkSource
A default DashChunkSource implementation.
Summary
Nested types |
|---|
public final class DefaultDashChunkSource.Factory implements DashChunkSource.Factory
|
protected final class DefaultDashChunkSource.RepresentationHolderHolds information about a snapshot of a single |
protected final class DefaultDashChunkSource.RepresentationSegmentIterator extends BaseMediaChunkIterator
|
Protected fields |
|
|---|---|
final DefaultDashChunkSource.RepresentationHolder[] |
Public constructors |
|---|
DefaultDashChunkSource( |
Public methods |
|
|---|---|
long |
getAdjustedSeekPositionUs(Adjusts a seek position given the specified |
void |
getNextChunk(Returns the next chunk to load. |
int |
getPreferredQueueSize(long playbackPositionUs, List<MediaChunk> queue)Evaluates whether |
void |
If the source is currently having difficulty providing chunks, then this method throws the underlying error. |
void |
onChunkLoadCompleted(Chunk chunk)Called when the |
boolean |
onChunkLoadError(Called when the |
void |
release()Releases any held resources. |
boolean |
shouldCancelLoad(Returns whether an ongoing load of a chunk should be canceled. |
void |
updateManifest(DashManifest newManifest, int newPeriodIndex)Updates the manifest. |
void |
updateTrackSelection(ExoTrackSelection trackSelection)Updates the track selection. |
Protected methods |
|
|---|---|
Chunk |
@RequiresNonNull(value = "#1.chunkExtractor")Creates a new |
Chunk |
newMediaChunk( |
Protected fields
representationHolders
protected final DefaultDashChunkSource.RepresentationHolder[] representationHolders
Public constructors
DefaultDashChunkSource
public DefaultDashChunkSource(
ChunkExtractor.Factory chunkExtractorFactory,
LoaderErrorThrower manifestLoaderErrorThrower,
DashManifest manifest,
BaseUrlExclusionList baseUrlExclusionList,
int periodIndex,
int[] adaptationSetIndices,
ExoTrackSelection trackSelection,
@C.TrackType int trackType,
DataSource dataSource,
long elapsedRealtimeOffsetMs,
int maxSegmentsPerLoad,
boolean enableEventMessageTrack,
List<Format> closedCaptionFormats,
@Nullable PlayerEmsgHandler.PlayerTrackEmsgHandler playerTrackEmsgHandler,
PlayerId playerId,
@Nullable CmcdConfiguration cmcdConfiguration
)
| Parameters | |
|---|---|
ChunkExtractor.Factory chunkExtractorFactory |
Creates |
LoaderErrorThrower manifestLoaderErrorThrower |
Throws errors affecting loading of manifests. |
DashManifest manifest |
The initial manifest. |
BaseUrlExclusionList baseUrlExclusionList |
The base URL exclusion list. |
int periodIndex |
The index of the period in the manifest. |
int[] adaptationSetIndices |
The indices of the adaptation sets in the period. |
ExoTrackSelection trackSelection |
The track selection. |
@C.TrackType int trackType |
The |
DataSource dataSource |
A |
long elapsedRealtimeOffsetMs |
If known, an estimate of the instantaneous difference between server-side unix time and |
int maxSegmentsPerLoad |
The maximum number of segments to combine into a single request. Note that segments will only be combined if their |
boolean enableEventMessageTrack |
Whether to output an event message track. |
List<Format> closedCaptionFormats |
The |
@Nullable PlayerEmsgHandler.PlayerTrackEmsgHandler playerTrackEmsgHandler |
The |
PlayerId playerId |
The |
@Nullable CmcdConfiguration cmcdConfiguration |
The |
Public methods
getAdjustedSeekPositionUs
public long getAdjustedSeekPositionUs(
long positionUs,
SeekParameters seekParameters
)
Adjusts a seek position given the specified SeekParameters. Chunk boundaries are used as sync points.
| Parameters | |
|---|---|
long positionUs |
The seek position in microseconds. |
SeekParameters seekParameters |
Parameters that control how the seek is performed. |
| Returns | |
|---|---|
long |
The adjusted seek position, in microseconds. |
getNextChunk
public void getNextChunk(
LoadingInfo loadingInfo,
long loadPositionUs,
List<MediaChunk> queue,
ChunkHolder out
)
Returns the next chunk to load.
If a chunk is available then chunk is set. If the end of the stream has been reached then endOfStream is set. If a chunk is not available but the end of the stream has not been reached, the ChunkHolder is not modified.
| Parameters | |
|---|---|
LoadingInfo loadingInfo |
The |
long loadPositionUs |
The current load position in microseconds. If |
List<MediaChunk> queue |
The queue of buffered |
ChunkHolder out |
A holder to populate. |
getPreferredQueueSize
public int getPreferredQueueSize(long playbackPositionUs, List<MediaChunk> queue)
Evaluates whether MediaChunks 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.
| Parameters | |
|---|---|
long playbackPositionUs |
The current playback position, in microseconds. |
List<MediaChunk> queue |
The queue of buffered |
| Returns | |
|---|---|
int |
The preferred queue size. |
maybeThrowError
public void maybeThrowError()
If the source is currently having difficulty providing chunks, then this method throws the underlying error. Otherwise does nothing.
| Throws | |
|---|---|
java.io.IOException |
The underlying error. |
onChunkLoadCompleted
public void onChunkLoadCompleted(Chunk chunk)
Called when the ChunkSampleStream has finished loading a chunk obtained from this source.
| Parameters | |
|---|---|
Chunk chunk |
The chunk whose load has been completed. |
onChunkLoadError
public boolean onChunkLoadError(
Chunk chunk,
boolean cancelable,
LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo,
LoadErrorHandlingPolicy loadErrorHandlingPolicy
)
Called when the ChunkSampleStream encounters an error loading a chunk obtained from this source.
| Parameters | |
|---|---|
Chunk chunk |
The chunk whose load encountered the error. |
boolean cancelable |
Whether the load can be canceled. |
LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo |
The load error info. |
LoadErrorHandlingPolicy loadErrorHandlingPolicy |
The load error handling policy to customize the behaviour of handling the load error. |
| Returns | |
|---|---|
boolean |
Whether the load should be canceled so that a replacement chunk can be loaded instead. Must be |
shouldCancelLoad
public boolean shouldCancelLoad(
long playbackPositionUs,
Chunk loadingChunk,
List<MediaChunk> queue
)
Returns whether an ongoing load of a chunk should be canceled.
| Parameters | |
|---|---|
long playbackPositionUs |
The current playback position, in microseconds. |
Chunk loadingChunk |
The currently loading |
List<MediaChunk> queue |
The queue of buffered |
| Returns | |
|---|---|
boolean |
Whether the ongoing load of |
updateManifest
public void updateManifest(DashManifest newManifest, int newPeriodIndex)
Updates the manifest.
| Parameters | |
|---|---|
DashManifest newManifest |
The new manifest. |
int newPeriodIndex |
The index of the period covered by |
updateTrackSelection
public void updateTrackSelection(ExoTrackSelection trackSelection)
Updates the track selection.
| Parameters | |
|---|---|
ExoTrackSelection trackSelection |
The new track selection instance. Must be equivalent to the previous one. |
Protected methods
newInitializationChunk
@RequiresNonNull(value = "#1.chunkExtractor")
protected Chunk newInitializationChunk(
DefaultDashChunkSource.RepresentationHolder representationHolder,
DataSource dataSource,
Format trackFormat,
@C.SelectionReason int trackSelectionReason,
@Nullable Object trackSelectionData,
@Nullable RangedUri initializationUri,
@Nullable RangedUri indexUri,
@Nullable CmcdData.Factory cmcdDataFactory
)
Creates a new Chunk for initialization.
| Parameters | |
|---|---|
DefaultDashChunkSource.RepresentationHolder representationHolder |
The |
DataSource dataSource |
The source from which the data should be loaded. |
Format trackFormat |
The format of the track to which this chunk belongs. |
@C.SelectionReason int trackSelectionReason |
One of the |
@Nullable Object trackSelectionData |
Additional data related to track selection. |
@Nullable RangedUri initializationUri |
The URI pointing to initialization data. Can be |
@Nullable RangedUri indexUri |
The URI pointing to index data. Can be |
@Nullable CmcdData.Factory cmcdDataFactory |
The |
newMediaChunk
protected Chunk newMediaChunk(
DefaultDashChunkSource.RepresentationHolder representationHolder,
DataSource dataSource,
@C.TrackType int trackType,
Format trackFormat,
@C.SelectionReason int trackSelectionReason,
@Nullable Object trackSelectionData,
long firstSegmentNum,
int maxSegmentCount,
long seekTimeUs,
long nowPeriodTimeUs,
@Nullable CmcdData.Factory cmcdDataFactory
)