public final class MediaCodecInfo extends Object
MediaCodec for a given mime type.| Modifier and Type | Field | Description |
|---|---|---|
boolean |
adaptive |
Whether the decoder supports seamless resolution switches.
|
MediaCodecInfo.CodecCapabilities |
capabilities |
The capabilities of the decoder, like the profiles/levels it supports, or
null if not
known. |
String |
codecMimeType |
The MIME type that the codec uses for media of type
mimeType. |
boolean |
hardwareAccelerated |
Whether the codec is hardware accelerated.
|
static int |
MAX_SUPPORTED_INSTANCES_UNKNOWN |
The value returned by
getMaxSupportedInstances() if the upper bound on the maximum
number of supported instances is unknown. |
String |
mimeType |
The MIME type handled by the codec.
|
String |
name |
The name of the decoder.
|
boolean |
secure |
Whether the decoder is secure.
|
boolean |
softwareOnly |
Whether the codec is software only.
|
static String |
TAG |
|
boolean |
tunneling |
Whether the decoder supports tunneling.
|
boolean |
vendor |
Whether the codec is from the vendor.
|
| Modifier and Type | Method | Description |
|---|---|---|
Point |
alignVideoSizeV21(int width,
int height) |
Returns the smallest video size greater than or equal to a specified size that also satisfies
the
MediaCodec's width and height alignment requirements. |
DecoderReuseEvaluation |
canReuseCodec(Format oldFormat,
Format newFormat) |
Evaluates whether it's possible to reuse an instance of this decoder that's currently decoding
oldFormat to decode newFormat instead. |
int |
getMaxSupportedInstances() |
Returns an upper bound on the maximum number of supported instances, or
MAX_SUPPORTED_INSTANCES_UNKNOWN if unknown. |
MediaCodecInfo.CodecProfileLevel[] |
getProfileLevels() |
The profile levels supported by the decoder.
|
boolean |
isAudioChannelCountSupportedV21(int channelCount) |
Whether the decoder supports audio with a given channel count.
|
boolean |
isAudioSampleRateSupportedV21(int sampleRate) |
Whether the decoder supports audio with a given sample rate.
|
boolean |
isCodecSupported(Format format) |
Whether the decoder supports the codec of the given
format. |
boolean |
isFormatSupported(Format format) |
Returns whether the decoder may support decoding the given
format. |
boolean |
isHdr10PlusOutOfBandMetadataSupported() |
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
format. |
boolean |
isSeamlessAdaptationSupported(Format oldFormat,
Format newFormat,
boolean isNewFormatComplete) |
|
boolean |
isVideoSizeAndRateSupportedV21(int width,
int height,
double frameRate) |
Whether the decoder supports video with a given width, height and frame rate.
|
static MediaCodecInfo |
newInstance(String name,
String mimeType,
String codecMimeType,
MediaCodecInfo.CodecCapabilities capabilities,
boolean hardwareAccelerated,
boolean softwareOnly,
boolean vendor,
boolean forceDisableAdaptive,
boolean forceSecure) |
Creates an instance.
|
String |
toString() |
public static final String TAG
public static final int MAX_SUPPORTED_INSTANCES_UNKNOWN
getMaxSupportedInstances() if the upper bound on the maximum
number of supported instances is unknown.public final String name
May be passed to MediaCodec.createByCodecName(String) to create an instance of the
decoder.
public final String mimeType
public final String codecMimeType
@Nullable public final MediaCodecInfo.CodecCapabilities capabilities
null if not
known.public final boolean adaptive
public final boolean tunneling
public final boolean secure
public final boolean hardwareAccelerated
This could be an approximation as the exact information is only provided in API levels 29+.
MediaCodecInfo.isHardwareAccelerated()public final boolean softwareOnly
This could be an approximation as the exact information is only provided in API levels 29+.
MediaCodecInfo.isSoftwareOnly()public final boolean vendor
This could be an approximation as the exact information is only provided in API levels 29+.
MediaCodecInfo.isVendor()public static MediaCodecInfo newInstance(String name, String mimeType, String codecMimeType, @Nullable MediaCodecInfo.CodecCapabilities capabilities, boolean hardwareAccelerated, boolean softwareOnly, boolean vendor, boolean forceDisableAdaptive, boolean forceSecure)
name - The name of the MediaCodec.mimeType - A mime type supported by the MediaCodec.codecMimeType - 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.capabilities - The capabilities of the MediaCodec for the specified mime type, or
null if not known.hardwareAccelerated - Whether the MediaCodec is hardware accelerated.softwareOnly - Whether the MediaCodec is software only.vendor - Whether the MediaCodec is provided by the vendor.forceDisableAdaptive - Whether adaptive should be forced to false.forceSecure - Whether secure should be forced to true.public MediaCodecInfo.CodecProfileLevel[] getProfileLevels()
public int getMaxSupportedInstances()
MAX_SUPPORTED_INSTANCES_UNKNOWN if unknown. Applications should not expect to operate more
instances than the returned maximum.public boolean isFormatSupported(Format format) throws MediaCodecUtil.DecoderQueryException
format.format - The input media format.format.MediaCodecUtil.DecoderQueryException - Thrown if an error occurs while querying decoders.public boolean isCodecSupported(Format format)
format. If there is insufficient
information to decide, returns true.format - The input media format.format is supported by the decoder.public boolean isHdr10PlusOutOfBandMetadataSupported()
public boolean isSeamlessAdaptationSupported(Format format)
format.
For adaptation to succeed, the codec must also be configured with appropriate maximum values
and isSeamlessAdaptationSupported(Format, Format, boolean) must return true
for the old/new formats.
format - The format of media for which the decoder will be configured.@Deprecated public boolean isSeamlessAdaptationSupported(Format oldFormat, Format newFormat, boolean isNewFormatComplete)
oldFormat to newFormat. If newFormat may not be completely populated, pass
false for isNewFormatComplete.
For adaptation to succeed, the codec must also be configured with maximum values that are compatible with the new format.
oldFormat - The format being decoded.newFormat - The new format.isNewFormatComplete - Whether newFormat is populated with format-specific
metadata.public DecoderReuseEvaluation canReuseCodec(Format oldFormat, Format newFormat)
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.
oldFormat - The format being decoded.newFormat - The new format.public boolean isVideoSizeAndRateSupportedV21(int width,
int height,
double frameRate)
Must not be called if the device SDK version is less than 21.
width - Width in pixels.height - Height in pixels.frameRate - Optional frame rate in frames per second. Ignored if set to Format.NO_VALUE or any value less than or equal to 0.@Nullable public Point alignVideoSizeV21(int width, int height)
MediaCodec's width and height alignment requirements.
Must not be called if the device SDK version is less than 21.
width - Width in pixels.height - Height in pixels.MediaCodec's width and height alignment requirements, or null if not a video
codec.public boolean isAudioSampleRateSupportedV21(int sampleRate)
Must not be called if the device SDK version is less than 21.
sampleRate - The sample rate in Hz.public boolean isAudioChannelCountSupportedV21(int channelCount)
Must not be called if the device SDK version is less than 21.
channelCount - The channel count.