Class MediaCodecUtil
- java.lang.Object
-
- com.google.android.exoplayer2.mediacodec.MediaCodecUtil
-
@Deprecated public final class MediaCodecUtil extends Object
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.A utility class for querying the available codecs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MediaCodecUtil.DecoderQueryException
Deprecated.Thrown when an error occurs querying the device for its underlying media capabilities.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
clearDecoderInfoCache()
Deprecated.static String
getAlternativeCodecMimeType(Format format)
Deprecated.Returns an alternative codec MIME type (besides the defaultFormat.sampleMimeType
) that can be used to decode samples of the providedFormat
.static List<MediaCodecInfo>
getAlternativeDecoderInfos(MediaCodecSelector mediaCodecSelector, Format format, boolean requiresSecureDecoder, boolean requiresTunnelingDecoder)
Deprecated.Returns a list of decoders for alternative MIME types that can decode samples of the providedFormat
, in the priority order specified by theMediaCodecSelector
.static Pair<Integer,Integer>
getCodecProfileAndLevel(Format format)
Deprecated.Returns profile and level (as defined byMediaCodecInfo.CodecProfileLevel
) corresponding to the codec description string (as defined by RFC 6381) of the given format.static MediaCodecInfo
getDecoderInfo(String mimeType, boolean secure, boolean tunneling)
Deprecated.Returns information about the preferred decoder for a given MIME type.static List<MediaCodecInfo>
getDecoderInfos(String mimeType, boolean secure, boolean tunneling)
Deprecated.Returns allMediaCodecInfo
s for the given MIME type, in the order given byMediaCodecList
.static List<MediaCodecInfo>
getDecoderInfosSoftMatch(MediaCodecSelector mediaCodecSelector, Format format, boolean requiresSecureDecoder, boolean requiresTunnelingDecoder)
Deprecated.Returns a list of decoders that can decode media in the specified format, in the priority order specified by theMediaCodecSelector
.static List<MediaCodecInfo>
getDecoderInfosSortedByFormatSupport(List<MediaCodecInfo> decoderInfos, Format format)
Deprecated.Returns a copy of the provided decoder list sorted such that decoders with functional format support are listed first.static MediaCodecInfo
getDecryptOnlyDecoderInfo()
Deprecated.Returns information about a decoder that will only decrypt data, without decoding it.static int
maxH264DecodableFrameSize()
Deprecated.Returns the maximum frame size supported by the default H264 decoder.static void
warmDecoderInfoCache(String mimeType, boolean secure, boolean tunneling)
Deprecated.Optional call to warm the codec cache for a given MIME type.
-
-
-
Method Detail
-
warmDecoderInfoCache
public static void warmDecoderInfoCache(String mimeType, boolean secure, boolean tunneling)
Deprecated.Optional call to warm the codec cache for a given MIME type.Calling this method may speed up subsequent calls to
getDecoderInfo(String, boolean, boolean)
andgetDecoderInfos(String, boolean, boolean)
.- Parameters:
mimeType
- The MIME type.secure
- Whether the decoder is required to support secure decryption. Always pass false unless secure decryption really is required.tunneling
- Whether the decoder is required to support tunneling. Always pass false unless tunneling really is required.
-
clearDecoderInfoCache
public static void clearDecoderInfoCache()
Deprecated.
-
getDecryptOnlyDecoderInfo
@Nullable public static MediaCodecInfo getDecryptOnlyDecoderInfo() throws MediaCodecUtil.DecoderQueryException
Deprecated.Returns information about a decoder that will only decrypt data, without decoding it.- Returns:
- A
MediaCodecInfo
describing the decoder, or null if no suitable decoder exists. - Throws:
MediaCodecUtil.DecoderQueryException
- If there was an error querying the available decoders.
-
getDecoderInfo
@Nullable public static MediaCodecInfo getDecoderInfo(String mimeType, boolean secure, boolean tunneling) throws MediaCodecUtil.DecoderQueryException
Deprecated.Returns information about the preferred decoder for a given MIME type.- Parameters:
mimeType
- The MIME type.secure
- Whether the decoder is required to support secure decryption. Always pass false unless secure decryption really is required.tunneling
- Whether the decoder is required to support tunneling. Always pass false unless tunneling really is required.- Returns:
- A
MediaCodecInfo
describing the decoder, or null if no suitable decoder exists. - Throws:
MediaCodecUtil.DecoderQueryException
- If there was an error querying the available decoders.
-
getDecoderInfos
public static List<MediaCodecInfo> getDecoderInfos(String mimeType, boolean secure, boolean tunneling) throws MediaCodecUtil.DecoderQueryException
Deprecated.Returns allMediaCodecInfo
s for the given MIME type, in the order given byMediaCodecList
.- Parameters:
mimeType
- The MIME type.secure
- Whether the decoder is required to support secure decryption. Always pass false unless secure decryption really is required.tunneling
- Whether the decoder is required to support tunneling. Always pass false unless tunneling really is required.- Returns:
- An unmodifiable list of all
MediaCodecInfo
s for the given MIME type, in the order given byMediaCodecList
. - Throws:
MediaCodecUtil.DecoderQueryException
- If there was an error querying the available decoders.
-
getDecoderInfosSoftMatch
@RequiresNonNull("#2.sampleMimeType") public static List<MediaCodecInfo> getDecoderInfosSoftMatch(MediaCodecSelector mediaCodecSelector, Format format, boolean requiresSecureDecoder, boolean requiresTunnelingDecoder) throws MediaCodecUtil.DecoderQueryException
Deprecated.Returns a list of decoders that can decode media in the specified format, in the priority order specified by theMediaCodecSelector
.Since the
MediaCodecSelector
only has access toFormat.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(java.util.List<com.google.android.exoplayer2.mediacodec.MediaCodecInfo>, com.google.android.exoplayer2.Format)
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(java.lang.String, boolean, boolean)
, as it also considers alternative MIME types that are a close match usinggetAlternativeCodecMimeType(com.google.android.exoplayer2.Format)
.- Parameters:
mediaCodecSelector
- The decoder selector.format
- TheFormat
for which a decoder is required.requiresSecureDecoder
- Whether a secure decoder is required.requiresTunnelingDecoder
- Whether a tunneling decoder is required.- Returns:
- A list of
MediaCodecInfo
s corresponding to decoders. May be empty. - Throws:
MediaCodecUtil.DecoderQueryException
- Thrown if there was an error querying decoders.
-
getAlternativeDecoderInfos
public static List<MediaCodecInfo> getAlternativeDecoderInfos(MediaCodecSelector mediaCodecSelector, Format format, boolean requiresSecureDecoder, boolean requiresTunnelingDecoder) throws MediaCodecUtil.DecoderQueryException
Deprecated.Returns a list of decoders for alternative MIME types that can decode samples of the providedFormat
, in the priority order specified by theMediaCodecSelector
.Since the
MediaCodecSelector
only has access toFormat.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(java.util.List<com.google.android.exoplayer2.mediacodec.MediaCodecInfo>, com.google.android.exoplayer2.Format)
can be used to further sort the list into an order where decoders that fully support the format come first.- Parameters:
mediaCodecSelector
- The decoder selector.format
- TheFormat
for which an alternative decoder is required.requiresSecureDecoder
- Whether a secure decoder is required.requiresTunnelingDecoder
- Whether a tunneling decoder is required.- Returns:
- A list of
MediaCodecInfo
s corresponding to alternative decoders. May be empty. - Throws:
MediaCodecUtil.DecoderQueryException
- Thrown if there was an error querying decoders.
-
getDecoderInfosSortedByFormatSupport
@CheckResult public static List<MediaCodecInfo> getDecoderInfosSortedByFormatSupport(List<MediaCodecInfo> decoderInfos, Format format)
Deprecated.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.
-
maxH264DecodableFrameSize
public static int maxH264DecodableFrameSize() throws MediaCodecUtil.DecoderQueryException
Deprecated.Returns the maximum frame size supported by the default H264 decoder.- Returns:
- The maximum frame size for an H264 stream that can be decoded on the device.
- Throws:
MediaCodecUtil.DecoderQueryException
-
getCodecProfileAndLevel
@Nullable public static Pair<Integer,Integer> getCodecProfileAndLevel(Format format)
Deprecated.Returns profile and level (as defined byMediaCodecInfo.CodecProfileLevel
) corresponding to the codec description string (as defined by RFC 6381) of the given format.- Parameters:
format
- Media format with a codec description string, as defined by RFC 6381.- Returns:
- A pair (profile constant, level constant) if the codec of the
format
is well-formed and recognized, or null otherwise.
-
getAlternativeCodecMimeType
@Nullable public static String getAlternativeCodecMimeType(Format format)
Deprecated.Returns an alternative codec MIME type (besides the defaultFormat.sampleMimeType
) that can be used to decode samples of the providedFormat
.- Parameters:
format
- The media format.- Returns:
- An alternative MIME type of a codec that be used decode samples of the provided
Format
(besides the defaultFormat.sampleMimeType
), or null if no such alternative exists.
-
-