本文整理汇总了Java中android.media.MediaCodecInfo.VideoCapabilities方法的典型用法代码示例。如果您正苦于以下问题:Java MediaCodecInfo.VideoCapabilities方法的具体用法?Java MediaCodecInfo.VideoCapabilities怎么用?Java MediaCodecInfo.VideoCapabilities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.MediaCodecInfo
的用法示例。
在下文中一共展示了MediaCodecInfo.VideoCapabilities方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
* Initialize HeifReader module.
*
* @param context Context.
*/
public static void initialize(Context context) {
mRenderScript = RenderScript.create(context);
mCacheDir = context.getCacheDir();
// find best HEVC decoder
mDecoderName = null;
mDecoderSupportedSize = new Size(0, 0);
int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (codecInfo.isEncoder()) {
continue;
}
for (String type : codecInfo.getSupportedTypes()) {
if (type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_HEVC)) {
MediaCodecInfo.CodecCapabilities cap = codecInfo.getCapabilitiesForType(MediaFormat.MIMETYPE_VIDEO_HEVC);
MediaCodecInfo.VideoCapabilities vcap = cap.getVideoCapabilities();
Size supportedSize = new Size(vcap.getSupportedWidths().getUpper(), vcap.getSupportedHeights().getUpper());
Log.d(TAG, "HEVC decoder=\"" + codecInfo.getName() + "\""
+ " supported-size=" + supportedSize
+ " color-formats=" + Arrays.toString(cap.colorFormats)
);
if (mDecoderSupportedSize.getWidth() * mDecoderSupportedSize.getHeight() < supportedSize.getWidth() * supportedSize.getHeight()) {
mDecoderName = codecInfo.getName();
mDecoderSupportedSize = supportedSize;
}
}
}
}
if (mDecoderName == null) {
throw new RuntimeException("no HEVC decoding support");
}
Log.i(TAG, "HEVC decoder=\"" + mDecoderName + "\" supported-size=" + mDecoderSupportedSize);
}
示例2: getEncodVieoeCapability
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
public static EncodeVideoCapability getEncodVieoeCapability(MediaCodec mediaCodec, String mime)
{
if( mediaCodec == null || Build.VERSION.SDK_INT < 18) {
return null;
}
EncodeVideoCapability retCapability = new EncodeVideoCapability();
//String mime = mEncodeFormat.getValue();
MediaCodecInfo codecInfo = mediaCodec.getCodecInfo();
MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(mime);
int[] deviceColor = capabilities.colorFormats;
retCapability.colorFormat = deviceColor;
MediaCodecInfo.CodecProfileLevel[] profileLevels = capabilities.profileLevels;
if(null != profileLevels)
{
retCapability.profileLevel = new EncodeVideoCapability.ProfileLevel[profileLevels.length];
for(int i = 0; i < profileLevels.length; ++i)
{
retCapability.profileLevel[i] = new EncodeVideoCapability.ProfileLevel(profileLevels[i].profile, profileLevels[i].level);
}
}
Range<Integer> widthRange = null;
Range<Integer> heightRange = null;
if(Build.VERSION.SDK_INT >= 21) {
MediaCodecInfo.VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities();
heightRange = videoCapabilities.getSupportedHeights();
widthRange = videoCapabilities.getSupportedWidths();
retCapability.heightAlignment = videoCapabilities.getHeightAlignment();
retCapability.widthAlignment = videoCapabilities.getWidthAlignment();
}
else //for old device limite max width / height
{
// retCapability.widthUpper = 1280;
// retCapability.widthLower = 176;
// retCapability.heightUpper = 720;
// retCapability.heightLower = 144;
retCapability.heightAlignment = 2;
retCapability.widthAlignment = 2;
}
if(null != widthRange)
{
retCapability.widthUpper = widthRange.getUpper();
retCapability.widthLower = widthRange.getLower();
}
if(null != heightRange)
{
retCapability.heightUpper = heightRange.getUpper();
retCapability.heightLower = heightRange.getLower();
}
return retCapability;
}
示例3: getVideoCapabilitiesV21
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
@TargetApi(21)
private static MediaCodecInfo.VideoCapabilities getVideoCapabilitiesV21(String mimeType,
boolean secure) throws DecoderQueryException {
DecoderInfo decoderInfo = getDecoderInfo(mimeType, secure);
return decoderInfo == null ? null : decoderInfo.capabilities.getVideoCapabilities();
}
示例4: isSizeSupportedV21
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
* Tests whether the device advertises it can decode video of a given type at a specified width
* and height.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param mimeType The mime type.
* @param secure Whether the decoder is required to support secure decryption. Always pass false
* unless secure decryption really is required.
* @param width Width in pixels.
* @param height Height in pixels.
* @return Whether the decoder advertises support of the given size.
*/
@TargetApi(21)
public static boolean isSizeSupportedV21(String mimeType, boolean secure, int width,
int height) throws DecoderQueryException {
Assertions.checkState(Util.SDK_INT >= 21);
MediaCodecInfo.VideoCapabilities videoCapabilities = getVideoCapabilitiesV21(mimeType, secure);
return videoCapabilities != null && videoCapabilities.isSizeSupported(width, height);
}
示例5: isSizeAndRateSupportedV21
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
* Tests whether the device advertises it can decode video of a given type at a specified
* width, height, and frame rate.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param mimeType The mime type.
* @param secure Whether the decoder is required to support secure decryption. Always pass false
* unless secure decryption really is required.
* @param width Width in pixels.
* @param height Height in pixels.
* @param frameRate Frame rate in frames per second.
* @return Whether the decoder advertises support of the given size and frame rate.
*/
@TargetApi(21)
public static boolean isSizeAndRateSupportedV21(String mimeType, boolean secure,
int width, int height, double frameRate) throws DecoderQueryException {
Assertions.checkState(Util.SDK_INT >= 21);
MediaCodecInfo.VideoCapabilities videoCapabilities = getVideoCapabilitiesV21(mimeType, secure);
return videoCapabilities != null
&& videoCapabilities.areSizeAndRateSupported(width, height, frameRate);
}