次の方法で共有


MediaCodecInfo.CodecCapabilities.IsFormatSupported(MediaFormat) Method

Definition

Query whether codec supports a given MediaFormat.

[Android.Runtime.Register("isFormatSupported", "(Landroid/media/MediaFormat;)Z", "")]
public bool IsFormatSupported (Android.Media.MediaFormat? format);
[<Android.Runtime.Register("isFormatSupported", "(Landroid/media/MediaFormat;)Z", "")>]
member this.IsFormatSupported : Android.Media.MediaFormat -> bool

Parameters

format
MediaFormat

media format with optional feature directives.

Returns

whether the codec capabilities support the given format and feature requests.

Attributes

Remarks

Query whether codec supports a given MediaFormat.

<p class=note> <strong>Note:</strong> On android.os.Build.VERSION_CODES#LOLLIPOP, format must not contain a MediaFormat#KEY_FRAME_RATE frame rate. Use format.setString(MediaFormat.KEY_FRAME_RATE, null) to clear any existing frame rate setting in the format.

The following table summarizes the format keys considered by this method. This is especially important to consider when targeting a higher SDK version than the minimum SDK version, as this method will disregard some keys on devices below the target SDK version.

<table style="width: 0%"> <thead> <tr> <th rowspan=3>OS Version(s)</th> <td colspan=3>MediaFormat keys considered for</th> </tr><tr> <th>Audio Codecs</th> <th>Video Codecs</th> <th>Encoders</th> </tr> </thead> <tbody> <tr> <td>android.os.Build.VERSION_CODES#LOLLIPOP</td> <td rowspan=3>MediaFormat#KEY_MIME<sup>*</sup>,<br> MediaFormat#KEY_SAMPLE_RATE,<br> MediaFormat#KEY_CHANNEL_COUNT,</td> <td>MediaFormat#KEY_MIME<sup>*</sup>,<br> CodecCapabilities#FEATURE_AdaptivePlayback<sup>D</sup>,<br> CodecCapabilities#FEATURE_SecurePlayback<sup>D</sup>,<br> CodecCapabilities#FEATURE_TunneledPlayback<sup>D</sup>,<br> MediaFormat#KEY_WIDTH,<br> MediaFormat#KEY_HEIGHT,<br> <strong>no</strong> KEY_FRAME_RATE</td> <td rowspan=10>as to the left, plus<br> MediaFormat#KEY_BITRATE_MODE,<br> MediaFormat#KEY_PROFILE (and/or MediaFormat#KEY_AAC_PROFILE<sup>~</sup>),<br> <!-- {link MediaFormat#KEY_QUALITY},<br> --> MediaFormat#KEY_COMPLEXITY (and/or MediaFormat#KEY_FLAC_COMPRESSION_LEVEL<sup>~</sup>)</td> </tr><tr> <td>android.os.Build.VERSION_CODES#LOLLIPOP_MR1</td> <td rowspan=2>as above, plus<br> MediaFormat#KEY_FRAME_RATE</td> </tr><tr> <td>android.os.Build.VERSION_CODES#M</td> </tr><tr> <td>android.os.Build.VERSION_CODES#N</td> <td rowspan=2>as above, plus<br> MediaFormat#KEY_PROFILE,<br> <!-- {link MediaFormat#KEY_MAX_BIT_RATE},<br> --> MediaFormat#KEY_BIT_RATE</td> <td rowspan=2>as above, plus<br> MediaFormat#KEY_PROFILE,<br> MediaFormat#KEY_LEVEL<sup>+</sup>,<br> <!-- {link MediaFormat#KEY_MAX_BIT_RATE},<br> --> MediaFormat#KEY_BIT_RATE,<br> CodecCapabilities#FEATURE_IntraRefresh<sup>E</sup></td> </tr><tr> <td>android.os.Build.VERSION_CODES#N_MR1</td> </tr><tr> <td>android.os.Build.VERSION_CODES#O</td> <td rowspan=3 colspan=2>as above, plus<br> CodecCapabilities#FEATURE_PartialFrame<sup>D</sup></td> </tr><tr> <td>android.os.Build.VERSION_CODES#O_MR1</td> </tr><tr> <td>android.os.Build.VERSION_CODES#P</td> </tr><tr> <td>android.os.Build.VERSION_CODES#Q</td> <td colspan=2>as above, plus<br> CodecCapabilities#FEATURE_FrameParsing<sup>D</sup>,<br> CodecCapabilities#FEATURE_MultipleFrames,<br> CodecCapabilities#FEATURE_DynamicTimestamp</td> </tr><tr> <td>android.os.Build.VERSION_CODES#R</td> <td colspan=2>as above, plus<br> CodecCapabilities#FEATURE_LowLatency<sup>D</sup></td> </tr> <tr> <td colspan=4> <p class=note><strong>Notes:</strong><br> *: must be specified; otherwise, method returns false.<br> +: method does not verify that the format parameters are supported by the specified level.<br> D: decoders only<br> E: encoders only<br> ~: if both keys are provided values must match </td> </tr> </tbody> </table>

Java documentation for android.media.MediaCodecInfo.CodecCapabilities.isFormatSupported(android.media.MediaFormat).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to