Example usage for android.media MediaCodecInfo getSupportedTypes

List of usage examples for android.media MediaCodecInfo getSupportedTypes

Introduction

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

Prototype

public final String[] getSupportedTypes() 

Source Link

Document

Query the media types supported by the codec.

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 .  j  a  v  a 2s  .  c o m
        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.// w w w.  ja  v  a  2  s.  c o m
 *
 * @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;
}