blob: f061d220a4e98e15a0936d4e03e085490bfdba07 [file] [log] [blame]
James Dong1d7491b2010-01-19 17:45:38 -08001/*
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
24namespace android {
25
26enum camcorder_quality {
James Dong2a7e0a12011-02-28 21:07:39 -080027 CAMCORDER_QUALITY_LIST_START = 0,
James Dong0b42f252010-03-31 13:56:29 -070028 CAMCORDER_QUALITY_LOW = 0,
Nipun Kwatrac0a84782010-09-06 15:59:02 -070029 CAMCORDER_QUALITY_HIGH = 1,
30 CAMCORDER_QUALITY_QCIF = 2,
Nipun Kwatra9783ed82010-09-10 15:45:57 -070031 CAMCORDER_QUALITY_CIF = 3,
32 CAMCORDER_QUALITY_480P = 4,
33 CAMCORDER_QUALITY_720P = 5,
34 CAMCORDER_QUALITY_1080P = 6,
James Dong669012d2011-09-19 16:27:31 -070035 CAMCORDER_QUALITY_QVGA = 7,
Zhijun He5f6af1a2014-06-10 08:26:33 -070036 CAMCORDER_QUALITY_2160P = 8,
37 CAMCORDER_QUALITY_LIST_END = 8,
Nipun Kwatrac0a84782010-09-06 15:59:02 -070038
James Dong2a7e0a12011-02-28 21:07:39 -080039 CAMCORDER_QUALITY_TIME_LAPSE_LIST_START = 1000,
Nipun Kwatrac0a84782010-09-06 15:59:02 -070040 CAMCORDER_QUALITY_TIME_LAPSE_LOW = 1000,
41 CAMCORDER_QUALITY_TIME_LAPSE_HIGH = 1001,
42 CAMCORDER_QUALITY_TIME_LAPSE_QCIF = 1002,
Nipun Kwatra9783ed82010-09-10 15:45:57 -070043 CAMCORDER_QUALITY_TIME_LAPSE_CIF = 1003,
44 CAMCORDER_QUALITY_TIME_LAPSE_480P = 1004,
45 CAMCORDER_QUALITY_TIME_LAPSE_720P = 1005,
James Dong2a7e0a12011-02-28 21:07:39 -080046 CAMCORDER_QUALITY_TIME_LAPSE_1080P = 1006,
James Dong669012d2011-09-19 16:27:31 -070047 CAMCORDER_QUALITY_TIME_LAPSE_QVGA = 1007,
Zhijun He5f6af1a2014-06-10 08:26:33 -070048 CAMCORDER_QUALITY_TIME_LAPSE_2160P = 1008,
49 CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1008,
Zhijun Hee0790972014-07-23 15:17:26 -070050
51 CAMCORDER_QUALITY_HIGH_SPEED_LIST_START = 2000,
52 CAMCORDER_QUALITY_HIGH_SPEED_LOW = 2000,
53 CAMCORDER_QUALITY_HIGH_SPEED_HIGH = 2001,
54 CAMCORDER_QUALITY_HIGH_SPEED_480P = 2002,
55 CAMCORDER_QUALITY_HIGH_SPEED_720P = 2003,
56 CAMCORDER_QUALITY_HIGH_SPEED_1080P = 2004,
Zhijun He9520aa62014-09-09 16:18:31 -070057 CAMCORDER_QUALITY_HIGH_SPEED_2160P = 2005,
58 CAMCORDER_QUALITY_HIGH_SPEED_LIST_END = 2005,
James Dong1d7491b2010-01-19 17:45:38 -080059};
60
Hong Tengcabd5f82011-07-06 18:33:09 -070061/**
Hong Teng3a9cefe2011-11-10 14:54:26 -080062 * Set CIF as default maximum import and export resolution of video editor.
63 * The maximum import and export resolutions are platform specific,
64 * which should be defined in media_profiles.xml.
65 * Set default maximum prefetch YUV frames to 6, which means video editor can
66 * queue up to 6 YUV frames in the video encoder source.
67 * This value is used to limit the amount of memory used by video editor
68 * engine when the encoder consumes YUV frames at a lower speed
69 * than video editor engine produces.
Hong Tengcabd5f82011-07-06 18:33:09 -070070 */
71enum videoeditor_capability {
72 VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH = 352,
73 VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT = 288,
74 VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH = 352,
75 VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT = 288,
Hong Teng3a9cefe2011-11-10 14:54:26 -080076 VIDEOEDITOR_DEFAULT_MAX_PREFETCH_YUV_FRAMES = 6
Hong Tengcabd5f82011-07-06 18:33:09 -070077};
78
James Dong1d7491b2010-01-19 17:45:38 -080079enum video_decoder {
80 VIDEO_DECODER_WMV,
81};
82
83enum audio_decoder {
84 AUDIO_DECODER_WMA,
85};
86
87
88class MediaProfiles
89{
90public:
91
92 /**
93 * Returns the singleton instance for subsequence queries.
94 * or NULL if error.
95 */
96 static MediaProfiles* getInstance();
97
98 /**
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +080099 * Returns the value for the given param name for the given camera at
100 * the given quality level, or -1 if error.
James Dong1d7491b2010-01-19 17:45:38 -0800101 *
102 * Supported param name are:
James Dongf5a83852010-02-23 17:21:44 -0800103 * duration - the recording duration.
James Dong1d7491b2010-01-19 17:45:38 -0800104 * file.format - output file format. see mediarecorder.h for details
James Dong13896b92010-02-03 16:50:18 -0800105 * vid.codec - video encoder. see mediarecorder.h for details.
106 * aud.codec - audio encoder. see mediarecorder.h for details.
James Dong1d7491b2010-01-19 17:45:38 -0800107 * vid.width - video frame width
108 * vid.height - video frame height
109 * vid.fps - video frame rate
110 * vid.bps - video bit rate
111 * aud.bps - audio bit rate
112 * aud.hz - audio sample rate
113 * aud.ch - number of audio channels
114 */
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800115 int getCamcorderProfileParamByName(const char *name, int cameraId,
116 camcorder_quality quality) const;
James Dong1d7491b2010-01-19 17:45:38 -0800117
118 /**
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700119 * Returns true if a profile for the given camera at the given quality exists,
120 * or false if not.
121 */
122 bool hasCamcorderProfile(int cameraId, camcorder_quality quality) const;
123
124 /**
James Dong1d7491b2010-01-19 17:45:38 -0800125 * Returns the output file formats supported.
126 */
127 Vector<output_format> getOutputFileFormats() const;
128
129 /**
130 * Returns the video encoders supported.
131 */
132 Vector<video_encoder> getVideoEncoders() const;
133
134 /**
135 * Returns the value for the given param name for the given video encoder
136 * returned from getVideoEncoderByIndex or -1 if error.
137 *
138 * Supported param name are:
139 * enc.vid.width.min - min video frame width
140 * enc.vid.width.max - max video frame width
141 * enc.vid.height.min - min video frame height
142 * enc.vid.height.max - max video frame height
143 * enc.vid.bps.min - min bit rate in bits per second
144 * enc.vid.bps.max - max bit rate in bits per second
145 * enc.vid.fps.min - min frame rate in frames per second
146 * enc.vid.fps.max - max frame rate in frames per second
147 */
148 int getVideoEncoderParamByName(const char *name, video_encoder codec) const;
149
150 /**
Hong Tengcabd5f82011-07-06 18:33:09 -0700151 * Returns the value for the given param name for the video editor cap
152 * param or -1 if error.
153 * Supported param name are:
154 * videoeditor.input.width.max - max input video frame width
155 * videoeditor.input.height.max - max input video frame height
156 * videoeditor.output.width.max - max output video frame width
157 * videoeditor.output.height.max - max output video frame height
Hong Teng3a9cefe2011-11-10 14:54:26 -0800158 * maxPrefetchYUVFrames - max prefetch YUV frames in video editor engine. This value is used
159 * to limit the memory consumption.
Hong Tengcabd5f82011-07-06 18:33:09 -0700160 */
161 int getVideoEditorCapParamByName(const char *name) const;
162
163 /**
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700164 * Returns the value for the given param name for the video editor export codec format
165 * param or -1 if error.
166 * Supported param name are:
167 * videoeditor.export.profile - export video profile
168 * videoeditor.export.level - export video level
169 * Supported param codec are:
170 * 1 for h263
171 * 2 for h264
172 * 3 for mpeg4
173 */
174 int getVideoEditorExportParamByName(const char *name, int codec) const;
175
176 /**
James Dong1d7491b2010-01-19 17:45:38 -0800177 * Returns the audio encoders supported.
178 */
179 Vector<audio_encoder> getAudioEncoders() const;
180
181 /**
182 * Returns the value for the given param name for the given audio encoder
183 * returned from getAudioEncoderByIndex or -1 if error.
184 *
185 * Supported param name are:
186 * enc.aud.ch.min - min number of channels
187 * enc.aud.ch.max - max number of channels
188 * enc.aud.bps.min - min bit rate in bits per second
189 * enc.aud.bps.max - max bit rate in bits per second
190 * enc.aud.hz.min - min sample rate in samples per second
191 * enc.aud.hz.max - max sample rate in samples per second
192 */
193 int getAudioEncoderParamByName(const char *name, audio_encoder codec) const;
194
195 /**
196 * Returns the video decoders supported.
197 */
198 Vector<video_decoder> getVideoDecoders() const;
199
200 /**
201 * Returns the audio decoders supported.
202 */
203 Vector<audio_decoder> getAudioDecoders() const;
204
James Dongf5a83852010-02-23 17:21:44 -0800205 /**
206 * Returns the number of image encoding quality levels supported.
207 */
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800208 Vector<int> getImageEncodingQualityLevels(int cameraId) const;
James Dongf5a83852010-02-23 17:21:44 -0800209
James Dong0f056292011-05-09 18:49:31 -0700210 /**
211 * Returns the start time offset (in ms) for the given camera Id.
212 * If the given camera Id does not exist, -1 will be returned.
213 */
214 int getStartTimeOffsetMs(int cameraId) const;
215
James Dong1d7491b2010-01-19 17:45:38 -0800216private:
James Dong2a7e0a12011-02-28 21:07:39 -0800217 enum {
218 // Camcorder profiles (high/low) and timelapse profiles (high/low)
219 kNumRequiredProfiles = 4,
220 };
221
James Dong1d7491b2010-01-19 17:45:38 -0800222 MediaProfiles& operator=(const MediaProfiles&); // Don't call me
223 MediaProfiles(const MediaProfiles&); // Don't call me
Hong Tengcabd5f82011-07-06 18:33:09 -0700224 MediaProfiles() { mVideoEditorCap = NULL; } // Dummy default constructor
James Dong1d7491b2010-01-19 17:45:38 -0800225 ~MediaProfiles(); // Don't delete me
226
227 struct VideoCodec {
228 VideoCodec(video_encoder codec, int bitRate, int frameWidth, int frameHeight, int frameRate)
229 : mCodec(codec),
230 mBitRate(bitRate),
231 mFrameWidth(frameWidth),
232 mFrameHeight(frameHeight),
233 mFrameRate(frameRate) {}
234
James Dong2a7e0a12011-02-28 21:07:39 -0800235 VideoCodec(const VideoCodec& copy) {
236 mCodec = copy.mCodec;
237 mBitRate = copy.mBitRate;
238 mFrameWidth = copy.mFrameWidth;
239 mFrameHeight = copy.mFrameHeight;
240 mFrameRate = copy.mFrameRate;
241 }
242
James Dong1d7491b2010-01-19 17:45:38 -0800243 ~VideoCodec() {}
244
245 video_encoder mCodec;
246 int mBitRate;
247 int mFrameWidth;
248 int mFrameHeight;
249 int mFrameRate;
250 };
251
252 struct AudioCodec {
253 AudioCodec(audio_encoder codec, int bitRate, int sampleRate, int channels)
254 : mCodec(codec),
255 mBitRate(bitRate),
256 mSampleRate(sampleRate),
257 mChannels(channels) {}
258
James Dong2a7e0a12011-02-28 21:07:39 -0800259 AudioCodec(const AudioCodec& copy) {
260 mCodec = copy.mCodec;
261 mBitRate = copy.mBitRate;
262 mSampleRate = copy.mSampleRate;
263 mChannels = copy.mChannels;
264 }
265
James Dong1d7491b2010-01-19 17:45:38 -0800266 ~AudioCodec() {}
267
268 audio_encoder mCodec;
269 int mBitRate;
270 int mSampleRate;
271 int mChannels;
272 };
273
274 struct CamcorderProfile {
275 CamcorderProfile()
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800276 : mCameraId(0),
277 mFileFormat(OUTPUT_FORMAT_THREE_GPP),
James Dong1d7491b2010-01-19 17:45:38 -0800278 mQuality(CAMCORDER_QUALITY_HIGH),
279 mDuration(0),
280 mVideoCodec(0),
281 mAudioCodec(0) {}
282
James Dong2a7e0a12011-02-28 21:07:39 -0800283 CamcorderProfile(const CamcorderProfile& copy) {
284 mCameraId = copy.mCameraId;
285 mFileFormat = copy.mFileFormat;
286 mQuality = copy.mQuality;
287 mDuration = copy.mDuration;
288 mVideoCodec = new VideoCodec(*copy.mVideoCodec);
289 mAudioCodec = new AudioCodec(*copy.mAudioCodec);
290 }
291
James Dong1d7491b2010-01-19 17:45:38 -0800292 ~CamcorderProfile() {
293 delete mVideoCodec;
294 delete mAudioCodec;
295 }
296
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800297 int mCameraId;
James Dong1d7491b2010-01-19 17:45:38 -0800298 output_format mFileFormat;
299 camcorder_quality mQuality;
300 int mDuration;
301 VideoCodec *mVideoCodec;
302 AudioCodec *mAudioCodec;
303 };
304
305 struct VideoEncoderCap {
306 // Ugly constructor
307 VideoEncoderCap(video_encoder codec,
308 int minBitRate, int maxBitRate,
309 int minFrameWidth, int maxFrameWidth,
310 int minFrameHeight, int maxFrameHeight,
311 int minFrameRate, int maxFrameRate)
312 : mCodec(codec),
313 mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
314 mMinFrameWidth(minFrameWidth), mMaxFrameWidth(maxFrameWidth),
315 mMinFrameHeight(minFrameHeight), mMaxFrameHeight(maxFrameHeight),
316 mMinFrameRate(minFrameRate), mMaxFrameRate(maxFrameRate) {}
317
318 ~VideoEncoderCap() {}
319
320 video_encoder mCodec;
321 int mMinBitRate, mMaxBitRate;
322 int mMinFrameWidth, mMaxFrameWidth;
323 int mMinFrameHeight, mMaxFrameHeight;
324 int mMinFrameRate, mMaxFrameRate;
325 };
326
327 struct AudioEncoderCap {
328 // Ugly constructor
329 AudioEncoderCap(audio_encoder codec,
330 int minBitRate, int maxBitRate,
331 int minSampleRate, int maxSampleRate,
332 int minChannels, int maxChannels)
333 : mCodec(codec),
334 mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
335 mMinSampleRate(minSampleRate), mMaxSampleRate(maxSampleRate),
336 mMinChannels(minChannels), mMaxChannels(maxChannels) {}
337
338 ~AudioEncoderCap() {}
339
340 audio_encoder mCodec;
341 int mMinBitRate, mMaxBitRate;
342 int mMinSampleRate, mMaxSampleRate;
343 int mMinChannels, mMaxChannels;
344 };
345
346 struct VideoDecoderCap {
347 VideoDecoderCap(video_decoder codec): mCodec(codec) {}
348 ~VideoDecoderCap() {}
349
350 video_decoder mCodec;
351 };
352
353 struct AudioDecoderCap {
354 AudioDecoderCap(audio_decoder codec): mCodec(codec) {}
355 ~AudioDecoderCap() {}
356
357 audio_decoder mCodec;
358 };
359
360 struct NameToTagMap {
361 const char* name;
362 int tag;
363 };
364
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800365 struct ImageEncodingQualityLevels {
366 int mCameraId;
367 Vector<int> mLevels;
368 };
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700369 struct ExportVideoProfile {
370 ExportVideoProfile(int codec, int profile, int level)
371 :mCodec(codec),mProfile(profile),mLevel(level) {}
372 ~ExportVideoProfile() {}
373 int mCodec;
374 int mProfile;
375 int mLevel;
376 };
Hong Tengcabd5f82011-07-06 18:33:09 -0700377 struct VideoEditorCap {
378 VideoEditorCap(int inFrameWidth, int inFrameHeight,
Hong Teng3a9cefe2011-11-10 14:54:26 -0800379 int outFrameWidth, int outFrameHeight, int frames)
Hong Tengcabd5f82011-07-06 18:33:09 -0700380 : mMaxInputFrameWidth(inFrameWidth),
381 mMaxInputFrameHeight(inFrameHeight),
382 mMaxOutputFrameWidth(outFrameWidth),
Hong Teng3a9cefe2011-11-10 14:54:26 -0800383 mMaxOutputFrameHeight(outFrameHeight),
384 mMaxPrefetchYUVFrames(frames) {}
Hong Tengcabd5f82011-07-06 18:33:09 -0700385
386 ~VideoEditorCap() {}
387
388 int mMaxInputFrameWidth;
389 int mMaxInputFrameHeight;
390 int mMaxOutputFrameWidth;
391 int mMaxOutputFrameHeight;
Hong Teng3a9cefe2011-11-10 14:54:26 -0800392 int mMaxPrefetchYUVFrames;
Hong Tengcabd5f82011-07-06 18:33:09 -0700393 };
394
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700395 int getCamcorderProfileIndex(int cameraId, camcorder_quality quality) const;
James Dong2a7e0a12011-02-28 21:07:39 -0800396 void initRequiredProfileRefs(const Vector<int>& cameraIds);
397 int getRequiredProfileRefIndex(int cameraId);
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700398
James Dong1d7491b2010-01-19 17:45:38 -0800399 // Debug
400 static void logVideoCodec(const VideoCodec& codec);
401 static void logAudioCodec(const AudioCodec& codec);
402 static void logVideoEncoderCap(const VideoEncoderCap& cap);
403 static void logAudioEncoderCap(const AudioEncoderCap& cap);
404 static void logVideoDecoderCap(const VideoDecoderCap& cap);
405 static void logAudioDecoderCap(const AudioDecoderCap& cap);
Hong Tengcabd5f82011-07-06 18:33:09 -0700406 static void logVideoEditorCap(const VideoEditorCap& cap);
James Dong1d7491b2010-01-19 17:45:38 -0800407
408 // If the xml configuration file does exist, use the settings
409 // from the xml
410 static MediaProfiles* createInstanceFromXmlFile(const char *xml);
411 static output_format createEncoderOutputFileFormat(const char **atts);
412 static VideoCodec* createVideoCodec(const char **atts, MediaProfiles *profiles);
413 static AudioCodec* createAudioCodec(const char **atts, MediaProfiles *profiles);
414 static AudioDecoderCap* createAudioDecoderCap(const char **atts);
415 static VideoDecoderCap* createVideoDecoderCap(const char **atts);
416 static VideoEncoderCap* createVideoEncoderCap(const char **atts);
417 static AudioEncoderCap* createAudioEncoderCap(const char **atts);
Hong Tengcabd5f82011-07-06 18:33:09 -0700418 static VideoEditorCap* createVideoEditorCap(
419 const char **atts, MediaProfiles *profiles);
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700420 static ExportVideoProfile* createExportVideoProfile(const char **atts);
James Dong2a7e0a12011-02-28 21:07:39 -0800421
422 static CamcorderProfile* createCamcorderProfile(
423 int cameraId, const char **atts, Vector<int>& cameraIds);
424
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800425 static int getCameraId(const char **atts);
426
James Dong0f056292011-05-09 18:49:31 -0700427 void addStartTimeOffset(int cameraId, const char **atts);
428
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800429 ImageEncodingQualityLevels* findImageEncodingQualityLevels(int cameraId) const;
430 void addImageEncodingQualityLevel(int cameraId, const char** atts);
James Dong1d7491b2010-01-19 17:45:38 -0800431
432 // Customized element tag handler for parsing the xml configuration file.
433 static void startElementHandler(void *userData, const char *name, const char **atts);
434
435 // If the xml configuration file does not exist, use hard-coded values
436 static MediaProfiles* createDefaultInstance();
Nipun Kwatrad5672bc2010-09-16 22:25:23 -0700437
438 static CamcorderProfile *createDefaultCamcorderQcifProfile(camcorder_quality quality);
439 static CamcorderProfile *createDefaultCamcorderCifProfile(camcorder_quality quality);
440 static void createDefaultCamcorderLowProfiles(
441 MediaProfiles::CamcorderProfile **lowProfile,
442 MediaProfiles::CamcorderProfile **lowSpecificProfile);
443 static void createDefaultCamcorderHighProfiles(
444 MediaProfiles::CamcorderProfile **highProfile,
445 MediaProfiles::CamcorderProfile **highSpecificProfile);
446
447 static CamcorderProfile *createDefaultCamcorderTimeLapseQcifProfile(camcorder_quality quality);
448 static CamcorderProfile *createDefaultCamcorderTimeLapse480pProfile(camcorder_quality quality);
449 static void createDefaultCamcorderTimeLapseLowProfiles(
450 MediaProfiles::CamcorderProfile **lowTimeLapseProfile,
451 MediaProfiles::CamcorderProfile **lowSpecificTimeLapseProfile);
452 static void createDefaultCamcorderTimeLapseHighProfiles(
453 MediaProfiles::CamcorderProfile **highTimeLapseProfile,
454 MediaProfiles::CamcorderProfile **highSpecificTimeLapseProfile);
455
James Dong1d7491b2010-01-19 17:45:38 -0800456 static void createDefaultCamcorderProfiles(MediaProfiles *profiles);
457 static void createDefaultVideoEncoders(MediaProfiles *profiles);
458 static void createDefaultAudioEncoders(MediaProfiles *profiles);
459 static void createDefaultVideoDecoders(MediaProfiles *profiles);
460 static void createDefaultAudioDecoders(MediaProfiles *profiles);
461 static void createDefaultEncoderOutputFileFormats(MediaProfiles *profiles);
James Dongf5a83852010-02-23 17:21:44 -0800462 static void createDefaultImageEncodingQualityLevels(MediaProfiles *profiles);
463 static void createDefaultImageDecodingMaxMemory(MediaProfiles *profiles);
Hong Tengcabd5f82011-07-06 18:33:09 -0700464 static void createDefaultVideoEditorCap(MediaProfiles *profiles);
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700465 static void createDefaultExportVideoProfiles(MediaProfiles *profiles);
466
James Dong1d7491b2010-01-19 17:45:38 -0800467 static VideoEncoderCap* createDefaultH263VideoEncoderCap();
468 static VideoEncoderCap* createDefaultM4vVideoEncoderCap();
469 static AudioEncoderCap* createDefaultAmrNBEncoderCap();
470
471 static int findTagForName(const NameToTagMap *map, size_t nMappings, const char *name);
472
James Dong2a7e0a12011-02-28 21:07:39 -0800473 /**
474 * Check on existing profiles with the following criteria:
475 * 1. Low quality profile must have the lowest video
476 * resolution product (width x height)
477 * 2. High quality profile must have the highest video
478 * resolution product (width x height)
479 *
480 * and add required low/high quality camcorder/timelapse
481 * profiles if they are not found. This allows to remove
482 * duplicate profile definitions in the media_profiles.xml
483 * file.
484 */
485 void checkAndAddRequiredProfilesIfNecessary();
486
487
James Dong1d7491b2010-01-19 17:45:38 -0800488 // Mappings from name (for instance, codec name) to enum value
489 static const NameToTagMap sVideoEncoderNameMap[];
490 static const NameToTagMap sAudioEncoderNameMap[];
491 static const NameToTagMap sFileFormatMap[];
492 static const NameToTagMap sVideoDecoderNameMap[];
493 static const NameToTagMap sAudioDecoderNameMap[];
494 static const NameToTagMap sCamcorderQualityNameMap[];
495
496 static bool sIsInitialized;
497 static MediaProfiles *sInstance;
498 static Mutex sLock;
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800499 int mCurrentCameraId;
James Dong1d7491b2010-01-19 17:45:38 -0800500
501 Vector<CamcorderProfile*> mCamcorderProfiles;
502 Vector<AudioEncoderCap*> mAudioEncoders;
503 Vector<VideoEncoderCap*> mVideoEncoders;
504 Vector<AudioDecoderCap*> mAudioDecoders;
505 Vector<VideoDecoderCap*> mVideoDecoders;
506 Vector<output_format> mEncoderOutputFileFormats;
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800507 Vector<ImageEncodingQualityLevels *> mImageEncodingQualityLevels;
James Dong0f056292011-05-09 18:49:31 -0700508 KeyedVector<int, int> mStartTimeOffsets;
James Dong2a7e0a12011-02-28 21:07:39 -0800509
510 typedef struct {
511 bool mHasRefProfile; // Refers to an existing profile
512 int mRefProfileIndex; // Reference profile index
513 int mResolutionProduct; // width x height
514 } RequiredProfileRefInfo; // Required low and high profiles
515
516 typedef struct {
517 RequiredProfileRefInfo mRefs[kNumRequiredProfiles];
518 int mCameraId;
519 } RequiredProfiles;
520
521 RequiredProfiles *mRequiredProfileRefs;
522 Vector<int> mCameraIds;
Hong Tengcabd5f82011-07-06 18:33:09 -0700523 VideoEditorCap* mVideoEditorCap;
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700524 Vector<ExportVideoProfile*> mVideoEditorExportProfiles;
James Dong1d7491b2010-01-19 17:45:38 -0800525};
526
527}; // namespace android
528
529#endif // ANDROID_MEDIAPROFILES_H