Package com.google.android.exoplayer2.ext.opus

## Class OpusDecoder

- java.lang.Object
- - com.google.android.exoplayer2.decoder.SimpleDecoder<DecoderInputBuffer,​SimpleOutputBuffer,​OpusDecoderException>
  - - com.google.android.exoplayer2.ext.opus.OpusDecoder

- All Implemented Interfaces:
    `Decoder<DecoderInputBuffer,​SimpleOutputBuffer,​OpusDecoderException>`

      public final class OpusDecoder
      extends SimpleDecoder<DecoderInputBuffer,​SimpleOutputBuffer,​OpusDecoderException>

  Opus decoder.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `int` | `channelCount` |
    `boolean` | `outputFloat` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `OpusDecoder​(int numInputBuffers, int numOutputBuffers, int initialInputBufferSize, List<byte[]> initializationData, ExoMediaCrypto exoMediaCrypto, boolean outputFloat)` | Creates an Opus decoder.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected DecoderInputBuffer` | `createInputBuffer()` | Creates a new input buffer.
    `protected SimpleOutputBuffer` | `createOutputBuffer()` | Creates a new output buffer.
    `protected OpusDecoderException` | `createUnexpectedDecodeException​(Throwable error)` | Creates an exception to propagate for an unexpected decode error.
    `protected OpusDecoderException` | `decode​(DecoderInputBuffer inputBuffer, SimpleOutputBuffer outputBuffer, boolean reset)` | Decodes the `inputBuffer` and stores any decoded output in `outputBuffer`.
    `String` | `getName()` | Returns the name of the decoder.
    `void` | `release()` | Releases the decoder.

    - ### Methods inherited from class com.google.android.exoplayer2.decoder.SimpleDecoder

      `dequeueInputBuffer, dequeueOutputBuffer, flush, queueInputBuffer, releaseOutputBuffer, setInitialInputBufferSize`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### outputFloat

          public final boolean outputFloat

    - #### channelCount

          public final int channelCount

  - ### Constructor Detail

    - #### OpusDecoder

          public OpusDecoder​(int numInputBuffers,
                             int numOutputBuffers,
                             int initialInputBufferSize,
                             List<byte[]> initializationData,
                             @Nullable
                             ExoMediaCrypto exoMediaCrypto,
                             boolean outputFloat)
                      throws OpusDecoderException

      Creates an Opus decoder.
      Parameters:
        `numInputBuffers` - The number of input buffers.
        `numOutputBuffers` - The number of output buffers.
        `initialInputBufferSize` - The initial size of each input buffer.
        `initializationData` - Codec-specific initialization data. The first element must contain an opus header. Optionally, the list may contain two additional buffers, which must contain the encoder delay and seek pre roll values in nanoseconds, encoded as longs.
        `exoMediaCrypto` - The `ExoMediaCrypto` object required for decoding encrypted content. Maybe null and can be ignored if decoder does not handle encrypted content.
        `outputFloat` - Forces the decoder to output float PCM samples when set
      Throws:
        `OpusDecoderException` - 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 DecoderInputBuffer createInputBuffer()

      Description copied from class: `SimpleDecoder`
      Creates a new input buffer.
      Specified by:
        `createInputBuffer` in class `SimpleDecoder<DecoderInputBuffer,​SimpleOutputBuffer,​OpusDecoderException>`

    - #### createOutputBuffer

          protected SimpleOutputBuffer createOutputBuffer()

      Description copied from class: `SimpleDecoder`
      Creates a new output buffer.
      Specified by:
        `createOutputBuffer` in class `SimpleDecoder<DecoderInputBuffer,​SimpleOutputBuffer,​OpusDecoderException>`

    - #### createUnexpectedDecodeException

          protected OpusDecoderException createUnexpectedDecodeException​(Throwable error)

      Description copied from class: `SimpleDecoder`
      Creates an exception to propagate for an unexpected decode error.
      Specified by:
        `createUnexpectedDecodeException` in class `SimpleDecoder<DecoderInputBuffer,​SimpleOutputBuffer,​OpusDecoderException>`
      Parameters:
        `error` - The unexpected decode error.
      Returns:
        The exception to propagate.

    - #### decode

          @Nullable
          protected OpusDecoderException decode​(DecoderInputBuffer inputBuffer,
                                                SimpleOutputBuffer outputBuffer,
                                                boolean reset)

      Description copied from class: `SimpleDecoder`
      Decodes the `inputBuffer` and stores any decoded output in `outputBuffer`.
      Specified by:
        `decode` in class `SimpleDecoder<DecoderInputBuffer,​SimpleOutputBuffer,​OpusDecoderException>`
      Parameters:
        `inputBuffer` - The buffer to decode.
        `outputBuffer` - The output buffer to store decoded data. The flag `C.BUFFER_FLAG_DECODE_ONLY` will be set if the same flag is set on `inputBuffer`, 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 interface `Decoder<DecoderInputBuffer,​SimpleOutputBuffer,​OpusDecoderException>`
      Overrides:
        `release` in class `SimpleDecoder<DecoderInputBuffer,​SimpleOutputBuffer,​OpusDecoderException>`