# MediaCodecUtil

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/mediacodec/MediaCodecUtil.java+class:androidx.media3.exoplayer.mediacodec.MediaCodecUtil)

*** ** * ** ***


```
@UnstableApi
public final class MediaCodecUtil
```

<br />

*** ** * ** ***

A utility class for querying the available codecs.

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException extends https://developer.android.com/reference/java/lang/Exception.html` Thrown when an error occurs querying the device for its underlying media capabilities. |

| ### Public methods |
|---|---|
| `synchronized static void` | `@https://developer.android.com/reference/androidx/annotation/VisibleForTesting https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#clearDecoderInfoCache()()` |
| `static https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#createCodecProfileLevel(int,int)(int profile, int level)` Returns a `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html` configured with the provided `profile` and ` level`. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getAlternativeCodecMimeType(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Returns an alternative codec MIME type (besides the default `https://developer.android.com/reference/androidx/media3/common/Format#sampleMimeType()`) that can be used to decode samples of the provided `https://developer.android.com/reference/androidx/media3/common/Format`. |
| `static https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getAlternativeDecoderInfos(androidx.media3.exoplayer.mediacodec.MediaCodecSelector,androidx.media3.common.Format,boolean,boolean)( https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector mediaCodecSelector, https://developer.android.com/reference/androidx/media3/common/Format format, boolean requiresSecureDecoder, boolean requiresTunnelingDecoder )` Returns a list of decoders for `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getAlternativeCodecMimeType(androidx.media3.common.Format)` that can decode samples of the provided `https://developer.android.com/reference/androidx/media3/common/Format`, in the priority order specified by the `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector`. |
| `static https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getAlternativeDecoderInfosFilteredByFormatSupport(android.content.Context,androidx.media3.exoplayer.mediacodec.MediaCodecSelector,androidx.media3.common.Format,boolean,boolean)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector mediaCodecSelector, https://developer.android.com/reference/androidx/media3/common/Format format, boolean requiresSecureDecoder, boolean requiresTunnelingDecoder )` Returns a list of decoders for `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getAlternativeCodecMimeType(androidx.media3.common.Format)` that can decode samples of the provided `https://developer.android.com/reference/androidx/media3/common/Format`, in the priority order specified by the `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector`. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/java/lang/Integer.html, https://developer.android.com/reference/java/lang/Integer.html>` | `@https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "CodecSpecificDataUtil.getCodecProfileAndLevel(format)", imports = [""androidx.media3.common.util.CodecSpecificDataUtil""]) [getCodecProfileAndLevel](https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getCodecProfileAndLevel(androidx.media3.common.Format))(https://developer.android.com/reference/androidx/media3/common/Format format)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/util/CodecSpecificDataUtil#getCodecProfileAndLevel(androidx.media3.common.Format)`. <br /> |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfo(java.lang.String,boolean,boolean)(https://developer.android.com/reference/java/lang/String.html mimeType, boolean secure, boolean tunneling)` Returns information about the preferred decoder for a given MIME type. |
| `synchronized static https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfos(java.lang.String,boolean,boolean)(https://developer.android.com/reference/java/lang/String.html mimeType, boolean secure, boolean tunneling)` Returns all `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo`s for the given MIME type, in the order given by `https://developer.android.com/reference/android/media/MediaCodecList.html`. |
| `static https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/RequiresNonNull.html(value = "#2.sampleMimeType") https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfosSoftMatch(androidx.media3.exoplayer.mediacodec.MediaCodecSelector,androidx.media3.common.Format,boolean,boolean)( https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector mediaCodecSelector, https://developer.android.com/reference/androidx/media3/common/Format format, boolean requiresSecureDecoder, boolean requiresTunnelingDecoder )` Returns a list of decoders that can decode media in the specified format, in the priority order specified by the `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector`. |
| `static https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/RequiresNonNull.html(value = "#3.sampleMimeType") https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfosSoftMatchFilteredByFormatSupport(android.content.Context,androidx.media3.exoplayer.mediacodec.MediaCodecSelector,androidx.media3.common.Format,boolean,boolean)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector mediaCodecSelector, https://developer.android.com/reference/androidx/media3/common/Format format, boolean requiresSecureDecoder, boolean requiresTunnelingDecoder )` Returns a list of decoders that can decode media in the specified format, in the priority order specified by the `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector`. |
| `static https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfosSortedByFormatSupport(android.content.Context,java.util.List<androidx.media3.exoplayer.mediacodec.MediaCodecInfo>,androidx.media3.common.Format)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo> decoderInfos, https://developer.android.com/reference/androidx/media3/common/Format format )` Returns a copy of the provided decoder list sorted such that decoders with functional format support are listed first. |
| `static https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfosSortedByFullFormatSupport(android.content.Context,java.util.List<androidx.media3.exoplayer.mediacodec.MediaCodecInfo>,androidx.media3.common.Format)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo> decoderInfos, https://developer.android.com/reference/androidx/media3/common/Format format )` Returns a copy of the provided decoder list sorted such that decoders with complete format support are listed first. |
| `static https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfosSortedBySoftwareOnly(java.util.List<androidx.media3.exoplayer.mediacodec.MediaCodecInfo>)(https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo> decoderInfos)` Returns a copy of the provided decoder list sorted such that software decoders are listed first. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecryptOnlyDecoderInfo()()` Returns information about a decoder that will only decrypt data, without decoding it. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/util/CodecSpecificDataUtil.MediaCodecProfileAndLevel` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getHevcBaseLayerCodecProfileAndLevel(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Returns profile and level (as defined by `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html`) corresponding to the base layer (for the case of falling back to single-layer HEVC from L-HEVC). |
| `static int` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#maxH264DecodableFrameSize()()` Returns the maximum frame size supported by the default H264 decoder. |
| `static void` | `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#warmDecoderInfoCache(java.lang.String,boolean,boolean)(https://developer.android.com/reference/java/lang/String.html mimeType, boolean secure, boolean tunneling)` Optional call to warm the codec cache for a given MIME type. |

## Public methods

### clearDecoderInfoCache

```
@VisibleForTesting
synchronized public static void clearDecoderInfoCache()
```

### createCodecProfileLevel

```
@UnstableApi
public static MediaCodecInfo.CodecProfileLevel createCodecProfileLevel(int profile, int level)
```

Returns a `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html` configured with the provided `profile` and `
level`.

### getAlternativeCodecMimeType

```
public static @Nullable String getAlternativeCodecMimeType(Format format)
```

Returns an alternative codec MIME type (besides the default `https://developer.android.com/reference/androidx/media3/common/Format#sampleMimeType()`) that can be used to decode samples of the provided `https://developer.android.com/reference/androidx/media3/common/Format`.

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | An alternative MIME type of a codec that be used decode samples of the provided ` Format` (besides the default `https://developer.android.com/reference/androidx/media3/common/Format#sampleMimeType()`), or null if no such alternative exists. |

### getAlternativeDecoderInfos

```
public static List<MediaCodecInfo> getAlternativeDecoderInfos(
    MediaCodecSelector mediaCodecSelector,
    Format format,
    boolean requiresSecureDecoder,
    boolean requiresTunnelingDecoder
)
```

Returns a list of decoders for `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getAlternativeCodecMimeType(androidx.media3.common.Format)` that can decode samples of the provided `https://developer.android.com/reference/androidx/media3/common/Format`, in the priority order specified by the `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector`.

Since the `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector` only has access to `https://developer.android.com/reference/androidx/media3/common/Format#sampleMimeType()`, the list is not ordered to account for whether each decoder supports the details of the format (e.g., taking into account the format's profile, level, resolution and so on). `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfosSortedByFormatSupport(android.content.Context,java.util.List<androidx.media3.exoplayer.mediacodec.MediaCodecInfo>,androidx.media3.common.Format)` can be used to further sort the list into an order where decoders that fully support the format come first.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector mediaCodecSelector` | The decoder selector. |
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The `https://developer.android.com/reference/androidx/media3/common/Format` for which an alternative decoder is required. |
| `boolean requiresSecureDecoder` | Whether a secure decoder is required. |
| `boolean requiresTunnelingDecoder` | Whether a tunneling decoder is required. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | A list of `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo`s corresponding to alternative decoders. May be empty. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException` | Thrown if there was an error querying decoders. |

### getAlternativeDecoderInfosFilteredByFormatSupport

```
public static List<MediaCodecInfo> getAlternativeDecoderInfosFilteredByFormatSupport(
    Context context,
    MediaCodecSelector mediaCodecSelector,
    Format format,
    boolean requiresSecureDecoder,
    boolean requiresTunnelingDecoder
)
```

Returns a list of decoders for `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getAlternativeCodecMimeType(androidx.media3.common.Format)` that can decode samples of the provided `https://developer.android.com/reference/androidx/media3/common/Format`, in the priority order specified by the `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector`. Unlike `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getAlternativeDecoderInfos(androidx.media3.exoplayer.mediacodec.MediaCodecSelector,androidx.media3.common.Format,boolean,boolean)`, this method excludes decoders that do not support relevant format details.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The application context. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector mediaCodecSelector` | The decoder selector. |
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The `https://developer.android.com/reference/androidx/media3/common/Format` for which an alternative decoder is required. |
| `boolean requiresSecureDecoder` | Whether a secure decoder is required. |
| `boolean requiresTunnelingDecoder` | Whether a tunneling decoder is required. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | A list of `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo`s corresponding to alternative decoders. May be empty. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException` | Thrown if there was an error querying decoders. |

### getCodecProfileAndLevel

```
@InlineMe(replacement = "CodecSpecificDataUtil.getCodecProfileAndLevel(format)", imports = [""androidx.media3.common.util.CodecSpecificDataUtil""])
public static @Nullable Pair<Integer, Integer> [getCodecProfileAndLevel](https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getCodecProfileAndLevel(androidx.media3.common.Format))(Format format)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/util/CodecSpecificDataUtil#getCodecProfileAndLevel(androidx.media3.common.Format)`.

### getDecoderInfo

```
public static @Nullable MediaCodecInfo getDecoderInfo(String mimeType, boolean secure, boolean tunneling)
```

Returns information about the preferred decoder for a given MIME type.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html mimeType` | The MIME type. |
| `boolean secure` | Whether the decoder is required to support secure decryption. Always pass false unless secure decryption really is required. |
| `boolean tunneling` | Whether the decoder is required to support tunneling. Always pass false unless tunneling really is required. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo` | A `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo` describing the decoder, or null if no suitable decoder exists. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException` | If there was an error querying the available decoders. |

### getDecoderInfos

```
synchronized public static List<MediaCodecInfo> getDecoderInfos(String mimeType, boolean secure, boolean tunneling)
```

Returns all `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo`s for the given MIME type, in the order given by `https://developer.android.com/reference/android/media/MediaCodecList.html`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html mimeType` | The MIME type. |
| `boolean secure` | Whether the decoder is required to support secure decryption. Always pass false unless secure decryption really is required. |
| `boolean tunneling` | Whether the decoder is required to support tunneling. Always pass false unless tunneling really is required. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | An unmodifiable list of all `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo`s for the given MIME type, in the order given by `https://developer.android.com/reference/android/media/MediaCodecList.html`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException` | If there was an error querying the available decoders. |

### getDecoderInfosSoftMatch

```
@RequiresNonNull(value = "#2.sampleMimeType")
public static List<MediaCodecInfo> getDecoderInfosSoftMatch(
    MediaCodecSelector mediaCodecSelector,
    Format format,
    boolean requiresSecureDecoder,
    boolean requiresTunnelingDecoder
)
```

Returns a list of decoders that can decode media in the specified format, in the priority order specified by the `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector`.

Since the `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector` only has access to `https://developer.android.com/reference/androidx/media3/common/Format#sampleMimeType()`, the list is not ordered to account for whether each decoder supports the details of the format (e.g., taking into account the format's profile, level, resolution and so on). `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfosSortedByFormatSupport(android.content.Context,java.util.List<androidx.media3.exoplayer.mediacodec.MediaCodecInfo>,androidx.media3.common.Format)` can be used to further sort the list into an order where decoders that fully support the format come first.

This list is more complete than `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfos(java.lang.String,boolean,boolean)`, as it also considers alternative MIME types that are a close match using `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getAlternativeCodecMimeType(androidx.media3.common.Format)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector mediaCodecSelector` | The decoder selector. |
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The `https://developer.android.com/reference/androidx/media3/common/Format` for which a decoder is required. |
| `boolean requiresSecureDecoder` | Whether a secure decoder is required. |
| `boolean requiresTunnelingDecoder` | Whether a tunneling decoder is required. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | A list of `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo`s corresponding to decoders. May be empty. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException` | Thrown if there was an error querying decoders. |

### getDecoderInfosSoftMatchFilteredByFormatSupport

```
@RequiresNonNull(value = "#3.sampleMimeType")
public static List<MediaCodecInfo> getDecoderInfosSoftMatchFilteredByFormatSupport(
    Context context,
    MediaCodecSelector mediaCodecSelector,
    Format format,
    boolean requiresSecureDecoder,
    boolean requiresTunnelingDecoder
)
```

Returns a list of decoders that can decode media in the specified format, in the priority order specified by the `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector`. Unlike `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfosSoftMatch(androidx.media3.exoplayer.mediacodec.MediaCodecSelector,androidx.media3.common.Format,boolean,boolean)`, this method may exclude decoders that match the sample MIME type but do not support relevant format details.

This list is more complete than `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfos(java.lang.String,boolean,boolean)`, as it also considers alternative MIME types that are a close match using `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getAlternativeCodecMimeType(androidx.media3.common.Format)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The application context. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecSelector mediaCodecSelector` | The decoder selector. |
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The `https://developer.android.com/reference/androidx/media3/common/Format` for which a decoder is required. |
| `boolean requiresSecureDecoder` | Whether a secure decoder is required. |
| `boolean requiresTunnelingDecoder` | Whether a tunneling decoder is required. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo>` | A list of `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo`s corresponding to decoders. May be empty. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException` | Thrown if there was an error querying decoders. |

### getDecoderInfosSortedByFormatSupport

```
public static List<MediaCodecInfo> getDecoderInfosSortedByFormatSupport(
    Context context,
    List<MediaCodecInfo> decoderInfos,
    Format format
)
```

Returns a copy of the provided decoder list sorted such that decoders with functional format support are listed first. The returned list is modifiable for convenience.

### getDecoderInfosSortedByFullFormatSupport

```
public static List<MediaCodecInfo> getDecoderInfosSortedByFullFormatSupport(
    Context context,
    List<MediaCodecInfo> decoderInfos,
    Format format
)
```

Returns a copy of the provided decoder list sorted such that decoders with complete format support are listed first. The returned list is modifiable for convenience.

### getDecoderInfosSortedBySoftwareOnly

```
public static List<MediaCodecInfo> getDecoderInfosSortedBySoftwareOnly(List<MediaCodecInfo> decoderInfos)
```

Returns a copy of the provided decoder list sorted such that software decoders are listed first. Break ties by listing non-`https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo#vendor()` decoders first, due to issues with decoder reuse with some software vendor codecs. See b/382447848.

The returned list is not modifiable.

### getDecryptOnlyDecoderInfo

```
public static @Nullable MediaCodecInfo getDecryptOnlyDecoderInfo()
```

Returns information about a decoder that will only decrypt data, without decoding it.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo` | A `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecInfo` describing the decoder, or null if no suitable decoder exists. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException` | If there was an error querying the available decoders. |

### getHevcBaseLayerCodecProfileAndLevel

```
public static @Nullable CodecSpecificDataUtil.MediaCodecProfileAndLevel getHevcBaseLayerCodecProfileAndLevel(Format format)
```

Returns profile and level (as defined by `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html`) corresponding to the base layer (for the case of falling back to single-layer HEVC from L-HEVC).

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format format` | Media format with codec specific initialization data. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/util/CodecSpecificDataUtil.MediaCodecProfileAndLevel` | A pair (profile constant, level constant) if the initializationData of the ` format` is well-formed and recognized, or null otherwise. |

### maxH264DecodableFrameSize

```
public static int maxH264DecodableFrameSize()
```

Returns the maximum frame size supported by the default H264 decoder.

| Returns |
|---|---|
| `int` | The maximum frame size for an H264 stream that can be decoded on the device. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException` |   |

### warmDecoderInfoCache

```
public static void warmDecoderInfoCache(String mimeType, boolean secure, boolean tunneling)
```

Optional call to warm the codec cache for a given MIME type.

Calling this method may speed up subsequent calls to `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfo(java.lang.String,boolean,boolean)` and `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil#getDecoderInfos(java.lang.String,boolean,boolean)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html mimeType` | The MIME type. |
| `boolean secure` | Whether the decoder is required to support secure decryption. Always pass false unless secure decryption really is required. |
| `boolean tunneling` | Whether the decoder is required to support tunneling. Always pass false unless tunneling really is required. |