blob: ec3eb9bb3834053ae99ce3711dd889cac09eb88e [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,
Ethan Chen8d420ed2013-11-14 00:40:54 -080035#ifdef QCOM_HARDWARE
Alok Kediya601e9b52013-09-27 11:55:10 +053036 CAMCORDER_QUALITY_QVGA = 7,
37 CAMCORDER_QUALITY_FWVGA = 8,
38 CAMCORDER_QUALITY_WVGA = 9,
39 CAMCORDER_QUALITY_VGA = 10,
40 CAMCORDER_QUALITY_WQVGA = 11,
41 CAMCORDER_QUALITY_4kUHD = 12,
42 CAMCORDER_QUALITY_4kDCI = 13,
43 CAMCORDER_QUALITY_LIST_END = 13,
Ethan Chen8d420ed2013-11-14 00:40:54 -080044#else
45 CAMCORDER_QUALITY_QVGA = 11,
46 CAMCORDER_QUALITY_FWVGA = 7,
47 CAMCORDER_QUALITY_WVGA = 8,
48 CAMCORDER_QUALITY_VGA = 9,
49 CAMCORDER_QUALITY_WQVGA = 10,
50 CAMCORDER_QUALITY_LIST_END = 11,
51#endif
Nipun Kwatrac0a84782010-09-06 15:59:02 -070052
James Dong2a7e0a12011-02-28 21:07:39 -080053 CAMCORDER_QUALITY_TIME_LAPSE_LIST_START = 1000,
Nipun Kwatrac0a84782010-09-06 15:59:02 -070054 CAMCORDER_QUALITY_TIME_LAPSE_LOW = 1000,
55 CAMCORDER_QUALITY_TIME_LAPSE_HIGH = 1001,
56 CAMCORDER_QUALITY_TIME_LAPSE_QCIF = 1002,
Nipun Kwatra9783ed82010-09-10 15:45:57 -070057 CAMCORDER_QUALITY_TIME_LAPSE_CIF = 1003,
58 CAMCORDER_QUALITY_TIME_LAPSE_480P = 1004,
59 CAMCORDER_QUALITY_TIME_LAPSE_720P = 1005,
James Dong2a7e0a12011-02-28 21:07:39 -080060 CAMCORDER_QUALITY_TIME_LAPSE_1080P = 1006,
James Dong669012d2011-09-19 16:27:31 -070061 CAMCORDER_QUALITY_TIME_LAPSE_QVGA = 1007,
Ethan Chen8d420ed2013-11-14 00:40:54 -080062#ifdef QCOM_HARDWARE
Alok Kediya601e9b52013-09-27 11:55:10 +053063 CAMCORDER_QUALITY_TIME_LAPSE_FWVGA = 1008,
64 CAMCORDER_QUALITY_TIME_LAPSE_WVGA = 1009,
65 CAMCORDER_QUALITY_TIME_LAPSE_VGA = 1010,
66 CAMCORDER_QUALITY_TIME_LAPSE_WQVGA = 1011,
67 CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1011,
Ethan Chen8d420ed2013-11-14 00:40:54 -080068#else
69 CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1007,
70#endif
James Dong1d7491b2010-01-19 17:45:38 -080071};
72
Hong Tengcabd5f82011-07-06 18:33:09 -070073/**
Hong Teng3a9cefe2011-11-10 14:54:26 -080074 * Set CIF as default maximum import and export resolution of video editor.
75 * The maximum import and export resolutions are platform specific,
76 * which should be defined in media_profiles.xml.
77 * Set default maximum prefetch YUV frames to 6, which means video editor can
78 * queue up to 6 YUV frames in the video encoder source.
79 * This value is used to limit the amount of memory used by video editor
80 * engine when the encoder consumes YUV frames at a lower speed
81 * than video editor engine produces.
Hong Tengcabd5f82011-07-06 18:33:09 -070082 */
83enum videoeditor_capability {
84 VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH = 352,
85 VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT = 288,
86 VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH = 352,
87 VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT = 288,
Hong Teng3a9cefe2011-11-10 14:54:26 -080088 VIDEOEDITOR_DEFAULT_MAX_PREFETCH_YUV_FRAMES = 6
Hong Tengcabd5f82011-07-06 18:33:09 -070089};
90
James Dong1d7491b2010-01-19 17:45:38 -080091enum video_decoder {
92 VIDEO_DECODER_WMV,
93};
94
95enum audio_decoder {
96 AUDIO_DECODER_WMA,
97};
98
99
100class MediaProfiles
101{
102public:
103
104 /**
105 * Returns the singleton instance for subsequence queries.
106 * or NULL if error.
107 */
108 static MediaProfiles* getInstance();
109
110 /**
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800111 * Returns the value for the given param name for the given camera at
112 * the given quality level, or -1 if error.
James Dong1d7491b2010-01-19 17:45:38 -0800113 *
114 * Supported param name are:
James Dongf5a83852010-02-23 17:21:44 -0800115 * duration - the recording duration.
James Dong1d7491b2010-01-19 17:45:38 -0800116 * file.format - output file format. see mediarecorder.h for details
James Dong13896b92010-02-03 16:50:18 -0800117 * vid.codec - video encoder. see mediarecorder.h for details.
118 * aud.codec - audio encoder. see mediarecorder.h for details.
James Dong1d7491b2010-01-19 17:45:38 -0800119 * vid.width - video frame width
120 * vid.height - video frame height
121 * vid.fps - video frame rate
122 * vid.bps - video bit rate
123 * aud.bps - audio bit rate
124 * aud.hz - audio sample rate
125 * aud.ch - number of audio channels
126 */
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800127 int getCamcorderProfileParamByName(const char *name, int cameraId,
128 camcorder_quality quality) const;
James Dong1d7491b2010-01-19 17:45:38 -0800129
130 /**
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700131 * Returns true if a profile for the given camera at the given quality exists,
132 * or false if not.
133 */
134 bool hasCamcorderProfile(int cameraId, camcorder_quality quality) const;
135
136 /**
James Dong1d7491b2010-01-19 17:45:38 -0800137 * Returns the output file formats supported.
138 */
139 Vector<output_format> getOutputFileFormats() const;
140
141 /**
142 * Returns the video encoders supported.
143 */
144 Vector<video_encoder> getVideoEncoders() const;
145
146 /**
147 * Returns the value for the given param name for the given video encoder
148 * returned from getVideoEncoderByIndex or -1 if error.
149 *
150 * Supported param name are:
151 * enc.vid.width.min - min video frame width
152 * enc.vid.width.max - max video frame width
153 * enc.vid.height.min - min video frame height
154 * enc.vid.height.max - max video frame height
155 * enc.vid.bps.min - min bit rate in bits per second
156 * enc.vid.bps.max - max bit rate in bits per second
157 * enc.vid.fps.min - min frame rate in frames per second
158 * enc.vid.fps.max - max frame rate in frames per second
159 */
160 int getVideoEncoderParamByName(const char *name, video_encoder codec) const;
161
162 /**
Hong Tengcabd5f82011-07-06 18:33:09 -0700163 * Returns the value for the given param name for the video editor cap
164 * param or -1 if error.
165 * Supported param name are:
166 * videoeditor.input.width.max - max input video frame width
167 * videoeditor.input.height.max - max input video frame height
168 * videoeditor.output.width.max - max output video frame width
169 * videoeditor.output.height.max - max output video frame height
Hong Teng3a9cefe2011-11-10 14:54:26 -0800170 * maxPrefetchYUVFrames - max prefetch YUV frames in video editor engine. This value is used
171 * to limit the memory consumption.
Hong Tengcabd5f82011-07-06 18:33:09 -0700172 */
173 int getVideoEditorCapParamByName(const char *name) const;
174
175 /**
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700176 * Returns the value for the given param name for the video editor export codec format
177 * param or -1 if error.
178 * Supported param name are:
179 * videoeditor.export.profile - export video profile
180 * videoeditor.export.level - export video level
181 * Supported param codec are:
182 * 1 for h263
183 * 2 for h264
184 * 3 for mpeg4
185 */
186 int getVideoEditorExportParamByName(const char *name, int codec) const;
187
188 /**
James Dong1d7491b2010-01-19 17:45:38 -0800189 * Returns the audio encoders supported.
190 */
191 Vector<audio_encoder> getAudioEncoders() const;
192
193 /**
194 * Returns the value for the given param name for the given audio encoder
195 * returned from getAudioEncoderByIndex or -1 if error.
196 *
197 * Supported param name are:
198 * enc.aud.ch.min - min number of channels
199 * enc.aud.ch.max - max number of channels
200 * enc.aud.bps.min - min bit rate in bits per second
201 * enc.aud.bps.max - max bit rate in bits per second
202 * enc.aud.hz.min - min sample rate in samples per second
203 * enc.aud.hz.max - max sample rate in samples per second
204 */
205 int getAudioEncoderParamByName(const char *name, audio_encoder codec) const;
206
207 /**
208 * Returns the video decoders supported.
209 */
210 Vector<video_decoder> getVideoDecoders() const;
211
212 /**
213 * Returns the audio decoders supported.
214 */
215 Vector<audio_decoder> getAudioDecoders() const;
216
James Dongf5a83852010-02-23 17:21:44 -0800217 /**
218 * Returns the number of image encoding quality levels supported.
219 */
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800220 Vector<int> getImageEncodingQualityLevels(int cameraId) const;
James Dongf5a83852010-02-23 17:21:44 -0800221
James Dong0f056292011-05-09 18:49:31 -0700222 /**
223 * Returns the start time offset (in ms) for the given camera Id.
224 * If the given camera Id does not exist, -1 will be returned.
225 */
226 int getStartTimeOffsetMs(int cameraId) const;
227
James Dong1d7491b2010-01-19 17:45:38 -0800228private:
James Dong2a7e0a12011-02-28 21:07:39 -0800229 enum {
230 // Camcorder profiles (high/low) and timelapse profiles (high/low)
231 kNumRequiredProfiles = 4,
232 };
233
James Dong1d7491b2010-01-19 17:45:38 -0800234 MediaProfiles& operator=(const MediaProfiles&); // Don't call me
235 MediaProfiles(const MediaProfiles&); // Don't call me
Hong Tengcabd5f82011-07-06 18:33:09 -0700236 MediaProfiles() { mVideoEditorCap = NULL; } // Dummy default constructor
James Dong1d7491b2010-01-19 17:45:38 -0800237 ~MediaProfiles(); // Don't delete me
238
239 struct VideoCodec {
240 VideoCodec(video_encoder codec, int bitRate, int frameWidth, int frameHeight, int frameRate)
241 : mCodec(codec),
242 mBitRate(bitRate),
243 mFrameWidth(frameWidth),
244 mFrameHeight(frameHeight),
245 mFrameRate(frameRate) {}
246
James Dong2a7e0a12011-02-28 21:07:39 -0800247 VideoCodec(const VideoCodec& copy) {
248 mCodec = copy.mCodec;
249 mBitRate = copy.mBitRate;
250 mFrameWidth = copy.mFrameWidth;
251 mFrameHeight = copy.mFrameHeight;
252 mFrameRate = copy.mFrameRate;
253 }
254
James Dong1d7491b2010-01-19 17:45:38 -0800255 ~VideoCodec() {}
256
257 video_encoder mCodec;
258 int mBitRate;
259 int mFrameWidth;
260 int mFrameHeight;
261 int mFrameRate;
262 };
263
264 struct AudioCodec {
265 AudioCodec(audio_encoder codec, int bitRate, int sampleRate, int channels)
266 : mCodec(codec),
267 mBitRate(bitRate),
268 mSampleRate(sampleRate),
269 mChannels(channels) {}
270
James Dong2a7e0a12011-02-28 21:07:39 -0800271 AudioCodec(const AudioCodec& copy) {
272 mCodec = copy.mCodec;
273 mBitRate = copy.mBitRate;
274 mSampleRate = copy.mSampleRate;
275 mChannels = copy.mChannels;
276 }
277
James Dong1d7491b2010-01-19 17:45:38 -0800278 ~AudioCodec() {}
279
280 audio_encoder mCodec;
281 int mBitRate;
282 int mSampleRate;
283 int mChannels;
284 };
285
286 struct CamcorderProfile {
287 CamcorderProfile()
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800288 : mCameraId(0),
289 mFileFormat(OUTPUT_FORMAT_THREE_GPP),
James Dong1d7491b2010-01-19 17:45:38 -0800290 mQuality(CAMCORDER_QUALITY_HIGH),
291 mDuration(0),
292 mVideoCodec(0),
293 mAudioCodec(0) {}
294
James Dong2a7e0a12011-02-28 21:07:39 -0800295 CamcorderProfile(const CamcorderProfile& copy) {
296 mCameraId = copy.mCameraId;
297 mFileFormat = copy.mFileFormat;
298 mQuality = copy.mQuality;
299 mDuration = copy.mDuration;
300 mVideoCodec = new VideoCodec(*copy.mVideoCodec);
301 mAudioCodec = new AudioCodec(*copy.mAudioCodec);
302 }
303
James Dong1d7491b2010-01-19 17:45:38 -0800304 ~CamcorderProfile() {
305 delete mVideoCodec;
306 delete mAudioCodec;
307 }
308
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800309 int mCameraId;
James Dong1d7491b2010-01-19 17:45:38 -0800310 output_format mFileFormat;
311 camcorder_quality mQuality;
312 int mDuration;
313 VideoCodec *mVideoCodec;
314 AudioCodec *mAudioCodec;
315 };
316
317 struct VideoEncoderCap {
318 // Ugly constructor
319 VideoEncoderCap(video_encoder codec,
320 int minBitRate, int maxBitRate,
321 int minFrameWidth, int maxFrameWidth,
322 int minFrameHeight, int maxFrameHeight,
323 int minFrameRate, int maxFrameRate)
324 : mCodec(codec),
325 mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
326 mMinFrameWidth(minFrameWidth), mMaxFrameWidth(maxFrameWidth),
327 mMinFrameHeight(minFrameHeight), mMaxFrameHeight(maxFrameHeight),
328 mMinFrameRate(minFrameRate), mMaxFrameRate(maxFrameRate) {}
329
330 ~VideoEncoderCap() {}
331
332 video_encoder mCodec;
333 int mMinBitRate, mMaxBitRate;
334 int mMinFrameWidth, mMaxFrameWidth;
335 int mMinFrameHeight, mMaxFrameHeight;
336 int mMinFrameRate, mMaxFrameRate;
337 };
338
339 struct AudioEncoderCap {
340 // Ugly constructor
341 AudioEncoderCap(audio_encoder codec,
342 int minBitRate, int maxBitRate,
343 int minSampleRate, int maxSampleRate,
344 int minChannels, int maxChannels)
345 : mCodec(codec),
346 mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
347 mMinSampleRate(minSampleRate), mMaxSampleRate(maxSampleRate),
348 mMinChannels(minChannels), mMaxChannels(maxChannels) {}
349
350 ~AudioEncoderCap() {}
351
352 audio_encoder mCodec;
353 int mMinBitRate, mMaxBitRate;
354 int mMinSampleRate, mMaxSampleRate;
355 int mMinChannels, mMaxChannels;
356 };
357
358 struct VideoDecoderCap {
359 VideoDecoderCap(video_decoder codec): mCodec(codec) {}
360 ~VideoDecoderCap() {}
361
362 video_decoder mCodec;
363 };
364
365 struct AudioDecoderCap {
366 AudioDecoderCap(audio_decoder codec): mCodec(codec) {}
367 ~AudioDecoderCap() {}
368
369 audio_decoder mCodec;
370 };
371
372 struct NameToTagMap {
373 const char* name;
374 int tag;
375 };
376
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800377 struct ImageEncodingQualityLevels {
378 int mCameraId;
379 Vector<int> mLevels;
380 };
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700381 struct ExportVideoProfile {
382 ExportVideoProfile(int codec, int profile, int level)
383 :mCodec(codec),mProfile(profile),mLevel(level) {}
384 ~ExportVideoProfile() {}
385 int mCodec;
386 int mProfile;
387 int mLevel;
388 };
Hong Tengcabd5f82011-07-06 18:33:09 -0700389 struct VideoEditorCap {
390 VideoEditorCap(int inFrameWidth, int inFrameHeight,
Hong Teng3a9cefe2011-11-10 14:54:26 -0800391 int outFrameWidth, int outFrameHeight, int frames)
Hong Tengcabd5f82011-07-06 18:33:09 -0700392 : mMaxInputFrameWidth(inFrameWidth),
393 mMaxInputFrameHeight(inFrameHeight),
394 mMaxOutputFrameWidth(outFrameWidth),
Hong Teng3a9cefe2011-11-10 14:54:26 -0800395 mMaxOutputFrameHeight(outFrameHeight),
396 mMaxPrefetchYUVFrames(frames) {}
Hong Tengcabd5f82011-07-06 18:33:09 -0700397
398 ~VideoEditorCap() {}
399
400 int mMaxInputFrameWidth;
401 int mMaxInputFrameHeight;
402 int mMaxOutputFrameWidth;
403 int mMaxOutputFrameHeight;
Hong Teng3a9cefe2011-11-10 14:54:26 -0800404 int mMaxPrefetchYUVFrames;
Hong Tengcabd5f82011-07-06 18:33:09 -0700405 };
406
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700407 int getCamcorderProfileIndex(int cameraId, camcorder_quality quality) const;
James Dong2a7e0a12011-02-28 21:07:39 -0800408 void initRequiredProfileRefs(const Vector<int>& cameraIds);
409 int getRequiredProfileRefIndex(int cameraId);
Nipun Kwatra8bb56032010-09-09 16:25:08 -0700410
James Dong1d7491b2010-01-19 17:45:38 -0800411 // Debug
412 static void logVideoCodec(const VideoCodec& codec);
413 static void logAudioCodec(const AudioCodec& codec);
414 static void logVideoEncoderCap(const VideoEncoderCap& cap);
415 static void logAudioEncoderCap(const AudioEncoderCap& cap);
416 static void logVideoDecoderCap(const VideoDecoderCap& cap);
417 static void logAudioDecoderCap(const AudioDecoderCap& cap);
Hong Tengcabd5f82011-07-06 18:33:09 -0700418 static void logVideoEditorCap(const VideoEditorCap& cap);
James Dong1d7491b2010-01-19 17:45:38 -0800419
420 // If the xml configuration file does exist, use the settings
421 // from the xml
422 static MediaProfiles* createInstanceFromXmlFile(const char *xml);
423 static output_format createEncoderOutputFileFormat(const char **atts);
424 static VideoCodec* createVideoCodec(const char **atts, MediaProfiles *profiles);
425 static AudioCodec* createAudioCodec(const char **atts, MediaProfiles *profiles);
426 static AudioDecoderCap* createAudioDecoderCap(const char **atts);
427 static VideoDecoderCap* createVideoDecoderCap(const char **atts);
428 static VideoEncoderCap* createVideoEncoderCap(const char **atts);
429 static AudioEncoderCap* createAudioEncoderCap(const char **atts);
Hong Tengcabd5f82011-07-06 18:33:09 -0700430 static VideoEditorCap* createVideoEditorCap(
431 const char **atts, MediaProfiles *profiles);
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700432 static ExportVideoProfile* createExportVideoProfile(const char **atts);
James Dong2a7e0a12011-02-28 21:07:39 -0800433
434 static CamcorderProfile* createCamcorderProfile(
435 int cameraId, const char **atts, Vector<int>& cameraIds);
436
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800437 static int getCameraId(const char **atts);
438
James Dong0f056292011-05-09 18:49:31 -0700439 void addStartTimeOffset(int cameraId, const char **atts);
440
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800441 ImageEncodingQualityLevels* findImageEncodingQualityLevels(int cameraId) const;
442 void addImageEncodingQualityLevel(int cameraId, const char** atts);
James Dong1d7491b2010-01-19 17:45:38 -0800443
444 // Customized element tag handler for parsing the xml configuration file.
445 static void startElementHandler(void *userData, const char *name, const char **atts);
446
447 // If the xml configuration file does not exist, use hard-coded values
448 static MediaProfiles* createDefaultInstance();
Nipun Kwatrad5672bc2010-09-16 22:25:23 -0700449
450 static CamcorderProfile *createDefaultCamcorderQcifProfile(camcorder_quality quality);
451 static CamcorderProfile *createDefaultCamcorderCifProfile(camcorder_quality quality);
452 static void createDefaultCamcorderLowProfiles(
453 MediaProfiles::CamcorderProfile **lowProfile,
454 MediaProfiles::CamcorderProfile **lowSpecificProfile);
455 static void createDefaultCamcorderHighProfiles(
456 MediaProfiles::CamcorderProfile **highProfile,
457 MediaProfiles::CamcorderProfile **highSpecificProfile);
458
459 static CamcorderProfile *createDefaultCamcorderTimeLapseQcifProfile(camcorder_quality quality);
460 static CamcorderProfile *createDefaultCamcorderTimeLapse480pProfile(camcorder_quality quality);
461 static void createDefaultCamcorderTimeLapseLowProfiles(
462 MediaProfiles::CamcorderProfile **lowTimeLapseProfile,
463 MediaProfiles::CamcorderProfile **lowSpecificTimeLapseProfile);
464 static void createDefaultCamcorderTimeLapseHighProfiles(
465 MediaProfiles::CamcorderProfile **highTimeLapseProfile,
466 MediaProfiles::CamcorderProfile **highSpecificTimeLapseProfile);
467
James Dong1d7491b2010-01-19 17:45:38 -0800468 static void createDefaultCamcorderProfiles(MediaProfiles *profiles);
469 static void createDefaultVideoEncoders(MediaProfiles *profiles);
470 static void createDefaultAudioEncoders(MediaProfiles *profiles);
471 static void createDefaultVideoDecoders(MediaProfiles *profiles);
472 static void createDefaultAudioDecoders(MediaProfiles *profiles);
473 static void createDefaultEncoderOutputFileFormats(MediaProfiles *profiles);
James Dongf5a83852010-02-23 17:21:44 -0800474 static void createDefaultImageEncodingQualityLevels(MediaProfiles *profiles);
475 static void createDefaultImageDecodingMaxMemory(MediaProfiles *profiles);
Hong Tengcabd5f82011-07-06 18:33:09 -0700476 static void createDefaultVideoEditorCap(MediaProfiles *profiles);
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700477 static void createDefaultExportVideoProfiles(MediaProfiles *profiles);
478
James Dong1d7491b2010-01-19 17:45:38 -0800479 static VideoEncoderCap* createDefaultH263VideoEncoderCap();
480 static VideoEncoderCap* createDefaultM4vVideoEncoderCap();
481 static AudioEncoderCap* createDefaultAmrNBEncoderCap();
Ethan Chen8d420ed2013-11-14 00:40:54 -0800482#ifdef QCOM_HARDWARE
Alok Kediya601e9b52013-09-27 11:55:10 +0530483 static AudioEncoderCap* createDefaultAacEncoderCap();
484 static AudioEncoderCap* createDefaultLpcmEncoderCap();
Ethan Chen8d420ed2013-11-14 00:40:54 -0800485#endif
James Dong1d7491b2010-01-19 17:45:38 -0800486
487 static int findTagForName(const NameToTagMap *map, size_t nMappings, const char *name);
488
James Dong2a7e0a12011-02-28 21:07:39 -0800489 /**
490 * Check on existing profiles with the following criteria:
491 * 1. Low quality profile must have the lowest video
492 * resolution product (width x height)
493 * 2. High quality profile must have the highest video
494 * resolution product (width x height)
495 *
496 * and add required low/high quality camcorder/timelapse
497 * profiles if they are not found. This allows to remove
498 * duplicate profile definitions in the media_profiles.xml
499 * file.
500 */
501 void checkAndAddRequiredProfilesIfNecessary();
502
503
James Dong1d7491b2010-01-19 17:45:38 -0800504 // Mappings from name (for instance, codec name) to enum value
505 static const NameToTagMap sVideoEncoderNameMap[];
506 static const NameToTagMap sAudioEncoderNameMap[];
507 static const NameToTagMap sFileFormatMap[];
508 static const NameToTagMap sVideoDecoderNameMap[];
509 static const NameToTagMap sAudioDecoderNameMap[];
510 static const NameToTagMap sCamcorderQualityNameMap[];
511
512 static bool sIsInitialized;
513 static MediaProfiles *sInstance;
514 static Mutex sLock;
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800515 int mCurrentCameraId;
James Dong1d7491b2010-01-19 17:45:38 -0800516
517 Vector<CamcorderProfile*> mCamcorderProfiles;
518 Vector<AudioEncoderCap*> mAudioEncoders;
519 Vector<VideoEncoderCap*> mVideoEncoders;
520 Vector<AudioDecoderCap*> mAudioDecoders;
521 Vector<VideoDecoderCap*> mVideoDecoders;
522 Vector<output_format> mEncoderOutputFileFormats;
Chih-Chung Chang3eaa4e92010-06-22 20:50:55 +0800523 Vector<ImageEncodingQualityLevels *> mImageEncodingQualityLevels;
James Dong0f056292011-05-09 18:49:31 -0700524 KeyedVector<int, int> mStartTimeOffsets;
James Dong2a7e0a12011-02-28 21:07:39 -0800525
526 typedef struct {
527 bool mHasRefProfile; // Refers to an existing profile
528 int mRefProfileIndex; // Reference profile index
529 int mResolutionProduct; // width x height
530 } RequiredProfileRefInfo; // Required low and high profiles
531
532 typedef struct {
533 RequiredProfileRefInfo mRefs[kNumRequiredProfiles];
534 int mCameraId;
535 } RequiredProfiles;
536
537 RequiredProfiles *mRequiredProfileRefs;
538 Vector<int> mCameraIds;
Hong Tengcabd5f82011-07-06 18:33:09 -0700539 VideoEditorCap* mVideoEditorCap;
Rajneesh Chowdury8f74b712011-08-12 16:43:37 -0700540 Vector<ExportVideoProfile*> mVideoEditorExportProfiles;
James Dong1d7491b2010-01-19 17:45:38 -0800541};
542
543}; // namespace android
544
545#endif // ANDROID_MEDIAPROFILES_H