blob: 253c5575a561c07dba86df784138415084138235 [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,
57 CAMCORDER_QUALITY_HIGH_SPEED_LIST_END = 2004,
James Dong1d7491b2010-01-19 17:45:38 -080058};
59
Hong Tengcabd5f82011-07-06 18:33:09 -070060/**
Hong Teng3a9cefe2011-11-10 14:54:26 -080061 * Set CIF as default maximum import and export resolution of video editor.
62 * The maximum import and export resolutions are platform specific,
63 * which should be defined in media_profiles.xml.
64 * Set default maximum prefetch YUV frames to 6, which means video editor can
65 * queue up to 6 YUV frames in the video encoder source.
66 * This value is used to limit the amount of memory used by video editor
67 * engine when the encoder consumes YUV frames at a lower speed
68 * than video editor engine produces.
Hong Tengcabd5f82011-07-06 18:33:09 -070069 */
70enum videoeditor_capability {
71 VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH = 352,
72 VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT = 288,
73 VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH = 352,
74 VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT = 288,
Hong Teng3a9cefe2011-11-10 14:54:26 -080075 VIDEOEDITOR_DEFAULT_MAX_PREFETCH_YUV_FRAMES = 6
Hong Tengcabd5f82011-07-06 18:33:09 -070076};
77
James Dong1d7491b2010-01-19 17:45:38 -080078enum video_decoder {
79 VIDEO_DECODER_WMV,
80};
81
82enum audio_decoder {
83 AUDIO_DECODER_WMA,
84};
85
86
87class MediaProfiles
88{
89public:
90
91 /**
92 * Returns the singleton instance for subsequence queries.
93 * or NULL if error.
94 */
95 static MediaProfiles* getInstance();
96
97 /**
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +080098 * Returns the value for the given param name for the given camera at
99 * the given quality level, or -1 if error.
James Dong1d7491b2010-01-19 17:45:38 -0800100 *
101 * Supported param name are:
James Dongf5a83852010-02-23 17:21:44 -0800102 * duration - the recording duration.
James Dong1d7491b2010-01-19 17:45:38 -0800103 * file.format - output file format. see mediarecorder.h for details
James Dong13896b92010-02-03 16:50:18 -0800104 * vid.codec - video encoder. see mediarecorder.h for details.
105 * aud.codec - audio encoder. see mediarecorder.h for details.
James Dong1d7491b2010-01-19 17:45:38 -0800106 * vid.width - video frame width
107 * vid.height - video frame height
108 * vid.fps - video frame rate
109 * vid.bps - video bit rate
110 * aud.bps - audio bit rate
111 * aud.hz - audio sample rate
112 * aud.ch - number of audio channels
113 */
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800114 int getCamcorderProfileParamByName(const char *name, int cameraId,
115 camcorder_quality quality) const;
James Dong1d7491b2010-01-19 17:45:38 -0800116
117 /**
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700118 * Returns true if a profile for the given camera at the given quality exists,
119 * or false if not.
120 */
121 bool hasCamcorderProfile(int cameraId, camcorder_quality quality) const;
122
123 /**
James Dong1d7491b2010-01-19 17:45:38 -0800124 * Returns the output file formats supported.
125 */
126 Vector<output_format> getOutputFileFormats() const;
127
128 /**
129 * Returns the video encoders supported.
130 */
131 Vector<video_encoder> getVideoEncoders() const;
132
133 /**
134 * Returns the value for the given param name for the given video encoder
135 * returned from getVideoEncoderByIndex or -1 if error.
136 *
137 * Supported param name are:
138 * enc.vid.width.min - min video frame width
139 * enc.vid.width.max - max video frame width
140 * enc.vid.height.min - min video frame height
141 * enc.vid.height.max - max video frame height
142 * enc.vid.bps.min - min bit rate in bits per second
143 * enc.vid.bps.max - max bit rate in bits per second
144 * enc.vid.fps.min - min frame rate in frames per second
145 * enc.vid.fps.max - max frame rate in frames per second
146 */
147 int getVideoEncoderParamByName(const char *name, video_encoder codec) const;
148
149 /**
Hong Tengcabd5f82011-07-06 18:33:09 -0700150 * Returns the value for the given param name for the video editor cap
151 * param or -1 if error.
152 * Supported param name are:
153 * videoeditor.input.width.max - max input video frame width
154 * videoeditor.input.height.max - max input video frame height
155 * videoeditor.output.width.max - max output video frame width
156 * videoeditor.output.height.max - max output video frame height
Hong Teng3a9cefe2011-11-10 14:54:26 -0800157 * maxPrefetchYUVFrames - max prefetch YUV frames in video editor engine. This value is used
158 * to limit the memory consumption.
Hong Tengcabd5f82011-07-06 18:33:09 -0700159 */
160 int getVideoEditorCapParamByName(const char *name) const;
161
162 /**
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700163 * Returns the value for the given param name for the video editor export codec format
164 * param or -1 if error.
165 * Supported param name are:
166 * videoeditor.export.profile - export video profile
167 * videoeditor.export.level - export video level
168 * Supported param codec are:
169 * 1 for h263
170 * 2 for h264
171 * 3 for mpeg4
172 */
173 int getVideoEditorExportParamByName(const char *name, int codec) const;
174
175 /**
James Dong1d7491b2010-01-19 17:45:38 -0800176 * Returns the audio encoders supported.
177 */
178 Vector<audio_encoder> getAudioEncoders() const;
179
180 /**
181 * Returns the value for the given param name for the given audio encoder
182 * returned from getAudioEncoderByIndex or -1 if error.
183 *
184 * Supported param name are:
185 * enc.aud.ch.min - min number of channels
186 * enc.aud.ch.max - max number of channels
187 * enc.aud.bps.min - min bit rate in bits per second
188 * enc.aud.bps.max - max bit rate in bits per second
189 * enc.aud.hz.min - min sample rate in samples per second
190 * enc.aud.hz.max - max sample rate in samples per second
191 */
192 int getAudioEncoderParamByName(const char *name, audio_encoder codec) const;
193
194 /**
195 * Returns the video decoders supported.
196 */
197 Vector<video_decoder> getVideoDecoders() const;
198
199 /**
200 * Returns the audio decoders supported.
201 */
202 Vector<audio_decoder> getAudioDecoders() const;
203
James Dongf5a83852010-02-23 17:21:44 -0800204 /**
205 * Returns the number of image encoding quality levels supported.
206 */
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800207 Vector<int> getImageEncodingQualityLevels(int cameraId) const;
James Dongf5a83852010-02-23 17:21:44 -0800208
James Dong0f056292011-05-09 18:49:31 -0700209 /**
210 * Returns the start time offset (in ms) for the given camera Id.
211 * If the given camera Id does not exist, -1 will be returned.
212 */
213 int getStartTimeOffsetMs(int cameraId) const;
214
James Dong1d7491b2010-01-19 17:45:38 -0800215private:
James Dong2a7e0a12011-02-28 21:07:39 -0800216 enum {
217 // Camcorder profiles (high/low) and timelapse profiles (high/low)
218 kNumRequiredProfiles = 4,
219 };
220
James Dong1d7491b2010-01-19 17:45:38 -0800221 MediaProfiles& operator=(const MediaProfiles&); // Don't call me
222 MediaProfiles(const MediaProfiles&); // Don't call me
Hong Tengcabd5f82011-07-06 18:33:09 -0700223 MediaProfiles() { mVideoEditorCap = NULL; } // Dummy default constructor
James Dong1d7491b2010-01-19 17:45:38 -0800224 ~MediaProfiles(); // Don't delete me
225
226 struct VideoCodec {
227 VideoCodec(video_encoder codec, int bitRate, int frameWidth, int frameHeight, int frameRate)
228 : mCodec(codec),
229 mBitRate(bitRate),
230 mFrameWidth(frameWidth),
231 mFrameHeight(frameHeight),
232 mFrameRate(frameRate) {}
233
James Dong2a7e0a12011-02-28 21:07:39 -0800234 VideoCodec(const VideoCodec& copy) {
235 mCodec = copy.mCodec;
236 mBitRate = copy.mBitRate;
237 mFrameWidth = copy.mFrameWidth;
238 mFrameHeight = copy.mFrameHeight;
239 mFrameRate = copy.mFrameRate;
240 }
241
James Dong1d7491b2010-01-19 17:45:38 -0800242 ~VideoCodec() {}
243
244 video_encoder mCodec;
245 int mBitRate;
246 int mFrameWidth;
247 int mFrameHeight;
248 int mFrameRate;
249 };
250
251 struct AudioCodec {
252 AudioCodec(audio_encoder codec, int bitRate, int sampleRate, int channels)
253 : mCodec(codec),
254 mBitRate(bitRate),
255 mSampleRate(sampleRate),
256 mChannels(channels) {}
257
James Dong2a7e0a12011-02-28 21:07:39 -0800258 AudioCodec(const AudioCodec& copy) {
259 mCodec = copy.mCodec;
260 mBitRate = copy.mBitRate;
261 mSampleRate = copy.mSampleRate;
262 mChannels = copy.mChannels;
263 }
264
James Dong1d7491b2010-01-19 17:45:38 -0800265 ~AudioCodec() {}
266
267 audio_encoder mCodec;
268 int mBitRate;
269 int mSampleRate;
270 int mChannels;
271 };
272
273 struct CamcorderProfile {
274 CamcorderProfile()
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800275 : mCameraId(0),
276 mFileFormat(OUTPUT_FORMAT_THREE_GPP),
James Dong1d7491b2010-01-19 17:45:38 -0800277 mQuality(CAMCORDER_QUALITY_HIGH),
278 mDuration(0),
279 mVideoCodec(0),
280 mAudioCodec(0) {}
281
James Dong2a7e0a12011-02-28 21:07:39 -0800282 CamcorderProfile(const CamcorderProfile& copy) {
283 mCameraId = copy.mCameraId;
284 mFileFormat = copy.mFileFormat;
285 mQuality = copy.mQuality;
286 mDuration = copy.mDuration;
287 mVideoCodec = new VideoCodec(*copy.mVideoCodec);
288 mAudioCodec = new AudioCodec(*copy.mAudioCodec);
289 }
290
James Dong1d7491b2010-01-19 17:45:38 -0800291 ~CamcorderProfile() {
292 delete mVideoCodec;
293 delete mAudioCodec;
294 }
295
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800296 int mCameraId;
James Dong1d7491b2010-01-19 17:45:38 -0800297 output_format mFileFormat;
298 camcorder_quality mQuality;
299 int mDuration;
300 VideoCodec *mVideoCodec;
301 AudioCodec *mAudioCodec;
302 };
303
304 struct VideoEncoderCap {
305 // Ugly constructor
306 VideoEncoderCap(video_encoder codec,
307 int minBitRate, int maxBitRate,
308 int minFrameWidth, int maxFrameWidth,
309 int minFrameHeight, int maxFrameHeight,
310 int minFrameRate, int maxFrameRate)
311 : mCodec(codec),
312 mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
313 mMinFrameWidth(minFrameWidth), mMaxFrameWidth(maxFrameWidth),
314 mMinFrameHeight(minFrameHeight), mMaxFrameHeight(maxFrameHeight),
315 mMinFrameRate(minFrameRate), mMaxFrameRate(maxFrameRate) {}
316
317 ~VideoEncoderCap() {}
318
319 video_encoder mCodec;
320 int mMinBitRate, mMaxBitRate;
321 int mMinFrameWidth, mMaxFrameWidth;
322 int mMinFrameHeight, mMaxFrameHeight;
323 int mMinFrameRate, mMaxFrameRate;
324 };
325
326 struct AudioEncoderCap {
327 // Ugly constructor
328 AudioEncoderCap(audio_encoder codec,
329 int minBitRate, int maxBitRate,
330 int minSampleRate, int maxSampleRate,
331 int minChannels, int maxChannels)
332 : mCodec(codec),
333 mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
334 mMinSampleRate(minSampleRate), mMaxSampleRate(maxSampleRate),
335 mMinChannels(minChannels), mMaxChannels(maxChannels) {}
336
337 ~AudioEncoderCap() {}
338
339 audio_encoder mCodec;
340 int mMinBitRate, mMaxBitRate;
341 int mMinSampleRate, mMaxSampleRate;
342 int mMinChannels, mMaxChannels;
343 };
344
345 struct VideoDecoderCap {
346 VideoDecoderCap(video_decoder codec): mCodec(codec) {}
347 ~VideoDecoderCap() {}
348
349 video_decoder mCodec;
350 };
351
352 struct AudioDecoderCap {
353 AudioDecoderCap(audio_decoder codec): mCodec(codec) {}
354 ~AudioDecoderCap() {}
355
356 audio_decoder mCodec;
357 };
358
359 struct NameToTagMap {
360 const char* name;
361 int tag;
362 };
363
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800364 struct ImageEncodingQualityLevels {
365 int mCameraId;
366 Vector<int> mLevels;
367 };
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700368 struct ExportVideoProfile {
369 ExportVideoProfile(int codec, int profile, int level)
370 :mCodec(codec),mProfile(profile),mLevel(level) {}
371 ~ExportVideoProfile() {}
372 int mCodec;
373 int mProfile;
374 int mLevel;
375 };
Hong Tengcabd5f82011-07-06 18:33:09 -0700376 struct VideoEditorCap {
377 VideoEditorCap(int inFrameWidth, int inFrameHeight,
Hong Teng3a9cefe2011-11-10 14:54:26 -0800378 int outFrameWidth, int outFrameHeight, int frames)
Hong Tengcabd5f82011-07-06 18:33:09 -0700379 : mMaxInputFrameWidth(inFrameWidth),
380 mMaxInputFrameHeight(inFrameHeight),
381 mMaxOutputFrameWidth(outFrameWidth),
Hong Teng3a9cefe2011-11-10 14:54:26 -0800382 mMaxOutputFrameHeight(outFrameHeight),
383 mMaxPrefetchYUVFrames(frames) {}
Hong Tengcabd5f82011-07-06 18:33:09 -0700384
385 ~VideoEditorCap() {}
386
387 int mMaxInputFrameWidth;
388 int mMaxInputFrameHeight;
389 int mMaxOutputFrameWidth;
390 int mMaxOutputFrameHeight;
Hong Teng3a9cefe2011-11-10 14:54:26 -0800391 int mMaxPrefetchYUVFrames;
Hong Tengcabd5f82011-07-06 18:33:09 -0700392 };
393
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700394 int getCamcorderProfileIndex(int cameraId, camcorder_quality quality) const;
James Dong2a7e0a12011-02-28 21:07:39 -0800395 void initRequiredProfileRefs(const Vector<int>& cameraIds);
396 int getRequiredProfileRefIndex(int cameraId);
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700397
James Dong1d7491b2010-01-19 17:45:38 -0800398 // Debug
399 static void logVideoCodec(const VideoCodec& codec);
400 static void logAudioCodec(const AudioCodec& codec);
401 static void logVideoEncoderCap(const VideoEncoderCap& cap);
402 static void logAudioEncoderCap(const AudioEncoderCap& cap);
403 static void logVideoDecoderCap(const VideoDecoderCap& cap);
404 static void logAudioDecoderCap(const AudioDecoderCap& cap);
Hong Tengcabd5f82011-07-06 18:33:09 -0700405 static void logVideoEditorCap(const VideoEditorCap& cap);
James Dong1d7491b2010-01-19 17:45:38 -0800406
407 // If the xml configuration file does exist, use the settings
408 // from the xml
409 static MediaProfiles* createInstanceFromXmlFile(const char *xml);
410 static output_format createEncoderOutputFileFormat(const char **atts);
411 static VideoCodec* createVideoCodec(const char **atts, MediaProfiles *profiles);
412 static AudioCodec* createAudioCodec(const char **atts, MediaProfiles *profiles);
413 static AudioDecoderCap* createAudioDecoderCap(const char **atts);
414 static VideoDecoderCap* createVideoDecoderCap(const char **atts);
415 static VideoEncoderCap* createVideoEncoderCap(const char **atts);
416 static AudioEncoderCap* createAudioEncoderCap(const char **atts);
Hong Tengcabd5f82011-07-06 18:33:09 -0700417 static VideoEditorCap* createVideoEditorCap(
418 const char **atts, MediaProfiles *profiles);
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700419 static ExportVideoProfile* createExportVideoProfile(const char **atts);
James Dong2a7e0a12011-02-28 21:07:39 -0800420
421 static CamcorderProfile* createCamcorderProfile(
422 int cameraId, const char **atts, Vector<int>& cameraIds);
423
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800424 static int getCameraId(const char **atts);
425
James Dong0f056292011-05-09 18:49:31 -0700426 void addStartTimeOffset(int cameraId, const char **atts);
427
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800428 ImageEncodingQualityLevels* findImageEncodingQualityLevels(int cameraId) const;
429 void addImageEncodingQualityLevel(int cameraId, const char** atts);
James Dong1d7491b2010-01-19 17:45:38 -0800430
431 // Customized element tag handler for parsing the xml configuration file.
432 static void startElementHandler(void *userData, const char *name, const char **atts);
433
434 // If the xml configuration file does not exist, use hard-coded values
435 static MediaProfiles* createDefaultInstance();
Nipun Kwatrad5672bc2010-09-16 22:25:23 -0700436
437 static CamcorderProfile *createDefaultCamcorderQcifProfile(camcorder_quality quality);
438 static CamcorderProfile *createDefaultCamcorderCifProfile(camcorder_quality quality);
439 static void createDefaultCamcorderLowProfiles(
440 MediaProfiles::CamcorderProfile **lowProfile,
441 MediaProfiles::CamcorderProfile **lowSpecificProfile);
442 static void createDefaultCamcorderHighProfiles(
443 MediaProfiles::CamcorderProfile **highProfile,
444 MediaProfiles::CamcorderProfile **highSpecificProfile);
445
446 static CamcorderProfile *createDefaultCamcorderTimeLapseQcifProfile(camcorder_quality quality);
447 static CamcorderProfile *createDefaultCamcorderTimeLapse480pProfile(camcorder_quality quality);
448 static void createDefaultCamcorderTimeLapseLowProfiles(
449 MediaProfiles::CamcorderProfile **lowTimeLapseProfile,
450 MediaProfiles::CamcorderProfile **lowSpecificTimeLapseProfile);
451 static void createDefaultCamcorderTimeLapseHighProfiles(
452 MediaProfiles::CamcorderProfile **highTimeLapseProfile,
453 MediaProfiles::CamcorderProfile **highSpecificTimeLapseProfile);
454
James Dong1d7491b2010-01-19 17:45:38 -0800455 static void createDefaultCamcorderProfiles(MediaProfiles *profiles);
456 static void createDefaultVideoEncoders(MediaProfiles *profiles);
457 static void createDefaultAudioEncoders(MediaProfiles *profiles);
458 static void createDefaultVideoDecoders(MediaProfiles *profiles);
459 static void createDefaultAudioDecoders(MediaProfiles *profiles);
460 static void createDefaultEncoderOutputFileFormats(MediaProfiles *profiles);
James Dongf5a83852010-02-23 17:21:44 -0800461 static void createDefaultImageEncodingQualityLevels(MediaProfiles *profiles);
462 static void createDefaultImageDecodingMaxMemory(MediaProfiles *profiles);
Hong Tengcabd5f82011-07-06 18:33:09 -0700463 static void createDefaultVideoEditorCap(MediaProfiles *profiles);
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700464 static void createDefaultExportVideoProfiles(MediaProfiles *profiles);
465
James Dong1d7491b2010-01-19 17:45:38 -0800466 static VideoEncoderCap* createDefaultH263VideoEncoderCap();
467 static VideoEncoderCap* createDefaultM4vVideoEncoderCap();
468 static AudioEncoderCap* createDefaultAmrNBEncoderCap();
469
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