Example usage for android.media MediaCodecInfo isEncoder

List of usage examples for android.media MediaCodecInfo isEncoder

Introduction

In this page you can find the example usage for android.media MediaCodecInfo isEncoder.

Prototype

public final boolean isEncoder() 

Source Link

Document

Query if the codec is an encoder.

Usage

From source file:Main.java

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;
        }/*ww  w. jav a 2s  .c  om*/
        String[] types = codecInfo.getSupportedTypes();
        for (int j = 0; j < types.length; j++) {
            if (types[j].equalsIgnoreCase(mimeType)) {
                return codecInfo;
            }
        }
    }
    return null;
}

From source file:Main.java

/**
 * Returns the first codec capable of encoding the specified MIME type, or null if no
 * match was found./*  ww  w  .java2s  .  com*/
 *
 * @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;
}

From source file:org.xwalk.runtime.extension.api.device_capabilities.MediaCodec.java

public void getCodecsList() {
    int numCodecs = android.media.MediaCodecList.getCodecCount();
    for (int i = 0; i < numCodecs; i++) {
        android.media.MediaCodecInfo codecInfo = android.media.MediaCodecList.getCodecInfoAt(i);
        String name = codecInfo.getName().toUpperCase();
        boolean hasAdded = false;

        for (String nameListElement : AUDIO_CODEC_NAMES) {
            if (name.contains(nameListElement)) {
                mAudioCodecsSet.add(new AudioCodecElement(nameListElement));
                hasAdded = true;/*from w ww . j a  va 2s . c  o  m*/
                break;
            }
        }

        if (hasAdded) {
            continue;
        }

        for (String nameListElement : VIDEO_CODEC_NAMES) {
            if (name.contains(nameListElement)) {
                boolean isEncoder = codecInfo.isEncoder();
                // FIXME(fyraimar): Get the right hwAccel value.
                mVideoCodecsSet.add(new VideoCodecElement(nameListElement, isEncoder, false));
                break;
            }
        }
    }
}