@UnstableApi
public abstract class Chunk implements Loader.Loadable

Known direct subclasses
DataChunk

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

InitializationChunk

A Chunk that uses an Extractor to decode initialization data for single track.

MediaChunk

An abstract base class for Chunks that contain media samples.

Known indirect subclasses
BaseMediaChunk

A base implementation of MediaChunk that outputs to a BaseMediaChunkOutput.

ContainerMediaChunk

A BaseMediaChunk that uses an Extractor to decode sample data.

FakeMediaChunk

Fake MediaChunk.

SingleSampleMediaChunk

A BaseMediaChunk for chunks consisting of a single raw sample.


An abstract base class for Loadable implementations that load chunks of data required for the playback of streams.

Summary

Public fields

final DataSpec

The DataSpec that defines the data to be loaded.

final long

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

final long

Identifies the load task for this loadable.

final long

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

final Format

The format of the track to which this chunk belongs.

final @Nullable Object

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

final int

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

final int

The data type of the chunk.

Protected fields

final StatsDataSource

Public constructors

Chunk(
    DataSource dataSource,
    DataSpec dataSpec,
    @C.DataType int type,
    Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long startTimeUs,
    long endTimeUs
)

Public methods

final long

Returns the number of bytes that have been loaded.

final long

Returns the duration of the chunk in microseconds.

final Map<StringList<String>>

Returns the response headers associated with the last open call.

final Uri

Returns the Uri associated with the last open call.

Inherited methods

From androidx.media3.exoplayer.upstream.Loader.Loadable
abstract void

Cancels the load.

abstract void

Performs the load, returning on completion or cancellation.

Public fields

dataSpec

public final DataSpec dataSpec

The DataSpec that defines the data to be loaded.

endTimeUs

public final long endTimeUs

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

loadTaskId

public final long loadTaskId

Identifies the load task for this loadable.

startTimeUs

public final long startTimeUs

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

trackFormat

public final Format trackFormat

The format of the track to which this chunk belongs.

trackSelectionData

public final @Nullable Object trackSelectionData

Optional data associated with the selection of the track to which this chunk belongs. Null if the chunk does not belong to a track, or if there is no associated track selection data.

trackSelectionReason

@C.SelectionReason
public final int trackSelectionReason

One of the selection reasons if the chunk belongs to a track. SELECTION_REASON_UNKNOWN if the chunk does not belong to a track, or if the selection reason is unknown.

type

@C.DataType
public final int type

The data type of the chunk. For reporting only.

Protected fields

dataSource

protected final StatsDataSource dataSource

Public constructors

Chunk

public Chunk(
    DataSource dataSource,
    DataSpec dataSpec,
    @C.DataType int type,
    Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long startTimeUs,
    long endTimeUs
)
Parameters
DataSource dataSource

The source from which the data should be loaded.

DataSpec dataSpec

Defines the data to be loaded.

@C.DataType int type

See type.

Format trackFormat

See trackFormat.

@C.SelectionReason int trackSelectionReason

See trackSelectionReason.

@Nullable Object trackSelectionData

See trackSelectionData.

long startTimeUs

See startTimeUs.

long endTimeUs

See endTimeUs.

Public methods

bytesLoaded

public final long bytesLoaded()

Returns the number of bytes that have been loaded. Must only be called after the load completed, failed, or was canceled.

getDurationUs

public final long getDurationUs()

Returns the duration of the chunk in microseconds.

getResponseHeaders

public final Map<StringList<String>> getResponseHeaders()

Returns the response headers associated with the last open call. Must only be called after the load completed, failed, or was canceled.

getUri

public final Uri getUri()

Returns the Uri associated with the last open call. If redirection occurred, this is the redirected uri. Must only be called after the load completed, failed, or was canceled.

See also
getUri