# Cea608Decoder

Artifact: [androidx.media3:media3-extractor](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/extractor/text/cea/Cea608Decoder.java+class:androidx.media3.extractor.text.cea.Cea608Decoder)

*** ** * ** ***


```
@UnstableApi
public final class Cea608Decoder implements SubtitleDecoder
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleDecoder` for CEA-608 (also known as "line 21 captions" and "EIA-608").

## Summary

| ### Constants |
|---|---|
| `static final long` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#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 |
|---|
| `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#Cea608Decoder(java.lang.String,int,long)( https://developer.android.com/reference/java/lang/String.html mimeType, int accessibilityChannel, long validDataChannelTimeoutMs )` Constructs an instance. |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleInputBuffer` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#dequeueInputBuffer()()` Dequeues the next input buffer to be filled and queued to the decoder. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#dequeueOutputBuffer()()` Dequeues the next output buffer from the decoder. |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#flush()()` Flushes the decoder. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#getName()()` Returns the name of the decoder. |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#queueInputBuffer(androidx.media3.extractor.text.SubtitleInputBuffer)(https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleInputBuffer inputBuffer)` Queues an input buffer to the decoder. |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#release()()` Releases the decoder. |
| `final void` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#setOutputStartTimeUs(long)(long outputStartTimeUs)` Sets the timestamp from which output buffers should be produced, in microseconds. |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#setPositionUs(long)(long positionUs)` Informs the decoder of the current playback position. |

| ### Protected methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#createSubtitle()()` Creates a `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle` from the available data. |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#decode(androidx.media3.extractor.text.SubtitleInputBuffer)(https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleInputBuffer inputBuffer)` Filters and processes the raw data, providing `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle`s via `https://developer.android.com/reference/androidx/media3/extractor/text/cea/CeaDecoder#createSubtitle()` when sufficient data has been processed. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#getAvailableOutputBuffer()()` |
| `final long` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#getPositionUs()()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#isNewSubtitleDataAvailable()()` Returns whether there is data available to create a new `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle`. |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#releaseOutputBuffer(androidx.media3.extractor.text.SubtitleOutputBuffer)(https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer outputBuffer)` |

| ### Inherited methods |
|---|
| From [androidx.media3.decoder.Decoder](https://developer.android.com/reference/androidx/media3/decoder/Decoder) |---|---| | `abstract @https://developer.android.com/reference/androidx/annotation/Nullable I` | `https://developer.android.com/reference/androidx/media3/decoder/Decoder#dequeueInputBuffer()()` Dequeues the next input buffer to be filled and queued to the decoder. | | `abstract @https://developer.android.com/reference/androidx/annotation/Nullable O` | `https://developer.android.com/reference/androidx/media3/decoder/Decoder#dequeueOutputBuffer()()` Dequeues the next output buffer from the decoder. | | `abstract void` | `https://developer.android.com/reference/androidx/media3/decoder/Decoder#queueInputBuffer(I)(I inputBuffer)` Queues an input buffer to the decoder. | | `void` | `https://developer.android.com/reference/androidx/media3/decoder/Decoder#setCallback(androidx.media3.decoder.Decoder.Callback,java.util.concurrent.Executor)(https://developer.android.com/reference/androidx/media3/decoder/Decoder.Callback callback, https://developer.android.com/reference/java/util/concurrent/Executor.html executor)` Sets the callback and executor. | |

## 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 |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html mimeType` | The MIME type of the CEA-608 data. |
| `int accessibilityChannel` | The Accessibility channel, or `https://developer.android.com/reference/androidx/media3/common/Format#NO_VALUE()` if unknown. |
| `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 `https://developer.android.com/reference/androidx/media3/extractor/text/cea/Cea608Decoder#MIN_DATA_CHANNEL_TIMEOUT_MS()` or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` for no timeout. |

## Public methods

### dequeueInputBuffer

```
public @Nullable SubtitleInputBuffer dequeueInputBuffer()
```

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleInputBuffer` | The input buffer, which will have been cleared, or null if a buffer isn't available. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/decoder/Decoder` | If a decoder error has occurred. |
| `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleDecoderException` |   |

### dequeueOutputBuffer

```
public @Nullable SubtitleOutputBuffer dequeueOutputBuffer()
```

Dequeues the next output buffer from the decoder.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer` | The output buffer, or null if an output buffer isn't available. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/decoder/Decoder` | If a decoder error has occurred. |
| `https://developer.android.com/reference/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 |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | The name of the decoder. |

### queueInputBuffer

```
public void queueInputBuffer(SubtitleInputBuffer inputBuffer)
```

Queues an input buffer to the decoder.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleInputBuffer inputBuffer` | The input buffer. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/decoder/Decoder` | If a decoder error has occurred. |
| `https://developer.android.com/reference/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 `https://developer.android.com/reference/androidx/media3/decoder/Decoder#dequeueOutputBuffer()`.

This method must only be called before `https://developer.android.com/reference/androidx/media3/decoder/Decoder#queueInputBuffer(I)` initially or after `https://developer.android.com/reference/androidx/media3/decoder/Decoder#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 `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle` from the available data.

### decode

```
protected void decode(SubtitleInputBuffer inputBuffer)
```

Filters and processes the raw data, providing `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle`s via `https://developer.android.com/reference/androidx/media3/extractor/text/cea/CeaDecoder#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 `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle`.

### releaseOutputBuffer

```
protected void releaseOutputBuffer(SubtitleOutputBuffer outputBuffer)
```