@UnstableApi
abstract class DataChunk : Chunk


A base class for Chunk implementations where the data should be loaded into a byte[] before being consumed.

Summary

Public constructors

DataChunk(
    dataSource: DataSource!,
    dataSpec: DataSpec!,
    @C.DataType type: Int,
    trackFormat: Format!,
    @C.SelectionReason trackSelectionReason: Int,
    trackSelectionData: Any?,
    data: ByteArray?
)

Public functions

Unit

Cancels the load.

ByteArray<Byte>!

Returns the array in which the data is held.

Unit

Performs the load, returning on completion or cancellation.

Protected functions

abstract Unit
consume(data: ByteArray!, limit: Int)

Called by load.

Inherited functions

From androidx.media3.exoplayer.source.chunk.Chunk
Long

Returns the number of bytes that have been loaded.

Long

Returns the duration of the chunk in microseconds.

(Mutable)Map<String!, (Mutable)List<String!>!>!

Returns the response headers associated with the last open call.

Uri!

Returns the Uri associated with the last open call.

Inherited properties

From androidx.media3.exoplayer.source.chunk.Chunk
StatsDataSource!
DataSpec!

The DataSpec that defines the data to be loaded.

Long

The end time of the media contained by the chunk, or TIME_UNSET if the data being loaded does not contain media samples.

Long

Identifies the load task for this loadable.

Long

The start time of the media contained by the chunk, or TIME_UNSET if the data being loaded does not contain media samples.

Format!

The format of the track to which this chunk belongs.

Any?

Optional data associated with the selection of the track to which this chunk belongs.

Int

One of the selection reasons if the chunk belongs to a track.

Int

The data type of the chunk.

Public constructors

DataChunk

DataChunk(
    dataSource: DataSource!,
    dataSpec: DataSpec!,
    @C.DataType type: Int,
    trackFormat: Format!,
    @C.SelectionReason trackSelectionReason: Int,
    trackSelectionData: Any?,
    data: ByteArray?
)
Parameters
dataSource: DataSource!

The source from which the data should be loaded.

dataSpec: DataSpec!

Defines the data to be loaded.

@C.DataType type: Int

See type.

trackFormat: Format!

See trackFormat.

@C.SelectionReason trackSelectionReason: Int

See trackSelectionReason.

trackSelectionData: Any?

See trackSelectionData.

data: ByteArray?

An optional recycled array that can be used as a holder for the data.

Public functions

cancelLoad

fun cancelLoad(): Unit

Cancels the load.

Loadable implementations should ensure that a currently executing load call will exit reasonably quickly after this method is called. The load call may exit either by returning or by throwing an IOException.

If there is a currently executing load call, then the thread on which that call is being made will be interrupted immediately after the call to this method. Hence implementations do not need to (and should not attempt to) interrupt the loading thread themselves.

Although the loading thread will be interrupted, Loadable implementations should not use the interrupted status of the loading thread in load to determine whether the load has been canceled. This approach is not robust [Internal ref: b/79223737]. Instead, implementations should use their own flag to signal cancelation (for example, using ).

getDataHolder

fun getDataHolder(): ByteArray<Byte>!

Returns the array in which the data is held.

This method should be used for recycling the holder only, and not for reading the data.

Returns
ByteArray<Byte>!

The array in which the data is held.

load

fun load(): Unit

Performs the load, returning on completion or cancellation.

Throws
java.io.IOException

If the input could not be loaded.

Protected functions

consume

protected abstract fun consume(data: ByteArray!, limit: Int): Unit

Called by load. Implementations should override this method to consume the loaded data.

Parameters
data: ByteArray!

An array containing the data.

limit: Int

The limit of the data.

Throws
java.io.IOException

If an error occurs consuming the loaded data.