當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaCodecList.getCodecInfoAt方法代碼示例

本文整理匯總了Java中android.media.MediaCodecList.getCodecInfoAt方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaCodecList.getCodecInfoAt方法的具體用法?Java MediaCodecList.getCodecInfoAt怎麽用?Java MediaCodecList.getCodecInfoAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.media.MediaCodecList的用法示例。


在下文中一共展示了MediaCodecList.getCodecInfoAt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initialize

import android.media.MediaCodecList; //導入方法依賴的package包/類
/**
 * Initialize HeifReader module.
 *
 * @param context Context.
 */
public static void initialize(Context context) {
    mRenderScript = RenderScript.create(context);
    mCacheDir = context.getCacheDir();

    // find best HEVC decoder
    mDecoderName = null;
    mDecoderSupportedSize = new Size(0, 0);
    int numCodecs = MediaCodecList.getCodecCount();
    for (int i = 0; i < numCodecs; i++) {
        MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
        if (codecInfo.isEncoder()) {
            continue;
        }
        for (String type : codecInfo.getSupportedTypes()) {
            if (type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_HEVC)) {
                MediaCodecInfo.CodecCapabilities cap = codecInfo.getCapabilitiesForType(MediaFormat.MIMETYPE_VIDEO_HEVC);
                MediaCodecInfo.VideoCapabilities vcap = cap.getVideoCapabilities();
                Size supportedSize = new Size(vcap.getSupportedWidths().getUpper(), vcap.getSupportedHeights().getUpper());
                Log.d(TAG, "HEVC decoder=\"" + codecInfo.getName() + "\""
                        + " supported-size=" + supportedSize
                        + " color-formats=" + Arrays.toString(cap.colorFormats)
                );
                if (mDecoderSupportedSize.getWidth() * mDecoderSupportedSize.getHeight() < supportedSize.getWidth() * supportedSize.getHeight()) {
                    mDecoderName = codecInfo.getName();
                    mDecoderSupportedSize = supportedSize;
                }
            }
        }
    }
    if (mDecoderName == null) {
        throw new RuntimeException("no HEVC decoding support");
    }
    Log.i(TAG, "HEVC decoder=\"" + mDecoderName + "\" supported-size=" + mDecoderSupportedSize);
}
 
開發者ID:yohhoy,項目名稱:heifreader,代碼行數:40,代碼來源:HeifReader.java

示例2: selectCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
/**
 * Returns the first codec capable of encoding the specified MIME type, or null if no match was
 * found.
 */
@TargetApi(18)
public 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;
}
 
開發者ID:wuyisheng,項目名稱:libRtmp,代碼行數:22,代碼來源:AndroidUntil.java

示例3: selectAudioCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
/**
     * 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;
    }
 
開發者ID:FacePlusPlus,項目名稱:MegviiFacepp-Android-SDK,代碼行數:30,代碼來源:MediaAudioEncoder.java

示例4: selectAudioCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
private static MediaCodecInfo selectAudioCodec(final String mimeType) {
    // 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;
        }
        final String[] types = codecInfo.getSupportedTypes();
        for (String type : types) {
            if (type.equalsIgnoreCase(mimeType)) {
                return codecInfo;
            }
        }
    }
    return null;
}
 
開發者ID:uestccokey,項目名稱:EZFilter,代碼行數:19,代碼來源:MediaAudioEncoder.java

示例5: selectVideoCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:FacePlusPlus,項目名稱:MegviiFacepp-Android-SDK,代碼行數:31,代碼來源:MediaVideoEncoder.java

示例6: selectVideoCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:vipycm,項目名稱:mao-android,代碼行數:32,代碼來源:MediaVideoEncoder.java

示例7: selectCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
@SuppressLint("NewApi")
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;
}
 
開發者ID:chengzichen,項目名稱:KrGallery,代碼行數:24,代碼來源:MediaController.java

示例8: findCodecForType

import android.media.MediaCodecList; //導入方法依賴的package包/類
private MediaCodecInfo findCodecForType(VideoCodecType type) {
  // HW decoding is not supported on builds before KITKAT.
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
    return null;
  }

  for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
    MediaCodecInfo info = null;
    try {
      info = MediaCodecList.getCodecInfoAt(i);
    } catch (IllegalArgumentException e) {
      Logging.e(TAG, "Cannot retrieve encoder codec info", e);
    }

    if (info == null || info.isEncoder()) {
      continue;
    }

    if (isSupportedCodec(info, type)) {
      return info;
    }
  }
  return null; // No support for this type.
}
 
開發者ID:Piasy,項目名稱:AppRTC-Android,代碼行數:25,代碼來源:HardwareVideoDecoderFactory.java

示例9: selectVideoCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
/**
 * select the first codec that match a specific MIME type
 * @param mimeType
 * @return null if no codec matched
 */
protected static final MediaCodecInfo selectVideoCodec(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]);
				int format = selectColorFormat(codecInfo, mimeType);
				if (format > 0) {
					return codecInfo;
				}
			}
		}
	}
	return null;
}
 
開發者ID:saki4510t,項目名稱:libcommon,代碼行數:31,代碼來源:MediaVideoEncoder.java

示例10: selectCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
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;
}
 
開發者ID:jianliaoim,項目名稱:talk-android,代碼行數:24,代碼來源:MediaController.java

示例11: listCodecs

import android.media.MediaCodecList; //導入方法依賴的package包/類
public static String listCodecs()
{
    String results = "";
    int numCodecs = MediaCodecList.getCodecCount();
    for (int i = 0; i < numCodecs; i++) {
        MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);

        // grab results and put them in a list
        String name = codecInfo.getName();
        boolean isEncoder = codecInfo.isEncoder();
        String[] types = codecInfo.getSupportedTypes();
        String typeList = "";
        for (String s : types) typeList += s + " ";
        results += (i + 1) + ". " + name + " " + typeList + "\n\n";
    }
    return results;
}
 
開發者ID:teocci,項目名稱:YouTube-In-Background,代碼行數:18,代碼來源:AudioPlayer.java

示例12: selectCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:PhilLab,項目名稱:Android-MediaCodec-Examples,代碼行數:21,代碼來源:EncodeDecodeTest.java

示例13: selectAudioCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
/**
     * select the first codec that match a specific MIME type
     * @param mimeType
     * @return
     */
    @SuppressLint("LongLogTag")
	private static final MediaCodecInfo selectAudioCodec(final String mimeType) {
    	if (DEBUG) Log.v("AbstractTLMediaAudioEncoder", "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()) {	// skip decoder
                continue;
            }
            final String[] types = codecInfo.getSupportedTypes();
            for (int j = 0; j < types.length; j++) {
            	if (DEBUG) Log.i("AbstractTLMediaAudioEncoder",
            		"supportedType:" + codecInfo.getName() + ",MIME=" + types[j]);
                if (types[j].equalsIgnoreCase(mimeType)) {
               		result = codecInfo;
           			break LOOP;
                }
            }
        }
   		return result;
    }
 
開發者ID:saki4510t,項目名稱:TimeLapseRecordingSample,代碼行數:30,代碼來源:AbstractTLMediaAudioEncoder.java

示例14: selectCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
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;
}
 
開發者ID:Piasy,項目名稱:AndroidPlayground,代碼行數:19,代碼來源:MainActivity.java

示例15: chooseVideoEncoder

import android.media.MediaCodecList; //導入方法依賴的package包/類
private MediaCodecInfo chooseVideoEncoder(String name, MediaCodecInfo def) {

        int nbCodecs = MediaCodecList.getCodecCount();
        for (int i = 0; i < nbCodecs; i++) {
            MediaCodecInfo mci = MediaCodecList.getCodecInfoAt(i);
            if (!mci.isEncoder()) {
                continue;
            }

            String[] types = mci.getSupportedTypes();
            for (int j = 0; j < types.length; j++) {
                if (types[j].equalsIgnoreCase(CODEC)) {
                    if (name == null) {
                        return mci;
                    }

                    if (mci.getName().contains(name)) {
                        return mci;
                    }
                }
            }
        }

        return def;
    }
 
開發者ID:a3213105,項目名稱:Android-rtmp-publisher,代碼行數:26,代碼來源:VideoProcessor.java


注:本文中的android.media.MediaCodecList.getCodecInfoAt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。