ChunkSampleStream.EmbeddedSampleStream


public final inner class ChunkSampleStream.EmbeddedSampleStream implements SampleStream


A SampleStream embedded in a ChunkSampleStream.

Summary

Public fields

final ChunkSampleStream<T>

Public constructors

EmbeddedSampleStream(
    ChunkSampleStream<T> parent,
    SampleQueue sampleQueue,
    int index
)

Public methods

boolean

Returns whether data is available to be read.

void

Throws an error that's preventing data from being read.

int
readData(
    FormatHolder formatHolder,
    DecoderInputBuffer buffer,
    @SampleStream.ReadFlags int readFlags
)

Attempts to read from the stream.

void
int
skipData(long positionUs)

Attempts to skip to the keyframe before the specified position, or to the end of the stream if positionUs is beyond it.

Inherited Constants

From androidx.media3.exoplayer.source.SampleStream
static final int

Specifies that data, supplementalData and cryptoInfo should not be populated when reading a sample buffer.

static final int

Specifies that the read position should not be advanced if a sample buffer is read.

static final int

Specifies that if a sample buffer would normally be read next, the format of the stream should be read instead.

Public fields

parent

public final ChunkSampleStream<T> parent

Public constructors

EmbeddedSampleStream

public EmbeddedSampleStream(
    ChunkSampleStream<T> parent,
    SampleQueue sampleQueue,
    int index
)

Public methods

isReady

public boolean isReady()

Returns whether data is available to be read.

Note: If the stream has ended then a buffer with the end of stream flag can always be read from readData. Hence an ended stream is always ready.

Returns
boolean

Whether data is available to be read.

maybeThrowError

public void maybeThrowError()

Throws an error that's preventing data from being read. Does nothing if no such error exists.

Throws
java.io.IOException

The underlying error.

readData

public int readData(
    FormatHolder formatHolder,
    DecoderInputBuffer buffer,
    @SampleStream.ReadFlags int readFlags
)

Attempts to read from the stream.

If the stream has ended then BUFFER_FLAG_END_OF_STREAM flag is set on buffer and RESULT_BUFFER_READ is returned. Else if no data is available then RESULT_NOTHING_READ is returned. Else if the format of the media is changing or if formatRequired is set then formatHolder is populated and RESULT_FORMAT_READ is returned. Else buffer is populated and RESULT_BUFFER_READ is returned.

Parameters
FormatHolder formatHolder

A FormatHolder to populate in the case of reading a format.

DecoderInputBuffer buffer

A DecoderInputBuffer to populate in the case of reading a sample or the end of the stream. If the end of the stream has been reached, the BUFFER_FLAG_END_OF_STREAM flag will be set on the buffer.

@SampleStream.ReadFlags int readFlags

Flags controlling the behavior of this read operation.

Returns
int

The result of the read operation.

Throws
androidx.media3.decoder.DecoderInputBuffer.InsufficientCapacityException

If the buffer has insufficient capacity to hold the data of a sample being read. The buffer timestamp and flags are populated if this exception is thrown, but the read position is not advanced.

release

public void release()

skipData

public int skipData(long positionUs)

Attempts to skip to the keyframe before the specified position, or to the end of the stream if positionUs is beyond it.

Parameters
long positionUs

The specified time.

Returns
int

The number of samples that were skipped.