1/* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.media; 18 19import android.media.MediaCodecInfo; 20 21/** 22 * Allows you to enumerate available codecs, each specified as a {@link MediaCodecInfo} object, 23 * find a codec supporting a given format and query the capabilities 24 * of a given codec. 25 * <p>See {@link MediaCodecInfo} for sample usage. 26 */ 27final public class MediaCodecList { 28 /** 29 * Count the number of available codecs. 30 */ 31 public static native final int getCodecCount(); 32 33 public static final MediaCodecInfo getCodecInfoAt(int index) { 34 if (index < 0 || index > getCodecCount()) { 35 throw new IllegalArgumentException(); 36 } 37 38 return new MediaCodecInfo(index); 39 } 40 41 /* package private */ static native final String getCodecName(int index); 42 43 /* package private */ static native final boolean isEncoder(int index); 44 45 /* package private */ static native final String[] getSupportedTypes(int index); 46 47 /* package private */ static native final MediaCodecInfo.CodecCapabilities 48 getCodecCapabilities(int index, String type); 49 50 /* package private */ static native final int findCodecByName(String codec); 51 52 private static native final void native_init(); 53 54 private MediaCodecList() {} 55 56 static { 57 System.loadLibrary("media_jni"); 58 native_init(); 59 } 60} 61