Added in API level 31

ApplicationMediaCapabilities

class ApplicationMediaCapabilities : Parcelable
kotlin.Any
   ↳ android.media.ApplicationMediaCapabilities

ApplicationMediaCapabilities is an immutable class that encapsulates an application's capabilities for handling newer video codec format and media features.

Android 12 introduces Compatible media transcoding feature. See Compatible media transcoding. By default, Android assumes apps can support playback of all media formats. Apps that would like to request that media be transcoded into a more compatible format should declare their media capabilities in a media_capabilities.xml resource file and add it as a property tag in the AndroidManifest.xml file. Here is a example:

<code>&lt;media-capabilities xmlns:android="http://schemas.android.com/apk/res/android"&gt;
   &lt;format android:name="HEVC" supported="true"/&gt;
   &lt;format android:name="HDR10" supported="false"/&gt;
   &lt;format android:name="HDR10Plus" supported="false"/&gt;
 &lt;/media-capabilities&gt;
 </code>
The ApplicationMediaCapabilities class is generated from this xml and used by the platform to represent an application's media capabilities in order to determine whether modern media files need to be transcoded for that application.

ApplicationMediaCapabilities objects can also be built by applications at runtime for use with ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle) to provide more control over the transcoding that is built into the platform. ApplicationMediaCapabilities provided by applications at runtime like this override the default manifest capabilities for that media access.The object could be build either through createFromXml(org.xmlpull.v1.XmlPullParser) or through the builder class ApplicationMediaCapabilities.Builder

Video Codec Support

Newer video codes include HEVC, VP9 and AV1. Application only needs to indicate their support for newer format with this class as they are assumed to support older format like h.264.

Capability of handling HDR(high dynamic range) video

There are four types of HDR video(Dolby-Vision, HDR10, HDR10+, HLG) supported by the platform, application will only need to specify individual types they supported.

Summary

Nested classes

Builder class for ApplicationMediaCapabilities objects.

Inherited constants
Public methods
static ApplicationMediaCapabilities

Creates ApplicationMediaCapabilities from an xml.

Int

MutableList<String!>

Query all hdr types that are supported by the application.

MutableList<String!>

Query the video codec mime types supported by the application.

MutableList<String!>

Query all hdr types that are not supported by the application.

MutableList<String!>

Query the video codec mime types that are not supported by the application.

Boolean

Query if a format is specified by the application.

Boolean

Query if a HDR type is supported by the application.

Boolean

Query if a video codec format is supported by the application.

String

Unit
writeToParcel(dest: Parcel, flags: Int)

Flatten this object in to a Parcel.

Properties
static Parcelable.Creator<ApplicationMediaCapabilities!>

Public methods

createFromXml

Added in API level 31
static fun createFromXml(xmlParser: XmlPullParser): ApplicationMediaCapabilities

Creates ApplicationMediaCapabilities from an xml. The xml's syntax is the same as the media_capabilities.xml used by the AndroidManifest.xml.

Here is an example:

<code>&lt;media-capabilities xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;format android:name="HEVC" supported="true"/&gt;
      &lt;format android:name="HDR10" supported="false"/&gt;
      &lt;format android:name="HDR10Plus" supported="false"/&gt;
  &lt;/media-capabilities&gt;
  </code>

Parameters
xmlParser XmlPullParser: The underlying XmlPullParser that will read the xml. This value cannot be null.
Return
ApplicationMediaCapabilities An ApplicationMediaCapabilities object. This value cannot be null.
Exceptions
java.lang.UnsupportedOperationException if the capabilities in xml config are invalid or incompatible.

describeContents

Added in API level 31
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getSupportedHdrTypes

Added in API level 31
fun getSupportedHdrTypes(): MutableList<String!>

Query all hdr types that are supported by the application.

Return
MutableList<String!> List of supported hdr types. The list will be empty if there are none. This value cannot be null.

getSupportedVideoMimeTypes

Added in API level 31
fun getSupportedVideoMimeTypes(): MutableList<String!>

Query the video codec mime types supported by the application.

Return
MutableList<String!> List of supported video codec mime types. The list will be empty if there are none. This value cannot be null.

getUnsupportedHdrTypes

Added in API level 31
fun getUnsupportedHdrTypes(): MutableList<String!>

Query all hdr types that are not supported by the application.

Return
MutableList<String!> List of unsupported hdr types. The list will be empty if there are none. This value cannot be null.

getUnsupportedVideoMimeTypes

Added in API level 31
fun getUnsupportedVideoMimeTypes(): MutableList<String!>

Query the video codec mime types that are not supported by the application.

Return
MutableList<String!> List of unsupported video codec mime types. The list will be empty if there are none. This value cannot be null.

isFormatSpecified

Added in API level 31
fun isFormatSpecified(format: String): Boolean

Query if a format is specified by the application.

The format could be either the video format or the hdr format.

Parameters
format String: The name of the format. This value cannot be null.
Return
Boolean true if application specifies the format, false otherwise.

isHdrTypeSupported

Added in API level 31
fun isHdrTypeSupported(hdrType: String): Boolean

Query if a HDR type is supported by the application.

If the application has not specified supporting the format or not, this will return false. Use isFormatSpecified(java.lang.String) to query if a format is specified or not.

Parameters
hdrType String: The type of the HDR format. This value cannot be null. Value is android.media.MediaFeature.HdrType#DOLBY_VISION, android.media.MediaFeature.HdrType#HDR10, android.media.MediaFeature.HdrType#HDR10_PLUS, or android.media.MediaFeature.HdrType#HLG
Return
Boolean true if application supports the HDR format, false otherwise.

isVideoMimeTypeSupported

Added in API level 31
fun isVideoMimeTypeSupported(videoMime: String): Boolean

Query if a video codec format is supported by the application.

If the application has not specified supporting the format or not, this will return false. Use isFormatSpecified(java.lang.String) to query if a format is specified or not.

Parameters
videoMime String: The mime type of the video codec format. Must be the one used in MediaFormat#KEY_MIME. This value cannot be null.
Return
Boolean true if application supports the video codec format, false otherwise.

toString

Added in API level 31
fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 31
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 31
static val CREATOR: Parcelable.Creator<ApplicationMediaCapabilities!>