Search in sources :

Example 1 with CodecProfileLevel

use of android.media.MediaCodecInfo.CodecProfileLevel in project ExoPlayer by google.

the class MediaCodecUtil method maxH264DecodableFrameSize.

/**
   * Returns the maximum frame size supported by the default H264 decoder.
   *
   * @return The maximum frame size for an H264 stream that can be decoded on the device.
   */
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
    if (maxH264DecodableFrameSize == -1) {
        int result = 0;
        MediaCodecInfo decoderInfo = getDecoderInfo(MimeTypes.VIDEO_H264, false);
        if (decoderInfo != null) {
            for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
                result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);
            }
            // We assume support for at least 480p (SDK_INT >= 21) or 360p (SDK_INT < 21), which are
            // the levels mandated by the Android CDD.
            result = Math.max(result, Util.SDK_INT >= 21 ? (720 * 480) : (480 * 360));
        }
        maxH264DecodableFrameSize = result;
    }
    return maxH264DecodableFrameSize;
}
Also used : CodecProfileLevel(android.media.MediaCodecInfo.CodecProfileLevel) SuppressLint(android.annotation.SuppressLint)

Example 2 with CodecProfileLevel

use of android.media.MediaCodecInfo.CodecProfileLevel in project ExoPlayer by google.

the class MediaCodecInfo method isCodecSupported.

/**
   * Whether the decoder supports the given {@code codec}. If there is insufficient information to
   * decide, returns true.
   *
   * @param codec Codec string as defined in RFC 6381.
   * @return True if the given codec is supported by the decoder.
   */
public boolean isCodecSupported(String codec) {
    if (codec == null || mimeType == null) {
        return true;
    }
    String codecMimeType = MimeTypes.getMediaMimeType(codec);
    if (codecMimeType == null) {
        return true;
    }
    if (!mimeType.equals(codecMimeType)) {
        logNoSupport("codec.mime " + codec + ", " + codecMimeType);
        return false;
    }
    Pair<Integer, Integer> codecProfileAndLevel = MediaCodecUtil.getCodecProfileAndLevel(codec);
    if (codecProfileAndLevel == null) {
        // If we don't know any better, we assume that the profile and level are supported.
        return true;
    }
    for (CodecProfileLevel capabilities : getProfileLevels()) {
        if (capabilities.profile == codecProfileAndLevel.first && capabilities.level >= codecProfileAndLevel.second) {
            return true;
        }
    }
    logNoSupport("codec.profileLevel, " + codec + ", " + codecMimeType);
    return false;
}
Also used : CodecProfileLevel(android.media.MediaCodecInfo.CodecProfileLevel)

Example 3 with CodecProfileLevel

use of android.media.MediaCodecInfo.CodecProfileLevel in project edx-app-android by edx.

the class MediaCodecUtil method isH264ProfileSupported.

/**
 * @param profile An AVC profile constant from {@link CodecProfileLevel}.
 * @param level An AVC profile level from {@link CodecProfileLevel}.
 * @return Whether the specified profile is supported at the specified level.
 */
public static boolean isH264ProfileSupported(int profile, int level) {
    Pair<MediaCodecInfo, CodecCapabilities> info = getMediaCodecInfo(MimeTypes.VIDEO_H264);
    if (info == null) {
        return false;
    }
    CodecCapabilities capabilities = info.second;
    for (int i = 0; i < capabilities.profileLevels.length; i++) {
        CodecProfileLevel profileLevel = capabilities.profileLevels[i];
        if (profileLevel.profile == profile && profileLevel.level >= level) {
            return true;
        }
    }
    return false;
}
Also used : CodecProfileLevel(android.media.MediaCodecInfo.CodecProfileLevel) MediaCodecInfo(android.media.MediaCodecInfo) CodecCapabilities(android.media.MediaCodecInfo.CodecCapabilities)

Example 4 with CodecProfileLevel

use of android.media.MediaCodecInfo.CodecProfileLevel in project edx-app-android by edx.

the class MediaCodecUtil method maxH264DecodableFrameSize.

/**
 * @return the maximum frame size for an H264 stream that can be decoded on the device.
 */
public static int maxH264DecodableFrameSize() {
    Pair<MediaCodecInfo, CodecCapabilities> info = getMediaCodecInfo(MimeTypes.VIDEO_H264);
    if (info == null) {
        return 0;
    }
    int maxH264DecodableFrameSize = 0;
    CodecCapabilities capabilities = info.second;
    for (int i = 0; i < capabilities.profileLevels.length; i++) {
        CodecProfileLevel profileLevel = capabilities.profileLevels[i];
        maxH264DecodableFrameSize = Math.max(avcLevelToMaxFrameSize(profileLevel.level), maxH264DecodableFrameSize);
    }
    return maxH264DecodableFrameSize;
}
Also used : CodecProfileLevel(android.media.MediaCodecInfo.CodecProfileLevel) MediaCodecInfo(android.media.MediaCodecInfo) CodecCapabilities(android.media.MediaCodecInfo.CodecCapabilities)

Example 5 with CodecProfileLevel

use of android.media.MediaCodecInfo.CodecProfileLevel in project developmentDependencyLibrary by MatchlessBrother.

the class IjkMediaCodecInfo method dumpProfileLevels.

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void dumpProfileLevels(String mimeType) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
        return;
    try {
        CodecCapabilities caps = mCodecInfo.getCapabilitiesForType(mimeType);
        int maxProfile = 0;
        int maxLevel = 0;
        if (caps != null) {
            if (caps.profileLevels != null) {
                for (CodecProfileLevel profileLevel : caps.profileLevels) {
                    if (profileLevel == null)
                        continue;
                    maxProfile = Math.max(maxProfile, profileLevel.profile);
                    maxLevel = Math.max(maxLevel, profileLevel.level);
                }
            }
        }
        Log.i(TAG, String.format(Locale.US, "%s", getProfileLevelName(maxProfile, maxLevel)));
    } catch (Throwable e) {
        Log.i(TAG, "profile-level: exception");
    }
}
Also used : CodecProfileLevel(android.media.MediaCodecInfo.CodecProfileLevel) CodecCapabilities(android.media.MediaCodecInfo.CodecCapabilities) TargetApi(android.annotation.TargetApi)

Aggregations

CodecProfileLevel (android.media.MediaCodecInfo.CodecProfileLevel)5 CodecCapabilities (android.media.MediaCodecInfo.CodecCapabilities)3 MediaCodecInfo (android.media.MediaCodecInfo)2 SuppressLint (android.annotation.SuppressLint)1 TargetApi (android.annotation.TargetApi)1