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