Java Code Examples for android.media.MediaCodecList#getCodecCount()
The following examples show how to use
android.media.MediaCodecList#getCodecCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EncodeDecode.java From videocreator with Apache License 2.0 | 6 votes |
/** * Returns the first codec capable of encoding the specified MIME type, or * null if no match was found. */ 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; }
Example 2
Source File: MediaVideoEncoder.java From AudioVideoRecordingSample with Apache License 2.0 | 6 votes |
/** * select the first codec that match a specific MIME type * @param mimeType * @return null if no codec matched */ protected static final MediaCodecInfo selectVideoCodec(final String mimeType) { if (DEBUG) Log.v(TAG, "selectVideoCodec:"); // get the list of available codecs final int numCodecs = MediaCodecList.getCodecCount(); for (int i = 0; i < numCodecs; i++) { final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); if (!codecInfo.isEncoder()) { // skipp decoder continue; } // select first codec that match a specific MIME type and color format final String[] types = codecInfo.getSupportedTypes(); for (int j = 0; j < types.length; j++) { if (types[j].equalsIgnoreCase(mimeType)) { if (DEBUG) Log.i(TAG, "codec:" + codecInfo.getName() + ",MIME=" + types[j]); final int format = selectColorFormat(codecInfo, mimeType); if (format > 0) { return codecInfo; } } } } return null; }
Example 3
Source File: SvcEncoder.java From cameraMediaCodec with BSD 2-Clause "Simplified" License | 6 votes |
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)) { Log.d("AvcEncoder", "selectCodec OK, get "+mimeType); return codecInfo; } } } return null; }
Example 4
Source File: AvcEncoder.java From videocreator with Apache License 2.0 | 6 votes |
public int[] getMediaCodecList() { //获取解码器列表 int numCodecs = MediaCodecList.getCodecCount(); MediaCodecInfo codecInfo = null; for (int i = 0; i < numCodecs && codecInfo == null; i++) { MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i); if (!info.isEncoder()) { continue; } String[] types = info.getSupportedTypes(); boolean found = false; //轮训所要的解码器 for (int j = 0; j < types.length && !found; j++) { if (types[j].equals("video/avc")) { found = true; } } if (!found) { continue; } codecInfo = info; } Log.d(TAG, "found" + codecInfo.getName() + "supporting" + " video/avc"); MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType("video/avc"); return capabilities.colorFormats; }
Example 5
Source File: VideoController.java From VideoCompressor with Apache License 2.0 | 6 votes |
public static MediaCodecInfo selectCodec(String mimeType) { int numCodecs = MediaCodecList.getCodecCount(); MediaCodecInfo lastCodecInfo = null; for (int i = 0; i < numCodecs; i++) { MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); if (!codecInfo.isEncoder()) { continue; } String[] types = codecInfo.getSupportedTypes(); for (String type : types) { if (type.equalsIgnoreCase(mimeType)) { lastCodecInfo = codecInfo; if (!lastCodecInfo.getName().equals("OMX.SEC.avc.enc")) { return lastCodecInfo; } else if (lastCodecInfo.getName().equals("OMX.SEC.AVC.Encoder")) { return lastCodecInfo; } } } } return lastCodecInfo; }
Example 6
Source File: MediaAudioEncoder.java From PLDroidShortVideo with Apache License 2.0 | 6 votes |
/** * select the first codec that match a specific MIME type * * @param mimeType * @return */ private static final MediaCodecInfo selectAudioCodec(final String mimeType) { if (DEBUG) Log.v(TAG, "selectAudioCodec:"); MediaCodecInfo result = null; // get the list of available codecs final int numCodecs = MediaCodecList.getCodecCount(); LOOP: for (int i = 0; i < numCodecs; i++) { final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); if (!codecInfo.isEncoder()) { // skipp decoder continue; } final String[] types = codecInfo.getSupportedTypes(); for (int j = 0; j < types.length; j++) { if (DEBUG) Log.i(TAG, "supportedType:" + codecInfo.getName() + ",MIME=" + types[j]); if (types[j].equalsIgnoreCase(mimeType)) { if (result == null) { result = codecInfo; break LOOP; } } } } return result; }
Example 7
Source File: MediaSurfaceEncoder.java From AndroidUSBCamera with Apache License 2.0 | 6 votes |
/** * select the first codec that match a specific MIME type * @param mimeType * @return null if no codec matched */ protected static final MediaCodecInfo selectVideoCodec(final String mimeType) { if (DEBUG) Log.v(TAG, "selectVideoCodec:"); // get the list of available codecs final int numCodecs = MediaCodecList.getCodecCount(); for (int i = 0; i < numCodecs; i++) { final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); if (!codecInfo.isEncoder()) { // skipp decoder continue; } // select first codec that match a specific MIME type and color format final String[] types = codecInfo.getSupportedTypes(); for (int j = 0; j < types.length; j++) { if (types[j].equalsIgnoreCase(mimeType)) { if (DEBUG) Log.i(TAG, "codec:" + codecInfo.getName() + ",MIME=" + types[j]); final int format = selectColorFormat(codecInfo, mimeType); if (format > 0) { return codecInfo; } } } } return null; }
Example 8
Source File: MediaAudioEncoder.java From CameraRecorder-android with MIT License | 6 votes |
/** * select the first codec that match a specific MIME type * * @param mimeType * @return */ private static final MediaCodecInfo selectAudioCodec(final String mimeType) { Log.v(TAG, "selectAudioCodec:"); MediaCodecInfo result = null; // get the list of available codecs final int numCodecs = MediaCodecList.getCodecCount(); LOOP: for (int i = 0; i < numCodecs; i++) { final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); if (!codecInfo.isEncoder()) { // skipp decoder continue; } final String[] types = codecInfo.getSupportedTypes(); for (int j = 0; j < types.length; j++) { Log.i(TAG, "supportedType:" + codecInfo.getName() + ",MIME=" + types[j]); if (types[j].equalsIgnoreCase(mimeType)) { if (result == null) { result = codecInfo; break LOOP; } } } } return result; }
Example 9
Source File: MediaConverter.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
/** * Returns the first codec capable of encoding the specified MIME type, or null if no match was * found. */ static MediaCodecInfo selectCodec(final String mimeType) { final int numCodecs = MediaCodecList.getCodecCount(); for (int i = 0; i < numCodecs; i++) { final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); if (!codecInfo.isEncoder()) { continue; } final String[] types = codecInfo.getSupportedTypes(); for (String type : types) { if (type.equalsIgnoreCase(mimeType)) { return codecInfo; } } } return null; }
Example 10
Source File: SMedia.java From NewsMe with Apache License 2.0 | 5 votes |
/** * check c name */ private String haveSEC() { try { int numCodecs = MediaCodecList.getCodecCount(); for (int i = 0; i < numCodecs; i++) { MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); if (codecInfo.isEncoder()) { continue; } String[] types = codecInfo.getSupportedTypes(); if (null == types) { break; } for (int j = 0; j < types.length; j++) { if (types[j] != null && types[j].equalsIgnoreCase(mime) && codecInfo.getName().equalsIgnoreCase( "OMX.SEC.AVC.Decoder")) { // Log.d(TAG, "find SEC," +codecInfo.getName() // +"->support type["+j+"]="+types[j]); return codecInfo.getName(); } } } } catch (Exception ex) { Log.e(TAG, "find SEC error!"); } // Log.d(TAG, "not find SEC!"); return ""; }
Example 11
Source File: MediaVideoBufferEncoder.java From AndroidUSBCamera with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") protected final MediaCodecInfo selectVideoCodec(final String mimeType) { if (DEBUG) Log.v(TAG, "selectVideoCodec:"); // get the list of available codecs final int numCodecs = MediaCodecList.getCodecCount(); for (int i = 0; i < numCodecs; i++) { final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); if (!codecInfo.isEncoder()) { // skipp decoder continue; } // select first codec that match a specific MIME type and color format final String[] types = codecInfo.getSupportedTypes(); for (int j = 0; j < types.length; j++) { if (types[j].equalsIgnoreCase(mimeType)) { if (DEBUG) Log.i(TAG, "codec:" + codecInfo.getName() + ",MIME=" + types[j]); final int format = selectColorFormat(codecInfo, mimeType); if (format > 0) { mColorFormat = format; return codecInfo; } } } } return null; }
Example 12
Source File: TLMediaVideoEncoder.java From TimeLapseRecordingSample with Apache License 2.0 | 5 votes |
/** * select first encoder matched to specific MIME * @param mimeType * @return return null if not found */ @SuppressWarnings("deprecation") protected static final MediaCodecInfo selectVideoCodec(final String mimeType) { if (DEBUG) Log.v(TAG, "selectVideoCodec:"); // get the list of available codecs final int numCodecs = MediaCodecList.getCodecCount(); for (int i = 0; i < numCodecs; i++) { final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); if (!codecInfo.isEncoder()) { // skipp decoder continue; } // select first codec that match a specific MIME type and color format final String[] types = codecInfo.getSupportedTypes(); for (String type : types) { if (type.equalsIgnoreCase(mimeType)) { if (DEBUG) Log.i(TAG, "codec:" + codecInfo.getName() + ",MIME=" + type); int format = selectColorFormat(codecInfo, mimeType); if (format > 0) { return codecInfo; } } } } return null; }
Example 13
Source File: CodecManager.java From spydroid-ipcamera with GNU General Public License v3.0 | 4 votes |
/** * Returns an associative array of the supported color formats and the names of the encoders for a given mime type * This can take up to sec on certain phones the first time you run it... **/ @SuppressLint("NewApi") static private void findSupportedColorFormats(String mimeType) { SparseArray<ArrayList<String>> softwareCodecs = new SparseArray<ArrayList<String>>(); SparseArray<ArrayList<String>> hardwareCodecs = new SparseArray<ArrayList<String>>(); if (sSoftwareCodecs.containsKey(mimeType)) { return; } Log.v(TAG,"Searching supported color formats for mime type \""+mimeType+"\"..."); // We loop through the encoders, apparently this can take up to a sec (testes on a GS3) for(int j = MediaCodecList.getCodecCount() - 1; j >= 0; j--){ MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(j); if (!codecInfo.isEncoder()) continue; String[] types = codecInfo.getSupportedTypes(); for (int i = 0; i < types.length; i++) { if (types[i].equalsIgnoreCase(mimeType)) { MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(mimeType); boolean software = false; for (int k=0;k<SOFTWARE_ENCODERS.length;k++) { if (codecInfo.getName().equalsIgnoreCase(SOFTWARE_ENCODERS[i])) { software = true; } } // And through the color formats supported for (int k = 0; k < capabilities.colorFormats.length; k++) { int format = capabilities.colorFormats[k]; if (software) { if (softwareCodecs.get(format) == null) softwareCodecs.put(format, new ArrayList<String>()); softwareCodecs.get(format).add(codecInfo.getName()); } else { if (hardwareCodecs.get(format) == null) hardwareCodecs.put(format, new ArrayList<String>()); hardwareCodecs.get(format).add(codecInfo.getName()); } } } } } // Logs the supported color formats on the phone StringBuilder e = new StringBuilder(); e.append("Supported color formats on this phone: "); for (int i=0;i<softwareCodecs.size();i++) e.append(softwareCodecs.keyAt(i)+", "); for (int i=0;i<hardwareCodecs.size();i++) e.append(hardwareCodecs.keyAt(i)+(i==hardwareCodecs.size()-1?".":", ")); Log.v(TAG, e.toString()); sSoftwareCodecs.put(mimeType, softwareCodecs); sHardwareCodecs.put(mimeType, hardwareCodecs); return; }
Example 14
Source File: MediaCodecListCompat.java From phoenix with Apache License 2.0 | 4 votes |
private static int getCodecCount() { return MediaCodecList.getCodecCount(); }
Example 15
Source File: IjkMediaPlayer.java From MediaSDK with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public String onMediaCodecSelect(IMediaPlayer mp, String mimeType, int profile, int level) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return null; if (TextUtils.isEmpty(mimeType)) return null; Log.i(TAG, String.format(Locale.US, "onSelectCodec: mime=%s, profile=%d, level=%d", mimeType, profile, level)); ArrayList<IjkMediaCodecInfo> candidateCodecList = new ArrayList<IjkMediaCodecInfo>(); int numCodecs = MediaCodecList.getCodecCount(); for (int i = 0; i < numCodecs; i++) { MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); Log.d(TAG, String.format(Locale.US, " found codec: %s", codecInfo.getName())); if (codecInfo.isEncoder()) continue; String[] types = codecInfo.getSupportedTypes(); if (types == null) continue; for(String type: types) { if (TextUtils.isEmpty(type)) continue; Log.d(TAG, String.format(Locale.US, " mime: %s", type)); if (!type.equalsIgnoreCase(mimeType)) continue; IjkMediaCodecInfo candidate = IjkMediaCodecInfo.setupCandidate(codecInfo, mimeType); if (candidate == null) continue; candidateCodecList.add(candidate); Log.i(TAG, String.format(Locale.US, "candidate codec: %s rank=%d", codecInfo.getName(), candidate.mRank)); candidate.dumpProfileLevels(mimeType); } } if (candidateCodecList.isEmpty()) { return null; } IjkMediaCodecInfo bestCodec = candidateCodecList.get(0); for (IjkMediaCodecInfo codec : candidateCodecList) { if (codec.mRank > bestCodec.mRank) { bestCodec = codec; } } if (bestCodec.mRank < IjkMediaCodecInfo.RANK_LAST_CHANCE) { Log.w(TAG, String.format(Locale.US, "unaccetable codec: %s", bestCodec.mCodecInfo.getName())); return null; } Log.i(TAG, String.format(Locale.US, "selected codec: %s rank=%d", bestCodec.mCodecInfo.getName(), bestCodec.mRank)); return bestCodec.mCodecInfo.getName(); }
Example 16
Source File: IjkMediaPlayer.java From JZVideoDemo with MIT License | 4 votes |
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public String onMediaCodecSelect(IMediaPlayer mp, String mimeType, int profile, int level) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return null; if (TextUtils.isEmpty(mimeType)) return null; Log.i(TAG, String.format(Locale.US, "onSelectCodec: mime=%s, profile=%d, level=%d", mimeType, profile, level)); ArrayList<IjkMediaCodecInfo> candidateCodecList = new ArrayList<IjkMediaCodecInfo>(); int numCodecs = MediaCodecList.getCodecCount(); for (int i = 0; i < numCodecs; i++) { MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); Log.d(TAG, String.format(Locale.US, " found codec: %s", codecInfo.getName())); if (codecInfo.isEncoder()) continue; String[] types = codecInfo.getSupportedTypes(); if (types == null) continue; for (String type : types) { if (TextUtils.isEmpty(type)) continue; Log.d(TAG, String.format(Locale.US, " mime: %s", type)); if (!type.equalsIgnoreCase(mimeType)) continue; IjkMediaCodecInfo candidate = IjkMediaCodecInfo.setupCandidate(codecInfo, mimeType); if (candidate == null) continue; candidateCodecList.add(candidate); Log.i(TAG, String.format(Locale.US, "candidate codec: %s rank=%d", codecInfo.getName(), candidate.mRank)); candidate.dumpProfileLevels(mimeType); } } if (candidateCodecList.isEmpty()) { return null; } IjkMediaCodecInfo bestCodec = candidateCodecList.get(0); for (IjkMediaCodecInfo codec : candidateCodecList) { if (codec.mRank > bestCodec.mRank) { bestCodec = codec; } } if (bestCodec.mRank < IjkMediaCodecInfo.RANK_LAST_CHANCE) { Log.w(TAG, String.format(Locale.US, "unaccetable codec: %s", bestCodec.mCodecInfo.getName())); return null; } Log.i(TAG, String.format(Locale.US, "selected codec: %s rank=%d", bestCodec.mCodecInfo.getName(), bestCodec.mRank)); return bestCodec.mCodecInfo.getName(); }
Example 17
Source File: IjkMediaPlayer.java From IjkPlayerDemo with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public String onMediaCodecSelect(IMediaPlayer mp, String mimeType, int profile, int level) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return null; if (TextUtils.isEmpty(mimeType)) return null; Log.i(TAG, String.format(Locale.US, "onSelectCodec: mime=%s, profile=%d, level=%d", mimeType, profile, level)); ArrayList<IjkMediaCodecInfo> candidateCodecList = new ArrayList<IjkMediaCodecInfo>(); int numCodecs = MediaCodecList.getCodecCount(); for (int i = 0; i < numCodecs; i++) { MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); Log.d(TAG, String.format(Locale.US, " found codec: %s", codecInfo.getName())); if (codecInfo.isEncoder()) continue; String[] types = codecInfo.getSupportedTypes(); if (types == null) continue; for(String type: types) { if (TextUtils.isEmpty(type)) continue; Log.d(TAG, String.format(Locale.US, " mime: %s", type)); if (!type.equalsIgnoreCase(mimeType)) continue; IjkMediaCodecInfo candidate = IjkMediaCodecInfo.setupCandidate(codecInfo, mimeType); if (candidate == null) continue; candidateCodecList.add(candidate); Log.i(TAG, String.format(Locale.US, "candidate codec: %s rank=%d", codecInfo.getName(), candidate.mRank)); candidate.dumpProfileLevels(mimeType); } } if (candidateCodecList.isEmpty()) { return null; } IjkMediaCodecInfo bestCodec = candidateCodecList.get(0); for (IjkMediaCodecInfo codec : candidateCodecList) { if (codec.mRank > bestCodec.mRank) { bestCodec = codec; } } if (bestCodec.mRank < IjkMediaCodecInfo.RANK_LAST_CHANCE) { Log.w(TAG, String.format(Locale.US, "unaccetable codec: %s", bestCodec.mCodecInfo.getName())); return null; } Log.i(TAG, String.format(Locale.US, "selected codec: %s rank=%d", bestCodec.mCodecInfo.getName(), bestCodec.mRank)); return bestCodec.mCodecInfo.getName(); }
Example 18
Source File: IjkMediaPlayer.java From LivePlayback with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public String onMediaCodecSelect(IMediaPlayer mp, String mimeType, int profile, int level) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return null; if (TextUtils.isEmpty(mimeType)) return null; Log.i(TAG, String.format(Locale.US, "onSelectCodec: mime=%s, profile=%d, level=%d", mimeType, profile, level)); ArrayList<IjkMediaCodecInfo> candidateCodecList = new ArrayList<IjkMediaCodecInfo>(); int numCodecs = MediaCodecList.getCodecCount(); for (int i = 0; i < numCodecs; i++) { MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); Log.d(TAG, String.format(Locale.US, " found codec: %s", codecInfo.getName())); if (codecInfo.isEncoder()) continue; String[] types = codecInfo.getSupportedTypes(); if (types == null) continue; for(String type: types) { if (TextUtils.isEmpty(type)) continue; Log.d(TAG, String.format(Locale.US, " mime: %s", type)); if (!type.equalsIgnoreCase(mimeType)) continue; IjkMediaCodecInfo candidate = IjkMediaCodecInfo.setupCandidate(codecInfo, mimeType); if (candidate == null) continue; candidateCodecList.add(candidate); Log.i(TAG, String.format(Locale.US, "candidate codec: %s rank=%d", codecInfo.getName(), candidate.mRank)); candidate.dumpProfileLevels(mimeType); } } if (candidateCodecList.isEmpty()) { return null; } IjkMediaCodecInfo bestCodec = candidateCodecList.get(0); for (IjkMediaCodecInfo codec : candidateCodecList) { if (codec.mRank > bestCodec.mRank) { bestCodec = codec; } } if (bestCodec.mRank < IjkMediaCodecInfo.RANK_LAST_CHANCE) { Log.w(TAG, String.format(Locale.US, "unaccetable codec: %s", bestCodec.mCodecInfo.getName())); return null; } Log.i(TAG, String.format(Locale.US, "selected codec: %s rank=%d", bestCodec.mCodecInfo.getName(), bestCodec.mRank)); return bestCodec.mCodecInfo.getName(); }
Example 19
Source File: IjkMediaPlayer.java From AndroidTvDemo with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public String onMediaCodecSelect(IMediaPlayer mp, String mimeType, int profile, int level) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return null; if (TextUtils.isEmpty(mimeType)) return null; Log.i(TAG, String.format(Locale.US, "onSelectCodec: mime=%s, profile=%d, level=%d", mimeType, profile, level)); ArrayList<IjkMediaCodecInfo> candidateCodecList = new ArrayList<IjkMediaCodecInfo>(); int numCodecs = MediaCodecList.getCodecCount(); for (int i = 0; i < numCodecs; i++) { MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i); Log.d(TAG, String.format(Locale.US, " found codec: %s", codecInfo.getName())); if (codecInfo.isEncoder()) continue; String[] types = codecInfo.getSupportedTypes(); if (types == null) continue; for(String type: types) { if (TextUtils.isEmpty(type)) continue; Log.d(TAG, String.format(Locale.US, " mime: %s", type)); if (!type.equalsIgnoreCase(mimeType)) continue; IjkMediaCodecInfo candidate = IjkMediaCodecInfo.setupCandidate(codecInfo, mimeType); if (candidate == null) continue; candidateCodecList.add(candidate); Log.i(TAG, String.format(Locale.US, "candidate codec: %s rank=%d", codecInfo.getName(), candidate.mRank)); candidate.dumpProfileLevels(mimeType); } } if (candidateCodecList.isEmpty()) { return null; } IjkMediaCodecInfo bestCodec = candidateCodecList.get(0); for (IjkMediaCodecInfo codec : candidateCodecList) { if (codec.mRank > bestCodec.mRank) { bestCodec = codec; } } if (bestCodec.mRank < IjkMediaCodecInfo.RANK_LAST_CHANCE) { Log.w(TAG, String.format(Locale.US, "unaccetable codec: %s", bestCodec.mCodecInfo.getName())); return null; } Log.i(TAG, String.format(Locale.US, "selected codec: %s rank=%d", bestCodec.mCodecInfo.getName(), bestCodec.mRank)); return bestCodec.mCodecInfo.getName(); }
Example 20
Source File: MediaCodecVideoDecoder.java From droidkit-webrtc with BSD 3-Clause "New" or "Revised" License | 4 votes |
private static DecoderProperties findVp8HwDecoder() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return null; // MediaCodec.setParameters is missing. for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) { MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i); if (info.isEncoder()) { continue; } String name = null; for (String mimeType : info.getSupportedTypes()) { if (mimeType.equals(VP8_MIME_TYPE)) { name = info.getName(); break; } } if (name == null) { continue; // No VP8 support in this codec; try the next one. } Log.d(TAG, "Found candidate decoder " + name); CodecCapabilities capabilities = info.getCapabilitiesForType(VP8_MIME_TYPE); for (int colorFormat : capabilities.colorFormats) { Log.d(TAG, " Color: 0x" + Integer.toHexString(colorFormat)); } // Check if this is supported HW decoder for (String hwCodecPrefix : supportedHwCodecPrefixes) { if (!name.startsWith(hwCodecPrefix)) { continue; } // Check if codec supports either yuv420 or nv12 for (int supportedColorFormat : supportedColorList) { for (int codecColorFormat : capabilities.colorFormats) { if (codecColorFormat == supportedColorFormat) { // Found supported HW VP8 decoder Log.d(TAG, "Found target decoder " + name + ". Color: 0x" + Integer.toHexString(codecColorFormat)); return new DecoderProperties(name, codecColorFormat); } } } } } return null; // No HW VP8 decoder. }