android.media.MediaCodec# getCodecInfo ( ) 源码实例Demo

下面列出了android.media.MediaCodec# getCodecInfo ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: VideoProcessor   文件: VideoUtil.java

public static boolean trySetProfileAndLevel(MediaCodec codec, String mime, MediaFormat format, int profileInt, int levelInt) {
    MediaCodecInfo codecInfo = codec.getCodecInfo();
    MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(mime);
    MediaCodecInfo.CodecProfileLevel[] profileLevels = capabilities.profileLevels;
    if (profileLevels == null) {
        return false;
    }
    for (MediaCodecInfo.CodecProfileLevel level : profileLevels) {
        if (level.profile == profileInt) {
            if (level.level == levelInt) {
                format.setInteger(MediaFormat.KEY_PROFILE, profileInt);
                format.setInteger(MediaFormat.KEY_LEVEL, levelInt);
                return true;
            }
        }
    }
    return false;
}
 
源代码2 项目: 365browser   文件: MediaCodecUtil.java

/**
 * Returns true if the given codec supports adaptive playback (dynamic resolution change).
 * @param mediaCodec the codec.
 * @param mime MIME type that corresponds to the codec creation.
 * @return true if this codec and mime type combination supports adaptive playback.
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean codecSupportsAdaptivePlayback(MediaCodec mediaCodec, String mime) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || mediaCodec == null) {
        return false;
    }
    try {
        MediaCodecInfo info = mediaCodec.getCodecInfo();
        if (info.isEncoder()) {
            return false;
        }

        if (isAdaptivePlaybackBlacklisted(mime)) {
            return false;
        }

        MediaCodecInfo.CodecCapabilities capabilities = info.getCapabilitiesForType(mime);
        return (capabilities != null)
                && capabilities.isFeatureSupported(
                           MediaCodecInfo.CodecCapabilities.FEATURE_AdaptivePlayback);
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "Cannot retrieve codec information", e);
    }
    return false;
}
 
源代码3 项目: VideoProcessor   文件: VideoUtil.java

public static int getMaxSupportBitrate(MediaCodec codec, String mime) {
    try {
        MediaCodecInfo codecInfo = codec.getCodecInfo();
        MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(mime);
        Integer maxBitrate = capabilities.getVideoCapabilities().getBitrateRange().getUpper();
        return maxBitrate;
    } catch (Exception e) {
        CL.e(e);
        return -1;
    }
}