| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2010, The Android Open Source Project. |
| vivek mehta | 2192bc9 | 2012-12-04 11:46:08 -0800 | [diff] [blame] | 4 | ** Copyright (c) 2010 - 2012, The Linux Foundation. All rights reserved. |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 5 | ** |
| 6 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | ** you may not use this file except in compliance with the License. |
| 8 | ** You may obtain a copy of the License at |
| 9 | ** |
| 10 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | ** |
| 12 | ** Unless required by applicable law or agreed to in writing, software |
| 13 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | ** See the License for the specific language governing permissions and |
| 16 | ** limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #ifndef ANDROID_MEDIAPROFILES_H |
| 20 | #define ANDROID_MEDIAPROFILES_H |
| 21 | |
| 22 | #include <utils/threads.h> |
| 23 | #include <media/mediarecorder.h> |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | enum camcorder_quality { |
| James Dong | 2a7e0a1 | 2011-02-28 21:07:39 -0800 | [diff] [blame] | 28 | CAMCORDER_QUALITY_LIST_START = 0, |
| James Dong | 0b42f25 | 2010-03-31 13:56:29 -0700 | [diff] [blame] | 29 | CAMCORDER_QUALITY_LOW = 0, |
| Nipun Kwatra | c0a8478 | 2010-09-06 15:59:02 -0700 | [diff] [blame] | 30 | CAMCORDER_QUALITY_HIGH = 1, |
| 31 | CAMCORDER_QUALITY_QCIF = 2, |
| Nipun Kwatra | 9783ed8 | 2010-09-10 15:45:57 -0700 | [diff] [blame] | 32 | CAMCORDER_QUALITY_CIF = 3, |
| 33 | CAMCORDER_QUALITY_480P = 4, |
| 34 | CAMCORDER_QUALITY_720P = 5, |
| 35 | CAMCORDER_QUALITY_1080P = 6, |
| Ankit Premrajka | 140a9ac | 2011-11-21 19:25:02 -0800 | [diff] [blame] | 36 | CAMCORDER_QUALITY_QVGA = 11, |
| 37 | CAMCORDER_QUALITY_FWVGA = 7, |
| 38 | CAMCORDER_QUALITY_WVGA = 8, |
| 39 | CAMCORDER_QUALITY_VGA = 9, |
| 40 | CAMCORDER_QUALITY_WQVGA = 10, |
| 41 | |
| 42 | CAMCORDER_QUALITY_LIST_END = 11, |
| Nipun Kwatra | c0a8478 | 2010-09-06 15:59:02 -0700 | [diff] [blame] | 43 | |
| James Dong | 2a7e0a1 | 2011-02-28 21:07:39 -0800 | [diff] [blame] | 44 | CAMCORDER_QUALITY_TIME_LAPSE_LIST_START = 1000, |
| Nipun Kwatra | c0a8478 | 2010-09-06 15:59:02 -0700 | [diff] [blame] | 45 | CAMCORDER_QUALITY_TIME_LAPSE_LOW = 1000, |
| 46 | CAMCORDER_QUALITY_TIME_LAPSE_HIGH = 1001, |
| 47 | CAMCORDER_QUALITY_TIME_LAPSE_QCIF = 1002, |
| Nipun Kwatra | 9783ed8 | 2010-09-10 15:45:57 -0700 | [diff] [blame] | 48 | CAMCORDER_QUALITY_TIME_LAPSE_CIF = 1003, |
| 49 | CAMCORDER_QUALITY_TIME_LAPSE_480P = 1004, |
| 50 | CAMCORDER_QUALITY_TIME_LAPSE_720P = 1005, |
| James Dong | 2a7e0a1 | 2011-02-28 21:07:39 -0800 | [diff] [blame] | 51 | CAMCORDER_QUALITY_TIME_LAPSE_1080P = 1006, |
| James Dong | 669012d | 2011-09-19 16:27:31 -0700 | [diff] [blame] | 52 | CAMCORDER_QUALITY_TIME_LAPSE_QVGA = 1007, |
| 53 | CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1007, |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 56 | /** |
| Hong Teng | 3a9cefe | 2011-11-10 14:54:26 -0800 | [diff] [blame] | 57 | * Set CIF as default maximum import and export resolution of video editor. |
| 58 | * The maximum import and export resolutions are platform specific, |
| 59 | * which should be defined in media_profiles.xml. |
| 60 | * Set default maximum prefetch YUV frames to 6, which means video editor can |
| 61 | * queue up to 6 YUV frames in the video encoder source. |
| 62 | * This value is used to limit the amount of memory used by video editor |
| 63 | * engine when the encoder consumes YUV frames at a lower speed |
| 64 | * than video editor engine produces. |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 65 | */ |
| 66 | enum videoeditor_capability { |
| 67 | VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH = 352, |
| 68 | VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT = 288, |
| 69 | VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH = 352, |
| 70 | VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT = 288, |
| Hong Teng | 3a9cefe | 2011-11-10 14:54:26 -0800 | [diff] [blame] | 71 | VIDEOEDITOR_DEFAULT_MAX_PREFETCH_YUV_FRAMES = 6 |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 74 | enum video_decoder { |
| 75 | VIDEO_DECODER_WMV, |
| 76 | }; |
| 77 | |
| 78 | enum audio_decoder { |
| 79 | AUDIO_DECODER_WMA, |
| 80 | }; |
| 81 | |
| 82 | |
| 83 | class MediaProfiles |
| 84 | { |
| 85 | public: |
| 86 | |
| 87 | /** |
| 88 | * Returns the singleton instance for subsequence queries. |
| 89 | * or NULL if error. |
| 90 | */ |
| 91 | static MediaProfiles* getInstance(); |
| 92 | |
| 93 | /** |
| Chih-Chung Chang | 3eaa4e9 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 94 | * Returns the value for the given param name for the given camera at |
| 95 | * the given quality level, or -1 if error. |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 96 | * |
| 97 | * Supported param name are: |
| James Dong | f5a8385 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 98 | * duration - the recording duration. |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 99 | * file.format - output file format. see mediarecorder.h for details |
| James Dong | 13896b9 | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 100 | * vid.codec - video encoder. see mediarecorder.h for details. |
| 101 | * aud.codec - audio encoder. see mediarecorder.h for details. |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 102 | * vid.width - video frame width |
| 103 | * vid.height - video frame height |
| 104 | * vid.fps - video frame rate |
| 105 | * vid.bps - video bit rate |
| 106 | * aud.bps - audio bit rate |
| 107 | * aud.hz - audio sample rate |
| 108 | * aud.ch - number of audio channels |
| 109 | */ |
| Chih-Chung Chang | 3eaa4e9 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 110 | int getCamcorderProfileParamByName(const char *name, int cameraId, |
| 111 | camcorder_quality quality) const; |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 112 | |
| 113 | /** |
| Nipun Kwatra | 8bb5603 | 2010-09-09 16:25:08 -0700 | [diff] [blame] | 114 | * Returns true if a profile for the given camera at the given quality exists, |
| 115 | * or false if not. |
| 116 | */ |
| 117 | bool hasCamcorderProfile(int cameraId, camcorder_quality quality) const; |
| 118 | |
| 119 | /** |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 120 | * Returns the output file formats supported. |
| 121 | */ |
| 122 | Vector<output_format> getOutputFileFormats() const; |
| 123 | |
| 124 | /** |
| 125 | * Returns the video encoders supported. |
| 126 | */ |
| 127 | Vector<video_encoder> getVideoEncoders() const; |
| 128 | |
| 129 | /** |
| 130 | * Returns the value for the given param name for the given video encoder |
| 131 | * returned from getVideoEncoderByIndex or -1 if error. |
| 132 | * |
| 133 | * Supported param name are: |
| 134 | * enc.vid.width.min - min video frame width |
| 135 | * enc.vid.width.max - max video frame width |
| 136 | * enc.vid.height.min - min video frame height |
| 137 | * enc.vid.height.max - max video frame height |
| 138 | * enc.vid.bps.min - min bit rate in bits per second |
| 139 | * enc.vid.bps.max - max bit rate in bits per second |
| 140 | * enc.vid.fps.min - min frame rate in frames per second |
| 141 | * enc.vid.fps.max - max frame rate in frames per second |
| 142 | */ |
| 143 | int getVideoEncoderParamByName(const char *name, video_encoder codec) const; |
| 144 | |
| 145 | /** |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 146 | * Returns the value for the given param name for the video editor cap |
| 147 | * param or -1 if error. |
| 148 | * Supported param name are: |
| 149 | * videoeditor.input.width.max - max input video frame width |
| 150 | * videoeditor.input.height.max - max input video frame height |
| 151 | * videoeditor.output.width.max - max output video frame width |
| 152 | * videoeditor.output.height.max - max output video frame height |
| Hong Teng | 3a9cefe | 2011-11-10 14:54:26 -0800 | [diff] [blame] | 153 | * maxPrefetchYUVFrames - max prefetch YUV frames in video editor engine. This value is used |
| 154 | * to limit the memory consumption. |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 155 | */ |
| 156 | int getVideoEditorCapParamByName(const char *name) const; |
| 157 | |
| 158 | /** |
| Rajneesh Chowdury | 8f74b71 | 2011-08-12 16:43:37 -0700 | [diff] [blame] | 159 | * Returns the value for the given param name for the video editor export codec format |
| 160 | * param or -1 if error. |
| 161 | * Supported param name are: |
| 162 | * videoeditor.export.profile - export video profile |
| 163 | * videoeditor.export.level - export video level |
| 164 | * Supported param codec are: |
| 165 | * 1 for h263 |
| 166 | * 2 for h264 |
| 167 | * 3 for mpeg4 |
| 168 | */ |
| 169 | int getVideoEditorExportParamByName(const char *name, int codec) const; |
| 170 | |
| 171 | /** |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 172 | * Returns the audio encoders supported. |
| 173 | */ |
| 174 | Vector<audio_encoder> getAudioEncoders() const; |
| 175 | |
| 176 | /** |
| 177 | * Returns the value for the given param name for the given audio encoder |
| 178 | * returned from getAudioEncoderByIndex or -1 if error. |
| 179 | * |
| 180 | * Supported param name are: |
| 181 | * enc.aud.ch.min - min number of channels |
| 182 | * enc.aud.ch.max - max number of channels |
| 183 | * enc.aud.bps.min - min bit rate in bits per second |
| 184 | * enc.aud.bps.max - max bit rate in bits per second |
| 185 | * enc.aud.hz.min - min sample rate in samples per second |
| 186 | * enc.aud.hz.max - max sample rate in samples per second |
| 187 | */ |
| 188 | int getAudioEncoderParamByName(const char *name, audio_encoder codec) const; |
| 189 | |
| 190 | /** |
| 191 | * Returns the video decoders supported. |
| 192 | */ |
| 193 | Vector<video_decoder> getVideoDecoders() const; |
| 194 | |
| 195 | /** |
| 196 | * Returns the audio decoders supported. |
| 197 | */ |
| 198 | Vector<audio_decoder> getAudioDecoders() const; |
| 199 | |
| James Dong | f5a8385 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 200 | /** |
| 201 | * Returns the number of image encoding quality levels supported. |
| 202 | */ |
| Chih-Chung Chang | 3eaa4e9 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 203 | Vector<int> getImageEncodingQualityLevels(int cameraId) const; |
| James Dong | f5a8385 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 204 | |
| James Dong | 0f05629 | 2011-05-09 18:49:31 -0700 | [diff] [blame] | 205 | /** |
| 206 | * Returns the start time offset (in ms) for the given camera Id. |
| 207 | * If the given camera Id does not exist, -1 will be returned. |
| 208 | */ |
| 209 | int getStartTimeOffsetMs(int cameraId) const; |
| 210 | |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 211 | private: |
| James Dong | 2a7e0a1 | 2011-02-28 21:07:39 -0800 | [diff] [blame] | 212 | enum { |
| 213 | // Camcorder profiles (high/low) and timelapse profiles (high/low) |
| 214 | kNumRequiredProfiles = 4, |
| 215 | }; |
| 216 | |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 217 | MediaProfiles& operator=(const MediaProfiles&); // Don't call me |
| 218 | MediaProfiles(const MediaProfiles&); // Don't call me |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 219 | MediaProfiles() { mVideoEditorCap = NULL; } // Dummy default constructor |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 220 | ~MediaProfiles(); // Don't delete me |
| 221 | |
| 222 | struct VideoCodec { |
| 223 | VideoCodec(video_encoder codec, int bitRate, int frameWidth, int frameHeight, int frameRate) |
| 224 | : mCodec(codec), |
| 225 | mBitRate(bitRate), |
| 226 | mFrameWidth(frameWidth), |
| 227 | mFrameHeight(frameHeight), |
| 228 | mFrameRate(frameRate) {} |
| 229 | |
| James Dong | 2a7e0a1 | 2011-02-28 21:07:39 -0800 | [diff] [blame] | 230 | VideoCodec(const VideoCodec& copy) { |
| 231 | mCodec = copy.mCodec; |
| 232 | mBitRate = copy.mBitRate; |
| 233 | mFrameWidth = copy.mFrameWidth; |
| 234 | mFrameHeight = copy.mFrameHeight; |
| 235 | mFrameRate = copy.mFrameRate; |
| 236 | } |
| 237 | |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 238 | ~VideoCodec() {} |
| 239 | |
| 240 | video_encoder mCodec; |
| 241 | int mBitRate; |
| 242 | int mFrameWidth; |
| 243 | int mFrameHeight; |
| 244 | int mFrameRate; |
| 245 | }; |
| 246 | |
| 247 | struct AudioCodec { |
| 248 | AudioCodec(audio_encoder codec, int bitRate, int sampleRate, int channels) |
| 249 | : mCodec(codec), |
| 250 | mBitRate(bitRate), |
| 251 | mSampleRate(sampleRate), |
| 252 | mChannels(channels) {} |
| 253 | |
| James Dong | 2a7e0a1 | 2011-02-28 21:07:39 -0800 | [diff] [blame] | 254 | AudioCodec(const AudioCodec& copy) { |
| 255 | mCodec = copy.mCodec; |
| 256 | mBitRate = copy.mBitRate; |
| 257 | mSampleRate = copy.mSampleRate; |
| 258 | mChannels = copy.mChannels; |
| 259 | } |
| 260 | |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 261 | ~AudioCodec() {} |
| 262 | |
| 263 | audio_encoder mCodec; |
| 264 | int mBitRate; |
| 265 | int mSampleRate; |
| 266 | int mChannels; |
| 267 | }; |
| 268 | |
| 269 | struct CamcorderProfile { |
| 270 | CamcorderProfile() |
| Chih-Chung Chang | 3eaa4e9 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 271 | : mCameraId(0), |
| 272 | mFileFormat(OUTPUT_FORMAT_THREE_GPP), |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 273 | mQuality(CAMCORDER_QUALITY_HIGH), |
| 274 | mDuration(0), |
| 275 | mVideoCodec(0), |
| 276 | mAudioCodec(0) {} |
| 277 | |
| James Dong | 2a7e0a1 | 2011-02-28 21:07:39 -0800 | [diff] [blame] | 278 | CamcorderProfile(const CamcorderProfile& copy) { |
| 279 | mCameraId = copy.mCameraId; |
| 280 | mFileFormat = copy.mFileFormat; |
| 281 | mQuality = copy.mQuality; |
| 282 | mDuration = copy.mDuration; |
| 283 | mVideoCodec = new VideoCodec(*copy.mVideoCodec); |
| 284 | mAudioCodec = new AudioCodec(*copy.mAudioCodec); |
| 285 | } |
| 286 | |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 287 | ~CamcorderProfile() { |
| 288 | delete mVideoCodec; |
| 289 | delete mAudioCodec; |
| 290 | } |
| 291 | |
| Chih-Chung Chang | 3eaa4e9 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 292 | int mCameraId; |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 293 | output_format mFileFormat; |
| 294 | camcorder_quality mQuality; |
| 295 | int mDuration; |
| 296 | VideoCodec *mVideoCodec; |
| 297 | AudioCodec *mAudioCodec; |
| 298 | }; |
| 299 | |
| 300 | struct VideoEncoderCap { |
| 301 | // Ugly constructor |
| 302 | VideoEncoderCap(video_encoder codec, |
| 303 | int minBitRate, int maxBitRate, |
| 304 | int minFrameWidth, int maxFrameWidth, |
| 305 | int minFrameHeight, int maxFrameHeight, |
| 306 | int minFrameRate, int maxFrameRate) |
| 307 | : mCodec(codec), |
| 308 | mMinBitRate(minBitRate), mMaxBitRate(maxBitRate), |
| 309 | mMinFrameWidth(minFrameWidth), mMaxFrameWidth(maxFrameWidth), |
| 310 | mMinFrameHeight(minFrameHeight), mMaxFrameHeight(maxFrameHeight), |
| 311 | mMinFrameRate(minFrameRate), mMaxFrameRate(maxFrameRate) {} |
| 312 | |
| 313 | ~VideoEncoderCap() {} |
| 314 | |
| 315 | video_encoder mCodec; |
| 316 | int mMinBitRate, mMaxBitRate; |
| 317 | int mMinFrameWidth, mMaxFrameWidth; |
| 318 | int mMinFrameHeight, mMaxFrameHeight; |
| 319 | int mMinFrameRate, mMaxFrameRate; |
| 320 | }; |
| 321 | |
| 322 | struct AudioEncoderCap { |
| 323 | // Ugly constructor |
| 324 | AudioEncoderCap(audio_encoder codec, |
| 325 | int minBitRate, int maxBitRate, |
| 326 | int minSampleRate, int maxSampleRate, |
| 327 | int minChannels, int maxChannels) |
| 328 | : mCodec(codec), |
| 329 | mMinBitRate(minBitRate), mMaxBitRate(maxBitRate), |
| 330 | mMinSampleRate(minSampleRate), mMaxSampleRate(maxSampleRate), |
| 331 | mMinChannels(minChannels), mMaxChannels(maxChannels) {} |
| 332 | |
| 333 | ~AudioEncoderCap() {} |
| 334 | |
| 335 | audio_encoder mCodec; |
| 336 | int mMinBitRate, mMaxBitRate; |
| 337 | int mMinSampleRate, mMaxSampleRate; |
| 338 | int mMinChannels, mMaxChannels; |
| 339 | }; |
| 340 | |
| 341 | struct VideoDecoderCap { |
| 342 | VideoDecoderCap(video_decoder codec): mCodec(codec) {} |
| 343 | ~VideoDecoderCap() {} |
| 344 | |
| 345 | video_decoder mCodec; |
| 346 | }; |
| 347 | |
| 348 | struct AudioDecoderCap { |
| 349 | AudioDecoderCap(audio_decoder codec): mCodec(codec) {} |
| 350 | ~AudioDecoderCap() {} |
| 351 | |
| 352 | audio_decoder mCodec; |
| 353 | }; |
| 354 | |
| 355 | struct NameToTagMap { |
| 356 | const char* name; |
| 357 | int tag; |
| 358 | }; |
| 359 | |
| Chih-Chung Chang | 3eaa4e9 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 360 | struct ImageEncodingQualityLevels { |
| 361 | int mCameraId; |
| 362 | Vector<int> mLevels; |
| 363 | }; |
| Rajneesh Chowdury | 8f74b71 | 2011-08-12 16:43:37 -0700 | [diff] [blame] | 364 | struct ExportVideoProfile { |
| 365 | ExportVideoProfile(int codec, int profile, int level) |
| 366 | :mCodec(codec),mProfile(profile),mLevel(level) {} |
| 367 | ~ExportVideoProfile() {} |
| 368 | int mCodec; |
| 369 | int mProfile; |
| 370 | int mLevel; |
| 371 | }; |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 372 | struct VideoEditorCap { |
| 373 | VideoEditorCap(int inFrameWidth, int inFrameHeight, |
| Hong Teng | 3a9cefe | 2011-11-10 14:54:26 -0800 | [diff] [blame] | 374 | int outFrameWidth, int outFrameHeight, int frames) |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 375 | : mMaxInputFrameWidth(inFrameWidth), |
| 376 | mMaxInputFrameHeight(inFrameHeight), |
| 377 | mMaxOutputFrameWidth(outFrameWidth), |
| Hong Teng | 3a9cefe | 2011-11-10 14:54:26 -0800 | [diff] [blame] | 378 | mMaxOutputFrameHeight(outFrameHeight), |
| 379 | mMaxPrefetchYUVFrames(frames) {} |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 380 | |
| 381 | ~VideoEditorCap() {} |
| 382 | |
| 383 | int mMaxInputFrameWidth; |
| 384 | int mMaxInputFrameHeight; |
| 385 | int mMaxOutputFrameWidth; |
| 386 | int mMaxOutputFrameHeight; |
| Hong Teng | 3a9cefe | 2011-11-10 14:54:26 -0800 | [diff] [blame] | 387 | int mMaxPrefetchYUVFrames; |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 388 | }; |
| 389 | |
| Nipun Kwatra | 8bb5603 | 2010-09-09 16:25:08 -0700 | [diff] [blame] | 390 | int getCamcorderProfileIndex(int cameraId, camcorder_quality quality) const; |
| James Dong | 2a7e0a1 | 2011-02-28 21:07:39 -0800 | [diff] [blame] | 391 | void initRequiredProfileRefs(const Vector<int>& cameraIds); |
| 392 | int getRequiredProfileRefIndex(int cameraId); |
| Nipun Kwatra | 8bb5603 | 2010-09-09 16:25:08 -0700 | [diff] [blame] | 393 | |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 394 | // Debug |
| 395 | static void logVideoCodec(const VideoCodec& codec); |
| 396 | static void logAudioCodec(const AudioCodec& codec); |
| 397 | static void logVideoEncoderCap(const VideoEncoderCap& cap); |
| 398 | static void logAudioEncoderCap(const AudioEncoderCap& cap); |
| 399 | static void logVideoDecoderCap(const VideoDecoderCap& cap); |
| 400 | static void logAudioDecoderCap(const AudioDecoderCap& cap); |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 401 | static void logVideoEditorCap(const VideoEditorCap& cap); |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 402 | |
| 403 | // If the xml configuration file does exist, use the settings |
| 404 | // from the xml |
| 405 | static MediaProfiles* createInstanceFromXmlFile(const char *xml); |
| 406 | static output_format createEncoderOutputFileFormat(const char **atts); |
| 407 | static VideoCodec* createVideoCodec(const char **atts, MediaProfiles *profiles); |
| 408 | static AudioCodec* createAudioCodec(const char **atts, MediaProfiles *profiles); |
| 409 | static AudioDecoderCap* createAudioDecoderCap(const char **atts); |
| 410 | static VideoDecoderCap* createVideoDecoderCap(const char **atts); |
| 411 | static VideoEncoderCap* createVideoEncoderCap(const char **atts); |
| 412 | static AudioEncoderCap* createAudioEncoderCap(const char **atts); |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 413 | static VideoEditorCap* createVideoEditorCap( |
| 414 | const char **atts, MediaProfiles *profiles); |
| Rajneesh Chowdury | 8f74b71 | 2011-08-12 16:43:37 -0700 | [diff] [blame] | 415 | static ExportVideoProfile* createExportVideoProfile(const char **atts); |
| James Dong | 2a7e0a1 | 2011-02-28 21:07:39 -0800 | [diff] [blame] | 416 | |
| 417 | static CamcorderProfile* createCamcorderProfile( |
| 418 | int cameraId, const char **atts, Vector<int>& cameraIds); |
| 419 | |
| Chih-Chung Chang | 3eaa4e9 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 420 | static int getCameraId(const char **atts); |
| 421 | |
| James Dong | 0f05629 | 2011-05-09 18:49:31 -0700 | [diff] [blame] | 422 | void addStartTimeOffset(int cameraId, const char **atts); |
| 423 | |
| Chih-Chung Chang | 3eaa4e9 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 424 | ImageEncodingQualityLevels* findImageEncodingQualityLevels(int cameraId) const; |
| 425 | void addImageEncodingQualityLevel(int cameraId, const char** atts); |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 426 | |
| 427 | // Customized element tag handler for parsing the xml configuration file. |
| 428 | static void startElementHandler(void *userData, const char *name, const char **atts); |
| 429 | |
| 430 | // If the xml configuration file does not exist, use hard-coded values |
| 431 | static MediaProfiles* createDefaultInstance(); |
| Nipun Kwatra | d5672bc | 2010-09-16 22:25:23 -0700 | [diff] [blame] | 432 | |
| 433 | static CamcorderProfile *createDefaultCamcorderQcifProfile(camcorder_quality quality); |
| 434 | static CamcorderProfile *createDefaultCamcorderCifProfile(camcorder_quality quality); |
| 435 | static void createDefaultCamcorderLowProfiles( |
| 436 | MediaProfiles::CamcorderProfile **lowProfile, |
| 437 | MediaProfiles::CamcorderProfile **lowSpecificProfile); |
| 438 | static void createDefaultCamcorderHighProfiles( |
| 439 | MediaProfiles::CamcorderProfile **highProfile, |
| 440 | MediaProfiles::CamcorderProfile **highSpecificProfile); |
| 441 | |
| 442 | static CamcorderProfile *createDefaultCamcorderTimeLapseQcifProfile(camcorder_quality quality); |
| 443 | static CamcorderProfile *createDefaultCamcorderTimeLapse480pProfile(camcorder_quality quality); |
| 444 | static void createDefaultCamcorderTimeLapseLowProfiles( |
| 445 | MediaProfiles::CamcorderProfile **lowTimeLapseProfile, |
| 446 | MediaProfiles::CamcorderProfile **lowSpecificTimeLapseProfile); |
| 447 | static void createDefaultCamcorderTimeLapseHighProfiles( |
| 448 | MediaProfiles::CamcorderProfile **highTimeLapseProfile, |
| 449 | MediaProfiles::CamcorderProfile **highSpecificTimeLapseProfile); |
| 450 | |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 451 | static void createDefaultCamcorderProfiles(MediaProfiles *profiles); |
| 452 | static void createDefaultVideoEncoders(MediaProfiles *profiles); |
| 453 | static void createDefaultAudioEncoders(MediaProfiles *profiles); |
| 454 | static void createDefaultVideoDecoders(MediaProfiles *profiles); |
| 455 | static void createDefaultAudioDecoders(MediaProfiles *profiles); |
| 456 | static void createDefaultEncoderOutputFileFormats(MediaProfiles *profiles); |
| James Dong | f5a8385 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 457 | static void createDefaultImageEncodingQualityLevels(MediaProfiles *profiles); |
| 458 | static void createDefaultImageDecodingMaxMemory(MediaProfiles *profiles); |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 459 | static void createDefaultVideoEditorCap(MediaProfiles *profiles); |
| Rajneesh Chowdury | 8f74b71 | 2011-08-12 16:43:37 -0700 | [diff] [blame] | 460 | static void createDefaultExportVideoProfiles(MediaProfiles *profiles); |
| 461 | |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 462 | static VideoEncoderCap* createDefaultH263VideoEncoderCap(); |
| 463 | static VideoEncoderCap* createDefaultM4vVideoEncoderCap(); |
| 464 | static AudioEncoderCap* createDefaultAmrNBEncoderCap(); |
| vivek mehta | 2192bc9 | 2012-12-04 11:46:08 -0800 | [diff] [blame] | 465 | #ifdef QCOM_HARDWARE |
| 466 | static AudioEncoderCap* createDefaultAacEncoderCap(); |
| 467 | static AudioEncoderCap* createDefaultLpcmEncoderCap(); |
| 468 | #endif |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 469 | |
| 470 | static int findTagForName(const NameToTagMap *map, size_t nMappings, const char *name); |
| 471 | |
| James Dong | 2a7e0a1 | 2011-02-28 21:07:39 -0800 | [diff] [blame] | 472 | /** |
| 473 | * Check on existing profiles with the following criteria: |
| 474 | * 1. Low quality profile must have the lowest video |
| 475 | * resolution product (width x height) |
| 476 | * 2. High quality profile must have the highest video |
| 477 | * resolution product (width x height) |
| 478 | * |
| 479 | * and add required low/high quality camcorder/timelapse |
| 480 | * profiles if they are not found. This allows to remove |
| 481 | * duplicate profile definitions in the media_profiles.xml |
| 482 | * file. |
| 483 | */ |
| 484 | void checkAndAddRequiredProfilesIfNecessary(); |
| 485 | |
| 486 | |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 487 | // Mappings from name (for instance, codec name) to enum value |
| 488 | static const NameToTagMap sVideoEncoderNameMap[]; |
| 489 | static const NameToTagMap sAudioEncoderNameMap[]; |
| 490 | static const NameToTagMap sFileFormatMap[]; |
| 491 | static const NameToTagMap sVideoDecoderNameMap[]; |
| 492 | static const NameToTagMap sAudioDecoderNameMap[]; |
| 493 | static const NameToTagMap sCamcorderQualityNameMap[]; |
| 494 | |
| 495 | static bool sIsInitialized; |
| 496 | static MediaProfiles *sInstance; |
| 497 | static Mutex sLock; |
| Chih-Chung Chang | 3eaa4e9 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 498 | int mCurrentCameraId; |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 499 | |
| 500 | Vector<CamcorderProfile*> mCamcorderProfiles; |
| 501 | Vector<AudioEncoderCap*> mAudioEncoders; |
| 502 | Vector<VideoEncoderCap*> mVideoEncoders; |
| 503 | Vector<AudioDecoderCap*> mAudioDecoders; |
| 504 | Vector<VideoDecoderCap*> mVideoDecoders; |
| 505 | Vector<output_format> mEncoderOutputFileFormats; |
| Chih-Chung Chang | 3eaa4e9 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 506 | Vector<ImageEncodingQualityLevels *> mImageEncodingQualityLevels; |
| James Dong | 0f05629 | 2011-05-09 18:49:31 -0700 | [diff] [blame] | 507 | KeyedVector<int, int> mStartTimeOffsets; |
| James Dong | 2a7e0a1 | 2011-02-28 21:07:39 -0800 | [diff] [blame] | 508 | |
| 509 | typedef struct { |
| 510 | bool mHasRefProfile; // Refers to an existing profile |
| 511 | int mRefProfileIndex; // Reference profile index |
| 512 | int mResolutionProduct; // width x height |
| 513 | } RequiredProfileRefInfo; // Required low and high profiles |
| 514 | |
| 515 | typedef struct { |
| 516 | RequiredProfileRefInfo mRefs[kNumRequiredProfiles]; |
| 517 | int mCameraId; |
| 518 | } RequiredProfiles; |
| 519 | |
| 520 | RequiredProfiles *mRequiredProfileRefs; |
| 521 | Vector<int> mCameraIds; |
| Hong Teng | cabd5f8 | 2011-07-06 18:33:09 -0700 | [diff] [blame] | 522 | VideoEditorCap* mVideoEditorCap; |
| Rajneesh Chowdury | 8f74b71 | 2011-08-12 16:43:37 -0700 | [diff] [blame] | 523 | Vector<ExportVideoProfile*> mVideoEditorExportProfiles; |
| James Dong | 1d7491b | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 524 | }; |
| 525 | |
| 526 | }; // namespace android |
| 527 | |
| 528 | #endif // ANDROID_MEDIAPROFILES_H |