SimpleSubtitleDecoder
@UnstableApi
abstract class SimpleSubtitleDecoder : SimpleDecoder, SubtitleDecoder
| kotlin.Any | ||
| ↳ | androidx.media3.decoder.SimpleDecoder | |
| ↳ | androidx.media3.extractor.text.SimpleSubtitleDecoder |
Base class for subtitle parsers that use their own decode thread.
Summary
Protected constructors |
|---|
SimpleSubtitleDecoder(name: String!) |
Public functions |
|
|---|---|
Unit |
setPositionUs(positionUs: Long)Informs the decoder of the current playback position. |
Protected functions |
|
|---|---|
SubtitleInputBuffer! |
Creates a new input buffer. |
SubtitleOutputBuffer! |
Creates a new output buffer. |
SubtitleDecoderException! |
createUnexpectedDecodeException(error: Throwable!)Creates an exception to propagate for an unexpected decode error. |
abstract Subtitle! |
Decodes data into a |
SubtitleDecoderException? |
decode(Decodes the |
Inherited functions |
||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Protected constructors
SimpleSubtitleDecoder
protected SimpleSubtitleDecoder(name: String!)
| Parameters | |
|---|---|
name: String! |
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: Long |
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: Throwable! |
The unexpected decode error. |
| Returns | |
|---|---|
SubtitleDecoderException! |
The exception to propagate. |
decode
protected abstract fun decode(data: ByteArray!, length: Int, reset: Boolean): Subtitle!
Decodes data into a Subtitle.
| Parameters | |
|---|---|
data: ByteArray! |
An array holding the data to be decoded, starting at position 0. |
length: Int |
The number of bytes from |
reset: Boolean |
Whether the decoder must be reset before decoding. |
| Throws | |
|---|---|
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: SubtitleInputBuffer! |
The buffer to decode. |
outputBuffer: SubtitleOutputBuffer! |
The output buffer to store decoded data. The output buffer will not be made available to dequeue if its |
reset: Boolean |
Whether the decoder must be reset before decoding. |
| Returns | |
|---|---|
SubtitleDecoderException? |
A decoder exception if an error occurred, or null if decoding was successful. |