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