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
19public final class MediaCodecInfo {
20    private int mIndex;
21
22    /* package private */ MediaCodecInfo(int index) {
23        mIndex = index;
24    }
25
26    /**
27     * Retrieve the codec name.
28     */
29    public final String getName() {
30        return MediaCodecList.getCodecName(mIndex);
31    }
32
33    /**
34     * Query if the codec is an encoder.
35     */
36    public final boolean isEncoder() {
37        return MediaCodecList.isEncoder(mIndex);
38    }
39
40    /**
41     * Query the media types supported by the codec.
42     */
43    public final String[] getSupportedTypes() {
44        return MediaCodecList.getSupportedTypes(mIndex);
45    }
46
47    public static final class CodecCapabilities {
48        public CodecProfileLevel[] profileLevels;
49
50        // from OMX_COLOR_FORMATTYPE
51        public final static int COLOR_FormatMonochrome              = 1;
52        public final static int COLOR_Format8bitRGB332              = 2;
53        public final static int COLOR_Format12bitRGB444             = 3;
54        public final static int COLOR_Format16bitARGB4444           = 4;
55        public final static int COLOR_Format16bitARGB1555           = 5;
56        public final static int COLOR_Format16bitRGB565             = 6;
57        public final static int COLOR_Format16bitBGR565             = 7;
58        public final static int COLOR_Format18bitRGB666             = 8;
59        public final static int COLOR_Format18bitARGB1665           = 9;
60        public final static int COLOR_Format19bitARGB1666           = 10;
61        public final static int COLOR_Format24bitRGB888             = 11;
62        public final static int COLOR_Format24bitBGR888             = 12;
63        public final static int COLOR_Format24bitARGB1887           = 13;
64        public final static int COLOR_Format25bitARGB1888           = 14;
65        public final static int COLOR_Format32bitBGRA8888           = 15;
66        public final static int COLOR_Format32bitARGB8888           = 16;
67        public final static int COLOR_FormatYUV411Planar            = 17;
68        public final static int COLOR_FormatYUV411PackedPlanar      = 18;
69        public final static int COLOR_FormatYUV420Planar            = 19;
70        public final static int COLOR_FormatYUV420PackedPlanar      = 20;
71        public final static int COLOR_FormatYUV420SemiPlanar        = 21;
72        public final static int COLOR_FormatYUV422Planar            = 22;
73        public final static int COLOR_FormatYUV422PackedPlanar      = 23;
74        public final static int COLOR_FormatYUV422SemiPlanar        = 24;
75        public final static int COLOR_FormatYCbYCr                  = 25;
76        public final static int COLOR_FormatYCrYCb                  = 26;
77        public final static int COLOR_FormatCbYCrY                  = 27;
78        public final static int COLOR_FormatCrYCbY                  = 28;
79        public final static int COLOR_FormatYUV444Interleaved       = 29;
80        public final static int COLOR_FormatRawBayer8bit            = 30;
81        public final static int COLOR_FormatRawBayer10bit           = 31;
82        public final static int COLOR_FormatRawBayer8bitcompressed  = 32;
83        public final static int COLOR_FormatL2                      = 33;
84        public final static int COLOR_FormatL4                      = 34;
85        public final static int COLOR_FormatL8                      = 35;
86        public final static int COLOR_FormatL16                     = 36;
87        public final static int COLOR_FormatL24                     = 37;
88        public final static int COLOR_FormatL32                     = 38;
89        public final static int COLOR_FormatYUV420PackedSemiPlanar  = 39;
90        public final static int COLOR_FormatYUV422PackedSemiPlanar  = 40;
91        public final static int COLOR_Format18BitBGR666             = 41;
92        public final static int COLOR_Format24BitARGB6666           = 42;
93        public final static int COLOR_Format24BitABGR6666           = 43;
94
95        public final static int COLOR_TI_FormatYUV420PackedSemiPlanar = 0x7f000100;
96        public final static int COLOR_QCOM_FormatYUV420SemiPlanar     = 0x7fa30c00;
97
98        /**
99         * Defined in the OpenMAX IL specs, color format values are drawn from
100         * OMX_COLOR_FORMATTYPE.
101         */
102        public int[] colorFormats;
103    };
104
105    public static final class CodecProfileLevel {
106        // from OMX_VIDEO_AVCPROFILETYPE
107        public static final int AVCProfileBaseline = 0x01;
108        public static final int AVCProfileMain     = 0x02;
109        public static final int AVCProfileExtended = 0x04;
110        public static final int AVCProfileHigh     = 0x08;
111        public static final int AVCProfileHigh10   = 0x10;
112        public static final int AVCProfileHigh422  = 0x20;
113        public static final int AVCProfileHigh444  = 0x40;
114
115        // from OMX_VIDEO_AVCLEVELTYPE
116        public static final int AVCLevel1       = 0x01;
117        public static final int AVCLevel1b      = 0x02;
118        public static final int AVCLevel11      = 0x04;
119        public static final int AVCLevel12      = 0x08;
120        public static final int AVCLevel13      = 0x10;
121        public static final int AVCLevel2       = 0x20;
122        public static final int AVCLevel21      = 0x40;
123        public static final int AVCLevel22      = 0x80;
124        public static final int AVCLevel3       = 0x100;
125        public static final int AVCLevel31      = 0x200;
126        public static final int AVCLevel32      = 0x400;
127        public static final int AVCLevel4       = 0x800;
128        public static final int AVCLevel41      = 0x1000;
129        public static final int AVCLevel42      = 0x2000;
130        public static final int AVCLevel5       = 0x4000;
131        public static final int AVCLevel51      = 0x8000;
132
133        // from OMX_VIDEO_H263PROFILETYPE
134        public static final int H263ProfileBaseline             = 0x01;
135        public static final int H263ProfileH320Coding           = 0x02;
136        public static final int H263ProfileBackwardCompatible   = 0x04;
137        public static final int H263ProfileISWV2                = 0x08;
138        public static final int H263ProfileISWV3                = 0x10;
139        public static final int H263ProfileHighCompression      = 0x20;
140        public static final int H263ProfileInternet             = 0x40;
141        public static final int H263ProfileInterlace            = 0x80;
142        public static final int H263ProfileHighLatency          = 0x100;
143
144        // from OMX_VIDEO_H263LEVELTYPE
145        public static final int H263Level10      = 0x01;
146        public static final int H263Level20      = 0x02;
147        public static final int H263Level30      = 0x04;
148        public static final int H263Level40      = 0x08;
149        public static final int H263Level45      = 0x10;
150        public static final int H263Level50      = 0x20;
151        public static final int H263Level60      = 0x40;
152        public static final int H263Level70      = 0x80;
153
154        // from OMX_VIDEO_MPEG4PROFILETYPE
155        public static final int MPEG4ProfileSimple              = 0x01;
156        public static final int MPEG4ProfileSimpleScalable      = 0x02;
157        public static final int MPEG4ProfileCore                = 0x04;
158        public static final int MPEG4ProfileMain                = 0x08;
159        public static final int MPEG4ProfileNbit                = 0x10;
160        public static final int MPEG4ProfileScalableTexture     = 0x20;
161        public static final int MPEG4ProfileSimpleFace          = 0x40;
162        public static final int MPEG4ProfileSimpleFBA           = 0x80;
163        public static final int MPEG4ProfileBasicAnimated       = 0x100;
164        public static final int MPEG4ProfileHybrid              = 0x200;
165        public static final int MPEG4ProfileAdvancedRealTime    = 0x400;
166        public static final int MPEG4ProfileCoreScalable        = 0x800;
167        public static final int MPEG4ProfileAdvancedCoding      = 0x1000;
168        public static final int MPEG4ProfileAdvancedCore        = 0x2000;
169        public static final int MPEG4ProfileAdvancedScalable    = 0x4000;
170        public static final int MPEG4ProfileAdvancedSimple      = 0x8000;
171
172        // from OMX_VIDEO_MPEG4LEVELTYPE
173        public static final int MPEG4Level0      = 0x01;
174        public static final int MPEG4Level0b     = 0x02;
175        public static final int MPEG4Level1      = 0x04;
176        public static final int MPEG4Level2      = 0x08;
177        public static final int MPEG4Level3      = 0x10;
178        public static final int MPEG4Level4      = 0x20;
179        public static final int MPEG4Level4a     = 0x40;
180        public static final int MPEG4Level5      = 0x80;
181
182        // from OMX_AUDIO_AACPROFILETYPE
183        public static final int AACObjectMain       = 1;
184        public static final int AACObjectLC         = 2;
185        public static final int AACObjectSSR        = 3;
186        public static final int AACObjectLTP        = 4;
187        public static final int AACObjectHE         = 5;
188        public static final int AACObjectScalable   = 6;
189        public static final int AACObjectERLC       = 17;
190        public static final int AACObjectLD         = 23;
191        public static final int AACObjectHE_PS      = 29;
192        public static final int AACObjectELD        = 39;
193
194        /**
195         * Defined in the OpenMAX IL specs, depending on the type of media
196         * this can be OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263PROFILETYPE,
197         * or OMX_VIDEO_MPEG4PROFILETYPE.
198         */
199        public int profile;
200
201        /**
202         * Defined in the OpenMAX IL specs, depending on the type of media
203         * this can be OMX_VIDEO_AVCLEVELTYPE, OMX_VIDEO_H263LEVELTYPE
204         * or OMX_VIDEO_MPEG4LEVELTYPE.
205         */
206        public int level;
207    };
208
209    public final CodecCapabilities getCapabilitiesForType(
210            String type) {
211        return MediaCodecList.getCodecCapabilities(mIndex, type);
212    }
213}
214