2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.media;
19 import java.util.List;
20 import java.util.ArrayList;
23 * The EncoderCapabilities class is used to retrieve the
24 * capabilities for different video and audio
25 * encoders supported on a specific Android platform.
28 public class EncoderCapabilities
30 private static final String TAG = "EncoderCapabilities";
33 * The VideoEncoderCap class represents a video encoder's
34 * supported parameter range in:
37 * <li>Resolution: the frame size (width/height) in pixels;
38 * <li>Bit rate: the compressed output bit rate in bits per second;
39 * <li>Frame rate: the output number of frames per second.
43 static public class VideoEncoderCap {
44 // These are not modifiable externally, thus are public accessible
45 public final int mCodec; // @see android.media.MediaRecorder.VideoEncoder
46 public final int mMinBitRate, mMaxBitRate; // min and max bit rate (bps)
47 public final int mMinFrameRate, mMaxFrameRate; // min and max frame rate (fps)
48 public final int mMinFrameWidth, mMaxFrameWidth; // min and max frame width (pixel)
49 public final int mMinFrameHeight, mMaxFrameHeight; // minn and max frame height (pixel)
51 // Private constructor called by JNI
52 private VideoEncoderCap(int codec,
53 int minBitRate, int maxBitRate,
54 int minFrameRate, int maxFrameRate,
55 int minFrameWidth, int maxFrameWidth,
56 int minFrameHeight, int maxFrameHeight) {
58 mMinBitRate = minBitRate;
59 mMaxBitRate = maxBitRate;
60 mMinFrameRate = minFrameRate;
61 mMaxFrameRate = maxFrameRate;
62 mMinFrameWidth = minFrameWidth;
63 mMaxFrameWidth = maxFrameWidth;
64 mMinFrameHeight = minFrameHeight;
65 mMaxFrameHeight = maxFrameHeight;
70 * The AudioEncoderCap class represents an audio encoder's
74 * <li>Bit rate: the compressed output bit rate in bits per second;
75 * <li>Sample rate: the sampling rate used for recording the audio in samples per second;
76 * <li>Number of channels: the number of channels the audio is recorded.
80 static public class AudioEncoderCap {
81 // These are not modifiable externally, thus are public accessible
82 public final int mCodec; // @see android.media.MediaRecorder.AudioEncoder
83 public final int mMinChannels, mMaxChannels; // min and max number of channels
84 public final int mMinSampleRate, mMaxSampleRate; // min and max sample rate (hz)
85 public final int mMinBitRate, mMaxBitRate; // min and max bit rate (bps)
87 // Private constructor called by JNI
88 private AudioEncoderCap(int codec,
89 int minBitRate, int maxBitRate,
90 int minSampleRate, int maxSampleRate,
91 int minChannels, int maxChannels) {
93 mMinBitRate = minBitRate;
94 mMaxBitRate = maxBitRate;
95 mMinSampleRate = minSampleRate;
96 mMaxSampleRate = maxSampleRate;
97 mMinChannels = minChannels;
98 mMaxChannels = maxChannels;
103 System.loadLibrary("media_jni");
108 * Returns the array of supported output file formats.
109 * @see android.media.MediaRecorder.OutputFormat
111 public static int[] getOutputFileFormats() {
112 int nFormats = native_get_num_file_formats();
113 if (nFormats == 0) return null;
115 int[] formats = new int[nFormats];
116 for (int i = 0; i < nFormats; ++i) {
117 formats[i] = native_get_file_format(i);
123 * Returns the capabilities of the supported video encoders.
124 * @see android.media.EncoderCapabilities.VideoEncoderCap
126 public static List<VideoEncoderCap> getVideoEncoders() {
127 int nEncoders = native_get_num_video_encoders();
128 if (nEncoders == 0) return null;
130 List<VideoEncoderCap> encoderList = new ArrayList<VideoEncoderCap>();
131 for (int i = 0; i < nEncoders; ++i) {
132 encoderList.add(native_get_video_encoder_cap(i));
138 * Returns the capabilities of the supported audio encoders.
139 * @see android.media.EncoderCapabilities.AudioEncoderCap
141 public static List<AudioEncoderCap> getAudioEncoders() {
142 int nEncoders = native_get_num_audio_encoders();
143 if (nEncoders == 0) return null;
145 List<AudioEncoderCap> encoderList = new ArrayList<AudioEncoderCap>();
146 for (int i = 0; i < nEncoders; ++i) {
147 encoderList.add(native_get_audio_encoder_cap(i));
153 private EncoderCapabilities() {} // Don't call me
155 // Implemented by JNI
156 private static native final void native_init();
157 private static native final int native_get_num_file_formats();
158 private static native final int native_get_file_format(int index);
159 private static native final int native_get_num_video_encoders();
160 private static native final VideoEncoderCap native_get_video_encoder_cap(int index);
161 private static native final int native_get_num_audio_encoders();
162 private static native final AudioEncoderCap native_get_audio_encoder_cap(int index);