Home | History | Annotate | Download | only in videoeditor
      1 /*
      2  * Copyright (C) 2011 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 package android.media.videoeditor;
     17 
     18 /**
     19  * The VideoEditorProfile class is used to retrieve the
     20  * predefined videoeditor profile settings for videoeditor applications.
     21  * These settings are read-only.
     22  *
     23  * <p>The videoeditor profile specifies the following set of parameters:
     24  * <ul>
     25  * <li> max input video frame width
     26  * <li> max input video frame height
     27  * <li> max output video frame width
     28  * <li> max output video frame height
     29  * </ul>
     30  * {@hide}
     31  */
     32 public class VideoEditorProfile
     33 {
     34     static {
     35         System.loadLibrary("media_jni");
     36         native_init();
     37     }
     38     /**
     39      * The max input video frame width
     40      */
     41     public int maxInputVideoFrameWidth;
     42 
     43     /**
     44      * The max input video frame height
     45      */
     46     public int maxInputVideoFrameHeight;
     47 
     48     /**
     49      * The max ouput video frame width
     50      */
     51     public int maxOutputVideoFrameWidth;
     52 
     53     /**
     54      * The max ouput video frame height
     55      */
     56     public int maxOutputVideoFrameHeight;
     57 
     58     /**
     59      * Returns the videoeditor profile
     60      */
     61     public static VideoEditorProfile get() {
     62         return native_get_videoeditor_profile();
     63     }
     64 
     65     /**
     66      * Returns the supported profile by given video codec
     67      */
     68     public static int getExportProfile(int vidCodec) {
     69         int profile = -1;
     70 
     71         switch (vidCodec) {
     72             case MediaProperties.VCODEC_H263:
     73             case MediaProperties.VCODEC_H264:
     74             case MediaProperties.VCODEC_MPEG4:
     75                  profile = native_get_videoeditor_export_profile(vidCodec);
     76                  break;
     77             default :
     78                throw new IllegalArgumentException("Unsupported video codec" + vidCodec);
     79         }
     80 
     81         return profile;
     82     }
     83 
     84     /**
     85      * Returns the supported level by given video codec
     86      */
     87     public static int getExportLevel(int vidCodec) {
     88         int level = -1;
     89 
     90         switch (vidCodec) {
     91             case MediaProperties.VCODEC_H263:
     92             case MediaProperties.VCODEC_H264:
     93             case MediaProperties.VCODEC_MPEG4:
     94                  level = native_get_videoeditor_export_level(vidCodec);
     95                  break;
     96             default :
     97                throw new IllegalArgumentException("Unsupported video codec" + vidCodec);
     98         }
     99 
    100         return level;
    101     }
    102 
    103     // Private constructor called by JNI
    104     private VideoEditorProfile(int inputWidth,
    105                              int inputHeight,
    106                              int outputWidth,
    107                              int outputHeight) {
    108 
    109         this.maxInputVideoFrameWidth = inputWidth;
    110         this.maxInputVideoFrameHeight = inputHeight;
    111         this.maxOutputVideoFrameWidth = outputWidth;
    112         this.maxOutputVideoFrameHeight = outputHeight;
    113     }
    114 
    115     // Methods implemented by JNI
    116     private static native final void native_init();
    117     private static native final VideoEditorProfile
    118         native_get_videoeditor_profile();
    119     private static native final int native_get_videoeditor_export_profile(int codec);
    120     private static native final int native_get_videoeditor_export_level(int level);
    121 
    122 }
    123