SimpleSubtitleDecoder
@UnstableApi
public abstract class SimpleSubtitleDecoder extends SimpleDecoder implements SubtitleDecoder
| java.lang.Object | ||
| ↳ | androidx.media3.decoder.SimpleDecoder | |
| ↳ | androidx.media3.extractor.text.SimpleSubtitleDecoder |
Base class for subtitle parsers that use their own decode thread.
Summary
Protected constructors |
|---|
SimpleSubtitleDecoder(String name) |
Public methods |
|
|---|---|
final String |
getName()Returns the name of the decoder. |
void |
setPositionUs(long positionUs)Informs the decoder of the current playback position. |
Protected methods |
|
|---|---|
final SubtitleInputBuffer |
Creates a new input buffer. |
final SubtitleOutputBuffer |
Creates a new output buffer. |
final SubtitleDecoderException |
Creates an exception to propagate for an unexpected decode error. |
abstract Subtitle |
decode(byte[] data, int length, boolean reset)Decodes data into a |
final @Nullable SubtitleDecoderException |
decode(Decodes the |
Inherited methods |
||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Protected constructors
SimpleSubtitleDecoder
protected SimpleSubtitleDecoder(String name)
| Parameters | |
|---|---|
String name |
The name of the decoder. |
Public methods
getName
public final String getName()
Returns the name of the decoder.
| Returns | |
|---|---|
String |
The name of the decoder. |
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
createInputBuffer
protected final SubtitleInputBuffer createInputBuffer()
Creates a new input buffer.
createOutputBuffer
protected final SubtitleOutputBuffer createOutputBuffer()
Creates a new output buffer.
createUnexpectedDecodeException
protected final SubtitleDecoderException createUnexpectedDecodeException(Throwable error)
Creates an exception to propagate for an unexpected decode error.
| Parameters | |
|---|---|
Throwable error |
The unexpected decode error. |
| Returns | |
|---|---|
SubtitleDecoderException |
The exception to propagate. |
decode
protected abstract Subtitle decode(byte[] data, int length, boolean reset)
Decodes data into a Subtitle.
| Parameters | |
|---|---|
byte[] data |
An array holding the data to be decoded, starting at position 0. |
int length |
The number of bytes from |
boolean reset |
Whether the decoder must be reset before decoding. |
| Throws | |
|---|---|
androidx.media3.extractor.text.SubtitleDecoderException |
If a decoding error occurs. |
decode
protected final @Nullable SubtitleDecoderException decode(
SubtitleInputBuffer inputBuffer,
SubtitleOutputBuffer outputBuffer,
boolean reset
)
Decodes the inputBuffer and stores any decoded output in outputBuffer.
| Parameters | |
|---|---|
SubtitleInputBuffer inputBuffer |
The buffer to decode. |
SubtitleOutputBuffer outputBuffer |
The output buffer to store decoded data. The output buffer will not be made available to dequeue if its |
boolean reset |
Whether the decoder must be reset before decoding. |
| Returns | |
|---|---|
@Nullable SubtitleDecoderException |
A decoder exception if an error occurred, or null if decoding was successful. |