MediaCodecUtil
@UnstableApi
class MediaCodecUtil
A utility class for querying the available codecs.
Summary
Nested types |
|---|
|
Thrown when an error occurs querying the device for its underlying media capabilities. |
Public functions |
|
|---|---|
synchronized java-static Unit |
|
java-static MediaCodecInfo.CodecProfileLevel! |
@UnstableApiReturns a |
java-static String? |
getAlternativeCodecMimeType(format: Format!)Returns an alternative codec MIME type (besides the default |
java-static (Mutable)List<MediaCodecInfo!>! |
getAlternativeDecoderInfos(Returns a list of decoders for |
java-static Pair<Int!, Int!>? |
@InlineMe(replacement = "CodecSpecificDataUtil.getCodecProfileAndLevel(format)", imports = [""androidx.media3.common.util.CodecSpecificDataUtil""])This function is deprecated. |
java-static MediaCodecInfo? |
getDecoderInfo(mimeType: String!, secure: Boolean, tunneling: Boolean)Returns information about the preferred decoder for a given MIME type. |
synchronized java-static (Mutable)List<MediaCodecInfo!>! |
getDecoderInfos(mimeType: String!, secure: Boolean, tunneling: Boolean)Returns all |
java-static (Mutable)List<MediaCodecInfo!>! |
@RequiresNonNull(value = "#2.sampleMimeType")Returns a list of decoders that can decode media in the specified format, in the priority order specified by the |
java-static (Mutable)List<MediaCodecInfo!>! |
getDecoderInfosSortedByFormatSupport(Returns a copy of the provided decoder list sorted such that decoders with functional format support are listed first. |
java-static (Mutable)List<MediaCodecInfo!>! |
getDecoderInfosSortedByFullFormatSupport(Returns a copy of the provided decoder list sorted such that decoders with complete format support are listed first. |
java-static (Mutable)List<MediaCodecInfo!>! |
getDecoderInfosSortedBySoftwareOnly(Returns a copy of the provided decoder list sorted such that software decoders are listed first. |
java-static MediaCodecInfo? |
Returns information about a decoder that will only decrypt data, without decoding it. |
java-static Pair<Int!, Int!>? |
getHevcBaseLayerCodecProfileAndLevel(format: Format!)Returns profile and level (as defined by |
java-static Int |
Returns the maximum frame size supported by the default H264 decoder. |
java-static Unit |
warmDecoderInfoCache(mimeType: String!, secure: Boolean, tunneling: Boolean)Optional call to warm the codec cache for a given MIME type. |
Public functions
createCodecProfileLevel
@UnstableApi
java-static fun createCodecProfileLevel(profile: Int, level: Int): MediaCodecInfo.CodecProfileLevel!
Returns a CodecProfileLevel configured with the provided profile and
level.
getAlternativeCodecMimeType
java-static fun getAlternativeCodecMimeType(format: Format!): String?
Returns an alternative codec MIME type (besides the default sampleMimeType) that can be used to decode samples of the provided Format.
| Parameters | |
|---|---|
format: Format! |
The media format. |
| Returns | |
|---|---|
String? |
An alternative MIME type of a codec that be used decode samples of the provided |
getAlternativeDecoderInfos
java-static fun getAlternativeDecoderInfos(
mediaCodecSelector: MediaCodecSelector!,
format: Format!,
requiresSecureDecoder: Boolean,
requiresTunnelingDecoder: Boolean
): (Mutable)List<MediaCodecInfo!>!
Returns a list of decoders for alternative MIME types that can decode samples of the provided Format, in the priority order specified by the MediaCodecSelector.
Since the MediaCodecSelector only has access to 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). getDecoderInfosSortedByFormatSupport can be used to further sort the list into an order where decoders that fully support the format come first.
| Parameters | |
|---|---|
mediaCodecSelector: MediaCodecSelector! |
The decoder selector. |
format: Format! |
The |
requiresSecureDecoder: Boolean |
Whether a secure decoder is required. |
requiresTunnelingDecoder: Boolean |
Whether a tunneling decoder is required. |
| Returns | |
|---|---|
(Mutable)List<MediaCodecInfo!>! |
A list of |
| Throws | |
|---|---|
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""])
java-static fungetCodecProfileAndLevel(format: Format!): Pair<Int!, Int!>?
getDecoderInfo
java-static fun getDecoderInfo(mimeType: String!, secure: Boolean, tunneling: Boolean): MediaCodecInfo?
Returns information about the preferred decoder for a given MIME type.
| Parameters | |
|---|---|
mimeType: String! |
The MIME type. |
secure: Boolean |
Whether the decoder is required to support secure decryption. Always pass false unless secure decryption really is required. |
tunneling: Boolean |
Whether the decoder is required to support tunneling. Always pass false unless tunneling really is required. |
| Returns | |
|---|---|
MediaCodecInfo? |
A |
| Throws | |
|---|---|
androidx.media3.exoplayer.mediacodec.MediaCodecUtil.DecoderQueryException |
If there was an error querying the available decoders. |
getDecoderInfos
synchronized java-static fun getDecoderInfos(mimeType: String!, secure: Boolean, tunneling: Boolean): (Mutable)List<MediaCodecInfo!>!
Returns all MediaCodecInfos for the given MIME type, in the order given by MediaCodecList.
| Parameters | |
|---|---|
mimeType: String! |
The MIME type. |
secure: Boolean |
Whether the decoder is required to support secure decryption. Always pass false unless secure decryption really is required. |
tunneling: Boolean |
Whether the decoder is required to support tunneling. Always pass false unless tunneling really is required. |
| Returns | |
|---|---|
(Mutable)List<MediaCodecInfo!>! |
An unmodifiable list of all |
| Throws | |
|---|---|
androidx.media3.exoplayer.mediacodec.MediaCodecUtil.DecoderQueryException |
If there was an error querying the available decoders. |
getDecoderInfosSoftMatch
@RequiresNonNull(value = "#2.sampleMimeType")
java-static fun getDecoderInfosSoftMatch(
mediaCodecSelector: MediaCodecSelector!,
format: Format!,
requiresSecureDecoder: Boolean,
requiresTunnelingDecoder: Boolean
): (Mutable)List<MediaCodecInfo!>!
Returns a list of decoders that can decode media in the specified format, in the priority order specified by the MediaCodecSelector.
Since the MediaCodecSelector only has access to 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). getDecoderInfosSortedByFormatSupport 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 getDecoderInfos, as it also considers alternative MIME types that are a close match using getAlternativeCodecMimeType.
| Parameters | |
|---|---|
mediaCodecSelector: MediaCodecSelector! |
The decoder selector. |
format: Format! |
The |
requiresSecureDecoder: Boolean |
Whether a secure decoder is required. |
requiresTunnelingDecoder: Boolean |
Whether a tunneling decoder is required. |
| Returns | |
|---|---|
(Mutable)List<MediaCodecInfo!>! |
A list of |
| Throws | |
|---|---|
androidx.media3.exoplayer.mediacodec.MediaCodecUtil.DecoderQueryException |
Thrown if there was an error querying decoders. |
getDecoderInfosSortedByFormatSupport
java-static fun getDecoderInfosSortedByFormatSupport(
decoderInfos: (Mutable)List<MediaCodecInfo!>!,
format: Format!
): (Mutable)List<MediaCodecInfo!>!
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
java-static fun getDecoderInfosSortedByFullFormatSupport(
decoderInfos: (Mutable)List<MediaCodecInfo!>!,
format: Format!
): (Mutable)List<MediaCodecInfo!>!
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
java-static fun getDecoderInfosSortedBySoftwareOnly(
decoderInfos: (Mutable)List<MediaCodecInfo!>!
): (Mutable)List<MediaCodecInfo!>!
Returns a copy of the provided decoder list sorted such that software decoders are listed first. Break ties by listing non-vendor decoders first, due to issues with decoder reuse with some software vendor codecs. See b/382447848.
The returned list is not modifiable.
getDecryptOnlyDecoderInfo
java-static fun getDecryptOnlyDecoderInfo(): MediaCodecInfo?
Returns information about a decoder that will only decrypt data, without decoding it.
| Returns | |
|---|---|
MediaCodecInfo? |
A |
| Throws | |
|---|---|
androidx.media3.exoplayer.mediacodec.MediaCodecUtil.DecoderQueryException |
If there was an error querying the available decoders. |
getHevcBaseLayerCodecProfileAndLevel
java-static fun getHevcBaseLayerCodecProfileAndLevel(format: Format!): Pair<Int!, Int!>?
Returns profile and level (as defined by CodecProfileLevel) corresponding to the base layer (for the case of falling back to single-layer HEVC from L-HEVC).
| Parameters | |
|---|---|
format: Format! |
Media format with codec specific initialization data. |
maxH264DecodableFrameSize
java-static fun maxH264DecodableFrameSize(): Int
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. |
warmDecoderInfoCache
java-static fun warmDecoderInfoCache(mimeType: String!, secure: Boolean, tunneling: Boolean): Unit
Optional call to warm the codec cache for a given MIME type.
Calling this method may speed up subsequent calls to getDecoderInfo and getDecoderInfos.
| Parameters | |
|---|---|
mimeType: String! |
The MIME type. |
secure: Boolean |
Whether the decoder is required to support secure decryption. Always pass false unless secure decryption really is required. |
tunneling: Boolean |
Whether the decoder is required to support tunneling. Always pass false unless tunneling really is required. |