Class SimpleSubtitleDecoder
- java.lang.Object
-
- com.google.android.exoplayer2.decoder.SimpleDecoder<SubtitleInputBuffer,SubtitleOutputBuffer,SubtitleDecoderException>
-
- com.google.android.exoplayer2.text.SimpleSubtitleDecoder
-
- All Implemented Interfaces:
Decoder<SubtitleInputBuffer,SubtitleOutputBuffer,SubtitleDecoderException>
,SubtitleDecoder
- Direct Known Subclasses:
DvbDecoder
,Mp4WebvttDecoder
,PgsDecoder
,SsaDecoder
,SubripDecoder
,TtmlDecoder
,Tx3gDecoder
,WebvttDecoder
public abstract class SimpleSubtitleDecoder extends SimpleDecoder<SubtitleInputBuffer,SubtitleOutputBuffer,SubtitleDecoderException> implements SubtitleDecoder
Base class for subtitle parsers that use their own decode thread.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleSubtitleDecoder(String name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected SubtitleInputBuffer
createInputBuffer()
Creates a new input buffer.protected SubtitleOutputBuffer
createOutputBuffer()
Creates a new output buffer.protected SubtitleDecoderException
createUnexpectedDecodeException(Throwable error)
Creates an exception to propagate for an unexpected decode error.protected abstract Subtitle
decode(byte[] data, int size, boolean reset)
Decodes data into aSubtitle
.protected SubtitleDecoderException
decode(SubtitleInputBuffer inputBuffer, SubtitleOutputBuffer outputBuffer, boolean reset)
Decodes theinputBuffer
and stores any decoded output inoutputBuffer
.String
getName()
Returns the name of the decoder.void
setPositionUs(long positionUs)
Informs the decoder of the current playback position.-
Methods inherited from class com.google.android.exoplayer2.decoder.SimpleDecoder
dequeueInputBuffer, dequeueOutputBuffer, flush, queueInputBuffer, release, releaseOutputBuffer, setInitialInputBufferSize
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.android.exoplayer2.decoder.Decoder
dequeueInputBuffer, dequeueOutputBuffer, flush, queueInputBuffer, release
-
-
-
-
Constructor Detail
-
SimpleSubtitleDecoder
protected SimpleSubtitleDecoder(String name)
- Parameters:
name
- The name of the decoder.
-
-
Method Detail
-
getName
public final String getName()
Description copied from interface:Decoder
Returns the name of the decoder.- Specified by:
getName
in interfaceDecoder<SubtitleInputBuffer,SubtitleOutputBuffer,SubtitleDecoderException>
- Returns:
- The name of the decoder.
-
setPositionUs
public void setPositionUs(long positionUs)
Description copied from interface:SubtitleDecoder
Informs the decoder of the current playback position.Must be called prior to each attempt to dequeue output buffers from the decoder.
- Specified by:
setPositionUs
in interfaceSubtitleDecoder
- Parameters:
positionUs
- The current playback position in microseconds.
-
createInputBuffer
protected final SubtitleInputBuffer createInputBuffer()
Description copied from class:SimpleDecoder
Creates a new input buffer.- Specified by:
createInputBuffer
in classSimpleDecoder<SubtitleInputBuffer,SubtitleOutputBuffer,SubtitleDecoderException>
-
createOutputBuffer
protected final SubtitleOutputBuffer createOutputBuffer()
Description copied from class:SimpleDecoder
Creates a new output buffer.- Specified by:
createOutputBuffer
in classSimpleDecoder<SubtitleInputBuffer,SubtitleOutputBuffer,SubtitleDecoderException>
-
createUnexpectedDecodeException
protected final SubtitleDecoderException createUnexpectedDecodeException(Throwable error)
Description copied from class:SimpleDecoder
Creates an exception to propagate for an unexpected decode error.- Specified by:
createUnexpectedDecodeException
in classSimpleDecoder<SubtitleInputBuffer,SubtitleOutputBuffer,SubtitleDecoderException>
- Parameters:
error
- The unexpected decode error.- Returns:
- The exception to propagate.
-
decode
@Nullable protected final SubtitleDecoderException decode(SubtitleInputBuffer inputBuffer, SubtitleOutputBuffer outputBuffer, boolean reset)
Description copied from class:SimpleDecoder
Decodes theinputBuffer
and stores any decoded output inoutputBuffer
.- Specified by:
decode
in classSimpleDecoder<SubtitleInputBuffer,SubtitleOutputBuffer,SubtitleDecoderException>
- Parameters:
inputBuffer
- The buffer to decode.outputBuffer
- The output buffer to store decoded data. The flagC.BUFFER_FLAG_DECODE_ONLY
will be set if the same flag is set oninputBuffer
, but may be set/unset as required. If the flag is set when the call returns then the output buffer will not be made available to dequeue. The output buffer may not have been populated in this case.reset
- Whether the decoder must be reset before decoding.- Returns:
- A decoder exception if an error occurred, or null if decoding was successful.
-
decode
protected abstract Subtitle decode(byte[] data, int size, boolean reset) throws SubtitleDecoderException
Decodes data into aSubtitle
.- Parameters:
data
- An array holding the data to be decoded, starting at position 0.size
- The size of the data to be decoded.reset
- Whether the decoder must be reset before decoding.- Returns:
- The decoded
Subtitle
. - Throws:
SubtitleDecoderException
- If a decoding error occurs.
-
-