# SimpleSubtitleDecoder

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/SimpleSubtitleDecoder.java+class:androidx.media3.extractor.text.SimpleSubtitleDecoder)

*** ** * ** ***


```
@UnstableApi
abstract class SimpleSubtitleDecoder : SimpleDecoder<SubtitleInputBuffer!, SubtitleOutputBuffer!, SubtitleDecoderException!>, SubtitleDecoder
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.media3.decoder.SimpleDecoder](https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder)\<[SubtitleInputBuffer](https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleInputBuffer)!, [SubtitleOutputBuffer](https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleOutputBuffer)!, [SubtitleDecoderException](https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleDecoderException)!\> ||
|   | ↳ | [androidx.media3.extractor.text.SimpleSubtitleDecoder](https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SimpleSubtitleDecoder) |

*** ** * ** ***

Base class for subtitle parsers that use their own decode thread.

## Summary

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SimpleSubtitleDecoder#SimpleSubtitleDecoder(java.lang.String)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SimpleSubtitleDecoder#setPositionUs(long)(positionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Informs the decoder of the current playback position. |

| ### Protected functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleInputBuffer!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SimpleSubtitleDecoder#createInputBuffer()()` Creates a new input buffer. |
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleOutputBuffer!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SimpleSubtitleDecoder#createOutputBuffer()()` Creates a new output buffer. |
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleDecoderException!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SimpleSubtitleDecoder#createUnexpectedDecodeException(java.lang.Throwable)(error: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!)` Creates an exception to propagate for an unexpected decode error. |
| `abstract https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/Subtitle!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SimpleSubtitleDecoder#decode(byte[],int,boolean)(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, reset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Decodes data into a `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/Subtitle`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleDecoderException?` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SimpleSubtitleDecoder#decode(androidx.media3.extractor.text.SubtitleInputBuffer,androidx.media3.extractor.text.SubtitleOutputBuffer,boolean)( inputBuffer: https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleInputBuffer!, outputBuffer: https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleOutputBuffer!, reset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Decodes the `inputBuffer` and stores any decoded output in `outputBuffer`. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SimpleSubtitleDecoder#name()` |

### Inherited functions

From [androidx.media3.decoder.SimpleDecoder](https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder) `I?` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#dequeueInputBuffer()()`

Dequeues the next input buffer to be filled and queued to the decoder.
`O?` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#dequeueOutputBuffer()()`

Dequeues the next output buffer from the decoder.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#flush()()`

Flushes the decoder.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#isAtLeastOutputStartTimeUs(long)(timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

Returns whether a sample time is greater or equal to the `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#setOutputStartTimeUs(long)`, if set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#queueInputBuffer(I)(inputBuffer: I!)`

Queues an input buffer to the decoder.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper
https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#release()()`

Releases the decoder.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper
https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#releaseOutputBuffer(O)(outputBuffer: O!)`

Releases an output buffer back to the decoder.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#setCallback(androidx.media3.decoder.Decoder.Callback,java.util.concurrent.Executor)(callback: https://developer.android.com/reference/kotlin/androidx/media3/decoder/Decoder.Callback!, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html!)`

Sets the callback and executor.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#setInitialInputBufferSize(int)(size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Sets the initial size of each input buffer.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#setOutputStartTimeUs(long)(outputStartTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

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

## Protected constructors

### SimpleSubtitleDecoder

```
protected SimpleSubtitleDecoder(name: String!)
```

| Parameters |
|---|---|
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The name of the decoder. |

## Public functions

### setPositionUs

```
fun setPositionUs(positionUs: Long): Unit
```

Informs the decoder of the current playback position.

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

| Parameters |
|---|---|
| `positionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The current playback position in microseconds. |

## Protected functions

### createInputBuffer

```
protected fun createInputBuffer(): SubtitleInputBuffer!
```

Creates a new input buffer.

### createOutputBuffer

```
protected fun createOutputBuffer(): SubtitleOutputBuffer!
```

Creates a new output buffer.

### createUnexpectedDecodeException

```
protected fun createUnexpectedDecodeException(error: Throwable!): SubtitleDecoderException!
```

Creates an exception to propagate for an unexpected decode error.

| Parameters |
|---|---|
| `error: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!` | The unexpected decode error. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleDecoderException!` | The exception to propagate. |

### decode

```
protected abstract fun decode(data: ByteArray<Byte>!, length: Int, reset: Boolean): Subtitle!
```

Decodes data into a `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/Subtitle`.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | An array holding the data to be decoded, starting at position 0. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes from `data` to be decoded. |
| `reset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the decoder must be reset before decoding. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/Subtitle!` | The decoded `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/Subtitle`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleDecoderException` | If a decoding error occurs. |

### decode

```
protected fun decode(
    inputBuffer: SubtitleInputBuffer!,
    outputBuffer: SubtitleOutputBuffer!,
    reset: Boolean
): SubtitleDecoderException?
```

Decodes the `inputBuffer` and stores any decoded output in `outputBuffer`.

| Parameters |
|---|---|
| `inputBuffer: https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleInputBuffer!` | The buffer to decode. |
| `outputBuffer: https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleOutputBuffer!` | The output buffer to store decoded data. The output buffer will not be made available to dequeue if its `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderOutputBuffer#timeUs()` is not `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#isAtLeastOutputStartTimeUs(long)` or when it's marked with `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderOutputBuffer#shouldBeSkipped()`. The output buffer may not have been populated in these cases. |
| `reset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the decoder must be reset before decoding. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleDecoderException?` | A decoder exception if an error occurred, or null if decoding was successful. |

## Public properties

### name

```
val name: String!
```