MediaProfiles.h revision cabd5f867ec69c0dfe8333cba46323cb58917402
11d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*
21d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong **
31d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ** Copyright 2010, The Android Open Source Project.
41d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong **
51d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ** Licensed under the Apache License, Version 2.0 (the "License");
61d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ** you may not use this file except in compliance with the License.
71d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ** You may obtain a copy of the License at
81d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong **
91d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong **     http://www.apache.org/licenses/LICENSE-2.0
101d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong **
111d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ** Unless required by applicable law or agreed to in writing, software
121d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ** distributed under the License is distributed on an "AS IS" BASIS,
131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ** See the License for the specific language governing permissions and
151d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ** limitations under the License.
161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong */
171d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
181d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#ifndef ANDROID_MEDIAPROFILES_H
191d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#define ANDROID_MEDIAPROFILES_H
201d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#include <utils/threads.h>
221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#include <media/mediarecorder.h>
231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongnamespace android {
251d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongenum camcorder_quality {
272a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    CAMCORDER_QUALITY_LIST_START = 0,
280b42f253d15a190e230df43a4b45a3c483e5869aJames Dong    CAMCORDER_QUALITY_LOW  = 0,
29c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra    CAMCORDER_QUALITY_HIGH = 1,
30c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra    CAMCORDER_QUALITY_QCIF = 2,
319783ed8f85af3d7c72030098acfed7e1d6638349Nipun Kwatra    CAMCORDER_QUALITY_CIF = 3,
329783ed8f85af3d7c72030098acfed7e1d6638349Nipun Kwatra    CAMCORDER_QUALITY_480P = 4,
339783ed8f85af3d7c72030098acfed7e1d6638349Nipun Kwatra    CAMCORDER_QUALITY_720P = 5,
349783ed8f85af3d7c72030098acfed7e1d6638349Nipun Kwatra    CAMCORDER_QUALITY_1080P = 6,
352a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    CAMCORDER_QUALITY_LIST_END = 6,
36c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra
372a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    CAMCORDER_QUALITY_TIME_LAPSE_LIST_START = 1000,
38c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra    CAMCORDER_QUALITY_TIME_LAPSE_LOW  = 1000,
39c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra    CAMCORDER_QUALITY_TIME_LAPSE_HIGH = 1001,
40c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra    CAMCORDER_QUALITY_TIME_LAPSE_QCIF = 1002,
419783ed8f85af3d7c72030098acfed7e1d6638349Nipun Kwatra    CAMCORDER_QUALITY_TIME_LAPSE_CIF = 1003,
429783ed8f85af3d7c72030098acfed7e1d6638349Nipun Kwatra    CAMCORDER_QUALITY_TIME_LAPSE_480P = 1004,
439783ed8f85af3d7c72030098acfed7e1d6638349Nipun Kwatra    CAMCORDER_QUALITY_TIME_LAPSE_720P = 1005,
442a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    CAMCORDER_QUALITY_TIME_LAPSE_1080P = 1006,
452a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1006,
461d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong};
471d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
48cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng/**
49cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng *Set CIF as default maximum import and export resolution of video editor.
50cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng *The maximum import and export resolutions are platform specific,
51cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng *which should be defined in media_profiles.xml.
52cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng */
53cabd5f867ec69c0dfe8333cba46323cb58917402Hong Tengenum videoeditor_capability {
54cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH = 352,
55cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT = 288,
56cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH = 352,
57cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT = 288,
58cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng};
59cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng
601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongenum video_decoder {
611d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    VIDEO_DECODER_WMV,
621d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong};
631d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
641d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongenum audio_decoder {
651d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    AUDIO_DECODER_WMA,
661d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong};
671d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
681d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
691d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongclass MediaProfiles
701d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{
711d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongpublic:
721d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
731d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    /**
741d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * Returns the singleton instance for subsequence queries.
751d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * or NULL if error.
761d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     */
771d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static MediaProfiles* getInstance();
781d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
791d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    /**
803eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang     * Returns the value for the given param name for the given camera at
813eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang     * the given quality level, or -1 if error.
821d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     *
831d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * Supported param name are:
84f5a8385649204213dc19e1a64f4693931e048d85James Dong     * duration - the recording duration.
851d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * file.format - output file format. see mediarecorder.h for details
8613896b94336085d4e6ff555fa1a420312e8dea79James Dong     * vid.codec - video encoder. see mediarecorder.h for details.
8713896b94336085d4e6ff555fa1a420312e8dea79James Dong     * aud.codec - audio encoder. see mediarecorder.h for details.
881d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * vid.width - video frame width
891d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * vid.height - video frame height
901d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * vid.fps - video frame rate
911d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * vid.bps - video bit rate
921d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * aud.bps - audio bit rate
931d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * aud.hz - audio sample rate
941d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * aud.ch - number of audio channels
951d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     */
963eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang    int getCamcorderProfileParamByName(const char *name, int cameraId,
973eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang                                       camcorder_quality quality) const;
981d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
991d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    /**
1008bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra     * Returns true if a profile for the given camera at the given quality exists,
1018bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra     * or false if not.
1028bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra     */
1038bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra    bool hasCamcorderProfile(int cameraId, camcorder_quality quality) const;
1048bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra
1058bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra    /**
1061d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * Returns the output file formats supported.
1071d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     */
1081d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    Vector<output_format> getOutputFileFormats() const;
1091d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
1101d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    /**
1111d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * Returns the video encoders supported.
1121d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     */
1131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    Vector<video_encoder> getVideoEncoders() const;
1141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
1151d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    /**
1161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * Returns the value for the given param name for the given video encoder
1171d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * returned from getVideoEncoderByIndex or -1 if error.
1181d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     *
1191d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * Supported param name are:
1201d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.vid.width.min - min video frame width
1211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.vid.width.max - max video frame width
1221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.vid.height.min - min video frame height
1231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.vid.height.max - max video frame height
1241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.vid.bps.min - min bit rate in bits per second
1251d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.vid.bps.max - max bit rate in bits per second
1261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.vid.fps.min - min frame rate in frames per second
1271d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.vid.fps.max - max frame rate in frames per second
1281d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     */
1291d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    int getVideoEncoderParamByName(const char *name, video_encoder codec) const;
1301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
1311d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    /**
132cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng     * Returns the value for the given param name for the video editor cap
133cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng     * param or -1 if error.
134cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng     * Supported param name are:
135cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng     * videoeditor.input.width.max - max input video frame width
136cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng     * videoeditor.input.height.max - max input video frame height
137cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng     * videoeditor.output.width.max - max output video frame width
138cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng     * videoeditor.output.height.max - max output video frame height
139cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng     */
140cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    int getVideoEditorCapParamByName(const char *name) const;
141cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng
142cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    /**
1431d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * Returns the audio encoders supported.
1441d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     */
1451d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    Vector<audio_encoder> getAudioEncoders() const;
1461d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
1471d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    /**
1481d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * Returns the value for the given param name for the given audio encoder
1491d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * returned from getAudioEncoderByIndex or -1 if error.
1501d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     *
1511d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * Supported param name are:
1521d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.aud.ch.min - min number of channels
1531d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.aud.ch.max - max number of channels
1541d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.aud.bps.min - min bit rate in bits per second
1551d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.aud.bps.max - max bit rate in bits per second
1561d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.aud.hz.min - min sample rate in samples per second
1571d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     * enc.aud.hz.max - max sample rate in samples per second
1581d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     */
1591d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    int getAudioEncoderParamByName(const char *name, audio_encoder codec) const;
1601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
1611d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    /**
1621d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong      * Returns the video decoders supported.
1631d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong      */
1641d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    Vector<video_decoder> getVideoDecoders() const;
1651d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
1661d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong     /**
1671d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong      * Returns the audio decoders supported.
1681d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong      */
1691d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    Vector<audio_decoder> getAudioDecoders() const;
1701d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
171f5a8385649204213dc19e1a64f4693931e048d85James Dong    /**
172f5a8385649204213dc19e1a64f4693931e048d85James Dong     * Returns the number of image encoding quality levels supported.
173f5a8385649204213dc19e1a64f4693931e048d85James Dong     */
1743eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang    Vector<int> getImageEncodingQualityLevels(int cameraId) const;
175f5a8385649204213dc19e1a64f4693931e048d85James Dong
1760f056290cb16763453f18bbef80cde673041dbbcJames Dong    /**
1770f056290cb16763453f18bbef80cde673041dbbcJames Dong     * Returns the start time offset (in ms) for the given camera Id.
1780f056290cb16763453f18bbef80cde673041dbbcJames Dong     * If the given camera Id does not exist, -1 will be returned.
1790f056290cb16763453f18bbef80cde673041dbbcJames Dong     */
1800f056290cb16763453f18bbef80cde673041dbbcJames Dong    int getStartTimeOffsetMs(int cameraId) const;
1810f056290cb16763453f18bbef80cde673041dbbcJames Dong
1821d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongprivate:
1832a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    enum {
1842a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        // Camcorder profiles (high/low) and timelapse profiles (high/low)
1852a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        kNumRequiredProfiles = 4,
1862a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    };
1872a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong
1881d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    MediaProfiles& operator=(const MediaProfiles&);  // Don't call me
1891d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    MediaProfiles(const MediaProfiles&);             // Don't call me
190cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    MediaProfiles() { mVideoEditorCap = NULL; }        // Dummy default constructor
1911d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    ~MediaProfiles();                                // Don't delete me
1921d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
1931d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    struct VideoCodec {
1941d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        VideoCodec(video_encoder codec, int bitRate, int frameWidth, int frameHeight, int frameRate)
1951d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong            : mCodec(codec),
1961d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mBitRate(bitRate),
1971d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mFrameWidth(frameWidth),
1981d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mFrameHeight(frameHeight),
1991d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mFrameRate(frameRate) {}
2001d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2012a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        VideoCodec(const VideoCodec& copy) {
2022a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mCodec = copy.mCodec;
2032a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mBitRate = copy.mBitRate;
2042a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mFrameWidth = copy.mFrameWidth;
2052a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mFrameHeight = copy.mFrameHeight;
2062a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mFrameRate = copy.mFrameRate;
2072a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        }
2082a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong
2091d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        ~VideoCodec() {}
2101d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2111d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        video_encoder mCodec;
2121d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mBitRate;
2131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mFrameWidth;
2141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mFrameHeight;
2151d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mFrameRate;
2161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    };
2171d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2181d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    struct AudioCodec {
2191d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        AudioCodec(audio_encoder codec, int bitRate, int sampleRate, int channels)
2201d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong            : mCodec(codec),
2211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mBitRate(bitRate),
2221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mSampleRate(sampleRate),
2231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mChannels(channels) {}
2241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2252a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        AudioCodec(const AudioCodec& copy) {
2262a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mCodec = copy.mCodec;
2272a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mBitRate = copy.mBitRate;
2282a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mSampleRate = copy.mSampleRate;
2292a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mChannels = copy.mChannels;
2302a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        }
2312a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong
2321d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        ~AudioCodec() {}
2331d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2341d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        audio_encoder mCodec;
2351d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mBitRate;
2361d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mSampleRate;
2371d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mChannels;
2381d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    };
2391d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2401d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    struct CamcorderProfile {
2411d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        CamcorderProfile()
2423eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang            : mCameraId(0),
2433eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang              mFileFormat(OUTPUT_FORMAT_THREE_GPP),
2441d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mQuality(CAMCORDER_QUALITY_HIGH),
2451d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mDuration(0),
2461d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mVideoCodec(0),
2471d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mAudioCodec(0) {}
2481d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2492a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        CamcorderProfile(const CamcorderProfile& copy) {
2502a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mCameraId = copy.mCameraId;
2512a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mFileFormat = copy.mFileFormat;
2522a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mQuality = copy.mQuality;
2532a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mDuration = copy.mDuration;
2542a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mVideoCodec = new VideoCodec(*copy.mVideoCodec);
2552a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong            mAudioCodec = new AudioCodec(*copy.mAudioCodec);
2562a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        }
2572a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong
2581d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        ~CamcorderProfile() {
2591d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong            delete mVideoCodec;
2601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong            delete mAudioCodec;
2611d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        }
2621d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2633eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang        int mCameraId;
2641d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        output_format mFileFormat;
2651d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        camcorder_quality mQuality;
2661d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mDuration;
2671d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        VideoCodec *mVideoCodec;
2681d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        AudioCodec *mAudioCodec;
2691d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    };
2701d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2711d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    struct VideoEncoderCap {
2721d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        // Ugly constructor
2731d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        VideoEncoderCap(video_encoder codec,
2741d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong                        int minBitRate, int maxBitRate,
2751d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong                        int minFrameWidth, int maxFrameWidth,
2761d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong                        int minFrameHeight, int maxFrameHeight,
2771d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong                        int minFrameRate, int maxFrameRate)
2781d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong            : mCodec(codec),
2791d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
2801d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mMinFrameWidth(minFrameWidth), mMaxFrameWidth(maxFrameWidth),
2811d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mMinFrameHeight(minFrameHeight), mMaxFrameHeight(maxFrameHeight),
2821d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mMinFrameRate(minFrameRate), mMaxFrameRate(maxFrameRate) {}
2831d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2841d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong         ~VideoEncoderCap() {}
2851d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2861d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        video_encoder mCodec;
2871d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mMinBitRate, mMaxBitRate;
2881d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mMinFrameWidth, mMaxFrameWidth;
2891d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mMinFrameHeight, mMaxFrameHeight;
2901d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mMinFrameRate, mMaxFrameRate;
2911d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    };
2921d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
2931d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    struct AudioEncoderCap {
2941d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        // Ugly constructor
2951d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        AudioEncoderCap(audio_encoder codec,
2961d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong                        int minBitRate, int maxBitRate,
2971d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong                        int minSampleRate, int maxSampleRate,
2981d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong                        int minChannels, int maxChannels)
2991d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong            : mCodec(codec),
3001d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
3011d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mMinSampleRate(minSampleRate), mMaxSampleRate(maxSampleRate),
3021d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong              mMinChannels(minChannels), mMaxChannels(maxChannels) {}
3031d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
3041d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        ~AudioEncoderCap() {}
3051d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
3061d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        audio_encoder mCodec;
3071d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mMinBitRate, mMaxBitRate;
3081d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mMinSampleRate, mMaxSampleRate;
3091d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int mMinChannels, mMaxChannels;
3101d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    };
3111d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
3121d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    struct VideoDecoderCap {
3131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        VideoDecoderCap(video_decoder codec): mCodec(codec) {}
3141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        ~VideoDecoderCap() {}
3151d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
3161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        video_decoder mCodec;
3171d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    };
3181d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
3191d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    struct AudioDecoderCap {
3201d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        AudioDecoderCap(audio_decoder codec): mCodec(codec) {}
3211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        ~AudioDecoderCap() {}
3221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
3231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        audio_decoder mCodec;
3241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    };
3251d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
3261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    struct NameToTagMap {
3271d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        const char* name;
3281d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong        int tag;
3291d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    };
3301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
3313eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang    struct ImageEncodingQualityLevels {
3323eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang        int mCameraId;
3333eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang        Vector<int> mLevels;
3343eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang    };
3353eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang
336cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    struct VideoEditorCap {
337cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng        VideoEditorCap(int inFrameWidth, int inFrameHeight,
338cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng            int outFrameWidth, int outFrameHeight)
339cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng            : mMaxInputFrameWidth(inFrameWidth),
340cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng              mMaxInputFrameHeight(inFrameHeight),
341cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng              mMaxOutputFrameWidth(outFrameWidth),
342cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng              mMaxOutputFrameHeight(outFrameHeight) {}
343cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng
344cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng        ~VideoEditorCap() {}
345cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng
346cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng        int mMaxInputFrameWidth;
347cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng        int mMaxInputFrameHeight;
348cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng        int mMaxOutputFrameWidth;
349cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng        int mMaxOutputFrameHeight;
350cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    };
351cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng
3528bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra    int getCamcorderProfileIndex(int cameraId, camcorder_quality quality) const;
3532a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    void initRequiredProfileRefs(const Vector<int>& cameraIds);
3542a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    int getRequiredProfileRefIndex(int cameraId);
3558bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra
3561d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    // Debug
3571d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void logVideoCodec(const VideoCodec& codec);
3581d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void logAudioCodec(const AudioCodec& codec);
3591d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void logVideoEncoderCap(const VideoEncoderCap& cap);
3601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void logAudioEncoderCap(const AudioEncoderCap& cap);
3611d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void logVideoDecoderCap(const VideoDecoderCap& cap);
3621d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void logAudioDecoderCap(const AudioDecoderCap& cap);
363cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    static void logVideoEditorCap(const VideoEditorCap& cap);
3641d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
3651d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    // If the xml configuration file does exist, use the settings
3661d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    // from the xml
3671d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static MediaProfiles* createInstanceFromXmlFile(const char *xml);
3681d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static output_format createEncoderOutputFileFormat(const char **atts);
3691d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static VideoCodec* createVideoCodec(const char **atts, MediaProfiles *profiles);
3701d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static AudioCodec* createAudioCodec(const char **atts, MediaProfiles *profiles);
3711d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static AudioDecoderCap* createAudioDecoderCap(const char **atts);
3721d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static VideoDecoderCap* createVideoDecoderCap(const char **atts);
3731d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static VideoEncoderCap* createVideoEncoderCap(const char **atts);
3741d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static AudioEncoderCap* createAudioEncoderCap(const char **atts);
375cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    static VideoEditorCap* createVideoEditorCap(
376cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng                const char **atts, MediaProfiles *profiles);
3772a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong
3782a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    static CamcorderProfile* createCamcorderProfile(
3792a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong                int cameraId, const char **atts, Vector<int>& cameraIds);
3802a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong
3813eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang    static int getCameraId(const char **atts);
3823eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang
3830f056290cb16763453f18bbef80cde673041dbbcJames Dong    void addStartTimeOffset(int cameraId, const char **atts);
3840f056290cb16763453f18bbef80cde673041dbbcJames Dong
3853eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang    ImageEncodingQualityLevels* findImageEncodingQualityLevels(int cameraId) const;
3863eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang    void addImageEncodingQualityLevel(int cameraId, const char** atts);
3871d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
3881d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    // Customized element tag handler for parsing the xml configuration file.
3891d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void startElementHandler(void *userData, const char *name, const char **atts);
3901d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
3911d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    // If the xml configuration file does not exist, use hard-coded values
3921d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static MediaProfiles* createDefaultInstance();
393d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra
394d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra    static CamcorderProfile *createDefaultCamcorderQcifProfile(camcorder_quality quality);
395d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra    static CamcorderProfile *createDefaultCamcorderCifProfile(camcorder_quality quality);
396d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra    static void createDefaultCamcorderLowProfiles(
397d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra            MediaProfiles::CamcorderProfile **lowProfile,
398d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra            MediaProfiles::CamcorderProfile **lowSpecificProfile);
399d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra    static void createDefaultCamcorderHighProfiles(
400d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra            MediaProfiles::CamcorderProfile **highProfile,
401d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra            MediaProfiles::CamcorderProfile **highSpecificProfile);
402d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra
403d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra    static CamcorderProfile *createDefaultCamcorderTimeLapseQcifProfile(camcorder_quality quality);
404d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra    static CamcorderProfile *createDefaultCamcorderTimeLapse480pProfile(camcorder_quality quality);
405d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra    static void createDefaultCamcorderTimeLapseLowProfiles(
406d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra            MediaProfiles::CamcorderProfile **lowTimeLapseProfile,
407d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra            MediaProfiles::CamcorderProfile **lowSpecificTimeLapseProfile);
408d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra    static void createDefaultCamcorderTimeLapseHighProfiles(
409d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra            MediaProfiles::CamcorderProfile **highTimeLapseProfile,
410d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra            MediaProfiles::CamcorderProfile **highSpecificTimeLapseProfile);
411d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra
4121d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void createDefaultCamcorderProfiles(MediaProfiles *profiles);
4131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void createDefaultVideoEncoders(MediaProfiles *profiles);
4141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void createDefaultAudioEncoders(MediaProfiles *profiles);
4151d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void createDefaultVideoDecoders(MediaProfiles *profiles);
4161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void createDefaultAudioDecoders(MediaProfiles *profiles);
4171d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static void createDefaultEncoderOutputFileFormats(MediaProfiles *profiles);
418f5a8385649204213dc19e1a64f4693931e048d85James Dong    static void createDefaultImageEncodingQualityLevels(MediaProfiles *profiles);
419f5a8385649204213dc19e1a64f4693931e048d85James Dong    static void createDefaultImageDecodingMaxMemory(MediaProfiles *profiles);
420cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    static void createDefaultVideoEditorCap(MediaProfiles *profiles);
4211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static VideoEncoderCap* createDefaultH263VideoEncoderCap();
4221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static VideoEncoderCap* createDefaultM4vVideoEncoderCap();
4231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static AudioEncoderCap* createDefaultAmrNBEncoderCap();
4241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
4251d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static int findTagForName(const NameToTagMap *map, size_t nMappings, const char *name);
4261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
4272a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    /**
4282a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong     * Check on existing profiles with the following criteria:
4292a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong     * 1. Low quality profile must have the lowest video
4302a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong     *    resolution product (width x height)
4312a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong     * 2. High quality profile must have the highest video
4322a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong     *    resolution product (width x height)
4332a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong     *
4342a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong     * and add required low/high quality camcorder/timelapse
4352a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong     * profiles if they are not found. This allows to remove
4362a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong     * duplicate profile definitions in the media_profiles.xml
4372a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong     * file.
4382a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong     */
4392a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    void checkAndAddRequiredProfilesIfNecessary();
4402a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong
4412a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong
4421d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    // Mappings from name (for instance, codec name) to enum value
4431d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static const NameToTagMap sVideoEncoderNameMap[];
4441d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static const NameToTagMap sAudioEncoderNameMap[];
4451d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static const NameToTagMap sFileFormatMap[];
4461d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static const NameToTagMap sVideoDecoderNameMap[];
4471d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static const NameToTagMap sAudioDecoderNameMap[];
4481d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static const NameToTagMap sCamcorderQualityNameMap[];
4491d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
4501d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static bool sIsInitialized;
4511d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static MediaProfiles *sInstance;
4521d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    static Mutex sLock;
4533eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang    int mCurrentCameraId;
4541d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
4551d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    Vector<CamcorderProfile*> mCamcorderProfiles;
4561d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    Vector<AudioEncoderCap*>  mAudioEncoders;
4571d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    Vector<VideoEncoderCap*>  mVideoEncoders;
4581d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    Vector<AudioDecoderCap*>  mAudioDecoders;
4591d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    Vector<VideoDecoderCap*>  mVideoDecoders;
4601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong    Vector<output_format>     mEncoderOutputFileFormats;
4613eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang    Vector<ImageEncodingQualityLevels *>  mImageEncodingQualityLevels;
4620f056290cb16763453f18bbef80cde673041dbbcJames Dong    KeyedVector<int, int> mStartTimeOffsets;
4632a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong
4642a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    typedef struct {
4652a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        bool mHasRefProfile;      // Refers to an existing profile
4662a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        int  mRefProfileIndex;    // Reference profile index
4672a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        int  mResolutionProduct;  // width x height
4682a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    } RequiredProfileRefInfo;     // Required low and high profiles
4692a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong
4702a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    typedef struct {
4712a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        RequiredProfileRefInfo mRefs[kNumRequiredProfiles];
4722a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong        int mCameraId;
4732a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    } RequiredProfiles;
4742a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong
4752a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    RequiredProfiles *mRequiredProfileRefs;
4762a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong    Vector<int>              mCameraIds;
477cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng    VideoEditorCap* mVideoEditorCap;
4781d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong};
4791d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
4801d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong}; // namespace android
4811d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
4821d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#endif // ANDROID_MEDIAPROFILES_H
4831d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong
484