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 * MediaCodecList class can be used to enumerate available codecs,
23 * find a codec supporting a given format and query the capabilities
24 * of a given codec.
25 */
26final public class MediaCodecList {
27    /**
28     * Count the number of available codecs.
29     */
30    public static native final int getCodecCount();
31
32    public static final MediaCodecInfo getCodecInfoAt(int index) {
33        if (index < 0 || index > getCodecCount()) {
34            throw new IllegalArgumentException();
35        }
36
37        return new MediaCodecInfo(index);
38    }
39
40    /* package private */ static native final String getCodecName(int index);
41
42    /* package private */ static native final boolean isEncoder(int index);
43
44    /* package private */ static native final String[] getSupportedTypes(int index);
45
46    /* package private */ static native final MediaCodecInfo.CodecCapabilities
47        getCodecCapabilities(int index, String type);
48
49    private static native final void native_init();
50
51    private MediaCodecList() {}
52
53    static {
54        System.loadLibrary("media_jni");
55        native_init();
56    }
57}
58