1 /*
2  * Copyright (C) 2010 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 
17 package android.media;
18 
19 import android.compat.annotation.UnsupportedAppUsage;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 
24 /**
25  * {@hide}
26  *
27  * The DecoderCapabilities class is used to retrieve the types of the
28  * video and audio decoder(s) supported on a specific Android platform.
29  */
30 public class DecoderCapabilities
31 {
32     /**
33      * The VideoDecoder class represents the type of a video decoder
34      *
35      */
36     public enum VideoDecoder {
37         @UnsupportedAppUsage
38         VIDEO_DECODER_WMV,
39     };
40 
41     /**
42      * The AudioDecoder class represents the type of an audio decoder
43      */
44     public enum AudioDecoder {
45         @UnsupportedAppUsage
46         AUDIO_DECODER_WMA,
47     };
48 
49     static {
50         System.loadLibrary("media_jni");
native_init()51         native_init();
52     }
53 
54     /**
55      * Returns the list of video decoder types
56      * @see android.media.DecoderCapabilities.VideoDecoder
57      */
58     @UnsupportedAppUsage
getVideoDecoders()59     public static List<VideoDecoder> getVideoDecoders() {
60         List<VideoDecoder> decoderList = new ArrayList<VideoDecoder>();
61         int nDecoders = native_get_num_video_decoders();
62         for (int i = 0; i < nDecoders; ++i) {
63             decoderList.add(VideoDecoder.values()[native_get_video_decoder_type(i)]);
64         }
65         return decoderList;
66     }
67 
68     /**
69      * Returns the list of audio decoder types
70      * @see android.media.DecoderCapabilities.AudioDecoder
71      */
72     @UnsupportedAppUsage
getAudioDecoders()73     public static List<AudioDecoder> getAudioDecoders() {
74         List<AudioDecoder> decoderList = new ArrayList<AudioDecoder>();
75         int nDecoders = native_get_num_audio_decoders();
76         for (int i = 0; i < nDecoders; ++i) {
77             decoderList.add(AudioDecoder.values()[native_get_audio_decoder_type(i)]);
78         }
79         return decoderList;
80     }
81 
DecoderCapabilities()82     private DecoderCapabilities() {}  // Don't call me
83 
84     // Implemented by JNI
native_init()85     private static native final void native_init();
native_get_num_video_decoders()86     private static native final int native_get_num_video_decoders();
native_get_video_decoder_type(int index)87     private static native final int native_get_video_decoder_type(int index);
native_get_num_audio_decoders()88     private static native final int native_get_num_audio_decoders();
native_get_audio_decoder_type(int index)89     private static native final int native_get_audio_decoder_type(int index);
90 }
91