Java 类android.media.MediaCodecList 实例源码

项目:libRtmp    文件:AndroidUntil.java   
/**
 * 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;
}
项目:Amazing    文件:ScreenRecordActivity.java   
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void printInfo() {
    MediaCodecList list = new MediaCodecList(MediaCodecList.ALL_CODECS);
    MediaCodecInfo[] codecInfos = list.getCodecInfos();
    for (MediaCodecInfo info : codecInfos) {
        if (info.isEncoder()) {
            StringBuilder sb = new StringBuilder();
            sb.append(info.getName() + " types=");
            String[] supportedTypes = info.getSupportedTypes();
            for (String string : supportedTypes) {
                sb.append(" " + string);
            }
            LogUtil.e(sb.toString());
        }
    }
}
项目:heifreader    文件:HeifReader.java   
/**
 * 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);
}
项目:19porn    文件:EncodeUtils.java   
public static void showCodecInfo() {
    int mediaCodecCount = MediaCodecList.getCodecCount();

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

        Log.e(ERROR_TAGE, "CodecName:" + mediaCodecInfo.getName());
        String types[] = mediaCodecInfo.getSupportedTypes();

        String strTypes = "";
        for (int j = 0; j < types.length; j++) {
            if (!strTypes.isEmpty()) {
                final String SPLITE = ",  ";
                strTypes += SPLITE;
            }
            strTypes += types[j];
        }

        Log.e(ERROR_TAGE, "Suport Type:" + strTypes);
    }
}
项目:19porn    文件:EncodeUtils.java   
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;
}
项目:19porn    文件:EncodeUtils.java   
private static String FindHardWareEncoder21(String mime) {

        MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
        MediaCodecInfo[] mediaCodecInfos = mediaCodecList.getCodecInfos();

        for (int i = 0; i < mediaCodecInfos.length; i++) {
            MediaCodecInfo mediaCodecInfo = mediaCodecInfos[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(TAG, "hwDecoderName = " + decoderName);
                    boolean isHardwareEncode = (decoderName.indexOf("google") == -1);
                    if (isHardwareEncode) {
                        return decoderName;
                    }
                }
            }
        }

        return null;
    }
项目:airgram    文件:MediaController.java   
@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;
}
项目:Fatigue-Detection    文件:MediaVideoEncoder.java   
/**
 * 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;
}
项目:Fatigue-Detection    文件:MediaAudioEncoder.java   
/**
   * 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;
  }
项目:EasyScreenRecorder    文件:MediaAudioEncoder.java   
/**
     * 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;
    }
项目:KrGallery    文件:MediaController.java   
@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;
}
项目:AppRTC-Android    文件:HardwareVideoDecoderFactory.java   
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.
}
项目:AppRTC-Android    文件:HardwareVideoEncoderFactory.java   
private MediaCodecInfo findCodecForType(VideoCodecType type) {
  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.
}
项目:PlusGram    文件:MediaController.java   
@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;
}
项目:EZFilter    文件:MediaVideoEncoder.java   
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;
}
项目:EZFilter    文件:MediaAudioEncoder.java   
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;
}
项目:mao-android    文件:MediaVideoEncoder.java   
/**
 * 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;
}
项目:mao-android    文件:MediaAudioEncoder.java   
/**
 * 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;
}
项目:MegviiFacepp-Android-SDK    文件:MediaVideoEncoder.java   
/**
 * 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;
}
项目:MegviiFacepp-Android-SDK    文件:MediaAudioEncoder.java   
/**
     * 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;
    }
项目:AI-Powered-Intelligent-Banking-Platform    文件:AudioUtils.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<String> getAvailableEncoders(int sampleRate) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        MediaFormat format = MediaFormatFactory.createMediaFormat(MediaFormatFactory.Type.FLAC, sampleRate);
        MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
        String encoderAsStr = mcl.findEncoderForFormat(format);
        List<String> encoders = new ArrayList<>();
        for (MediaCodecInfo info : mcl.getCodecInfos()) {
            if (info.isEncoder()) {
                if (info.getName().equals(encoderAsStr)) {
                    encoders.add("*** " + info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                } else {
                    encoders.add(info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                }
            }
        }
        return encoders;
    }
    return Collections.emptyList();
}
项目:AI-Powered-Intelligent-Banking-Platform    文件:AudioUtils.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<String> getAvailableEncoders(int sampleRate) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        MediaFormat format = MediaFormatFactory.createMediaFormat(MediaFormatFactory.Type.FLAC, sampleRate);
        MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
        String encoderAsStr = mcl.findEncoderForFormat(format);
        List<String> encoders = new ArrayList<>();
        for (MediaCodecInfo info : mcl.getCodecInfos()) {
            if (info.isEncoder()) {
                if (info.getName().equals(encoderAsStr)) {
                    encoders.add("*** " + info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                } else {
                    encoders.add(info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                }
            }
        }
        return encoders;
    }
    return Collections.emptyList();
}
项目:live_master    文件:SrsEncoder.java   
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;
}
项目:VideoCompressor    文件:VideoController.java   
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;
}
项目:ssj    文件:CameraUtil.java   
/**
 * 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;
}
项目:UVCCameraZxing    文件:MediaSurfaceEncoder.java   
/**
 * 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;
}
项目:UVCCameraZxing    文件:MediaAudioEncoder.java   
/**
     * 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;
    }
项目:libcommon    文件:MediaVideoEncoder.java   
/**
 * 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;
}
项目:libcommon    文件:MediaAudioEncoder.java   
/**
 * select the first codec that match a specific MIME type
 * @param mimeType
 * @return
 */
private static final MediaCodecInfo selectAudioCodec(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)) {
                result = codecInfo;
                break LOOP;
            }
        }
    }
    return result;
}
项目:talk-android    文件:MediaController.java   
@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;
}
项目:YouTube-In-Background    文件:AudioPlayer.java   
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;
}
项目:SiliCompressor    文件:MediaController.java   
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;
}
项目:Android-MediaCodec-Examples    文件:DecodeEditEncodeTest.java   
/**
 * 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;
}
项目:Android-MediaCodec-Examples    文件:EncodeDecodeTest.java   
/**
 * 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;
}
项目:AlexaAndroid    文件:AudioUtils.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<String> getAvailableEncoders(int sampleRate) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        MediaFormat format = MediaFormatFactory.createMediaFormat(MediaFormatFactory.Type.FLAC, sampleRate);
        MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
        String encoderAsStr = mcl.findEncoderForFormat(format);
        List<String> encoders = new ArrayList<>();
        for (MediaCodecInfo info : mcl.getCodecInfos()) {
            if (info.isEncoder()) {
                if (info.getName().equals(encoderAsStr)) {
                    encoders.add("*** " + info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                } else {
                    encoders.add(info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                }
            }
        }
        return encoders;
    }
    return Collections.emptyList();
}
项目:AlexaAndroid    文件:AudioUtils.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<String> getAvailableEncoders(int sampleRate) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        MediaFormat format = MediaFormatFactory.createMediaFormat(MediaFormatFactory.Type.FLAC, sampleRate);
        MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
        String encoderAsStr = mcl.findEncoderForFormat(format);
        List<String> encoders = new ArrayList<>();
        for (MediaCodecInfo info : mcl.getCodecInfos()) {
            if (info.isEncoder()) {
                if (info.getName().equals(encoderAsStr)) {
                    encoders.add("*** " + info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                } else {
                    encoders.add(info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                }
            }
        }
        return encoders;
    }
    return Collections.emptyList();
}
项目:speechutils    文件:AudioUtils.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<String> getAvailableEncoders(int sampleRate) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        MediaFormat format = MediaFormatFactory.createMediaFormat(MediaFormatFactory.Type.FLAC, sampleRate);
        MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
        String encoderAsStr = mcl.findEncoderForFormat(format);
        List<String> encoders = new ArrayList<>();
        for (MediaCodecInfo info : mcl.getCodecInfos()) {
            if (info.isEncoder()) {
                if (info.getName().equals(encoderAsStr)) {
                    encoders.add("*** " + info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                } else {
                    encoders.add(info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                }
            }
        }
        return encoders;
    }
    return Collections.emptyList();
}
项目:TimeLapseRecordingSample    文件:AbstractTLMediaAudioEncoder.java   
/**
     * 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;
    }
项目:sagetv-miniclient    文件:AppUtil.java   
public static Set<String> getVideoDecoders() {
    Set<String> all = new TreeSet<>();
    int count = MediaCodecList.getCodecCount();
    for (int i = 0; i < count; i++) {
        MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
        if (!info.isEncoder()) {
            if (info.getSupportedTypes() != null) {
                for (String s : info.getSupportedTypes()) {
                    if (s.toLowerCase().contains("video")) {
                        all.add(info.getName());
                    }
                }
            }
        }
    }
    return all;
}
项目:sagetv-miniclient    文件:AppUtil.java   
public static Set<String> getAudioDecoders() {
    Set<String> all = new TreeSet<>();
    int count = MediaCodecList.getCodecCount();
    for (int i = 0; i < count; i++) {
        MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
        if (!info.isEncoder()) {
            if (info.getSupportedTypes() != null) {
                for (String s : info.getSupportedTypes()) {
                    if (s.toLowerCase().contains("audio")) {
                        all.add(info.getName());
                    }
                }
            }
        }
    }
    return all;
}