InitializationChunk


@UnstableApi
public final class InitializationChunk extends Chunk


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

Summary

Public fields

@Nullable ChunkIndex

Public constructors

InitializationChunk(
    DataSource dataSource,
    DataSpec dataSpec,
    Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    ChunkExtractor chunkExtractor
)

Public methods

void

Cancels the load.

@Nullable ChunkIndex

Returns the ChunkIndex obtained from the initialization chunk, or null if a has not been obtained.

void

Initializes the chunk for loading, setting a TrackOutputProvider for track outputs to which formats will be written as they are loaded.

void

Performs the load, returning on completion or cancellation.

Inherited fields

From androidx.media3.exoplayer.source.chunk.Chunk
final StatsDataSource
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.

Inherited methods

From androidx.media3.exoplayer.source.chunk.Chunk
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.

Public fields

chunkIndex

public @Nullable ChunkIndex chunkIndex

Public constructors

InitializationChunk

public InitializationChunk(
    DataSource dataSource,
    DataSpec dataSpec,
    Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    ChunkExtractor chunkExtractor
)
Parameters
DataSource dataSource

The source from which the data should be loaded.

DataSpec dataSpec

Defines the data to be loaded.

Format trackFormat

See trackFormat.

@C.SelectionReason int trackSelectionReason

See trackSelectionReason.

@Nullable Object trackSelectionData

See trackSelectionData.

ChunkExtractor chunkExtractor

A wrapped extractor to use for parsing the initialization data.

Public methods

cancelLoad

public void cancelLoad()

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 ).

getChunkIndex

public @Nullable ChunkIndex getChunkIndex()

Returns the ChunkIndex obtained from the initialization chunk, or null if a has not been obtained.

init

public void init(ChunkExtractor.TrackOutputProvider trackOutputProvider)

Initializes the chunk for loading, setting a TrackOutputProvider for track outputs to which formats will be written as they are loaded.

Parameters
ChunkExtractor.TrackOutputProvider trackOutputProvider

The TrackOutputProvider for track outputs to which formats will be written as they are loaded.

load

public void load()

Performs the load, returning on completion or cancellation.

Throws
java.io.IOException

If the input could not be loaded.