Package com.google.android.exoplayer2.mediacodec

## Class MediaFormatUtil

- java.lang.Object
- - com.google.android.exoplayer2.mediacodec.MediaFormatUtil

-     public final class MediaFormatUtil
      extends Object

  Helper class for configuring `MediaFormat` instances.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `maybeSetByteBuffer​(MediaFormat format, String key, byte[] value)` | Sets a `MediaFormat` `ByteBuffer` value.
    `static void` | `maybeSetColorInfo​(MediaFormat format, ColorInfo colorInfo)` | Sets a `MediaFormat`'s color information.
    `static void` | `maybeSetFloat​(MediaFormat format, String key, float value)` | Sets a `MediaFormat` float value.
    `static void` | `maybeSetInteger​(MediaFormat format, String key, int value)` | Sets a `MediaFormat` integer value.
    `static void` | `setCsdBuffers​(MediaFormat format, List<byte[]> csdBuffers)` | Sets a `MediaFormat`'s codec specific data buffers.
    `static void` | `setString​(MediaFormat format, String key, String value)` | Sets a `MediaFormat` `String` value.

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

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

- - ### Method Detail

    - #### setString

          public static void setString​(MediaFormat format,
                                       String key,
                                       String value)

      Sets a `MediaFormat` `String` value.
      Parameters:
        `format` - The `MediaFormat` being configured.
        `key` - The key to set.
        `value` - The value to set.

    - #### setCsdBuffers

          public static void setCsdBuffers​(MediaFormat format,
                                           List<byte[]> csdBuffers)

      Sets a `MediaFormat`'s codec specific data buffers.
      Parameters:
        `format` - The `MediaFormat` being configured.
        `csdBuffers` - The csd buffers to set.

    - #### maybeSetInteger

          public static void maybeSetInteger​(MediaFormat format,
                                             String key,
                                             int value)

      Sets a `MediaFormat` integer value. Does nothing if `value` is `Format.NO_VALUE`.
      Parameters:
        `format` - The `MediaFormat` being configured.
        `key` - The key to set.
        `value` - The value to set.

    - #### maybeSetFloat

          public static void maybeSetFloat​(MediaFormat format,
                                           String key,
                                           float value)

      Sets a `MediaFormat` float value. Does nothing if `value` is `Format.NO_VALUE`.
      Parameters:
        `format` - The `MediaFormat` being configured.
        `key` - The key to set.
        `value` - The value to set.

    - #### maybeSetByteBuffer

          public static void maybeSetByteBuffer​(MediaFormat format,
                                                String key,
                                                @Nullable
                                                byte[] value)

      Sets a `MediaFormat` `ByteBuffer` value. Does nothing if `value` is null.
      Parameters:
        `format` - The `MediaFormat` being configured.
        `key` - The key to set.
        `value` - The byte array that will be wrapped to obtain the value.

    - #### maybeSetColorInfo

          public static void maybeSetColorInfo​(MediaFormat format,
                                               @Nullable
                                               ColorInfo colorInfo)

      Sets a `MediaFormat`'s color information. Does nothing if `colorInfo` is null.
      Parameters:
        `format` - The `MediaFormat` being configured.
        `colorInfo` - The color info to set.