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