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