ApplicationMediaCapabilities
public
final
class
ApplicationMediaCapabilities
extends Object
implements
Parcelable
java.lang.Object | |
↳ | 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:
<media-capabilities xmlns:android="http://schemas.android.com/apk/res/android">
<format android:name="HEVC" supported="true"/>
<format android:name="HDR10" supported="false"/>
<format android:name="HDR10Plus" supported="false"/>
</media-capabilities>
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 | |
---|---|
class |
ApplicationMediaCapabilities.Builder
Builder class for |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<ApplicationMediaCapabilities> |
CREATOR
|
Public methods | |
---|---|
static
ApplicationMediaCapabilities
|
createFromXml(XmlPullParser xmlParser)
Creates |
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
List<String>
|
getSupportedHdrTypes()
Query all hdr types that are supported by the application. |
List<String>
|
getSupportedVideoMimeTypes()
Query the video codec mime types supported by the application. |
List<String>
|
getUnsupportedHdrTypes()
Query all hdr types that are not supported by the application. |
List<String>
|
getUnsupportedVideoMimeTypes()
Query the video codec mime types that are not supported by the application. |
boolean
|
isFormatSpecified(String format)
Query if a format is specified by the application. |
boolean
|
isHdrTypeSupported(String hdrType)
Query if a HDR type is supported by the application. |
boolean
|
isVideoMimeTypeSupported(String videoMime)
Query if a video codec format is supported by the application. |
String
|
toString()
Returns a string representation of the object. |
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
---|---|
Fields
Public methods
createFromXml
public static ApplicationMediaCapabilities createFromXml (XmlPullParser xmlParser)
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:
<media-capabilities xmlns:android="http://schemas.android.com/apk/res/android">
<format android:name="HEVC" supported="true"/>
<format android:name="HDR10" supported="false"/>
<format android:name="HDR10Plus" supported="false"/>
</media-capabilities>
Parameters | |
---|---|
xmlParser |
XmlPullParser : The underlying XmlPullParser that will read the xml.
This value cannot be null . |
Returns | |
---|---|
ApplicationMediaCapabilities |
An ApplicationMediaCapabilities object.
This value cannot be null . |
Throws | |
---|---|
UnsupportedOperationException |
if the capabilities in xml config are invalid or incompatible. |
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(android.os.Parcel, int)
,
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR
bit.
Returns | |
---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
getSupportedHdrTypes
public List<String> getSupportedHdrTypes ()
Query all hdr types that are supported by the application.
Returns | |
---|---|
List<String> |
List of supported hdr types. The list will be empty if there are none.
This value cannot be null . |
getSupportedVideoMimeTypes
public List<String> getSupportedVideoMimeTypes ()
Query the video codec mime types supported by the application.
Returns | |
---|---|
List<String> |
List of supported video codec mime types. The list will be empty if there are none.
This value cannot be null . |
getUnsupportedHdrTypes
public List<String> getUnsupportedHdrTypes ()
Query all hdr types that are not supported by the application.
Returns | |
---|---|
List<String> |
List of unsupported hdr types. The list will be empty if there are none.
This value cannot be null . |
getUnsupportedVideoMimeTypes
public List<String> getUnsupportedVideoMimeTypes ()
Query the video codec mime types that are not supported by the application.
Returns | |
---|---|
List<String> |
List of unsupported video codec mime types. The list will be empty if there are none.
This value cannot be null . |
isFormatSpecified
public boolean isFormatSpecified (String format)
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 . |
Returns | |
---|---|
boolean |
true if application specifies the format, false otherwise. |
isHdrTypeSupported
public boolean isHdrTypeSupported (String hdrType)
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 MediaFeature.HdrType.DOLBY_VISION , MediaFeature.HdrType.HDR10 , MediaFeature.HdrType.HDR10_PLUS , or MediaFeature.HdrType.HLG |
Returns | |
---|---|
boolean |
true if application supports the HDR format, false otherwise. |
isVideoMimeTypeSupported
public boolean isVideoMimeTypeSupported (String videoMime)
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 . |
Returns | |
---|---|
boolean |
true if application supports the video codec format, false otherwise. |
toString
public String toString ()
Returns a string representation of the object.
Returns | |
---|---|
String |
a string representation of the object. |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
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.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-12-18 UTC.