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


Java MediaCodecList.getCodecCount方法代碼示例

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


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

示例1: 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

示例2: FindHardWareEncoder16

import android.media.MediaCodecList; //導入方法依賴的package包/類
private static String FindHardWareEncoder16(String mime) {
    int mediaCodecCount = MediaCodecList.getCodecCount();

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

        String types[] = mediaCodecInfo.getSupportedTypes();
        for (int j = 0; j < types.length; j++) {
            if (types[j].equalsIgnoreCase(mime)) {
                String decoderName = mediaCodecInfo.getName();
                Log.e(ERROR_TAGE, "hwDecoderName = " + decoderName);
                boolean isHardwareEncode = (decoderName.indexOf("google") == -1);
                if (isHardwareEncode) {
                    return decoderName;
                }
            }
        }
    }

    return null;
}
 
開發者ID:lzmlsfe,項目名稱:19porn,代碼行數:25,代碼來源:EncodeUtils.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:vipycm,項目名稱:mao-android,代碼行數:32,代碼來源:MediaAudioEncoder.java

示例4: selectCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
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:fishwjy,項目名稱:VideoCompressor,代碼行數:23,代碼來源:VideoController.java

示例5: chooseVideoEncoder

import android.media.MediaCodecList; //導入方法依賴的package包/類
private MediaCodecInfo chooseVideoEncoder(String name) {
    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(VCODEC)) {
                Log.i(TAG, String.format("vencoder %s types: %s", mci.getName(), types[j]));
                if (name == null) {
                    return mci;
                }

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

    return null;
}
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:26,代碼來源:SrsEncoder.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:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:31,代碼來源:MediaVideoEncoder.java

示例7: 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();
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;
             			return result;
              	}
              }
          }
      }
 		return result;
  }
 
開發者ID:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:30,代碼來源:MediaAudioEncoder.java

示例8: 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:itsnothingg,項目名稱:EasyScreenRecorder,代碼行數:30,代碼來源:MediaAudioEncoder.java

示例9: 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

示例10: selectVideoCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
private static MediaCodecInfo selectVideoCodec(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;
        }
        // select first codec that match a specific MIME type and color format
        for (String type : codecInfo.getSupportedTypes()) {
            if (type.equalsIgnoreCase(mimeType)) {
                final int format = selectColorFormat(codecInfo, mimeType);
                if (format > 0) {
                    return codecInfo;
                }
            }
        }
    }
    return null;
}
 
開發者ID:uestccokey,項目名稱:EZFilter,代碼行數:22,代碼來源:MediaVideoEncoder.java

示例11: selectCodec

import android.media.MediaCodecList; //導入方法依賴的package包/類
/**
 * Returns the first codec capable of encoding the specified MIME type, or null if no
 * match was found.
 *
 * @param mimeType String
 * @return MediaCodecInfo
 */
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 (String type : types)
        {
            if (type.equalsIgnoreCase(mimeType))
            {
                return codecInfo;
            }
        }
    }
    return null;
}
 
開發者ID:hcmlab,項目名稱:ssj,代碼行數:29,代碼來源:CameraUtil.java

示例12: 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

示例13: 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,代碼來源:DecodeEditEncodeTest.java

示例14: getMediaCodecInfo

import android.media.MediaCodecList; //導入方法依賴的package包/類
/**
 * Returns the best decoder and its capabilities for the given mimeType. If there's no decoder
 * returns null.
 */
private static synchronized Pair<MediaCodecInfo, CodecCapabilities> getMediaCodecInfo(
    String mimeType) {
  Pair<MediaCodecInfo, CodecCapabilities> result = codecs.get(mimeType);
  if (result != null) {
    return result;
  }
  int numberOfCodecs = MediaCodecList.getCodecCount();
  // Note: MediaCodecList is sorted by the framework such that the best decoders come first.
  for (int i = 0; i < numberOfCodecs; i++) {
    MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
    String codecName = info.getName();
    if (!info.isEncoder() && isOmxCodec(codecName)) {
      String[] supportedTypes = info.getSupportedTypes();
      for (int j = 0; j < supportedTypes.length; j++) {
        String supportedType = supportedTypes[j];
        if (supportedType.equalsIgnoreCase(mimeType)) {
          result = Pair.create(info, info.getCapabilitiesForType(supportedType));
          codecs.put(mimeType, result);
          return result;
        }
      }
    }
  }
  return null;
}
 
開發者ID:edx,項目名稱:edx-app-android,代碼行數:30,代碼來源:MediaCodecUtil.java

示例15: 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:kingdawin,項目名稱:android-openmxplayer,代碼行數:17,代碼來源:OpenMXPlayer.java


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