SimpleDecoder
@UnstableApi
abstract class SimpleDecoder<I : DecoderInputBuffer?, O : DecoderOutputBuffer?, E : DecoderException?> : Decoder
BitmapFactoryImageDecoder |
An image decoder that uses |
SimpleSubtitleDecoder |
Base class for subtitle parsers that use their own decode thread. |
Base class for Decoders that use their own decode thread and decode each input buffer immediately into a corresponding output buffer.
Summary
Protected constructors |
|---|
SimpleDecoder(inputBuffers: Array<I!>!, outputBuffers: Array<O!>!) |
Public functions |
|
|---|---|
I? |
Dequeues the next input buffer to be filled and queued to the decoder. |
O? |
Dequeues the next output buffer from the decoder. |
Unit |
flush()Flushes the decoder. |
Unit |
queueInputBuffer(inputBuffer: I!)Queues an input buffer to the decoder. |
Unit |
Releases the decoder. |
Unit |
setOutputStartTimeUs(outputStartTimeUs: Long)Sets the timestamp from which output buffers should be produced, in microseconds. |
Protected functions |
|
|---|---|
abstract I! |
Creates a new input buffer. |
abstract O! |
Creates a new output buffer. |
abstract E! |
createUnexpectedDecodeException(error: Throwable!)Creates an exception to propagate for an unexpected decode error. |
abstract E? |
Decodes the |
Boolean |
isAtLeastOutputStartTimeUs(timeUs: Long)Returns whether a sample time is greater or equal to the |
Unit |
@CallSuperReleases an output buffer back to the decoder. |
Unit |
setInitialInputBufferSize(size: Int)Sets the initial size of each input buffer. |
Protected constructors
Public functions
dequeueInputBuffer
fun dequeueInputBuffer(): I?
Dequeues the next input buffer to be filled and queued to the decoder.
| Returns | |
|---|---|
I? |
The input buffer, which will have been cleared, or null if a buffer isn't available. |
| Throws | |
|---|---|
E |
If a decoder error has occurred. |
androidx.media3.decoder.SimpleDecoder |
dequeueOutputBuffer
fun dequeueOutputBuffer(): O?
Dequeues the next output buffer from the decoder.
| Returns | |
|---|---|
O? |
The output buffer, or null if an output buffer isn't available. |
| Throws | |
|---|---|
E |
If a decoder error has occurred. |
androidx.media3.decoder.SimpleDecoder |
flush
fun flush(): Unit
Flushes the decoder. Ownership of dequeued input buffers is returned to the decoder. The caller is still responsible for releasing any dequeued output buffers.
queueInputBuffer
fun queueInputBuffer(inputBuffer: I!): Unit
Queues an input buffer to the decoder.
| Parameters | |
|---|---|
inputBuffer: I! |
The input buffer. |
| Throws | |
|---|---|
E |
If a decoder error has occurred. |
androidx.media3.decoder.SimpleDecoder |
release
@CallSuper
fun release(): Unit
Releases the decoder. Must be called when the decoder is no longer needed.
setOutputStartTimeUs
fun setOutputStartTimeUs(outputStartTimeUs: Long): Unit
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 dequeueOutputBuffer.
This method must only be called before queuing the first input buffer initially or after flush.
| Parameters | |
|---|---|
outputStartTimeUs: Long |
The time from which output buffer should be produced, in microseconds. |
Protected functions
createUnexpectedDecodeException
protected abstract fun createUnexpectedDecodeException(error: Throwable!): E!
Creates an exception to propagate for an unexpected decode error.
| Parameters | |
|---|---|
error: Throwable! |
The unexpected decode error. |
| Returns | |
|---|---|
E! |
The exception to propagate. |
decode
protected abstract fun decode(inputBuffer: I!, outputBuffer: O!, reset: Boolean): E?
Decodes the inputBuffer and stores any decoded output in outputBuffer.
| Parameters | |
|---|---|
inputBuffer: I! |
The buffer to decode. |
outputBuffer: O! |
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 | |
|---|---|
E? |
A decoder exception if an error occurred, or null if decoding was successful. |
isAtLeastOutputStartTimeUs
protected fun isAtLeastOutputStartTimeUs(timeUs: Long): Boolean
Returns whether a sample time is greater or equal to the output start time, if set.
If this method returns false, the buffer will not be made available as an output buffer.
| Parameters | |
|---|---|
timeUs: Long |
The buffer time, in microseconds. |
| Returns | |
|---|---|
Boolean |
Whether the buffer time is greater or equal to the output start time, or |
releaseOutputBuffer
@CallSuper
protected fun releaseOutputBuffer(outputBuffer: O!): Unit
Releases an output buffer back to the decoder.
| Parameters | |
|---|---|
outputBuffer: O! |
The output buffer being released. |
setInitialInputBufferSize
protected fun setInitialInputBufferSize(size: Int): Unit
Sets the initial size of each input buffer.
This method should only be called before the decoder is used (i.e. before the first call to dequeueInputBuffer.
| Parameters | |
|---|---|
size: Int |
The required input buffer size. |