# CodecSpecificDataUtil

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/util/CodecSpecificDataUtil.java+class:androidx.media3.common.util.CodecSpecificDataUtil)

*** ** * ** ***


```
@UnstableApi
class CodecSpecificDataUtil
```

<br />

*** ** * ** ***

Provides utilities for handling various types of codec-specific data.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil.MediaCodecProfileAndLevel` A tuple of profile and level constants for `https://developer.android.com/reference/android/media/MediaCodec.html`. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#HAGC_T35_HEADER_LENGTH()` The length in bytes of the ITU-T T.35 header that prefixes HAGC (ST 2094-50) metadata in AV1 OBUs, HEVC SEIs and container metadata. |

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#buildApvCodecString(byte[])(initializationData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Returns an APV codec string based on the provided initialization data. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#buildAvcCodecString(int,int,int)( profileIdc: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, constraintsFlagsAndReservedZero2Bits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, levelIdc: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Builds an RFC 6381 AVC codec string using the provided parameters. |
| `java-static (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#buildCea708InitializationData(boolean)(isWideAspectRatio: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Returns initialization data for formats with MIME type `https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes#APPLICATION_CEA708()`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#buildDolbyVisionCodecString(int,int)(profile: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, level: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Builds a Dolby Vision codec string using profile and level. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#buildDolbyVisionInitializationData(int,int)(profile: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, level: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns initialization data for Dolby Vision according to [Dolby Vision ISO MediaFormat (section 2.2) specification](https://dolby.my.salesforce.com/sfc/p/#700000009YuG/a/4u000000l6FB/076wHYEmyEfz09m0V1bo85_25hlUJjaiWTbzorNmYY4). |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#buildH263CodecString(int,int)(profile: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, level: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Builds an RFC 6381 H263 codec string using profile and level. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#buildHevcCodecString(int,boolean,int,int,int[],int)( generalProfileSpace: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, generalTierFlag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, generalProfileIdc: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, generalProfileCompatibilityFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, constraintBytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!, generalLevelIdc: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Builds an RFC 6381 HEVC codec string using the provided parameters. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#buildIamfCodecString(byte[])(initializationData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Builds an RFC 6381 IAMF codec string from the given `initializationData`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#buildNalUnit(byte[],int,int)(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Constructs a NAL unit consisting of the NAL start code followed by the specified data. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#buildVp9CodecPrivateFromUncompressedHeader(java.nio.ByteBuffer)(sample: https://developer.android.com/reference/java/nio/ByteBuffer.html!)` Builds VP9 CodecPrivate from the uncompressed header of the first frame. |
| `java-static https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#buildVp9CodecPrivateInitializationData(byte,byte,byte,byte)( profile: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html, level: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html, bitDepth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html, chromaSubsampling: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html )` Returns initialization data in CodecPrivate format of VP9. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#calculateMediaCodecDolbyVisionLevel(int,int,float)( width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, frameRate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Calculates the Dolby Vision level based on resolution and frame rate. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#dolbyVisionConstantToLevelNumber(int)(levelConstant: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns Dolby Vision level number corresponding to the level constant. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#dolbyVisionConstantToProfileNumber(int)(profileConstant: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns Dolby Vision profile number corresponding to the profile constant. |
| `java-static https://developer.android.com/reference/android/util/Pair.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#getCodecProfileAndLevel(androidx.media3.common.Format)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!)` Returns profile and level (as defined by `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html`) corresponding to the codec description string (as defined by RFC 6381) of the given format. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#getDolbyVisionBaseLayerMimeType(androidx.media3.common.Format)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!)` Returns a Dolby Vision base layer codec MIME type of the provided `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil.MediaCodecProfileAndLevel?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#getHevcProfileAndLevel(java.lang.String,java.lang.String[],androidx.media3.common.ColorInfo)( codec: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, parts: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!, colorInfo: https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo? )` Returns Hevc profile and level corresponding to the codec description string (as defined by RFC 6381) and it `https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil.MediaCodecProfileAndLevel?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#getMediaCodecProfileAndLevel(androidx.media3.common.Format)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!)` Returns the profile and level corresponding to the codec description string (as defined by RFC 6381) of the given format. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#getOpusInitializationData(androidx.media3.common.Format)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!)` Returns initialization data for Opus according to [RFC 7845: 5.1](https://tools.ietf.org/html/rfc7845#section-5.1). |
| `java-static https://developer.android.com/reference/android/util/Pair.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#getVideoResolutionFromMpeg4VideoConfig(byte[])( videoSpecificConfig: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>! )` Parses an MPEG-4 Visual configuration information, as defined in ISO/IEC14496-2. |
| `java-static https://developer.android.com/reference/java/nio/ByteBuffer.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#getVorbisInitializationData(androidx.media3.common.Format)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!)` Creates the Vorbis initialization data (CodecPrivate). |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#h263ConstToLevelNumber(int)(levelConst: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Maps Android MediaCodec constants to H.263 Level numbers. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#h263ConstToProfileNumber(int)(profileConst: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Maps Android MediaCodec constants to H.263 Profile numbers. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#isHagcMetadata(java.nio.ByteBuffer)(buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!)` Returns whether the given `https://developer.android.com/reference/java/nio/ByteBuffer.html` contains HAGC (ST 2094-50) ITU-T T.35 metadata, without consuming any bytes. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#isHagcMetadata(byte[],int)(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns whether the given `data` contains HAGC (ST 2094-50) ITU-T T.35 metadata. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#isHagcTrack(androidx.media3.common.Format)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!)` Returns whether the given `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` represents an HAGC (ST 2094-50) metadata track. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#isHdr10PlusMetadata(java.nio.ByteBuffer)(payload: https://developer.android.com/reference/java/nio/ByteBuffer.html!)` Returns whether the given `https://developer.android.com/reference/java/nio/ByteBuffer.html` contains HDR10+ metadata at the current position. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#isHdr10PlusMetadata(java.nio.ByteBuffer,int,int)(buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!, offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns whether the given `https://developer.android.com/reference/java/nio/ByteBuffer.html` contains HDR10+ metadata at the given offset. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#parseAlacAudioSpecificConfig(byte[])(audioSpecificConfig: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Parses an ALAC AudioSpecificConfig (i.e. an [ALACSpecificConfig](https://github.com/macosforge/alac/blob/master/ALACMagicCookieDescription.txt)). |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#parseCea708InitializationData(java.util.List<byte[]>)( initializationData: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!>! )` Returns whether the CEA-708 closed caption service with the given initialization data is formatted for displays with 16:9 aspect ratio. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!>?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#splitNalUnits(byte[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Splits an array of NAL units. |

## Constants

### HAGC_T35_HEADER_LENGTH

```
const val HAGC_T35_HEADER_LENGTH: Int
```

The length in bytes of the ITU-T T.35 header that prefixes HAGC (ST 2094-50) metadata in AV1 OBUs, HEVC SEIs and container metadata.

## Public functions

### buildApvCodecString

```
java-static fun buildApvCodecString(initializationData: ByteArray<Byte>!): String!
```

Returns an APV codec string based on the provided initialization data.

Reference: [Codecs Parameter in APV ISO Base Media File Format](https://github.com/AcademySoftwareFoundation/openapv/blob/main/readme/apv_isobmff.md#sub-parameters-for-the-mime-tyype-codecs-parameter)

| Parameters |
|---|---|
| `initializationData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The initialization data containing profile, level, and band information. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The generated APV codec string. |

### buildAvcCodecString

```
java-static fun buildAvcCodecString(
    profileIdc: Int,
    constraintsFlagsAndReservedZero2Bits: Int,
    levelIdc: Int
): String!
```

Builds an RFC 6381 AVC codec string using the provided parameters.

| Parameters |
|---|---|
| `profileIdc: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The encoding profile. |
| `constraintsFlagsAndReservedZero2Bits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The constraint flags followed by the reserved zero 2 bits, all contained in the least significant byte of the integer. |
| `levelIdc: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The encoding level. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | An RFC 6381 AVC codec string built using the provided parameters. |

### buildCea708InitializationData

```
java-static fun buildCea708InitializationData(isWideAspectRatio: Boolean): (Mutable)List<Array<Byte>!>!
```

Returns initialization data for formats with MIME type `https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes#APPLICATION_CEA708()`.

| Parameters |
|---|---|
| `isWideAspectRatio: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the CEA-708 closed caption service is formatted for displays with 16:9 aspect ratio. |

| Returns |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!>!` | Initialization data for formats with MIME type `https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes#APPLICATION_CEA708()`. |

### buildDolbyVisionCodecString

```
java-static fun buildDolbyVisionCodecString(profile: Int, level: Int): String!
```

Builds a Dolby Vision codec string using profile and level.

Reference: href="https://professionalsupport.dolby.com/s/article/What-is-Dolby-Vision-Profile?language=en_US", \>, Dolby Vision Profile and Level (section 2.3)

### buildDolbyVisionInitializationData

```
java-static fun buildDolbyVisionInitializationData(profile: Int, level: Int): Array<Byte>!
```

Returns initialization data for Dolby Vision according to [Dolby Vision ISO MediaFormat (section 2.2) specification](https://dolby.my.salesforce.com/sfc/p/#700000009YuG/a/4u000000l6FB/076wHYEmyEfz09m0V1bo85_25hlUJjaiWTbzorNmYY4).

| Parameters |
|---|---|
| `profile: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The Dolby Vision codec profile. This is the integer profile, not the `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html` constant. |
| `level: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The Dolby Vision codec level. This is the integer level, not the `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html` constant. |

### buildH263CodecString

```
java-static fun buildH263CodecString(profile: Int, level: Int): String!
```

Builds an RFC 6381 H263 codec string using profile and level.

### buildHevcCodecString

```
java-static fun buildHevcCodecString(
    generalProfileSpace: Int,
    generalTierFlag: Boolean,
    generalProfileIdc: Int,
    generalProfileCompatibilityFlags: Int,
    constraintBytes: IntArray<Int>!,
    generalLevelIdc: Int
): String!
```

Builds an RFC 6381 HEVC codec string using the provided parameters.

### buildIamfCodecString

```
java-static fun buildIamfCodecString(initializationData: ByteArray<Byte>!): String?
```

Builds an RFC 6381 IAMF codec string from the given `initializationData`.

The format is defined by the [IAMF Codec Parameters String](https://aomediacodec.github.io/iamf/#codecsparameter) specification.

### buildNalUnit

```
java-static fun buildNalUnit(data: ByteArray<Byte>!, offset: Int, length: Int): Array<Byte>!
```

Constructs a NAL unit consisting of the NAL start code followed by the specified data.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | An array containing the data that should follow the NAL start code. |
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The start offset into `data`. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes to copy from `data` |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The constructed NAL unit. |

### buildVp9CodecPrivateFromUncompressedHeader

```
java-static fun buildVp9CodecPrivateFromUncompressedHeader(sample: ByteBuffer!): Array<Byte>?
```

Builds VP9 CodecPrivate from the uncompressed header of the first frame.

This method parses the uncompressed header of the first frame to extract the VP9 profile, bit depth, and chroma subsampling.

Refer to [6.2 of the VP9 bitstream specification](https://storage.googleapis.com/downloads.webmproject.org/docs/vp9/vp9-bitstream-specification-v0.7-20170222-draft.pdf) and [VP9 in ISO Media File Format](https://www.webmproject.org/vp9/mp4/#Semantics) for more details.

| Parameters |
|---|---|
| `sample: https://developer.android.com/reference/java/nio/ByteBuffer.html!` | The first frame's data. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | The CodecPrivate data for VP9 if parsing is successful, `null` otherwise. |

### buildVp9CodecPrivateInitializationData

```
java-static fun buildVp9CodecPrivateInitializationData(
    profile: Byte,
    level: Byte,
    bitDepth: Byte,
    chromaSubsampling: Byte
): ImmutableList<Array<Byte>!>!
```

Returns initialization data in CodecPrivate format of VP9.

Each feature of VP9 CodecPrivate is defined by the binary format of ID (1 byte), length (1 byte), and data (1 byte). See href="https://www.webmproject.org/docs/container/#vp9-codec-feature-metadata-codecprivate", \>, CodecPrivate format of VP9 for more details.

| Parameters |
|---|---|
| `profile: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html` | The VP9 codec profile. |
| `level: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html` | The VP9 codec level. |
| `bitDepth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html` | The bit depth of the luma and color components. |
| `chromaSubsampling: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html` | The chroma subsampling. |

### calculateMediaCodecDolbyVisionLevel

```
java-static fun calculateMediaCodecDolbyVisionLevel(
    width: Int,
    height: Int,
    frameRate: Float
): Int
```

Calculates the Dolby Vision level based on resolution and frame rate.

Refer to [Dolby Vision profiles and levels](https://professionalsupport.dolby.com/s/article/What-is-Dolby-Vision-Profile) for more details.

| Parameters |
|---|---|
| `width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The video width in pixels. |
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The video height in pixels. |
| `frameRate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The video frame rate in frames per second. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The Android MediaCodec constants for the Dolby Vision level, or -1 if it could not be determined. |

### dolbyVisionConstantToLevelNumber

```
java-static fun dolbyVisionConstantToLevelNumber(levelConstant: Int): Int
```

Returns Dolby Vision level number corresponding to the level constant.

| Parameters |
|---|---|
| `levelConstant: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The Dolby Vision level constant. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The Dolby Vision level number. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the level constant is not recognized. |

### dolbyVisionConstantToProfileNumber

```
java-static fun dolbyVisionConstantToProfileNumber(profileConstant: Int): Int
```

Returns Dolby Vision profile number corresponding to the profile constant.

| Parameters |
|---|---|
| `profileConstant: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The Dolby Vision profile constant. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The Dolby Vision profile number. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the profile constant is not recognized. |

### getCodecProfileAndLevel

```
java-static fun getCodecProfileAndLevel(format: Format!): Pair<Int!, Int!>?
```

Returns profile and level (as defined by `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html`) corresponding to the codec description string (as defined by RFC 6381) of the given format.

Consider using `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil#getMediaCodecProfileAndLevel(androidx.media3.common.Format)` instead in order to distinguish between:

- The `format` doesn't contain profile and level info, or it is malformed.
- The `format` contains profile and level info, but it cannot be represented with constants from `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html`.

| Parameters |
|---|---|
| `format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | Media format with a codec description string, as defined by RFC 6381. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/util/Pair.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>?` | A pair (profile constant, level constant) if the codec of the `format` is well-formed and recognized, or null otherwise. |

### getDolbyVisionBaseLayerMimeType

```
java-static fun getDolbyVisionBaseLayerMimeType(format: Format!): String?
```

Returns a Dolby Vision base layer codec MIME type of the provided `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`.

| Parameters |
|---|---|
| `format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The media format. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | A Dolby Vision base layer MIME type, or `null` if a Dolby Vision profile is not identified. |

### getHevcProfileAndLevel

```
java-static fun getHevcProfileAndLevel(
    codec: String!,
    parts: Array<String!>!,
    colorInfo: ColorInfo?
): CodecSpecificDataUtil.MediaCodecProfileAndLevel?
```

Returns Hevc profile and level corresponding to the codec description string (as defined by RFC 6381) and it `https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo`.

| Parameters |
|---|---|
| `codec: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The codec description string (as defined by RFC 6381). |
| `parts: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | The codec string split by ".". |
| `colorInfo: https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo?` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil.MediaCodecProfileAndLevel?` | A pair (profile constant, level constant) if profile and level are recognized, or `null` otherwise. |

### getMediaCodecProfileAndLevel

```
java-static fun getMediaCodecProfileAndLevel(format: Format!): CodecSpecificDataUtil.MediaCodecProfileAndLevel?
```

Returns the profile and level corresponding to the codec description string (as defined by RFC 6381) of the given format.

| Parameters |
|---|---|
| `format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | Media format with a codec description string, as defined by RFC 6381. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil.MediaCodecProfileAndLevel?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/CodecSpecificDataUtil.MediaCodecProfileAndLevel` if the codec of the `format` is well-formed, or null otherwise. |

### getOpusInitializationData

```
java-static fun getOpusInitializationData(format: Format!): Array<Byte>!
```

Returns initialization data for Opus according to [RFC 7845: 5.1](https://tools.ietf.org/html/rfc7845#section-5.1).

| Parameters |
|---|---|
| `format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | A byte array containing the Opus initialization data. |

### getVideoResolutionFromMpeg4VideoConfig

```
java-static fun getVideoResolutionFromMpeg4VideoConfig(
    videoSpecificConfig: ByteArray<Byte>!
): Pair<Int!, Int!>!
```

Parses an MPEG-4 Visual configuration information, as defined in ISO/IEC14496-2.

| Parameters |
|---|---|
| `videoSpecificConfig: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | A byte array containing the MPEG-4 Visual configuration information to parse. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/util/Pair.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>!` | A pair of the video's width and height. |

### getVorbisInitializationData

```
java-static fun getVorbisInitializationData(format: Format!): ByteBuffer!
```

Creates the Vorbis initialization data (CodecPrivate).

The format is as follows:

- Byte 1: The number of packets minus one. This is 2 for Vorbis, representing the Identification, Comment, and Setup headers.
- Bytes 2..n: The lengths of the first two packets (Identification and Comment headers), encoded using Xiph lacing. The length of the final packet (Setup header) is not explicitly stored.
- Bytes n+1 onwards: The Vorbis identification header, Vorbis comment header and the codec setup header.

See [A_VORBIS](https://www.matroska.org/technical/codec_specs.html) for CodecPrivate format of Vorbis.

| Parameters |
|---|---|
| `format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/nio/ByteBuffer.html!` | A `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the assembled Vorbis CodecPrivate data. |

### h263ConstToLevelNumber

```
java-static fun h263ConstToLevelNumber(levelConst: Int): Int
```

Maps Android MediaCodec constants to H.263 Level numbers.

| Parameters |
|---|---|
| `levelConst: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The MediaCodec H.263 level constant. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The H.263 level number, or -1 if the constant is not recognized. |

### h263ConstToProfileNumber

```
java-static fun h263ConstToProfileNumber(profileConst: Int): Int
```

Maps Android MediaCodec constants to H.263 Profile numbers.

| Parameters |
|---|---|
| `profileConst: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The MediaCodec H.263 profile constant. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The H.263 profile number, or -1 if the constant is not recognized. |

### isHagcMetadata

```
java-static fun isHagcMetadata(buffer: ByteBuffer!): Boolean
```

Returns whether the given `https://developer.android.com/reference/java/nio/ByteBuffer.html` contains HAGC (ST 2094-50) ITU-T T.35 metadata, without consuming any bytes.

| Parameters |
|---|---|
| `buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!` | The payload data. |

### isHagcMetadata

```
java-static fun isHagcMetadata(data: ByteArray<Byte>!, length: Int): Boolean
```

Returns whether the given `data` contains HAGC (ST 2094-50) ITU-T T.35 metadata.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The payload data. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The length of the payload data. |

### isHagcTrack

```
java-static fun isHagcTrack(format: Format!): Boolean
```

Returns whether the given `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` represents an HAGC (ST 2094-50) metadata track.

| Parameters |
|---|---|
| `format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The format of the track. |

### isHdr10PlusMetadata

```
java-static fun isHdr10PlusMetadata(payload: ByteBuffer!): Boolean
```

Returns whether the given `https://developer.android.com/reference/java/nio/ByteBuffer.html` contains HDR10+ metadata at the current position.

| Parameters |
|---|---|
| `payload: https://developer.android.com/reference/java/nio/ByteBuffer.html!` | The `https://developer.android.com/reference/java/nio/ByteBuffer.html` to check. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the payload contains HDR10+ metadata. |

### isHdr10PlusMetadata

```
java-static fun isHdr10PlusMetadata(buffer: ByteBuffer!, offset: Int, limit: Int): Boolean
```

Returns whether the given `https://developer.android.com/reference/java/nio/ByteBuffer.html` contains HDR10+ metadata at the given offset.

| Parameters |
|---|---|
| `buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!` | The `https://developer.android.com/reference/java/nio/ByteBuffer.html` to check. |
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The offset in the buffer to start checking from. |
| `limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The limit in the buffer to stop checking at. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the payload contains HDR10+ metadata. |

### parseAlacAudioSpecificConfig

```
java-static fun parseAlacAudioSpecificConfig(audioSpecificConfig: ByteArray<Byte>!): Array<Int>!
```

Parses an ALAC AudioSpecificConfig (i.e. an [ALACSpecificConfig](https://github.com/macosforge/alac/blob/master/ALACMagicCookieDescription.txt)).

| Parameters |
|---|---|
| `audioSpecificConfig: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | A byte array containing the AudioSpecificConfig to parse. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | An int array consisting of the sample rate in Hz, the channel count and the bit depth. |

### parseCea708InitializationData

```
java-static fun parseCea708InitializationData(
    initializationData: (Mutable)List<ByteArray<Byte>!>!
): Boolean
```

Returns whether the CEA-708 closed caption service with the given initialization data is formatted for displays with 16:9 aspect ratio.

| Parameters |
|---|---|
| `initializationData: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!>!` | The initialization data to parse. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the CEA-708 closed caption service is formatted for displays with 16:9 aspect ratio. |

### splitNalUnits

```
java-static fun splitNalUnits(data: ByteArray<Byte>!): Array<Array<Byte>!>?
```

Splits an array of NAL units.

If the input consists of NAL start code delimited units, then the returned array consists of the split NAL units, each of which is still prefixed with the NAL start code. For any other input, null is returned.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | An array of data. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!>?` | The individual NAL units, or null if the input did not consist of NAL start code delimited units. |