MediaCodecInfo
@UnstableApi
class MediaCodecInfo
Information about a MediaCodec for a given MIME type.
Summary
Constants |
|
|---|---|
const Int |
The value returned by |
const String! |
TAG = "MediaCodecInfo" |
Public functions |
|
|---|---|
Point? |
alignVideoSizeV21(width: Int, height: Int)Returns the smallest video size greater than or equal to a specified size that also satisfies the |
DecoderReuseEvaluation! |
canReuseCodec(oldFormat: Format!, newFormat: Format!)Evaluates whether it's possible to reuse an instance of this decoder that's currently decoding |
Float |
getMaxSupportedFrameRate(width: Int, height: Int)Returns the max video frame rate that this codec can support at the provided resolution, or |
Int |
Returns an upper bound on the maximum number of supported instances, or |
Array<MediaCodecInfo.CodecProfileLevel!>! |
The profile levels supported by the decoder. |
Boolean |
isAudioChannelCountSupportedV21(channelCount: Int)Whether the decoder supports audio with a given channel count. |
Boolean |
isAudioSampleRateSupportedV21(sampleRate: Int)Whether the decoder supports audio with a given sample rate. |
Boolean |
isFormatFunctionallySupported(format: Format!)Returns whether the decoder may functionally support decoding the given |
Boolean |
isFormatSupported(format: Format!)Returns whether the decoder may support decoding the given |
Boolean |
Whether the codec handles HDR10+ out-of-band metadata. |
Boolean |
isSeamlessAdaptationSupported(format: Format!)Returns whether it may be possible to adapt an instance of this decoder to playing a different format when the codec is configured to play media in the specified |
Boolean |
isVideoSizeAndRateSupportedV21(width: Int, height: Int, frameRate: Double)Whether the decoder supports video with a given width, height and frame rate. |
java-static MediaCodecInfo! |
newInstance(Creates an instance. |
String! |
toString() |
Public properties |
|
|---|---|
Boolean |
Whether the decoder supports seamless resolution switches. |
MediaCodecInfo.CodecCapabilities? |
The capabilities of the decoder, like the profiles/levels it supports, or |
String! |
The MIME type that the codec uses for media of type |
Boolean |
Whether the codec supports "detached" surface mode where it is able to decode without an attached surface. |
Boolean |
Whether the codec is hardware accelerated. |
String! |
The MIME type handled by the codec. |
String! |
The name of the decoder. |
Boolean |
Whether the decoder is secure. |
Boolean |
Whether the codec is software only. |
Boolean |
Whether the decoder supports tunneling. |
Boolean |
Whether the codec is from the vendor. |
Constants
MAX_SUPPORTED_INSTANCES_UNKNOWN
const val MAX_SUPPORTED_INSTANCES_UNKNOWN = -1: Int
The value returned by getMaxSupportedInstances if the upper bound on the maximum number of supported instances is unknown.
Public functions
alignVideoSizeV21
fun alignVideoSizeV21(width: Int, height: Int): Point?
Returns the smallest video size greater than or equal to a specified size that also satisfies the MediaCodec's width and height alignment requirements.
| Returns | |
|---|---|
Point? |
The smallest video size greater than or equal to the specified size that also satisfies the |
canReuseCodec
fun canReuseCodec(oldFormat: Format!, newFormat: Format!): DecoderReuseEvaluation!
Evaluates whether it's possible to reuse an instance of this decoder that's currently decoding oldFormat to decode newFormat instead.
For adaptation to succeed, the codec must also be configured with maximum values that are compatible with the new format.
| Returns | |
|---|---|
DecoderReuseEvaluation! |
The result of the evaluation. |
getMaxSupportedFrameRate
fun getMaxSupportedFrameRate(width: Int, height: Int): Float
Returns the max video frame rate that this codec can support at the provided resolution, or RATE_UNSET if this is not a video codec.
getMaxSupportedInstances
fun getMaxSupportedInstances(): Int
Returns an upper bound on the maximum number of supported instances, or MAX_SUPPORTED_INSTANCES_UNKNOWN if unknown. Applications should not expect to operate more instances than the returned maximum.
| See also | |
|---|---|
getMaxSupportedInstances |
getProfileLevels
fun getProfileLevels(): Array<MediaCodecInfo.CodecProfileLevel!>!
The profile levels supported by the decoder.
| Returns | |
|---|---|
Array<MediaCodecInfo.CodecProfileLevel!>! |
The profile levels supported by the decoder. |
isAudioChannelCountSupportedV21
fun isAudioChannelCountSupportedV21(channelCount: Int): Boolean
Whether the decoder supports audio with a given channel count.
| Parameters | |
|---|---|
channelCount: Int |
The channel count. |
| Returns | |
|---|---|
Boolean |
Whether the decoder supports audio with the given channel count. |
isAudioSampleRateSupportedV21
fun isAudioSampleRateSupportedV21(sampleRate: Int): Boolean
Whether the decoder supports audio with a given sample rate.
| Parameters | |
|---|---|
sampleRate: Int |
The sample rate in Hz. |
| Returns | |
|---|---|
Boolean |
Whether the decoder supports audio with the given sample rate. |
isFormatFunctionallySupported
fun isFormatFunctionallySupported(format: Format!): Boolean
Returns whether the decoder may functionally support decoding the given format.
| Parameters | |
|---|---|
format: Format! |
The input media format. |
| Returns | |
|---|---|
Boolean |
Whether the decoder may functionally support decoding the given |
isFormatSupported
fun isFormatSupported(format: Format!): Boolean
Returns whether the decoder may support decoding the given format both functionally and performantly.
| Parameters | |
|---|---|
format: Format! |
The input media format. |
| Returns | |
|---|---|
Boolean |
Whether the decoder may support decoding the given |
| Throws | |
|---|---|
androidx.media3.exoplayer.mediacodec.MediaCodecUtil.DecoderQueryException |
Thrown if an error occurs while querying decoders. |
isHdr10PlusOutOfBandMetadataSupported
fun isHdr10PlusOutOfBandMetadataSupported(): Boolean
Whether the codec handles HDR10+ out-of-band metadata.
isSeamlessAdaptationSupported
fun isSeamlessAdaptationSupported(format: Format!): Boolean
Returns whether it may be possible to adapt an instance of this decoder to playing a different format when the codec is configured to play media in the specified format.
For adaptation to succeed, the codec must also be configured with appropriate maximum values and canReuseCodec must return true for the old/new formats.
| Parameters | |
|---|---|
format: Format! |
The format of media for which the decoder will be configured. |
| Returns | |
|---|---|
Boolean |
Whether adaptation may be possible |
isVideoSizeAndRateSupportedV21
fun isVideoSizeAndRateSupportedV21(width: Int, height: Int, frameRate: Double): Boolean
Whether the decoder supports video with a given width, height and frame rate.
| Parameters | |
|---|---|
width: Int |
Width in pixels. |
height: Int |
Height in pixels. |
frameRate: Double |
Optional frame rate in frames per second. Ignored if set to |
| Returns | |
|---|---|
Boolean |
Whether the decoder supports video with the given width, height and frame rate. |
newInstance
java-static fun newInstance(
name: String!,
mimeType: String!,
codecMimeType: String!,
capabilities: MediaCodecInfo.CodecCapabilities?,
hardwareAccelerated: Boolean,
softwareOnly: Boolean,
vendor: Boolean,
forceDisableAdaptive: Boolean,
forceSecure: Boolean
): MediaCodecInfo!
Creates an instance.
| Parameters | |
|---|---|
name: String! |
The name of the |
mimeType: String! |
A MIME type supported by the |
codecMimeType: String! |
The MIME type that the codec uses for media of type |
capabilities: MediaCodecInfo.CodecCapabilities? |
The capabilities of the |
hardwareAccelerated: Boolean |
Whether the |
softwareOnly: Boolean |
Whether the |
vendor: Boolean |
Whether the |
forceDisableAdaptive: Boolean |
Whether |
forceSecure: Boolean |
Whether |
| Returns | |
|---|---|
MediaCodecInfo! |
The created instance. |
Public properties
capabilities
val capabilities: MediaCodecInfo.CodecCapabilities?
The capabilities of the decoder, like the profiles/levels it supports, or null if not known.
codecMimeType
val codecMimeType: String!
The MIME type that the codec uses for media of type mimeType. Equal to mimeType unless the codec is known to use a non-standard MIME type alias.
detachedSurfaceSupported
val detachedSurfaceSupported: Boolean
Whether the codec supports "detached" surface mode where it is able to decode without an attached surface. Only relevant for video codecs.
| See also | |
|---|---|
FEATURE_DetachedSurface |
hardwareAccelerated
val hardwareAccelerated: Boolean
Whether the codec is hardware accelerated.
This could be an approximation as the exact information is only provided in API levels 29+.
| See also | |
|---|---|
isHardwareAccelerated |
name
val name: String!
The name of the decoder.
May be passed to createByCodecName to create an instance of the decoder.
secure
val secure: Boolean
Whether the decoder is secure.
| See also | |
|---|---|
isFeatureSupported |
|
FEATURE_SecurePlayback |
softwareOnly
val softwareOnly: Boolean
Whether the codec is software only.
This could be an approximation as the exact information is only provided in API levels 29+.
| See also | |
|---|---|
isSoftwareOnly |