DefaultDashChunkSource


@UnstableApi
class DefaultDashChunkSource : DashChunkSource


A default DashChunkSource implementation.

Summary

Public constructors

DefaultDashChunkSource(
    chunkExtractorFactory: ChunkExtractor.Factory!,
    manifestLoaderErrorThrower: LoaderErrorThrower!,
    manifest: DashManifest!,
    baseUrlExclusionList: BaseUrlExclusionList!,
    periodIndex: Int,
    adaptationSetIndices: IntArray!,
    trackSelection: ExoTrackSelection!,
    @C.TrackType trackType: Int,
    dataSource: DataSource!,
    elapsedRealtimeOffsetMs: Long,
    maxSegmentsPerLoad: Int,
    enableEventMessageTrack: Boolean,
    closedCaptionFormats: (Mutable)List<Format!>!,
    playerTrackEmsgHandler: PlayerEmsgHandler.PlayerTrackEmsgHandler?,
    playerId: PlayerId!,
    cmcdConfiguration: CmcdConfiguration?
)

Public functions

Long
getAdjustedSeekPositionUs(
    positionUs: Long,
    seekParameters: SeekParameters!
)

Adjusts a seek position given the specified SeekParameters.

Unit
getNextChunk(
    loadingInfo: LoadingInfo!,
    loadPositionUs: Long,
    queue: (Mutable)List<MediaChunk!>!,
    out: ChunkHolder!
)

Returns the next chunk to load.

Int
getPreferredQueueSize(
    playbackPositionUs: Long,
    queue: (Mutable)List<MediaChunk!>!
)

Evaluates whether MediaChunks should be removed from the back of the queue.

Unit

If the source is currently having difficulty providing chunks, then this method throws the underlying error.

Unit

Called when the ChunkSampleStream has finished loading a chunk obtained from this source.

Boolean
onChunkLoadError(
    chunk: Chunk!,
    cancelable: Boolean,
    loadErrorInfo: LoadErrorHandlingPolicy.LoadErrorInfo!,
    loadErrorHandlingPolicy: LoadErrorHandlingPolicy!
)

Called when the ChunkSampleStream encounters an error loading a chunk obtained from this source.

Unit

Releases any held resources.

Boolean
shouldCancelLoad(
    playbackPositionUs: Long,
    loadingChunk: Chunk!,
    queue: (Mutable)List<MediaChunk!>!
)

Returns whether an ongoing load of a chunk should be canceled.

Unit
updateManifest(newManifest: DashManifest!, newPeriodIndex: Int)

Updates the manifest.

Unit

Updates the track selection.

Protected functions

Chunk!
@RequiresNonNull(value = "#1.chunkExtractor")
newInitializationChunk(
    representationHolder: DefaultDashChunkSource.RepresentationHolder!,
    dataSource: DataSource!,
    trackFormat: Format!,
    @C.SelectionReason trackSelectionReason: Int,
    trackSelectionData: Any?,
    initializationUri: RangedUri?,
    indexUri: RangedUri?,
    cmcdDataFactory: CmcdData.Factory?
)

Creates a new Chunk for initialization.

Chunk!
newMediaChunk(
    representationHolder: DefaultDashChunkSource.RepresentationHolder!,
    dataSource: DataSource!,
    @C.TrackType trackType: Int,
    trackFormat: Format!,
    @C.SelectionReason trackSelectionReason: Int,
    trackSelectionData: Any?,
    firstSegmentNum: Long,
    maxSegmentCount: Int,
    seekTimeUs: Long,
    nowPeriodTimeUs: Long,
    cmcdDataFactory: CmcdData.Factory?
)

Public constructors

DefaultDashChunkSource

DefaultDashChunkSource(
    chunkExtractorFactory: ChunkExtractor.Factory!,
    manifestLoaderErrorThrower: LoaderErrorThrower!,
    manifest: DashManifest!,
    baseUrlExclusionList: BaseUrlExclusionList!,
    periodIndex: Int,
    adaptationSetIndices: IntArray!,
    trackSelection: ExoTrackSelection!,
    @C.TrackType trackType: Int,
    dataSource: DataSource!,
    elapsedRealtimeOffsetMs: Long,
    maxSegmentsPerLoad: Int,
    enableEventMessageTrack: Boolean,
    closedCaptionFormats: (Mutable)List<Format!>!,
    playerTrackEmsgHandler: PlayerEmsgHandler.PlayerTrackEmsgHandler?,
    playerId: PlayerId!,
    cmcdConfiguration: CmcdConfiguration?
)
Parameters
chunkExtractorFactory: ChunkExtractor.Factory!

Creates ChunkExtractor instances to use for extracting chunks.

manifestLoaderErrorThrower: LoaderErrorThrower!

Throws errors affecting loading of manifests.

manifest: DashManifest!

The initial manifest.

baseUrlExclusionList: BaseUrlExclusionList!

The base URL exclusion list.

periodIndex: Int

The index of the period in the manifest.

adaptationSetIndices: IntArray!

The indices of the adaptation sets in the period.

trackSelection: ExoTrackSelection!

The track selection.

@C.TrackType trackType: Int

The type of the tracks in the selection.

dataSource: DataSource!

A DataSource suitable for loading the media data.

elapsedRealtimeOffsetMs: Long

If known, an estimate of the instantaneous difference between server-side unix time and elapsedRealtime in milliseconds, specified as the server's unix time minus the local elapsed time. Or TIME_UNSET if unknown.

maxSegmentsPerLoad: Int

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: Boolean

Whether to output an event message track.

closedCaptionFormats: (Mutable)List<Format!>!

The Formats of closed caption tracks to be output.

playerTrackEmsgHandler: PlayerEmsgHandler.PlayerTrackEmsgHandler?

The PlayerTrackEmsgHandler instance to handle emsg messages targeting the player. Maybe null if this is not necessary.

playerId: PlayerId!

The PlayerId of the player using this chunk source.

cmcdConfiguration: CmcdConfiguration?

The CmcdConfiguration for this chunk source.

Public functions

getAdjustedSeekPositionUs

fun getAdjustedSeekPositionUs(
    positionUs: Long,
    seekParameters: SeekParameters!
): Long

Adjusts a seek position given the specified SeekParameters. Chunk boundaries are used as sync points.

Parameters
positionUs: Long

The seek position in microseconds.

seekParameters: SeekParameters!

Parameters that control how the seek is performed.

Returns
Long

The adjusted seek position, in microseconds.

getNextChunk

fun getNextChunk(
    loadingInfo: LoadingInfo!,
    loadPositionUs: Long,
    queue: (Mutable)List<MediaChunk!>!,
    out: ChunkHolder!
): Unit

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 LoadingInfo when loading request is made.

loadPositionUs: Long

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 endTimeUs of the last chunk in the queue.

queue: (Mutable)List<MediaChunk!>!

The queue of buffered MediaChunks.

out: ChunkHolder!

A holder to populate.

getPreferredQueueSize

fun getPreferredQueueSize(
    playbackPositionUs: Long,
    queue: (Mutable)List<MediaChunk!>!
): Int

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
playbackPositionUs: Long

The current playback position, in microseconds.

queue: (Mutable)List<MediaChunk!>!

The queue of buffered MediaChunks.

Returns
Int

The preferred queue size.

maybeThrowError

fun maybeThrowError(): Unit

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

fun onChunkLoadCompleted(chunk: Chunk!): Unit

Called when the ChunkSampleStream has finished loading a chunk obtained from this source.

Parameters
chunk: Chunk!

The chunk whose load has been completed.

onChunkLoadError

fun onChunkLoadError(
    chunk: Chunk!,
    cancelable: Boolean,
    loadErrorInfo: LoadErrorHandlingPolicy.LoadErrorInfo!,
    loadErrorHandlingPolicy: LoadErrorHandlingPolicy!
): Boolean

Called when the ChunkSampleStream encounters an error loading a chunk obtained from this source.

Parameters
chunk: Chunk!

The chunk whose load encountered the error.

cancelable: Boolean

Whether the load can be canceled.

loadErrorInfo: LoadErrorHandlingPolicy.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 false if cancelable is false. If true, getNextChunk will be called to obtain the replacement chunk.

release

fun release(): Unit

Releases any held resources.

shouldCancelLoad

fun shouldCancelLoad(
    playbackPositionUs: Long,
    loadingChunk: Chunk!,
    queue: (Mutable)List<MediaChunk!>!
): Boolean

Returns whether an ongoing load of a chunk should be canceled.

Parameters
playbackPositionUs: Long

The current playback position, in microseconds.

loadingChunk: Chunk!

The currently loading Chunk.

queue: (Mutable)List<MediaChunk!>!

The queue of buffered MediaChunks.

Returns
Boolean

Whether the ongoing load of loadingChunk should be canceled.

updateManifest

fun updateManifest(newManifest: DashManifest!, newPeriodIndex: Int): Unit

Updates the manifest.

Parameters
newManifest: DashManifest!

The new manifest.

newPeriodIndex: Int

The index of the period covered by newManifest.

updateTrackSelection

fun updateTrackSelection(trackSelection: ExoTrackSelection!): Unit

Updates the track selection.

Parameters
trackSelection: ExoTrackSelection!

The new track selection instance. Must be equivalent to the previous one.

Protected functions

newInitializationChunk

@RequiresNonNull(value = "#1.chunkExtractor")
protected fun newInitializationChunk(
    representationHolder: DefaultDashChunkSource.RepresentationHolder!,
    dataSource: DataSource!,
    trackFormat: Format!,
    @C.SelectionReason trackSelectionReason: Int,
    trackSelectionData: Any?,
    initializationUri: RangedUri?,
    indexUri: RangedUri?,
    cmcdDataFactory: CmcdData.Factory?
): Chunk!

Creates a new Chunk for initialization.

Parameters
representationHolder: DefaultDashChunkSource.RepresentationHolder!

The Representation holder for initialization.

dataSource: DataSource!

The source from which the data should be loaded.

trackFormat: Format!

The format of the track to which this chunk belongs.

@C.SelectionReason trackSelectionReason: Int

One of the selection reasons.

trackSelectionData: Any?

Additional data related to track selection.

initializationUri: RangedUri?

The URI pointing to initialization data. Can be null if indexUri is not null.

indexUri: RangedUri?

The URI pointing to index data. Can be null if initializationUri is not null.

cmcdDataFactory: CmcdData.Factory?

The CmcdData.Factory for generating CMCD data.

newMediaChunk

protected fun newMediaChunk(
    representationHolder: DefaultDashChunkSource.RepresentationHolder!,
    dataSource: DataSource!,
    @C.TrackType trackType: Int,
    trackFormat: Format!,
    @C.SelectionReason trackSelectionReason: Int,
    trackSelectionData: Any?,
    firstSegmentNum: Long,
    maxSegmentCount: Int,
    seekTimeUs: Long,
    nowPeriodTimeUs: Long,
    cmcdDataFactory: CmcdData.Factory?
): Chunk!

Protected properties

representationHolders

protected val representationHoldersArray<DefaultDashChunkSource.RepresentationHolder!>!