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