@UnstableApi
public final class Cea708Decoder implements SubtitleDecoder


A SubtitleDecoder for CEA-708 (also known as "EIA-708").

Summary

Public constructors

Cea708Decoder(
    int accessibilityChannel,
    @Nullable List<byte[]> initializationData
)

Constructs an instance.

Public methods

@Nullable SubtitleInputBuffer

Dequeues the next input buffer to be filled and queued to the decoder.

@Nullable SubtitleOutputBuffer

Dequeues the next output buffer from the decoder.

void

Flushes the decoder.

String

Returns the name of the decoder.

void

Queues an input buffer to the decoder.

void

Releases the decoder.

final void
setOutputStartTimeUs(long outputStartTimeUs)

Sets the timestamp from which output buffers should be produced, in microseconds.

void
setPositionUs(long positionUs)

Informs the decoder of the current playback position.

Protected methods

Subtitle

Creates a Subtitle from the available data.

void

Filters and processes the raw data, providing Subtitles via createSubtitle when sufficient data has been processed.

final @Nullable SubtitleOutputBuffer
final long
boolean

Returns whether there is data available to create a new Subtitle.

void

Inherited methods

From androidx.media3.decoder.Decoder
abstract @Nullable I

Dequeues the next input buffer to be filled and queued to the decoder.

abstract @Nullable O

Dequeues the next output buffer from the decoder.

abstract void
queueInputBuffer(I inputBuffer)

Queues an input buffer to the decoder.

Public constructors

Cea708Decoder

public Cea708Decoder(
    int accessibilityChannel,
    @Nullable List<byte[]> initializationData
)

Constructs an instance.

Parameters
int accessibilityChannel

The accessibility channel, or NO_VALUE if unknown.

@Nullable List<byte[]> initializationData

Optional initialization data for the decoder. If present, it must conform to the structure created by buildCea708InitializationData.

Public methods

dequeueInputBuffer

public @Nullable SubtitleInputBuffer dequeueInputBuffer()

Dequeues the next input buffer to be filled and queued to the decoder.

Returns
@Nullable SubtitleInputBuffer

The input buffer, which will have been cleared, or null if a buffer isn't available.

Throws
E

If a decoder error has occurred.

androidx.media3.extractor.text.SubtitleDecoderException

dequeueOutputBuffer

public @Nullable SubtitleOutputBuffer dequeueOutputBuffer()

Dequeues the next output buffer from the decoder.

Returns
@Nullable SubtitleOutputBuffer

The output buffer, or null if an output buffer isn't available.

Throws
E

If a decoder error has occurred.

androidx.media3.extractor.text.SubtitleDecoderException

flush

public void flush()

Flushes the decoder. Ownership of dequeued input buffers is returned to the decoder. The caller is still responsible for releasing any dequeued output buffers.

getName

public String getName()

Returns the name of the decoder.

Returns
String

The name of the decoder.

queueInputBuffer

public void queueInputBuffer(SubtitleInputBuffer inputBuffer)

Queues an input buffer to the decoder.

Parameters
SubtitleInputBuffer inputBuffer

The input buffer.

Throws
E

If a decoder error has occurred.

androidx.media3.extractor.text.SubtitleDecoderException

release

public void release()

Releases the decoder. Must be called when the decoder is no longer needed.

setOutputStartTimeUs

public final void setOutputStartTimeUs(long outputStartTimeUs)

Sets the timestamp from which output buffers should be produced, in microseconds.

Any decoded buffer with a timestamp less than outputStartTimeUs should be skipped by the implementation and not made available via dequeueOutputBuffer.

This method must only be called before queuing the first input buffer initially or after flush.

Parameters
long outputStartTimeUs

The time from which output buffer should be produced, in microseconds.

setPositionUs

public void setPositionUs(long positionUs)

Informs the decoder of the current playback position.

Must be called prior to each attempt to dequeue output buffers from the decoder.

Parameters
long positionUs

The current playback position in microseconds.

Protected methods

createSubtitle

protected Subtitle createSubtitle()

Creates a Subtitle from the available data.

decode

protected void decode(SubtitleInputBuffer inputBuffer)

Filters and processes the raw data, providing Subtitles via createSubtitle when sufficient data has been processed.

getAvailableOutputBuffer

protected final @Nullable SubtitleOutputBuffer getAvailableOutputBuffer()

getPositionUs

protected final long getPositionUs()

isNewSubtitleDataAvailable

protected boolean isNewSubtitleDataAvailable()

Returns whether there is data available to create a new Subtitle.

releaseOutputBuffer

protected void releaseOutputBuffer(SubtitleOutputBuffer outputBuffer)