Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/media/MediaCodecInfo#nestedclasses) \| [Constants](https://developer.android.com/reference/android/media/MediaCodecInfo#constants) \| [Methods](https://developer.android.com/reference/android/media/MediaCodecInfo#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/media/MediaCodecInfo#inhmethods)

# MediaCodecInfo

*** ** * ** ***

` public final class MediaCodecInfo `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.media.MediaCodecInfo |

<br />

*** ** * ** ***

Provides information about a given media codec available on the device. You can iterate through all codecs available by querying `https://developer.android.com/reference/android/media/MediaCodecList`. For example, here's how to find an encoder that supports a given MIME type:

```
private static MediaCodecInfo selectCodec(String mimeType) {
    int numCodecs = MediaCodecList.getCodecCount();
    for (int i = 0; i < numCodecs; i++) {
        MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);

        if (!codecInfo.isEncoder()) {
            continue;
        }

        String[] types = codecInfo.getSupportedTypes();
        for (int j = 0; j < types.length; j++) {
            if (types[j].equalsIgnoreCase(mimeType)) {
                return codecInfo;
            }
        }
    }
    return null;
}
```

<br />

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/media/MediaCodecInfo.AudioCapabilities` A class that supports querying the audio capabilities of a codec. |
| ` class` | `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities` Encapsulates the capabilities of a given codec component. |
| ` class` | `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel` Encapsulates the profiles available for a codec component. |
| ` class` | `https://developer.android.com/reference/android/media/MediaCodecInfo.EncoderCapabilities` A class that supports querying the encoding capabilities of a codec. |
| ` class` | `https://developer.android.com/reference/android/media/MediaCodecInfo.VideoCapabilities` A class that supports querying the video capabilities of a codec. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/media/MediaCodecInfo#SECURITY_MODEL_MEMORY_SAFE` In this model the codec is not running in a sandboxed process, but written in a memory-safe way. |
| `int` | `https://developer.android.com/reference/android/media/MediaCodecInfo#SECURITY_MODEL_SANDBOXED` In this model the codec is running in a sandboxed process. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/media/MediaCodecInfo#getCanonicalName()() ` Retrieve the underlying codec name. |
| ` https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities` | ` https://developer.android.com/reference/android/media/MediaCodecInfo#getCapabilitiesForType(java.lang.String)(https://developer.android.com/reference/java/lang/String type) ` Enumerates the capabilities of the codec component. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/media/MediaCodecInfo#getName()() ` Retrieve the codec name. |
| ` int` | ` https://developer.android.com/reference/android/media/MediaCodecInfo#getSecurityModel()() ` Query the security model of the codec. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/media/MediaCodecInfo#getSupportedTypes()() ` Query the media types supported by the codec. |
| ` boolean` | ` https://developer.android.com/reference/android/media/MediaCodecInfo#isAlias()() ` Query if the codec is an alias for another underlying codec. |
| ` boolean` | ` https://developer.android.com/reference/android/media/MediaCodecInfo#isEncoder()() ` Query if the codec is an encoder. |
| ` boolean` | ` https://developer.android.com/reference/android/media/MediaCodecInfo#isHardwareAccelerated()() ` Query if the codec is hardware accelerated. |
| ` boolean` | ` https://developer.android.com/reference/android/media/MediaCodecInfo#isSoftwareOnly()() ` Query if the codec is software only. |
| ` boolean` | ` https://developer.android.com/reference/android/media/MediaCodecInfo#isVendor()() ` Query if the codec is provided by the Android platform (false) or the device manufacturer (true). |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### SECURITY_MODEL_MEMORY_SAFE

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SECURITY_MODEL_MEMORY_SAFE
```

In this model the codec is not running in a sandboxed process, but written in a memory-safe way. It typically means that the software implementation of the codec is written in a memory-safe language such as Rust.

<br />

Constant Value: 1 (0x00000001)

### SECURITY_MODEL_SANDBOXED

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SECURITY_MODEL_SANDBOXED
```

In this model the codec is running in a sandboxed process. Even if a malicious content was fed to the codecs in this model, the impact will be contained in the sandboxed process.

<br />

Constant Value: 0 (0x00000000)

## Public methods

### getCanonicalName

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getCanonicalName ()
```

Retrieve the underlying codec name. Device implementations may provide multiple aliases (codec names) for the same underlying codec to maintain backward app compatibility. This method returns the name of the underlying codec name, which must not be another alias. For non-aliases this is always the name of the codec.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value cannot be `null`. <br /> |

### getCapabilitiesForType

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MediaCodecInfo.CodecCapabilities getCapabilitiesForType (String type)
```

Enumerates the capabilities of the codec component. Since a single component can support data of a variety of types, the type has to be specified to yield a meaningful result.

<br />

| Parameters ||
|---|---|
| `type` | `String`: The MIME type to query <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities` | <br /> |

### getName

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getName ()
```

Retrieve the codec name. **Note:** Implementations may provide multiple aliases (codec names) for the same underlying codec, any of which can be used to instantiate the same underlying codec in `https://developer.android.com/reference/android/media/MediaCodec#createByCodecName(java.lang.String)`. Applications targeting SDK \< `https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q`, cannot determine if the multiple codec names listed in MediaCodecList are in-fact for the same codec.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value cannot be `null`. <br /> |

### getSecurityModel

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getSecurityModel ()
```

Query the security model of the codec.

<br />

| Returns ||
|---|---|
| `int` | Value is one of the following: - `https://developer.android.com/reference/android/media/MediaCodecInfo#SECURITY_MODEL_SANDBOXED` - `https://developer.android.com/reference/android/media/MediaCodecInfo#SECURITY_MODEL_MEMORY_SAFE` |

### getSupportedTypes

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String[] getSupportedTypes ()
```

Query the media types supported by the codec.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### isAlias

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isAlias ()
```

Query if the codec is an alias for another underlying codec.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isEncoder

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isEncoder ()
```

Query if the codec is an encoder.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isHardwareAccelerated

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isHardwareAccelerated ()
```

Query if the codec is hardware accelerated. This attribute is provided by the device manufacturer. Note that it cannot be tested for correctness.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isSoftwareOnly

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isSoftwareOnly ()
```

Query if the codec is software only. Software-only codecs are more secure as they run in a tighter security sandbox. On the other hand, software-only codecs do not provide any performance guarantees.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isVendor

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isVendor ()
```

Query if the codec is provided by the Android platform (false) or the device manufacturer (true).

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |