Search in sources :

Example 16 with MediaCodecInfo

use of android.media.MediaCodecInfo in project LanSoEditor_common by LanSoSdk.

the class VideoEditor method selectCodec.

private static MediaCodecInfo selectCodec(String mimeType) {
    int numCodecs = MediaCodecList.getCodecCount();
    for (int i = 0; i < numCodecs; i++) {
        MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
        if (!codecInfo.isEncoder()) {
            continue;
        }
        String[] types = codecInfo.getSupportedTypes();
        for (int j = 0; j < types.length; j++) {
            if (types[j].equalsIgnoreCase(mimeType)) {
                return codecInfo;
            }
        }
    }
    return null;
}
Also used : MediaCodecInfo(android.media.MediaCodecInfo)

Example 17 with MediaCodecInfo

use of android.media.MediaCodecInfo in project Pix-Art-Messenger by kriztan.

the class MediaCodecListCompat method findCoderForFormat.

private String findCoderForFormat(MediaFormat format, boolean findEncoder) {
    String mimeType = format.getString(MediaFormat.KEY_MIME);
    Iterator<MediaCodecInfo> iterator = new MediaCodecInfoIterator();
    while (iterator.hasNext()) {
        MediaCodecInfo codecInfo = iterator.next();
        if (codecInfo.isEncoder() != findEncoder)
            continue;
        if (Arrays.asList(codecInfo.getSupportedTypes()).contains(mimeType)) {
            return codecInfo.getName();
        }
    }
    return null;
}
Also used : MediaCodecInfo(android.media.MediaCodecInfo)

Example 18 with MediaCodecInfo

use of android.media.MediaCodecInfo in project EasyPlayer-RTMP-Android by EasyDSS.

the class EasyPlayerClient method codecName.

private static String codecName() {
    ArrayList<String> array = new ArrayList<>();
    int numCodecs = MediaCodecList.getCodecCount();
    for (int i1 = 0; i1 < numCodecs; i1++) {
        MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i1);
        if (codecInfo.isEncoder()) {
            continue;
        }
        if (codecMatch("video/avc", codecInfo)) {
            String name = codecInfo.getName();
            Log.d("DECODER", String.format("decoder:%s", name));
            array.add(name);
        }
    }
    // }
    if (array.isEmpty()) {
        return "";
    }
    return array.get(0);
}
Also used : MediaCodecInfo(android.media.MediaCodecInfo) ArrayList(java.util.ArrayList)

Example 19 with MediaCodecInfo

use of android.media.MediaCodecInfo 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 20 with MediaCodecInfo

use of android.media.MediaCodecInfo 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)

Aggregations

MediaCodecInfo (android.media.MediaCodecInfo)47 ArrayList (java.util.ArrayList)16 CodecCapabilities (android.media.MediaCodecInfo.CodecCapabilities)14 MediaCodecList (android.media.MediaCodecList)11 Point (android.graphics.Point)7 TargetApi (android.annotation.TargetApi)6 VideoCapabilities (android.media.MediaCodecInfo.VideoCapabilities)6 IOException (java.io.IOException)6 HashSet (java.util.HashSet)6 SuppressLint (android.annotation.SuppressLint)5 MediaFormat (android.media.MediaFormat)5 Size (android.util.Size)5 Test (org.junit.Test)5 Config (org.robolectric.annotation.Config)5 SparseIntArray (android.util.SparseIntArray)4 TreeMap (java.util.TreeMap)4 StreamConfigurationMap (android.hardware.camera2.params.StreamConfigurationMap)2 CodecProfileLevel (android.media.MediaCodecInfo.CodecProfileLevel)2 NonNull (android.support.annotation.NonNull)2 Range (android.util.Range)2