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