blob: 0df9fd4838ac88653dba6d0ecd9fca7a11ac8ed8 [file] [log] [blame]
James Dong1d7491b2010-01-19 17:45:38 -08001/*
2 **
3 ** Copyright 2010, The Android Open Source Project.
vivek mehta2192bc92012-12-04 11:46:08 -08004 ** Copyright (c) 2010 - 2012, The Linux Foundation. All rights reserved.
James Dong1d7491b2010-01-19 17:45:38 -08005 **
6 ** Licensed under the Apache License, Version 2.0 (the "License");
7 ** you may not use this file except in compliance with the License.
8 ** You may obtain a copy of the License at
9 **
10 ** http://www.apache.org/licenses/LICENSE-2.0
11 **
12 ** Unless required by applicable law or agreed to in writing, software
13 ** distributed under the License is distributed on an "AS IS" BASIS,
14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ** See the License for the specific language governing permissions and
16 ** limitations under the License.
17 */
18
19#ifndef ANDROID_MEDIAPROFILES_H
20#define ANDROID_MEDIAPROFILES_H
21
22#include <utils/threads.h>
23#include <media/mediarecorder.h>
24
25namespace android {
26
27enum camcorder_quality {
James Dong2a7e0a12011-02-28 21:07:39 -080028 CAMCORDER_QUALITY_LIST_START = 0,
James Dong0b42f252010-03-31 13:56:29 -070029 CAMCORDER_QUALITY_LOW = 0,
Nipun Kwatrac0a84782010-09-06 15:59:02 -070030 CAMCORDER_QUALITY_HIGH = 1,
31 CAMCORDER_QUALITY_QCIF = 2,
Nipun Kwatra9783ed82010-09-10 15:45:57 -070032 CAMCORDER_QUALITY_CIF = 3,
33 CAMCORDER_QUALITY_480P = 4,
34 CAMCORDER_QUALITY_720P = 5,
35 CAMCORDER_QUALITY_1080P = 6,
Ankit Premrajka140a9ac2011-11-21 19:25:02 -080036 CAMCORDER_QUALITY_QVGA = 11,
37 CAMCORDER_QUALITY_FWVGA = 7,
38 CAMCORDER_QUALITY_WVGA = 8,
39 CAMCORDER_QUALITY_VGA = 9,
40 CAMCORDER_QUALITY_WQVGA = 10,
41
42 CAMCORDER_QUALITY_LIST_END = 11,
Nipun Kwatrac0a84782010-09-06 15:59:02 -070043
James Dong2a7e0a12011-02-28 21:07:39 -080044 CAMCORDER_QUALITY_TIME_LAPSE_LIST_START = 1000,
Nipun Kwatrac0a84782010-09-06 15:59:02 -070045 CAMCORDER_QUALITY_TIME_LAPSE_LOW = 1000,
46 CAMCORDER_QUALITY_TIME_LAPSE_HIGH = 1001,
47 CAMCORDER_QUALITY_TIME_LAPSE_QCIF = 1002,
Nipun Kwatra9783ed82010-09-10 15:45:57 -070048 CAMCORDER_QUALITY_TIME_LAPSE_CIF = 1003,
49 CAMCORDER_QUALITY_TIME_LAPSE_480P = 1004,
50 CAMCORDER_QUALITY_TIME_LAPSE_720P = 1005,
James Dong2a7e0a12011-02-28 21:07:39 -080051 CAMCORDER_QUALITY_TIME_LAPSE_1080P = 1006,
James Dong669012d2011-09-19 16:27:31 -070052 CAMCORDER_QUALITY_TIME_LAPSE_QVGA = 1007,
53 CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1007,
James Dong1d7491b2010-01-19 17:45:38 -080054};
55
Hong Tengcabd5f82011-07-06 18:33:09 -070056/**
Hong Teng3a9cefe2011-11-10 14:54:26 -080057 * Set CIF as default maximum import and export resolution of video editor.
58 * The maximum import and export resolutions are platform specific,
59 * which should be defined in media_profiles.xml.
60 * Set default maximum prefetch YUV frames to 6, which means video editor can
61 * queue up to 6 YUV frames in the video encoder source.
62 * This value is used to limit the amount of memory used by video editor
63 * engine when the encoder consumes YUV frames at a lower speed
64 * than video editor engine produces.
Hong Tengcabd5f82011-07-06 18:33:09 -070065 */
66enum videoeditor_capability {
67 VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH = 352,
68 VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT = 288,
69 VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH = 352,
70 VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT = 288,
Hong Teng3a9cefe2011-11-10 14:54:26 -080071 VIDEOEDITOR_DEFAULT_MAX_PREFETCH_YUV_FRAMES = 6
Hong Tengcabd5f82011-07-06 18:33:09 -070072};
73
James Dong1d7491b2010-01-19 17:45:38 -080074enum video_decoder {
75 VIDEO_DECODER_WMV,
76};
77
78enum audio_decoder {
79 AUDIO_DECODER_WMA,
80};
81
82
83class MediaProfiles
84{
85public:
86
87 /**
88 * Returns the singleton instance for subsequence queries.
89 * or NULL if error.
90 */
91 static MediaProfiles* getInstance();
92
93 /**
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +080094 * Returns the value for the given param name for the given camera at
95 * the given quality level, or -1 if error.
James Dong1d7491b2010-01-19 17:45:38 -080096 *
97 * Supported param name are:
James Dongf5a83852010-02-23 17:21:44 -080098 * duration - the recording duration.
James Dong1d7491b2010-01-19 17:45:38 -080099 * file.format - output file format. see mediarecorder.h for details
James Dong13896b92010-02-03 16:50:18 -0800100 * vid.codec - video encoder. see mediarecorder.h for details.
101 * aud.codec - audio encoder. see mediarecorder.h for details.
James Dong1d7491b2010-01-19 17:45:38 -0800102 * vid.width - video frame width
103 * vid.height - video frame height
104 * vid.fps - video frame rate
105 * vid.bps - video bit rate
106 * aud.bps - audio bit rate
107 * aud.hz - audio sample rate
108 * aud.ch - number of audio channels
109 */
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800110 int getCamcorderProfileParamByName(const char *name, int cameraId,
111 camcorder_quality quality) const;
James Dong1d7491b2010-01-19 17:45:38 -0800112
113 /**
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700114 * Returns true if a profile for the given camera at the given quality exists,
115 * or false if not.
116 */
117 bool hasCamcorderProfile(int cameraId, camcorder_quality quality) const;
118
119 /**
James Dong1d7491b2010-01-19 17:45:38 -0800120 * Returns the output file formats supported.
121 */
122 Vector<output_format> getOutputFileFormats() const;
123
124 /**
125 * Returns the video encoders supported.
126 */
127 Vector<video_encoder> getVideoEncoders() const;
128
129 /**
130 * Returns the value for the given param name for the given video encoder
131 * returned from getVideoEncoderByIndex or -1 if error.
132 *
133 * Supported param name are:
134 * enc.vid.width.min - min video frame width
135 * enc.vid.width.max - max video frame width
136 * enc.vid.height.min - min video frame height
137 * enc.vid.height.max - max video frame height
138 * enc.vid.bps.min - min bit rate in bits per second
139 * enc.vid.bps.max - max bit rate in bits per second
140 * enc.vid.fps.min - min frame rate in frames per second
141 * enc.vid.fps.max - max frame rate in frames per second
142 */
143 int getVideoEncoderParamByName(const char *name, video_encoder codec) const;
144
145 /**
Hong Tengcabd5f82011-07-06 18:33:09 -0700146 * Returns the value for the given param name for the video editor cap
147 * param or -1 if error.
148 * Supported param name are:
149 * videoeditor.input.width.max - max input video frame width
150 * videoeditor.input.height.max - max input video frame height
151 * videoeditor.output.width.max - max output video frame width
152 * videoeditor.output.height.max - max output video frame height
Hong Teng3a9cefe2011-11-10 14:54:26 -0800153 * maxPrefetchYUVFrames - max prefetch YUV frames in video editor engine. This value is used
154 * to limit the memory consumption.
Hong Tengcabd5f82011-07-06 18:33:09 -0700155 */
156 int getVideoEditorCapParamByName(const char *name) const;
157
158 /**
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700159 * Returns the value for the given param name for the video editor export codec format
160 * param or -1 if error.
161 * Supported param name are:
162 * videoeditor.export.profile - export video profile
163 * videoeditor.export.level - export video level
164 * Supported param codec are:
165 * 1 for h263
166 * 2 for h264
167 * 3 for mpeg4
168 */
169 int getVideoEditorExportParamByName(const char *name, int codec) const;
170
171 /**
James Dong1d7491b2010-01-19 17:45:38 -0800172 * Returns the audio encoders supported.
173 */
174 Vector<audio_encoder> getAudioEncoders() const;
175
176 /**
177 * Returns the value for the given param name for the given audio encoder
178 * returned from getAudioEncoderByIndex or -1 if error.
179 *
180 * Supported param name are:
181 * enc.aud.ch.min - min number of channels
182 * enc.aud.ch.max - max number of channels
183 * enc.aud.bps.min - min bit rate in bits per second
184 * enc.aud.bps.max - max bit rate in bits per second
185 * enc.aud.hz.min - min sample rate in samples per second
186 * enc.aud.hz.max - max sample rate in samples per second
187 */
188 int getAudioEncoderParamByName(const char *name, audio_encoder codec) const;
189
190 /**
191 * Returns the video decoders supported.
192 */
193 Vector<video_decoder> getVideoDecoders() const;
194
195 /**
196 * Returns the audio decoders supported.
197 */
198 Vector<audio_decoder> getAudioDecoders() const;
199
James Dongf5a83852010-02-23 17:21:44 -0800200 /**
201 * Returns the number of image encoding quality levels supported.
202 */
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800203 Vector<int> getImageEncodingQualityLevels(int cameraId) const;
James Dongf5a83852010-02-23 17:21:44 -0800204
James Dong0f056292011-05-09 18:49:31 -0700205 /**
206 * Returns the start time offset (in ms) for the given camera Id.
207 * If the given camera Id does not exist, -1 will be returned.
208 */
209 int getStartTimeOffsetMs(int cameraId) const;
210
James Dong1d7491b2010-01-19 17:45:38 -0800211private:
James Dong2a7e0a12011-02-28 21:07:39 -0800212 enum {
213 // Camcorder profiles (high/low) and timelapse profiles (high/low)
214 kNumRequiredProfiles = 4,
215 };
216
James Dong1d7491b2010-01-19 17:45:38 -0800217 MediaProfiles& operator=(const MediaProfiles&); // Don't call me
218 MediaProfiles(const MediaProfiles&); // Don't call me
Hong Tengcabd5f82011-07-06 18:33:09 -0700219 MediaProfiles() { mVideoEditorCap = NULL; } // Dummy default constructor
James Dong1d7491b2010-01-19 17:45:38 -0800220 ~MediaProfiles(); // Don't delete me
221
222 struct VideoCodec {
223 VideoCodec(video_encoder codec, int bitRate, int frameWidth, int frameHeight, int frameRate)
224 : mCodec(codec),
225 mBitRate(bitRate),
226 mFrameWidth(frameWidth),
227 mFrameHeight(frameHeight),
228 mFrameRate(frameRate) {}
229
James Dong2a7e0a12011-02-28 21:07:39 -0800230 VideoCodec(const VideoCodec& copy) {
231 mCodec = copy.mCodec;
232 mBitRate = copy.mBitRate;
233 mFrameWidth = copy.mFrameWidth;
234 mFrameHeight = copy.mFrameHeight;
235 mFrameRate = copy.mFrameRate;
236 }
237
James Dong1d7491b2010-01-19 17:45:38 -0800238 ~VideoCodec() {}
239
240 video_encoder mCodec;
241 int mBitRate;
242 int mFrameWidth;
243 int mFrameHeight;
244 int mFrameRate;
245 };
246
247 struct AudioCodec {
248 AudioCodec(audio_encoder codec, int bitRate, int sampleRate, int channels)
249 : mCodec(codec),
250 mBitRate(bitRate),
251 mSampleRate(sampleRate),
252 mChannels(channels) {}
253
James Dong2a7e0a12011-02-28 21:07:39 -0800254 AudioCodec(const AudioCodec& copy) {
255 mCodec = copy.mCodec;
256 mBitRate = copy.mBitRate;
257 mSampleRate = copy.mSampleRate;
258 mChannels = copy.mChannels;
259 }
260
James Dong1d7491b2010-01-19 17:45:38 -0800261 ~AudioCodec() {}
262
263 audio_encoder mCodec;
264 int mBitRate;
265 int mSampleRate;
266 int mChannels;
267 };
268
269 struct CamcorderProfile {
270 CamcorderProfile()
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800271 : mCameraId(0),
272 mFileFormat(OUTPUT_FORMAT_THREE_GPP),
James Dong1d7491b2010-01-19 17:45:38 -0800273 mQuality(CAMCORDER_QUALITY_HIGH),
274 mDuration(0),
275 mVideoCodec(0),
276 mAudioCodec(0) {}
277
James Dong2a7e0a12011-02-28 21:07:39 -0800278 CamcorderProfile(const CamcorderProfile& copy) {
279 mCameraId = copy.mCameraId;
280 mFileFormat = copy.mFileFormat;
281 mQuality = copy.mQuality;
282 mDuration = copy.mDuration;
283 mVideoCodec = new VideoCodec(*copy.mVideoCodec);
284 mAudioCodec = new AudioCodec(*copy.mAudioCodec);
285 }
286
James Dong1d7491b2010-01-19 17:45:38 -0800287 ~CamcorderProfile() {
288 delete mVideoCodec;
289 delete mAudioCodec;
290 }
291
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800292 int mCameraId;
James Dong1d7491b2010-01-19 17:45:38 -0800293 output_format mFileFormat;
294 camcorder_quality mQuality;
295 int mDuration;
296 VideoCodec *mVideoCodec;
297 AudioCodec *mAudioCodec;
298 };
299
300 struct VideoEncoderCap {
301 // Ugly constructor
302 VideoEncoderCap(video_encoder codec,
303 int minBitRate, int maxBitRate,
304 int minFrameWidth, int maxFrameWidth,
305 int minFrameHeight, int maxFrameHeight,
306 int minFrameRate, int maxFrameRate)
307 : mCodec(codec),
308 mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
309 mMinFrameWidth(minFrameWidth), mMaxFrameWidth(maxFrameWidth),
310 mMinFrameHeight(minFrameHeight), mMaxFrameHeight(maxFrameHeight),
311 mMinFrameRate(minFrameRate), mMaxFrameRate(maxFrameRate) {}
312
313 ~VideoEncoderCap() {}
314
315 video_encoder mCodec;
316 int mMinBitRate, mMaxBitRate;
317 int mMinFrameWidth, mMaxFrameWidth;
318 int mMinFrameHeight, mMaxFrameHeight;
319 int mMinFrameRate, mMaxFrameRate;
320 };
321
322 struct AudioEncoderCap {
323 // Ugly constructor
324 AudioEncoderCap(audio_encoder codec,
325 int minBitRate, int maxBitRate,
326 int minSampleRate, int maxSampleRate,
327 int minChannels, int maxChannels)
328 : mCodec(codec),
329 mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
330 mMinSampleRate(minSampleRate), mMaxSampleRate(maxSampleRate),
331 mMinChannels(minChannels), mMaxChannels(maxChannels) {}
332
333 ~AudioEncoderCap() {}
334
335 audio_encoder mCodec;
336 int mMinBitRate, mMaxBitRate;
337 int mMinSampleRate, mMaxSampleRate;
338 int mMinChannels, mMaxChannels;
339 };
340
341 struct VideoDecoderCap {
342 VideoDecoderCap(video_decoder codec): mCodec(codec) {}
343 ~VideoDecoderCap() {}
344
345 video_decoder mCodec;
346 };
347
348 struct AudioDecoderCap {
349 AudioDecoderCap(audio_decoder codec): mCodec(codec) {}
350 ~AudioDecoderCap() {}
351
352 audio_decoder mCodec;
353 };
354
355 struct NameToTagMap {
356 const char* name;
357 int tag;
358 };
359
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800360 struct ImageEncodingQualityLevels {
361 int mCameraId;
362 Vector<int> mLevels;
363 };
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700364 struct ExportVideoProfile {
365 ExportVideoProfile(int codec, int profile, int level)
366 :mCodec(codec),mProfile(profile),mLevel(level) {}
367 ~ExportVideoProfile() {}
368 int mCodec;
369 int mProfile;
370 int mLevel;
371 };
Hong Tengcabd5f82011-07-06 18:33:09 -0700372 struct VideoEditorCap {
373 VideoEditorCap(int inFrameWidth, int inFrameHeight,
Hong Teng3a9cefe2011-11-10 14:54:26 -0800374 int outFrameWidth, int outFrameHeight, int frames)
Hong Tengcabd5f82011-07-06 18:33:09 -0700375 : mMaxInputFrameWidth(inFrameWidth),
376 mMaxInputFrameHeight(inFrameHeight),
377 mMaxOutputFrameWidth(outFrameWidth),
Hong Teng3a9cefe2011-11-10 14:54:26 -0800378 mMaxOutputFrameHeight(outFrameHeight),
379 mMaxPrefetchYUVFrames(frames) {}
Hong Tengcabd5f82011-07-06 18:33:09 -0700380
381 ~VideoEditorCap() {}
382
383 int mMaxInputFrameWidth;
384 int mMaxInputFrameHeight;
385 int mMaxOutputFrameWidth;
386 int mMaxOutputFrameHeight;
Hong Teng3a9cefe2011-11-10 14:54:26 -0800387 int mMaxPrefetchYUVFrames;
Hong Tengcabd5f82011-07-06 18:33:09 -0700388 };
389
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700390 int getCamcorderProfileIndex(int cameraId, camcorder_quality quality) const;
James Dong2a7e0a12011-02-28 21:07:39 -0800391 void initRequiredProfileRefs(const Vector<int>& cameraIds);
392 int getRequiredProfileRefIndex(int cameraId);
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700393
James Dong1d7491b2010-01-19 17:45:38 -0800394 // Debug
395 static void logVideoCodec(const VideoCodec& codec);
396 static void logAudioCodec(const AudioCodec& codec);
397 static void logVideoEncoderCap(const VideoEncoderCap& cap);
398 static void logAudioEncoderCap(const AudioEncoderCap& cap);
399 static void logVideoDecoderCap(const VideoDecoderCap& cap);
400 static void logAudioDecoderCap(const AudioDecoderCap& cap);
Hong Tengcabd5f82011-07-06 18:33:09 -0700401 static void logVideoEditorCap(const VideoEditorCap& cap);
James Dong1d7491b2010-01-19 17:45:38 -0800402
403 // If the xml configuration file does exist, use the settings
404 // from the xml
405 static MediaProfiles* createInstanceFromXmlFile(const char *xml);
406 static output_format createEncoderOutputFileFormat(const char **atts);
407 static VideoCodec* createVideoCodec(const char **atts, MediaProfiles *profiles);
408 static AudioCodec* createAudioCodec(const char **atts, MediaProfiles *profiles);
409 static AudioDecoderCap* createAudioDecoderCap(const char **atts);
410 static VideoDecoderCap* createVideoDecoderCap(const char **atts);
411 static VideoEncoderCap* createVideoEncoderCap(const char **atts);
412 static AudioEncoderCap* createAudioEncoderCap(const char **atts);
Hong Tengcabd5f82011-07-06 18:33:09 -0700413 static VideoEditorCap* createVideoEditorCap(
414 const char **atts, MediaProfiles *profiles);
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700415 static ExportVideoProfile* createExportVideoProfile(const char **atts);
James Dong2a7e0a12011-02-28 21:07:39 -0800416
417 static CamcorderProfile* createCamcorderProfile(
418 int cameraId, const char **atts, Vector<int>& cameraIds);
419
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800420 static int getCameraId(const char **atts);
421
James Dong0f056292011-05-09 18:49:31 -0700422 void addStartTimeOffset(int cameraId, const char **atts);
423
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800424 ImageEncodingQualityLevels* findImageEncodingQualityLevels(int cameraId) const;
425 void addImageEncodingQualityLevel(int cameraId, const char** atts);
James Dong1d7491b2010-01-19 17:45:38 -0800426
427 // Customized element tag handler for parsing the xml configuration file.
428 static void startElementHandler(void *userData, const char *name, const char **atts);
429
430 // If the xml configuration file does not exist, use hard-coded values
431 static MediaProfiles* createDefaultInstance();
Nipun Kwatrad5672bc2010-09-16 22:25:23 -0700432
433 static CamcorderProfile *createDefaultCamcorderQcifProfile(camcorder_quality quality);
434 static CamcorderProfile *createDefaultCamcorderCifProfile(camcorder_quality quality);
435 static void createDefaultCamcorderLowProfiles(
436 MediaProfiles::CamcorderProfile **lowProfile,
437 MediaProfiles::CamcorderProfile **lowSpecificProfile);
438 static void createDefaultCamcorderHighProfiles(
439 MediaProfiles::CamcorderProfile **highProfile,
440 MediaProfiles::CamcorderProfile **highSpecificProfile);
441
442 static CamcorderProfile *createDefaultCamcorderTimeLapseQcifProfile(camcorder_quality quality);
443 static CamcorderProfile *createDefaultCamcorderTimeLapse480pProfile(camcorder_quality quality);
444 static void createDefaultCamcorderTimeLapseLowProfiles(
445 MediaProfiles::CamcorderProfile **lowTimeLapseProfile,
446 MediaProfiles::CamcorderProfile **lowSpecificTimeLapseProfile);
447 static void createDefaultCamcorderTimeLapseHighProfiles(
448 MediaProfiles::CamcorderProfile **highTimeLapseProfile,
449 MediaProfiles::CamcorderProfile **highSpecificTimeLapseProfile);
450
James Dong1d7491b2010-01-19 17:45:38 -0800451 static void createDefaultCamcorderProfiles(MediaProfiles *profiles);
452 static void createDefaultVideoEncoders(MediaProfiles *profiles);
453 static void createDefaultAudioEncoders(MediaProfiles *profiles);
454 static void createDefaultVideoDecoders(MediaProfiles *profiles);
455 static void createDefaultAudioDecoders(MediaProfiles *profiles);
456 static void createDefaultEncoderOutputFileFormats(MediaProfiles *profiles);
James Dongf5a83852010-02-23 17:21:44 -0800457 static void createDefaultImageEncodingQualityLevels(MediaProfiles *profiles);
458 static void createDefaultImageDecodingMaxMemory(MediaProfiles *profiles);
Hong Tengcabd5f82011-07-06 18:33:09 -0700459 static void createDefaultVideoEditorCap(MediaProfiles *profiles);
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700460 static void createDefaultExportVideoProfiles(MediaProfiles *profiles);
461
James Dong1d7491b2010-01-19 17:45:38 -0800462 static VideoEncoderCap* createDefaultH263VideoEncoderCap();
463 static VideoEncoderCap* createDefaultM4vVideoEncoderCap();
464 static AudioEncoderCap* createDefaultAmrNBEncoderCap();
vivek mehta2192bc92012-12-04 11:46:08 -0800465#ifdef QCOM_HARDWARE
466 static AudioEncoderCap* createDefaultAacEncoderCap();
467 static AudioEncoderCap* createDefaultLpcmEncoderCap();
468#endif
James Dong1d7491b2010-01-19 17:45:38 -0800469
470 static int findTagForName(const NameToTagMap *map, size_t nMappings, const char *name);
471
James Dong2a7e0a12011-02-28 21:07:39 -0800472 /**
473 * Check on existing profiles with the following criteria:
474 * 1. Low quality profile must have the lowest video
475 * resolution product (width x height)
476 * 2. High quality profile must have the highest video
477 * resolution product (width x height)
478 *
479 * and add required low/high quality camcorder/timelapse
480 * profiles if they are not found. This allows to remove
481 * duplicate profile definitions in the media_profiles.xml
482 * file.
483 */
484 void checkAndAddRequiredProfilesIfNecessary();
485
486
James Dong1d7491b2010-01-19 17:45:38 -0800487 // Mappings from name (for instance, codec name) to enum value
488 static const NameToTagMap sVideoEncoderNameMap[];
489 static const NameToTagMap sAudioEncoderNameMap[];
490 static const NameToTagMap sFileFormatMap[];
491 static const NameToTagMap sVideoDecoderNameMap[];
492 static const NameToTagMap sAudioDecoderNameMap[];
493 static const NameToTagMap sCamcorderQualityNameMap[];
494
495 static bool sIsInitialized;
496 static MediaProfiles *sInstance;
497 static Mutex sLock;
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800498 int mCurrentCameraId;
James Dong1d7491b2010-01-19 17:45:38 -0800499
500 Vector<CamcorderProfile*> mCamcorderProfiles;
501 Vector<AudioEncoderCap*> mAudioEncoders;
502 Vector<VideoEncoderCap*> mVideoEncoders;
503 Vector<AudioDecoderCap*> mAudioDecoders;
504 Vector<VideoDecoderCap*> mVideoDecoders;
505 Vector<output_format> mEncoderOutputFileFormats;
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800506 Vector<ImageEncodingQualityLevels *> mImageEncodingQualityLevels;
James Dong0f056292011-05-09 18:49:31 -0700507 KeyedVector<int, int> mStartTimeOffsets;
James Dong2a7e0a12011-02-28 21:07:39 -0800508
509 typedef struct {
510 bool mHasRefProfile; // Refers to an existing profile
511 int mRefProfileIndex; // Reference profile index
512 int mResolutionProduct; // width x height
513 } RequiredProfileRefInfo; // Required low and high profiles
514
515 typedef struct {
516 RequiredProfileRefInfo mRefs[kNumRequiredProfiles];
517 int mCameraId;
518 } RequiredProfiles;
519
520 RequiredProfiles *mRequiredProfileRefs;
521 Vector<int> mCameraIds;
Hong Tengcabd5f82011-07-06 18:33:09 -0700522 VideoEditorCap* mVideoEditorCap;
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700523 Vector<ExportVideoProfile*> mVideoEditorExportProfiles;
James Dong1d7491b2010-01-19 17:45:38 -0800524};
525
526}; // namespace android
527
528#endif // ANDROID_MEDIAPROFILES_H