Class VpxDecoder
- java.lang.Object
-
- com.google.android.exoplayer2.decoder.SimpleDecoder<VideoDecoderInputBuffer,VideoDecoderOutputBuffer,VpxDecoderException>
-
- com.google.android.exoplayer2.ext.vp9.VpxDecoder
-
- All Implemented Interfaces:
Decoder<VideoDecoderInputBuffer,VideoDecoderOutputBuffer,VpxDecoderException>
public final class VpxDecoder extends SimpleDecoder<VideoDecoderInputBuffer,VideoDecoderOutputBuffer,VpxDecoderException>
Vpx decoder.
-
-
Constructor Summary
Constructors Constructor Description VpxDecoder(int numInputBuffers, int numOutputBuffers, int initialInputBufferSize, ExoMediaCrypto exoMediaCrypto, int threads)
Creates a VP9 decoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected VideoDecoderInputBuffer
createInputBuffer()
Creates a new input buffer.protected VideoDecoderOutputBuffer
createOutputBuffer()
Creates a new output buffer.protected VpxDecoderException
createUnexpectedDecodeException(Throwable error)
Creates an exception to propagate for an unexpected decode error.protected VpxDecoderException
decode(VideoDecoderInputBuffer inputBuffer, VideoDecoderOutputBuffer outputBuffer, boolean reset)
Decodes theinputBuffer
and stores any decoded output inoutputBuffer
.String
getName()
Returns the name of the decoder.void
release()
Releases the decoder.protected void
releaseOutputBuffer(VideoDecoderOutputBuffer buffer)
Releases an output buffer back to the decoder.void
renderToSurface(VideoDecoderOutputBuffer outputBuffer, Surface surface)
Renders the outputBuffer to the surface.void
setOutputMode(int outputMode)
Sets the output mode for frames rendered by the decoder.-
Methods inherited from class com.google.android.exoplayer2.decoder.SimpleDecoder
dequeueInputBuffer, dequeueOutputBuffer, flush, queueInputBuffer, setInitialInputBufferSize
-
-
-
-
Constructor Detail
-
VpxDecoder
public VpxDecoder(int numInputBuffers, int numOutputBuffers, int initialInputBufferSize, @Nullable ExoMediaCrypto exoMediaCrypto, int threads) throws VpxDecoderException
Creates a VP9 decoder.- Parameters:
numInputBuffers
- The number of input buffers.numOutputBuffers
- The number of output buffers.initialInputBufferSize
- The initial size of each input buffer.exoMediaCrypto
- TheExoMediaCrypto
object required for decoding encrypted content. Maybe null and can be ignored if decoder does not handle encrypted content.threads
- Number of threads libvpx will use to decode.- Throws:
VpxDecoderException
- Thrown if an exception occurs when initializing the decoder.
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:Decoder
Returns the name of the decoder.- Returns:
- The name of the decoder.
-
createInputBuffer
protected VideoDecoderInputBuffer createInputBuffer()
Description copied from class:SimpleDecoder
Creates a new input buffer.- Specified by:
createInputBuffer
in classSimpleDecoder<VideoDecoderInputBuffer,VideoDecoderOutputBuffer,VpxDecoderException>
-
createOutputBuffer
protected VideoDecoderOutputBuffer createOutputBuffer()
Description copied from class:SimpleDecoder
Creates a new output buffer.- Specified by:
createOutputBuffer
in classSimpleDecoder<VideoDecoderInputBuffer,VideoDecoderOutputBuffer,VpxDecoderException>
-
releaseOutputBuffer
protected void releaseOutputBuffer(VideoDecoderOutputBuffer buffer)
Description copied from class:SimpleDecoder
Releases an output buffer back to the decoder.- Overrides:
releaseOutputBuffer
in classSimpleDecoder<VideoDecoderInputBuffer,VideoDecoderOutputBuffer,VpxDecoderException>
- Parameters:
buffer
- The output buffer being released.
-
createUnexpectedDecodeException
protected VpxDecoderException createUnexpectedDecodeException(Throwable error)
Description copied from class:SimpleDecoder
Creates an exception to propagate for an unexpected decode error.- Specified by:
createUnexpectedDecodeException
in classSimpleDecoder<VideoDecoderInputBuffer,VideoDecoderOutputBuffer,VpxDecoderException>
- Parameters:
error
- The unexpected decode error.- Returns:
- The exception to propagate.
-
decode
@Nullable protected VpxDecoderException decode(VideoDecoderInputBuffer inputBuffer, VideoDecoderOutputBuffer outputBuffer, boolean reset)
Description copied from class:SimpleDecoder
Decodes theinputBuffer
and stores any decoded output inoutputBuffer
.- Specified by:
decode
in classSimpleDecoder<VideoDecoderInputBuffer,VideoDecoderOutputBuffer,VpxDecoderException>
- 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.
-
release
public void release()
Description copied from interface:Decoder
Releases the decoder. Must be called when the decoder is no longer needed.- Specified by:
release
in interfaceDecoder<VideoDecoderInputBuffer,VideoDecoderOutputBuffer,VpxDecoderException>
- Overrides:
release
in classSimpleDecoder<VideoDecoderInputBuffer,VideoDecoderOutputBuffer,VpxDecoderException>
-
setOutputMode
public void setOutputMode(@VideoOutputMode int outputMode)
Sets the output mode for frames rendered by the decoder.- Parameters:
outputMode
- The output mode.
-
renderToSurface
public void renderToSurface(VideoDecoderOutputBuffer outputBuffer, Surface surface) throws VpxDecoderException
Renders the outputBuffer to the surface. Used with OUTPUT_MODE_SURFACE_YUV only.- Throws:
VpxDecoderException
-
-