private static boolean hasCodecForMime(boolean encoder, String mime) { for (MediaCodecInfo info : sMCL.getCodecInfos()) { if (encoder != info.isEncoder()) { continue; } for (String type : info.getSupportedTypes()) { if (type.equalsIgnoreCase(mime)) { Log.i(TAG, "found codec " + info.getName() + " for mime " + mime); return true; } } } return false; }
@SuppressWarnings("deprecation") @SuppressLint("NewApi") private static LinkedList<MediaCodecInfo> getMediaCodecList() { LinkedList<MediaCodecInfo> infoList = new LinkedList<MediaCodecInfo>(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS); Collections.addAll(infoList, mcl.getCodecInfos()); } else { for (int i = 0; i < MediaCodecList.getCodecCount(); i++) { infoList.add(MediaCodecList.getCodecInfoAt(i)); } } return infoList; }