Cea608Decoder
@UnstableApi
public final class Cea608Decoder implements SubtitleDecoder
A SubtitleDecoder for CEA-608 (also known as "line 21 captions" and "EIA-608").
Summary
Constants |
|
|---|---|
static final long |
MIN_DATA_CHANNEL_TIMEOUT_MS = 16000The minimum value for the |
Public constructors |
|---|
Cea608Decoder(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 |
flush()Flushes the decoder. |
String |
getName()Returns the name of the decoder. |
void |
queueInputBuffer(SubtitleInputBuffer inputBuffer)Queues an input buffer to the decoder. |
void |
release()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 |
void |
decode(SubtitleInputBuffer inputBuffer)Filters and processes the raw data, providing |
final @Nullable SubtitleOutputBuffer |
|
final long |
|
boolean |
Returns whether there is data available to create a new |
void |
releaseOutputBuffer(SubtitleOutputBuffer outputBuffer) |
Inherited methods |
||||||
|---|---|---|---|---|---|---|
|
Constants
MIN_DATA_CHANNEL_TIMEOUT_MS
public static final long MIN_DATA_CHANNEL_TIMEOUT_MS = 16000
The minimum value for the validDataChannelTimeoutMs constructor parameter permitted by ANSI/CTA-608-E R-2014 Annex C.9.
Public constructors
Cea608Decoder
public Cea608Decoder(
String mimeType,
int accessibilityChannel,
long validDataChannelTimeoutMs
)
Constructs an instance.
| Parameters | |
|---|---|
String mimeType |
The MIME type of the CEA-608 data. |
int accessibilityChannel |
The Accessibility channel, or |
long validDataChannelTimeoutMs |
The timeout (in milliseconds) permitted by ANSI/CTA-608-E R-2014 Annex C.9 to clear "stuck" captions where no removal control code is received. The timeout should be at least |
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
decode
protected void decode(SubtitleInputBuffer inputBuffer)
Filters and processes the raw data, providing Subtitles via createSubtitle when sufficient data has been processed.
isNewSubtitleDataAvailable
protected boolean isNewSubtitleDataAvailable()
Returns whether there is data available to create a new Subtitle.