# IamfUtil

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

*** ** * ** ***


```
@UnstableApi
class IamfUtil
```

<br />

*** ** * ** ***

Constants and utils for configuring IAMF decoding.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil.OutputLayout` Represents the different output sound systems supported by IAMF. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 32) https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#CHANNEL_OUT_ITU_2051_SOUND_SYSTEM_H_9_10_3() = 67108860` |
| `const https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableSet.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>!` | `@https://developer.android.com/reference/kotlin/androidx/annotation/VisibleForTesting https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#IAMF_SUPPORTED_CHANNEL_MASKS()` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_BINAURAL() = 14` Decoder rendered binaural audio. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_0_1_0() = 12` Mono. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_2_3_0() = 11` IAMF extension 3.1.2. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_2_7_0() = 10` IAMF extension 7.1.2. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_6_9_0() = 13` IAMF Extension 9.1.6. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_A_0_2_0() = 0` ITU-R B.S. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_B_0_5_0() = 1` ITU-R B.S. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_C_2_5_0() = 2` ITU-R B.S. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_D_4_5_0() = 3` ITU-R B.S. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_E_4_5_1() = 4` ITU-R B.S. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_F_3_7_0() = 5` ITU-R B.S. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_G_4_9_0() = 6` ITU-R B.S. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_H_9_10_3() = 7` ITU-R B.S. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_I_0_7_0() = 8` ITU-R B.S. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_J_4_7_0() = 9` ITU-R B.S. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_UNSET() = -1` Value to be used to not specify an output layout. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#REQUESTED_MIX_PRESENTATION_ID_UNSET() = -1` Used to indicate no requested Mix Presentation ID when creating a decoder. |

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#getChannelMaskForOutputLayout(int)(@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil.OutputLayout outputLayout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the Android channel mask that most closely matches the given IAMF output layout. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#getOutputChannelMaskForCurrentConfiguration(androidx.media3.exoplayer.audio.AudioCapabilities)( audioCapabilities: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioCapabilities! )` Returns an appropriate channel mask for the current `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioCapabilities`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil.OutputLayout https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#getOutputLayoutForChannelMask(int)(channelMask: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns an IAMF output layout to try to match a given channel mask. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil.OutputLayout https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#getOutputLayoutForCurrentConfiguration(androidx.media3.exoplayer.audio.AudioCapabilities,boolean)( audioCapabilities: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioCapabilities!, useIntegratedBinauralRenderer: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Returns an appropriate output layout for the current `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioCapabilities`. |

## Constants

### CHANNEL_OUT_ITU_2051_SOUND_SYSTEM_H_9_10_3

```
@RequiresApi(value = 32)
const val CHANNEL_OUT_ITU_2051_SOUND_SYSTEM_H_9_10_3 = 67108860: Int
```

### IAMF_SUPPORTED_CHANNEL_MASKS

```
@VisibleForTesting
const val IAMF_SUPPORTED_CHANNEL_MASKS: ImmutableSet<Int!>!
```

### OUTPUT_LAYOUT_BINAURAL

```
const val OUTPUT_LAYOUT_BINAURAL = 14: Int
```

Decoder rendered binaural audio.

### OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_0_1_0

```
const val OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_0_1_0 = 12: Int
```

Mono.

### OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_2_3_0

```
const val OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_2_3_0 = 11: Int
```

IAMF extension 3.1.2.

### OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_2_7_0

```
const val OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_2_7_0 = 10: Int
```

IAMF extension 7.1.2.

### OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_6_9_0

```
const val OUTPUT_LAYOUT_IAMF_SOUND_SYSTEM_EXTENSION_6_9_0 = 13: Int
```

IAMF Extension 9.1.6.

### OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_A_0_2_0

```
const val OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_A_0_2_0 = 0: Int
```

ITU-R B.S. 2051-3 sound system A (0+2+0), commonly known as stereo.

### OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_B_0_5_0

```
const val OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_B_0_5_0 = 1: Int
```

ITU-R B.S. 2051-3 sound system B (0+5+0), commonly known as 5.1.

### OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_C_2_5_0

```
const val OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_C_2_5_0 = 2: Int
```

ITU-R B.S. 2051-3 sound system C (2+5+0), commonly known as 5.1.2.

### OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_D_4_5_0

```
const val OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_D_4_5_0 = 3: Int
```

ITU-R B.S. 2051-3 sound system D (4+5+0), commonly known as 5.1.4.

### OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_E_4_5_1

```
const val OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_E_4_5_1 = 4: Int
```

ITU-R B.S. 2051-3 sound system E (4+5+1).

### OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_F_3_7_0

```
const val OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_F_3_7_0 = 5: Int
```

ITU-R B.S. 2051-3 sound system F (3+7+0).

### OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_G_4_9_0

```
const val OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_G_4_9_0 = 6: Int
```

ITU-R B.S. 2051-3 sound system G (4+9+0).

### OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_H_9_10_3

```
const val OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_H_9_10_3 = 7: Int
```

ITU-R B.S. 2051-3 sound system H (9+10+3).

### OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_I_0_7_0

```
const val OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_I_0_7_0 = 8: Int
```

ITU-R B.S. 2051-3 sound system I (0+7+0), commonly known as 7.1.

### OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_J_4_7_0

```
const val OUTPUT_LAYOUT_ITU2051_SOUND_SYSTEM_J_4_7_0 = 9: Int
```

ITU-R B.S. 2051-3 sound system J (4+7+0), commonly known as 7.1.4.

### OUTPUT_LAYOUT_UNSET

```
const val OUTPUT_LAYOUT_UNSET = -1: Int
```

Value to be used to not specify an output layout.

### REQUESTED_MIX_PRESENTATION_ID_UNSET

```
const val REQUESTED_MIX_PRESENTATION_ID_UNSET = -1: Long
```

Used to indicate no requested Mix Presentation ID when creating a decoder.

When this value is used, the decoder will select a Mix Presentation ID based on the default logic, including considering the requested OutputLayout, if provided.

## Public functions

### getChannelMaskForOutputLayout

```
java-static fun getChannelMaskForOutputLayout(@IamfUtil.OutputLayout outputLayout: Int): Int
```

Returns the Android channel mask that most closely matches the given IAMF output layout.

Some AudioFormat-defined channel masks do not exactly match IAMF/ITU spec. Where there are differences, this method returns the more exact IAMF version.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | for invalid values of OutputLayout or OUTPUT_LAYOUT_UNSET. |

### getOutputChannelMaskForCurrentConfiguration

```
java-static fun getOutputChannelMaskForCurrentConfiguration(
    audioCapabilities: AudioCapabilities!
): Int
```

Returns an appropriate channel mask for the current `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioCapabilities`.

This is used to set the channel count and channel mask when using the framework Codec2 software decoder, which takes a ChannelMask to indicate the output layout and does not currently support direct binaural output from the decoder.

### getOutputLayoutForChannelMask

```
@IamfUtil.OutputLayout
java-static fun getOutputLayoutForChannelMask(channelMask: Int): Int
```

Returns an IAMF output layout to try to match a given channel mask.

Where there are differences between the placement of speakers as defined by AudioFormat channel masks and channel masks matching the IAMF/ITU standard, we permissively match both.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the channelMask has no matching IAMF output layout. |

### getOutputLayoutForCurrentConfiguration

```
@IamfUtil.OutputLayout
java-static fun getOutputLayoutForCurrentConfiguration(
    audioCapabilities: AudioCapabilities!,
    useIntegratedBinauralRenderer: Boolean
): Int
```

Returns an appropriate output layout for the current `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioCapabilities`.

This is used to configure the IAMF extension decoder, which requires an `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil.OutputLayout` to configure.

| Parameters |
|---|---|
| `audioCapabilities: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioCapabilities!` | The current `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioCapabilities`. |
| `useIntegratedBinauralRenderer: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | When it seems the user is using headphones (because `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioCapabilities#getSpatializerChannelMasks()` is non-empty), if ` useIntegratedBinauralRenderer` is `true`, this method will return `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/IamfUtil#OUTPUT_LAYOUT_BINAURAL()` to get binaural audio directly from the decoder, otherwise, it will return an output layout appropriate for the `https://developer.android.com/reference/android/media/Spatializer.html` based on the available Spatializer channel masks. |