Package com.google.android.exoplayer2.audio

## Class OpusUtil

- java.lang.Object
- - com.google.android.exoplayer2.audio.OpusUtil

-     public class OpusUtil
      extends Object

  Utility methods for handling Opus audio streams.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `SAMPLE_RATE` | Opus streams are always 48000 Hz.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static List<byte[]>` | `buildInitializationData​(byte[] header)` | Builds codec initialization data from an Opus Identification Header.
    `static int` | `getChannelCount​(byte[] header)` | Parses the channel count from an Opus Identification Header.
    `static int` | `getPreSkipSamples​(List<byte[]> initializationData)` | Returns the number of pre-skip samples specified by the given Opus codec initialization data.
    `static int` | `getSeekPreRollSamples​(List<byte[]> initializationData)` | Returns the number of seek per-roll samples specified by the given Opus codec initialization data.

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

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

- - ### Field Detail

    - #### SAMPLE_RATE

          public static final int SAMPLE_RATE

      Opus streams are always 48000 Hz.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getChannelCount

          public static int getChannelCount​(byte[] header)

      Parses the channel count from an Opus Identification Header.
      Parameters:
        `header` - An Opus Identification Header, as defined by RFC 7845.
      Returns:
        The parsed channel count.

    - #### buildInitializationData

          public static List<byte[]> buildInitializationData​(byte[] header)

      Builds codec initialization data from an Opus Identification Header.
      Parameters:
        `header` - An Opus Identification Header, as defined by RFC 7845.
      Returns:
        Codec initialization data suitable for an Opus MediaCodec.

    - #### getPreSkipSamples

          public static int getPreSkipSamples​(List<byte[]> initializationData)

      Returns the number of pre-skip samples specified by the given Opus codec initialization data.
      Parameters:
        `initializationData` - The codec initialization data.
      Returns:
        The number of pre-skip samples.

    - #### getSeekPreRollSamples

          public static int getSeekPreRollSamples​(List<byte[]> initializationData)

      Returns the number of seek per-roll samples specified by the given Opus codec initialization data.
      Parameters:
        `initializationData` - The codec initialization data.
      Returns:
        The number of seek pre-roll samples.