MediaProfiles.cpp revision 3856b090cd04ba5dd4a59a12430ed724d5995909
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 191d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong//#define LOG_NDEBUG 0 201d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#define LOG_TAG "MediaProfiles" 211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#include <stdlib.h> 231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#include <utils/Log.h> 241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#include <utils/Vector.h> 251d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#include <cutils/properties.h> 261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#include <expat.h> 271d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#include <media/MediaProfiles.h> 281d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#include <media/stagefright/MediaDebug.h> 298f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury#include <media/stagefright/openmax/OMX_Video.h> 301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 311d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongnamespace android { 321d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 331d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMutex MediaProfiles::sLock; 341d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongbool MediaProfiles::sIsInitialized = false; 351d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles *MediaProfiles::sInstance = NULL; 361d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 371d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongconst MediaProfiles::NameToTagMap MediaProfiles::sVideoEncoderNameMap[] = { 381d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong {"h263", VIDEO_ENCODER_H263}, 391d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong {"h264", VIDEO_ENCODER_H264}, 401d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong {"m4v", VIDEO_ENCODER_MPEG_4_SP} 411d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong}; 421d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 431d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongconst MediaProfiles::NameToTagMap MediaProfiles::sAudioEncoderNameMap[] = { 441d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong {"amrnb", AUDIO_ENCODER_AMR_NB}, 451d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong {"amrwb", AUDIO_ENCODER_AMR_WB}, 461d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong {"aac", AUDIO_ENCODER_AAC}, 471d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong}; 481d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 491d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongconst MediaProfiles::NameToTagMap MediaProfiles::sFileFormatMap[] = { 501d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong {"3gp", OUTPUT_FORMAT_THREE_GPP}, 511d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong {"mp4", OUTPUT_FORMAT_MPEG_4} 521d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong}; 531d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 541d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongconst MediaProfiles::NameToTagMap MediaProfiles::sVideoDecoderNameMap[] = { 551d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong {"wmv", VIDEO_DECODER_WMV} 561d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong}; 571d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 581d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongconst MediaProfiles::NameToTagMap MediaProfiles::sAudioDecoderNameMap[] = { 591d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong {"wma", AUDIO_DECODER_WMA} 601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong}; 611d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 621d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongconst MediaProfiles::NameToTagMap MediaProfiles::sCamcorderQualityNameMap[] = { 63c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra {"low", CAMCORDER_QUALITY_LOW}, 641d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong {"high", CAMCORDER_QUALITY_HIGH}, 65c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra {"qcif", CAMCORDER_QUALITY_QCIF}, 669783ed8f85af3d7c72030098acfed7e1d6638349Nipun Kwatra {"cif", CAMCORDER_QUALITY_CIF}, 67c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra {"480p", CAMCORDER_QUALITY_480P}, 68c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra {"720p", CAMCORDER_QUALITY_720P}, 69c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra {"1080p", CAMCORDER_QUALITY_1080P}, 70669012d77b00a2aacb6fd12837f2870f9ec17865James Dong {"qvga", CAMCORDER_QUALITY_QVGA}, 71c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra 72c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra {"timelapselow", CAMCORDER_QUALITY_TIME_LAPSE_LOW}, 73c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra {"timelapsehigh", CAMCORDER_QUALITY_TIME_LAPSE_HIGH}, 74c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra {"timelapseqcif", CAMCORDER_QUALITY_TIME_LAPSE_QCIF}, 759783ed8f85af3d7c72030098acfed7e1d6638349Nipun Kwatra {"timelapsecif", CAMCORDER_QUALITY_TIME_LAPSE_CIF}, 76c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra {"timelapse480p", CAMCORDER_QUALITY_TIME_LAPSE_480P}, 77c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra {"timelapse720p", CAMCORDER_QUALITY_TIME_LAPSE_720P}, 78669012d77b00a2aacb6fd12837f2870f9ec17865James Dong {"timelapse1080p", CAMCORDER_QUALITY_TIME_LAPSE_1080P}, 79669012d77b00a2aacb6fd12837f2870f9ec17865James Dong {"timelapseqvga", CAMCORDER_QUALITY_TIME_LAPSE_QVGA}, 801d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong}; 811d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 821d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 831d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::logVideoCodec(const MediaProfiles::VideoCodec& codec) 841d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("video codec:"); 863856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("codec = %d", codec.mCodec); 873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("bit rate: %d", codec.mBitRate); 883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("frame width: %d", codec.mFrameWidth); 893856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("frame height: %d", codec.mFrameHeight); 903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("frame rate: %d", codec.mFrameRate); 911d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 921d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 931d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 941d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::logAudioCodec(const MediaProfiles::AudioCodec& codec) 951d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 963856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("audio codec:"); 973856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("codec = %d", codec.mCodec); 983856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("bit rate: %d", codec.mBitRate); 993856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("sample rate: %d", codec.mSampleRate); 1003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("number of channels: %d", codec.mChannels); 1011d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 1021d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 1031d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 1041d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::logVideoEncoderCap(const MediaProfiles::VideoEncoderCap& cap) 1051d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 1063856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("video encoder cap:"); 1073856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("codec = %d", cap.mCodec); 1083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("bit rate: min = %d and max = %d", cap.mMinBitRate, cap.mMaxBitRate); 1093856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("frame width: min = %d and max = %d", cap.mMinFrameWidth, cap.mMaxFrameWidth); 1103856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("frame height: min = %d and max = %d", cap.mMinFrameHeight, cap.mMaxFrameHeight); 1113856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("frame rate: min = %d and max = %d", cap.mMinFrameRate, cap.mMaxFrameRate); 1121d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 1131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 1141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 1151d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::logAudioEncoderCap(const MediaProfiles::AudioEncoderCap& cap) 1161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 1173856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("audio encoder cap:"); 1183856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("codec = %d", cap.mCodec); 1193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("bit rate: min = %d and max = %d", cap.mMinBitRate, cap.mMaxBitRate); 1203856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("sample rate: min = %d and max = %d", cap.mMinSampleRate, cap.mMaxSampleRate); 1213856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("number of channels: min = %d and max = %d", cap.mMinChannels, cap.mMaxChannels); 1221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 1231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 1241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 1251d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::logVideoDecoderCap(const MediaProfiles::VideoDecoderCap& cap) 1261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 1273856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("video decoder cap:"); 1283856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("codec = %d", cap.mCodec); 1291d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 1301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 1311d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 1321d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::logAudioDecoderCap(const MediaProfiles::AudioDecoderCap& cap) 1331d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 1343856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("audio codec cap:"); 1353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("codec = %d", cap.mCodec); 1361d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 1371d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 138cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng/*static*/ void 139cabd5f867ec69c0dfe8333cba46323cb58917402Hong TengMediaProfiles::logVideoEditorCap(const MediaProfiles::VideoEditorCap& cap) 140cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng{ 1413856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("videoeditor cap:"); 1423856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("mMaxInputFrameWidth = %d", cap.mMaxInputFrameWidth); 1433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("mMaxInputFrameHeight = %d", cap.mMaxInputFrameHeight); 1443856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("mMaxOutputFrameWidth = %d", cap.mMaxOutputFrameWidth); 1453856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("mMaxOutputFrameHeight = %d", cap.mMaxOutputFrameHeight); 146cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng} 147cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng 1481d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ int 1491d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::findTagForName(const MediaProfiles::NameToTagMap *map, size_t nMappings, const char *name) 1501d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 1511d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong int tag = -1; 1521d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0; i < nMappings; ++i) { 1531d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp(map[i].name, name)) { 1541d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong tag = map[i].tag; 1551d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong break; 1561d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 1571d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 1581d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return tag; 1591d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 1601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 1611d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::VideoCodec* 1621d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createVideoCodec(const char **atts, MediaProfiles *profiles) 1631d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 1641d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(!strcmp("codec", atts[0]) && 1651d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("bitRate", atts[2]) && 1661d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("width", atts[4]) && 1671d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("height", atts[6]) && 1681d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("frameRate", atts[8])); 1691d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 1701d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const size_t nMappings = sizeof(sVideoEncoderNameMap)/sizeof(sVideoEncoderNameMap[0]); 1711d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const int codec = findTagForName(sVideoEncoderNameMap, nMappings, atts[1]); 1721d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(codec != -1); 1731d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 1741d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles::VideoCodec *videoCodec = 1751d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong new MediaProfiles::VideoCodec(static_cast<video_encoder>(codec), 1761d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong atoi(atts[3]), atoi(atts[5]), atoi(atts[7]), atoi(atts[9])); 1771d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong logVideoCodec(*videoCodec); 1781d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 1791d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong size_t nCamcorderProfiles; 1801d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK((nCamcorderProfiles = profiles->mCamcorderProfiles.size()) >= 1); 1811d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mCamcorderProfiles[nCamcorderProfiles - 1]->mVideoCodec = videoCodec; 1821d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return videoCodec; 1831d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 1841d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 1851d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::AudioCodec* 1861d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createAudioCodec(const char **atts, MediaProfiles *profiles) 1871d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 1881d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(!strcmp("codec", atts[0]) && 1891d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("bitRate", atts[2]) && 1901d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("sampleRate", atts[4]) && 1911d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("channels", atts[6])); 1921d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const size_t nMappings = sizeof(sAudioEncoderNameMap)/sizeof(sAudioEncoderNameMap[0]); 1931d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const int codec = findTagForName(sAudioEncoderNameMap, nMappings, atts[1]); 1941d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(codec != -1); 1951d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 1961d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles::AudioCodec *audioCodec = 1971d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong new MediaProfiles::AudioCodec(static_cast<audio_encoder>(codec), 1981d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong atoi(atts[3]), atoi(atts[5]), atoi(atts[7])); 1991d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong logAudioCodec(*audioCodec); 2001d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2011d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong size_t nCamcorderProfiles; 2021d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK((nCamcorderProfiles = profiles->mCamcorderProfiles.size()) >= 1); 2031d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mCamcorderProfiles[nCamcorderProfiles - 1]->mAudioCodec = audioCodec; 2041d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return audioCodec; 2051d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 2061d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::AudioDecoderCap* 2071d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createAudioDecoderCap(const char **atts) 2081d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 2091d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(!strcmp("name", atts[0]) && 2101d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("enabled", atts[2])); 2111d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2121d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const size_t nMappings = sizeof(sAudioDecoderNameMap)/sizeof(sAudioDecoderNameMap[0]); 2131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const int codec = findTagForName(sAudioDecoderNameMap, nMappings, atts[1]); 2141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(codec != -1); 2151d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles::AudioDecoderCap *cap = 2171d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong new MediaProfiles::AudioDecoderCap(static_cast<audio_decoder>(codec)); 2181d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong logAudioDecoderCap(*cap); 2191d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return cap; 2201d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 2211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::VideoDecoderCap* 2231d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createVideoDecoderCap(const char **atts) 2241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 2251d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(!strcmp("name", atts[0]) && 2261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("enabled", atts[2])); 2271d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2281d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const size_t nMappings = sizeof(sVideoDecoderNameMap)/sizeof(sVideoDecoderNameMap[0]); 2291d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const int codec = findTagForName(sVideoDecoderNameMap, nMappings, atts[1]); 2301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(codec != -1); 2311d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2321d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles::VideoDecoderCap *cap = 2331d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong new MediaProfiles::VideoDecoderCap(static_cast<video_decoder>(codec)); 2341d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong logVideoDecoderCap(*cap); 2351d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return cap; 2361d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 2371d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2381d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::VideoEncoderCap* 2391d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createVideoEncoderCap(const char **atts) 2401d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 2411d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(!strcmp("name", atts[0]) && 2421d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("enabled", atts[2]) && 2431d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("minBitRate", atts[4]) && 2441d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("maxBitRate", atts[6]) && 2451d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("minFrameWidth", atts[8]) && 2461d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("maxFrameWidth", atts[10]) && 2471d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("minFrameHeight", atts[12]) && 2481d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("maxFrameHeight", atts[14]) && 2491d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("minFrameRate", atts[16]) && 2501d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("maxFrameRate", atts[18])); 2511d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2521d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const size_t nMappings = sizeof(sVideoEncoderNameMap)/sizeof(sVideoEncoderNameMap[0]); 2531d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const int codec = findTagForName(sVideoEncoderNameMap, nMappings, atts[1]); 2541d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(codec != -1); 2551d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2561d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles::VideoEncoderCap *cap = 2571d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong new MediaProfiles::VideoEncoderCap(static_cast<video_encoder>(codec), 2581d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong atoi(atts[5]), atoi(atts[7]), atoi(atts[9]), atoi(atts[11]), atoi(atts[13]), 2591d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong atoi(atts[15]), atoi(atts[17]), atoi(atts[19])); 2601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong logVideoEncoderCap(*cap); 2611d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return cap; 2621d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 2631d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2641d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::AudioEncoderCap* 2651d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createAudioEncoderCap(const char **atts) 2661d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 2671d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(!strcmp("name", atts[0]) && 2681d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("enabled", atts[2]) && 2691d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("minBitRate", atts[4]) && 2701d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("maxBitRate", atts[6]) && 2711d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("minSampleRate", atts[8]) && 2721d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("maxSampleRate", atts[10]) && 2731d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("minChannels", atts[12]) && 2741d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("maxChannels", atts[14])); 2751d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2761d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const size_t nMappings = sizeof(sAudioEncoderNameMap)/sizeof(sAudioEncoderNameMap[0]); 2771d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const int codec = findTagForName(sAudioEncoderNameMap, nMappings, atts[1]); 2781d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(codec != -1); 2791d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2801d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles::AudioEncoderCap *cap = 2811d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong new MediaProfiles::AudioEncoderCap(static_cast<audio_encoder>(codec), atoi(atts[5]), atoi(atts[7]), 2821d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong atoi(atts[9]), atoi(atts[11]), atoi(atts[13]), 2831d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong atoi(atts[15])); 2841d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong logAudioEncoderCap(*cap); 2851d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return cap; 2861d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 2871d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2881d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ output_format 2891d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createEncoderOutputFileFormat(const char **atts) 2901d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 2911d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(!strcmp("name", atts[0])); 2921d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2931d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const size_t nMappings =sizeof(sFileFormatMap)/sizeof(sFileFormatMap[0]); 2941d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const int format = findTagForName(sFileFormatMap, nMappings, atts[1]); 2951d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(format != -1); 2961d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 2971d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return static_cast<output_format>(format); 2981d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 2991d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 3002a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dongstatic bool isCameraIdFound(int cameraId, const Vector<int>& cameraIds) { 3012a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong for (int i = 0, n = cameraIds.size(); i < n; ++i) { 3022a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong if (cameraId == cameraIds[i]) { 3032a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong return true; 3042a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 3052a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 3062a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong return false; 3072a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong} 3082a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 3091d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::CamcorderProfile* 3102a7e0a1eb29306982fd77bdc64d324464a48a2b9James DongMediaProfiles::createCamcorderProfile(int cameraId, const char **atts, Vector<int>& cameraIds) 3111d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 3121d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(!strcmp("quality", atts[0]) && 3131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("fileFormat", atts[2]) && 3141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong !strcmp("duration", atts[4])); 3151d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 3161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const size_t nProfileMappings = sizeof(sCamcorderQualityNameMap)/sizeof(sCamcorderQualityNameMap[0]); 3171d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const int quality = findTagForName(sCamcorderQualityNameMap, nProfileMappings, atts[1]); 3181d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(quality != -1); 3191d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 3201d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const size_t nFormatMappings = sizeof(sFileFormatMap)/sizeof(sFileFormatMap[0]); 3211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const int fileFormat = findTagForName(sFileFormatMap, nFormatMappings, atts[3]); 3221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(fileFormat != -1); 3231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 3241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles::CamcorderProfile *profile = new MediaProfiles::CamcorderProfile; 3253eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang profile->mCameraId = cameraId; 3262a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong if (!isCameraIdFound(cameraId, cameraIds)) { 3272a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong cameraIds.add(cameraId); 3282a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 3291d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profile->mFileFormat = static_cast<output_format>(fileFormat); 3301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profile->mQuality = static_cast<camcorder_quality>(quality); 3311d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profile->mDuration = atoi(atts[5]); 3321d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return profile; 3331d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 3341d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 3353eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung ChangMediaProfiles::ImageEncodingQualityLevels* 3363eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung ChangMediaProfiles::findImageEncodingQualityLevels(int cameraId) const 3373eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang{ 3383eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang int n = mImageEncodingQualityLevels.size(); 3393eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang for (int i = 0; i < n; i++) { 3403eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang ImageEncodingQualityLevels *levels = mImageEncodingQualityLevels[i]; 3413eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang if (levels->mCameraId == cameraId) { 3423eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang return levels; 3433eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang } 3443eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang } 3453eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang return NULL; 3463eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang} 3473eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang 3483eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Changvoid MediaProfiles::addImageEncodingQualityLevel(int cameraId, const char** atts) 349f5a8385649204213dc19e1a64f4693931e048d85James Dong{ 350f5a8385649204213dc19e1a64f4693931e048d85James Dong CHECK(!strcmp("quality", atts[0])); 3513eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang int quality = atoi(atts[1]); 3523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("%s: cameraId=%d, quality=%d\n", __func__, cameraId, quality); 3533eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang ImageEncodingQualityLevels *levels = findImageEncodingQualityLevels(cameraId); 3543eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang 3553eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang if (levels == NULL) { 3563eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang levels = new ImageEncodingQualityLevels(); 3573eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang levels->mCameraId = cameraId; 3583eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang mImageEncodingQualityLevels.add(levels); 3593eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang } 3603eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang 3613eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang levels->mLevels.add(quality); 3623eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang} 3633eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang 3643eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang/*static*/ int 3653eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung ChangMediaProfiles::getCameraId(const char** atts) 3663eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang{ 3673eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang if (!atts[0]) return 0; // default cameraId = 0 3683eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang CHECK(!strcmp("cameraId", atts[0])); 369f5a8385649204213dc19e1a64f4693931e048d85James Dong return atoi(atts[1]); 370f5a8385649204213dc19e1a64f4693931e048d85James Dong} 371f5a8385649204213dc19e1a64f4693931e048d85James Dong 3720f056290cb16763453f18bbef80cde673041dbbcJames Dongvoid MediaProfiles::addStartTimeOffset(int cameraId, const char** atts) 3730f056290cb16763453f18bbef80cde673041dbbcJames Dong{ 3740f056290cb16763453f18bbef80cde673041dbbcJames Dong int offsetTimeMs = 700; 3750f056290cb16763453f18bbef80cde673041dbbcJames Dong if (atts[2]) { 3760f056290cb16763453f18bbef80cde673041dbbcJames Dong CHECK(!strcmp("startOffsetMs", atts[2])); 3770f056290cb16763453f18bbef80cde673041dbbcJames Dong offsetTimeMs = atoi(atts[3]); 3780f056290cb16763453f18bbef80cde673041dbbcJames Dong } 3790f056290cb16763453f18bbef80cde673041dbbcJames Dong 3803856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("%s: cameraId=%d, offset=%d ms", __func__, cameraId, offsetTimeMs); 3810f056290cb16763453f18bbef80cde673041dbbcJames Dong mStartTimeOffsets.replaceValueFor(cameraId, offsetTimeMs); 3820f056290cb16763453f18bbef80cde673041dbbcJames Dong} 3838f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury/*static*/ MediaProfiles::ExportVideoProfile* 3848f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh ChowduryMediaProfiles::createExportVideoProfile(const char **atts) 3858f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury{ 3868f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury CHECK(!strcmp("name", atts[0]) && 3878f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury !strcmp("profile", atts[2]) && 3888f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury !strcmp("level", atts[4])); 3898f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury 3908f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury const size_t nMappings = 3918f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury sizeof(sVideoEncoderNameMap)/sizeof(sVideoEncoderNameMap[0]); 3928f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury const int codec = findTagForName(sVideoEncoderNameMap, nMappings, atts[1]); 3938f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury CHECK(codec != -1); 3948f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury 3958f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury MediaProfiles::ExportVideoProfile *profile = 3968f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury new MediaProfiles::ExportVideoProfile( 3978f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury codec, atoi(atts[3]), atoi(atts[5])); 3980f056290cb16763453f18bbef80cde673041dbbcJames Dong 3998f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury return profile; 4008f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury} 401cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng/*static*/ MediaProfiles::VideoEditorCap* 402cabd5f867ec69c0dfe8333cba46323cb58917402Hong TengMediaProfiles::createVideoEditorCap(const char **atts, MediaProfiles *profiles) 403cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng{ 404cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng CHECK(!strcmp("maxInputFrameWidth", atts[0]) && 405cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng !strcmp("maxInputFrameHeight", atts[2]) && 406cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng !strcmp("maxOutputFrameWidth", atts[4]) && 407cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng !strcmp("maxOutputFrameHeight", atts[6])); 408cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng 409cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng MediaProfiles::VideoEditorCap *pVideoEditorCap = 410cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng new MediaProfiles::VideoEditorCap(atoi(atts[1]), atoi(atts[3]), 411cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng atoi(atts[5]), atoi(atts[7])); 412cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng 413cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng logVideoEditorCap(*pVideoEditorCap); 414cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng profiles->mVideoEditorCap = pVideoEditorCap; 415cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng 416cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng return pVideoEditorCap; 417cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng} 418cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng 4191d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 4201d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::startElementHandler(void *userData, const char *name, const char **atts) 4211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 4221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles *profiles = (MediaProfiles *) userData; 4231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (strcmp("Video", name) == 0) { 4241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong createVideoCodec(atts, profiles); 4251d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } else if (strcmp("Audio", name) == 0) { 4261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong createAudioCodec(atts, profiles); 4271d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } else if (strcmp("VideoEncoderCap", name) == 0 && 4281d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong strcmp("true", atts[3]) == 0) { 4291d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mVideoEncoders.add(createVideoEncoderCap(atts)); 4301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } else if (strcmp("AudioEncoderCap", name) == 0 && 4311d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong strcmp("true", atts[3]) == 0) { 4321d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mAudioEncoders.add(createAudioEncoderCap(atts)); 4331d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } else if (strcmp("VideoDecoderCap", name) == 0 && 4341d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong strcmp("true", atts[3]) == 0) { 4351d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mVideoDecoders.add(createVideoDecoderCap(atts)); 4361d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } else if (strcmp("AudioDecoderCap", name) == 0 && 4371d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong strcmp("true", atts[3]) == 0) { 4381d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mAudioDecoders.add(createAudioDecoderCap(atts)); 4391d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } else if (strcmp("EncoderOutputFileFormat", name) == 0) { 4401d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mEncoderOutputFileFormats.add(createEncoderOutputFileFormat(atts)); 4413eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang } else if (strcmp("CamcorderProfiles", name) == 0) { 4423eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang profiles->mCurrentCameraId = getCameraId(atts); 4430f056290cb16763453f18bbef80cde673041dbbcJames Dong profiles->addStartTimeOffset(profiles->mCurrentCameraId, atts); 4441d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } else if (strcmp("EncoderProfile", name) == 0) { 4453eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang profiles->mCamcorderProfiles.add( 4462a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong createCamcorderProfile(profiles->mCurrentCameraId, atts, profiles->mCameraIds)); 447f5a8385649204213dc19e1a64f4693931e048d85James Dong } else if (strcmp("ImageEncoding", name) == 0) { 4483eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang profiles->addImageEncodingQualityLevel(profiles->mCurrentCameraId, atts); 449cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng } else if (strcmp("VideoEditorCap", name) == 0) { 450cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng createVideoEditorCap(atts, profiles); 4518f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury } else if (strcmp("ExportVideoProfile", name) == 0) { 4528f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury profiles->mVideoEditorExportProfiles.add(createExportVideoProfile(atts)); 4531d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 4541d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 4551d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 4562a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dongstatic bool isCamcorderProfile(camcorder_quality quality) { 4572a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong return quality >= CAMCORDER_QUALITY_LIST_START && 4582a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong quality <= CAMCORDER_QUALITY_LIST_END; 4592a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong} 4602a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 4612a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dongstatic bool isTimelapseProfile(camcorder_quality quality) { 4622a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong return quality >= CAMCORDER_QUALITY_TIME_LAPSE_LIST_START && 4632a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong quality <= CAMCORDER_QUALITY_TIME_LAPSE_LIST_END; 4642a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong} 4652a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 4662a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dongvoid MediaProfiles::initRequiredProfileRefs(const Vector<int>& cameraIds) { 4673856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("Number of camera ids: %d", cameraIds.size()); 4682a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong CHECK(cameraIds.size() > 0); 4692a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong mRequiredProfileRefs = new RequiredProfiles[cameraIds.size()]; 4702a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong for (size_t i = 0, n = cameraIds.size(); i < n; ++i) { 4712a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong mRequiredProfileRefs[i].mCameraId = cameraIds[i]; 4722a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong for (size_t j = 0; j < kNumRequiredProfiles; ++j) { 4732a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong mRequiredProfileRefs[i].mRefs[j].mHasRefProfile = false; 4742a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong mRequiredProfileRefs[i].mRefs[j].mRefProfileIndex = -1; 4752a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong if ((j & 1) == 0) { // low resolution 4762a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong mRequiredProfileRefs[i].mRefs[j].mResolutionProduct = 0x7FFFFFFF; 4772a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } else { // high resolution 4782a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong mRequiredProfileRefs[i].mRefs[j].mResolutionProduct = 0; 4792a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 4802a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 4812a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 4822a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong} 4832a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 4842a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dongint MediaProfiles::getRequiredProfileRefIndex(int cameraId) { 4852a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong for (size_t i = 0, n = mCameraIds.size(); i < n; ++i) { 4862a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong if (mCameraIds[i] == cameraId) { 4872a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong return i; 4882a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 4892a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 4902a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong return -1; 4912a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong} 4922a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 4932a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dongvoid MediaProfiles::checkAndAddRequiredProfilesIfNecessary() { 4942a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong if (sIsInitialized) { 4952a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong return; 4962a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 4972a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 4982a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong initRequiredProfileRefs(mCameraIds); 4992a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 5002a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong for (size_t i = 0, n = mCamcorderProfiles.size(); i < n; ++i) { 5012a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong int product = mCamcorderProfiles[i]->mVideoCodec->mFrameWidth * 5022a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong mCamcorderProfiles[i]->mVideoCodec->mFrameHeight; 5032a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 5042a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong camcorder_quality quality = mCamcorderProfiles[i]->mQuality; 5052a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong int cameraId = mCamcorderProfiles[i]->mCameraId; 5062a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong int index = -1; 5072a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong int refIndex = getRequiredProfileRefIndex(cameraId); 5082a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong CHECK(refIndex != -1); 5092a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong RequiredProfileRefInfo *info; 5102a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong camcorder_quality refQuality; 5112a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong VideoCodec *codec = NULL; 5122a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 5132a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong // Check high and low from either camcorder profile or timelapse profile 5142a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong // but not both. Default, check camcorder profile 5152a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong size_t j = 0; 5162a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong size_t n = 2; 5172a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong if (isTimelapseProfile(quality)) { 5182a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong // Check timelapse profile instead. 5192a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong j = 2; 5202a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong n = kNumRequiredProfiles; 5212a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } else { 5222a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong // Must be camcorder profile. 5232a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong CHECK(isCamcorderProfile(quality)); 5242a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 5252a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong for (; j < n; ++j) { 5262a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong info = &(mRequiredProfileRefs[refIndex].mRefs[j]); 5272a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong if ((j % 2 == 0 && product > info->mResolutionProduct) || // low 5282a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong (j % 2 != 0 && product < info->mResolutionProduct)) { // high 5292a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong continue; 5302a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 5312a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong switch (j) { 5322a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong case 0: 5332a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong refQuality = CAMCORDER_QUALITY_LOW; 5342a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong break; 5352a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong case 1: 5362a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong refQuality = CAMCORDER_QUALITY_HIGH; 5372a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong break; 5382a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong case 2: 5392a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong refQuality = CAMCORDER_QUALITY_TIME_LAPSE_LOW; 5402a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong break; 5412a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong case 3: 5422a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong refQuality = CAMCORDER_QUALITY_TIME_LAPSE_HIGH; 5432a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong break; 5442a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong default: 5452a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong CHECK(!"Should never reach here"); 5462a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 5472a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 5482a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong if (!info->mHasRefProfile) { 5492a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong index = getCamcorderProfileIndex(cameraId, refQuality); 5502a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 5512a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong if (index == -1) { 5522a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong // New high or low quality profile is found. 5532a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong // Update its reference. 5542a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong info->mHasRefProfile = true; 5552a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong info->mRefProfileIndex = i; 5562a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong info->mResolutionProduct = product; 5572a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 5582a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 5592a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 5602a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 5612a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong for (size_t cameraId = 0; cameraId < mCameraIds.size(); ++cameraId) { 5622a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong for (size_t j = 0; j < kNumRequiredProfiles; ++j) { 5632a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong int refIndex = getRequiredProfileRefIndex(cameraId); 5642a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong CHECK(refIndex != -1); 5652a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong RequiredProfileRefInfo *info = 5662a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong &mRequiredProfileRefs[refIndex].mRefs[j]; 5672a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 5682a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong if (info->mHasRefProfile) { 5692a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 5702a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong CamcorderProfile *profile = 5712a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong new CamcorderProfile( 5722a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong *mCamcorderProfiles[info->mRefProfileIndex]); 5732a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 5742a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong // Overwrite the quality 5752a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong switch (j % kNumRequiredProfiles) { 5762a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong case 0: 5772a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong profile->mQuality = CAMCORDER_QUALITY_LOW; 5782a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong break; 5792a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong case 1: 5802a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong profile->mQuality = CAMCORDER_QUALITY_HIGH; 5812a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong break; 5822a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong case 2: 5832a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong profile->mQuality = CAMCORDER_QUALITY_TIME_LAPSE_LOW; 5842a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong break; 5852a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong case 3: 5862a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong profile->mQuality = CAMCORDER_QUALITY_TIME_LAPSE_HIGH; 5872a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong break; 5882a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong default: 5892a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong CHECK(!"Should never come here"); 5902a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 5912a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 5922a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong int index = getCamcorderProfileIndex(cameraId, profile->mQuality); 5932a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong if (index != -1) { 5943856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("Profile quality %d for camera %d already exists", 5952a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong profile->mQuality, cameraId); 5962a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong CHECK(index == refIndex); 5972a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong continue; 5982a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 5992a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 6002a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong // Insert the new profile 6013856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("Add a profile: quality %d=>%d for camera %d", 6022a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong mCamcorderProfiles[info->mRefProfileIndex]->mQuality, 6032a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong profile->mQuality, cameraId); 6042a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 6052a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong mCamcorderProfiles.add(profile); 6062a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 6072a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 6082a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong } 6092a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong} 6102a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong 6111d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles* 6121d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::getInstance() 6131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 6143856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("getInstance"); 6151d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong Mutex::Autolock lock(sLock); 6161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!sIsInitialized) { 6171d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong char value[PROPERTY_VALUE_MAX]; 6181d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (property_get("media.settings.xml", value, NULL) <= 0) { 6191d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const char *defaultXmlFile = "/etc/media_profiles.xml"; 6201d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong FILE *fp = fopen(defaultXmlFile, "r"); 6211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (fp == NULL) { 6221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong LOGW("could not find media config xml file"); 6231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong sInstance = createDefaultInstance(); 6241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } else { 6251d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong fclose(fp); // close the file first. 6261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong sInstance = createInstanceFromXmlFile(defaultXmlFile); 6271d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 6281d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } else { 6291d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong sInstance = createInstanceFromXmlFile(value); 6301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 6312a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong CHECK(sInstance != NULL); 6322a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong sInstance->checkAndAddRequiredProfilesIfNecessary(); 6332a7e0a1eb29306982fd77bdc64d324464a48a2b9James Dong sIsInitialized = true; 6341d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 6351d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 6361d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return sInstance; 6371d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 6381d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 6391d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::VideoEncoderCap* 6401d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createDefaultH263VideoEncoderCap() 6411d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 6421d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return new MediaProfiles::VideoEncoderCap( 6431d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong VIDEO_ENCODER_H263, 192000, 420000, 176, 352, 144, 288, 1, 20); 6441d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 6451d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 6461d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::VideoEncoderCap* 6471d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createDefaultM4vVideoEncoderCap() 6481d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 6491d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return new MediaProfiles::VideoEncoderCap( 6501d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong VIDEO_ENCODER_MPEG_4_SP, 192000, 420000, 176, 352, 144, 288, 1, 20); 6511d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 6521d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 6531d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 6541d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 6551d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createDefaultVideoEncoders(MediaProfiles *profiles) 6561d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 6571d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mVideoEncoders.add(createDefaultH263VideoEncoderCap()); 6581d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mVideoEncoders.add(createDefaultM4vVideoEncoderCap()); 6591d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 6601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 6611d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::CamcorderProfile* 662d5672bc7162fa49abf9bb5844195887e911aa7ceNipun KwatraMediaProfiles::createDefaultCamcorderTimeLapseQcifProfile(camcorder_quality quality) 663c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra{ 664c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra MediaProfiles::VideoCodec *videoCodec = 665d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra new MediaProfiles::VideoCodec(VIDEO_ENCODER_H263, 1000000, 176, 144, 20); 666c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra 667c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra AudioCodec *audioCodec = new AudioCodec(AUDIO_ENCODER_AMR_NB, 12200, 8000, 1); 668c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra CamcorderProfile *profile = new MediaProfiles::CamcorderProfile; 669c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra profile->mCameraId = 0; 670c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra profile->mFileFormat = OUTPUT_FORMAT_THREE_GPP; 671d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profile->mQuality = quality; 672c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra profile->mDuration = 60; 673c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra profile->mVideoCodec = videoCodec; 674c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra profile->mAudioCodec = audioCodec; 675c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra return profile; 676c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra} 677c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra 678c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra/*static*/ MediaProfiles::CamcorderProfile* 679d5672bc7162fa49abf9bb5844195887e911aa7ceNipun KwatraMediaProfiles::createDefaultCamcorderTimeLapse480pProfile(camcorder_quality quality) 680c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra{ 681c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra MediaProfiles::VideoCodec *videoCodec = 682d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra new MediaProfiles::VideoCodec(VIDEO_ENCODER_H263, 20000000, 720, 480, 20); 683c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra 684c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra AudioCodec *audioCodec = new AudioCodec(AUDIO_ENCODER_AMR_NB, 12200, 8000, 1); 685c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra CamcorderProfile *profile = new MediaProfiles::CamcorderProfile; 686c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra profile->mCameraId = 0; 687c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra profile->mFileFormat = OUTPUT_FORMAT_THREE_GPP; 688d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profile->mQuality = quality; 689c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra profile->mDuration = 60; 690c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra profile->mVideoCodec = videoCodec; 691c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra profile->mAudioCodec = audioCodec; 692c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra return profile; 693c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra} 694c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra 695d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra/*static*/ void 696d5672bc7162fa49abf9bb5844195887e911aa7ceNipun KwatraMediaProfiles::createDefaultCamcorderTimeLapseLowProfiles( 697d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile **lowTimeLapseProfile, 698d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile **lowSpecificTimeLapseProfile) { 699d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra *lowTimeLapseProfile = createDefaultCamcorderTimeLapseQcifProfile(CAMCORDER_QUALITY_TIME_LAPSE_LOW); 700d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra *lowSpecificTimeLapseProfile = createDefaultCamcorderTimeLapseQcifProfile(CAMCORDER_QUALITY_TIME_LAPSE_QCIF); 701d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra} 702d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra 703d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra/*static*/ void 704d5672bc7162fa49abf9bb5844195887e911aa7ceNipun KwatraMediaProfiles::createDefaultCamcorderTimeLapseHighProfiles( 705d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile **highTimeLapseProfile, 706d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile **highSpecificTimeLapseProfile) { 707d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra *highTimeLapseProfile = createDefaultCamcorderTimeLapse480pProfile(CAMCORDER_QUALITY_TIME_LAPSE_HIGH); 708d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra *highSpecificTimeLapseProfile = createDefaultCamcorderTimeLapse480pProfile(CAMCORDER_QUALITY_TIME_LAPSE_480P); 709d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra} 710d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra 711c0a84782589eececdfa7e723e8aa0e572d0d79f5Nipun Kwatra/*static*/ MediaProfiles::CamcorderProfile* 712d5672bc7162fa49abf9bb5844195887e911aa7ceNipun KwatraMediaProfiles::createDefaultCamcorderQcifProfile(camcorder_quality quality) 7131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 7141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles::VideoCodec *videoCodec = 715d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra new MediaProfiles::VideoCodec(VIDEO_ENCODER_H263, 192000, 176, 144, 20); 7161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 717d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::AudioCodec *audioCodec = 718d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra new MediaProfiles::AudioCodec(AUDIO_ENCODER_AMR_NB, 12200, 8000, 1); 719d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra 720d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile *profile = new MediaProfiles::CamcorderProfile; 7213eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang profile->mCameraId = 0; 7221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profile->mFileFormat = OUTPUT_FORMAT_THREE_GPP; 723d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profile->mQuality = quality; 724d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profile->mDuration = 30; 7251d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profile->mVideoCodec = videoCodec; 7261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profile->mAudioCodec = audioCodec; 7271d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return profile; 7281d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 7291d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 7301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::CamcorderProfile* 731d5672bc7162fa49abf9bb5844195887e911aa7ceNipun KwatraMediaProfiles::createDefaultCamcorderCifProfile(camcorder_quality quality) 7321d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 7331d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles::VideoCodec *videoCodec = 734d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra new MediaProfiles::VideoCodec(VIDEO_ENCODER_H263, 360000, 352, 288, 20); 7351d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 736d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra AudioCodec *audioCodec = new AudioCodec(AUDIO_ENCODER_AMR_NB, 12200, 8000, 1); 737d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra CamcorderProfile *profile = new MediaProfiles::CamcorderProfile; 7383eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang profile->mCameraId = 0; 7391d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profile->mFileFormat = OUTPUT_FORMAT_THREE_GPP; 740d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profile->mQuality = quality; 741d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profile->mDuration = 60; 7421d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profile->mVideoCodec = videoCodec; 7431d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profile->mAudioCodec = audioCodec; 7441d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return profile; 7451d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 7461d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 7471d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 748d5672bc7162fa49abf9bb5844195887e911aa7ceNipun KwatraMediaProfiles::createDefaultCamcorderLowProfiles( 749d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile **lowProfile, 750d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile **lowSpecificProfile) { 751d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra *lowProfile = createDefaultCamcorderQcifProfile(CAMCORDER_QUALITY_LOW); 752d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra *lowSpecificProfile = createDefaultCamcorderQcifProfile(CAMCORDER_QUALITY_QCIF); 753d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra} 754d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra 755d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra/*static*/ void 756d5672bc7162fa49abf9bb5844195887e911aa7ceNipun KwatraMediaProfiles::createDefaultCamcorderHighProfiles( 757d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile **highProfile, 758d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile **highSpecificProfile) { 759d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra *highProfile = createDefaultCamcorderCifProfile(CAMCORDER_QUALITY_HIGH); 760d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra *highSpecificProfile = createDefaultCamcorderCifProfile(CAMCORDER_QUALITY_CIF); 761d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra} 762d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra 763d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra/*static*/ void 7641d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createDefaultCamcorderProfiles(MediaProfiles *profiles) 7651d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 766d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra // low camcorder profiles. 767d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile *lowProfile, *lowSpecificProfile; 768d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra createDefaultCamcorderLowProfiles(&lowProfile, &lowSpecificProfile); 769d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profiles->mCamcorderProfiles.add(lowProfile); 770d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profiles->mCamcorderProfiles.add(lowSpecificProfile); 771d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra 772d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra // high camcorder profiles. 773d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile* highProfile, *highSpecificProfile; 774d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra createDefaultCamcorderHighProfiles(&highProfile, &highSpecificProfile); 775d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profiles->mCamcorderProfiles.add(highProfile); 776d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profiles->mCamcorderProfiles.add(highSpecificProfile); 777d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra 778d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra // low camcorder time lapse profiles. 779d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile *lowTimeLapseProfile, *lowSpecificTimeLapseProfile; 780d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra createDefaultCamcorderTimeLapseLowProfiles(&lowTimeLapseProfile, &lowSpecificTimeLapseProfile); 781d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profiles->mCamcorderProfiles.add(lowTimeLapseProfile); 782d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profiles->mCamcorderProfiles.add(lowSpecificTimeLapseProfile); 783d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra 784d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra // high camcorder time lapse profiles. 785d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra MediaProfiles::CamcorderProfile *highTimeLapseProfile, *highSpecificTimeLapseProfile; 786d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra createDefaultCamcorderTimeLapseHighProfiles(&highTimeLapseProfile, &highSpecificTimeLapseProfile); 787d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profiles->mCamcorderProfiles.add(highTimeLapseProfile); 788d5672bc7162fa49abf9bb5844195887e911aa7ceNipun Kwatra profiles->mCamcorderProfiles.add(highSpecificTimeLapseProfile); 7898031ec79eb657a0ae84325410578ea87f50eeb54James Dong 7908031ec79eb657a0ae84325410578ea87f50eeb54James Dong // For emulator and other legacy devices which does not have a 7918031ec79eb657a0ae84325410578ea87f50eeb54James Dong // media_profiles.xml file, We assume that the default camera id 7928031ec79eb657a0ae84325410578ea87f50eeb54James Dong // is 0 and that is the only camera available. 7938031ec79eb657a0ae84325410578ea87f50eeb54James Dong profiles->mCameraIds.push(0); 7941d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 7951d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 7961d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 7971d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createDefaultAudioEncoders(MediaProfiles *profiles) 7981d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 7991d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mAudioEncoders.add(createDefaultAmrNBEncoderCap()); 8001d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 8011d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 8021d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 8031d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createDefaultVideoDecoders(MediaProfiles *profiles) 8041d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 8051d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles::VideoDecoderCap *cap = 8061d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong new MediaProfiles::VideoDecoderCap(VIDEO_DECODER_WMV); 8071d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 8081d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mVideoDecoders.add(cap); 8091d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 8101d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 8111d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 8121d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createDefaultAudioDecoders(MediaProfiles *profiles) 8131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 8141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles::AudioDecoderCap *cap = 8151d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong new MediaProfiles::AudioDecoderCap(AUDIO_DECODER_WMA); 8161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 8171d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mAudioDecoders.add(cap); 8181d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 8191d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 8201d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ void 8211d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createDefaultEncoderOutputFileFormats(MediaProfiles *profiles) 8221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 8231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mEncoderOutputFileFormats.add(OUTPUT_FORMAT_THREE_GPP); 8241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles->mEncoderOutputFileFormats.add(OUTPUT_FORMAT_MPEG_4); 8251d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 8261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 8271d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles::AudioEncoderCap* 8281d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createDefaultAmrNBEncoderCap() 8291d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 8301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return new MediaProfiles::AudioEncoderCap( 8311d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong AUDIO_ENCODER_AMR_NB, 5525, 12200, 8000, 8000, 1, 1); 8321d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 8331d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 834f5a8385649204213dc19e1a64f4693931e048d85James Dong/*static*/ void 835f5a8385649204213dc19e1a64f4693931e048d85James DongMediaProfiles::createDefaultImageEncodingQualityLevels(MediaProfiles *profiles) 836f5a8385649204213dc19e1a64f4693931e048d85James Dong{ 8373eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang ImageEncodingQualityLevels *levels = new ImageEncodingQualityLevels(); 8383eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang levels->mCameraId = 0; 8393eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang levels->mLevels.add(70); 8403eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang levels->mLevels.add(80); 8413eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang levels->mLevels.add(90); 8423eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang profiles->mImageEncodingQualityLevels.add(levels); 843f5a8385649204213dc19e1a64f4693931e048d85James Dong} 844f5a8385649204213dc19e1a64f4693931e048d85James Dong 845cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng/*static*/ void 846cabd5f867ec69c0dfe8333cba46323cb58917402Hong TengMediaProfiles::createDefaultVideoEditorCap(MediaProfiles *profiles) 847cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng{ 848cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng profiles->mVideoEditorCap = 849cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng new MediaProfiles::VideoEditorCap( 850cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH, 851cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT, 852cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH, 853cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT); 854cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng} 8558f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury/*static*/ void 8568f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh ChowduryMediaProfiles::createDefaultExportVideoProfiles(MediaProfiles *profiles) 8578f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury{ 8588f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury // Create default video export profiles 8598f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury profiles->mVideoEditorExportProfiles.add( 8608f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury new ExportVideoProfile(VIDEO_ENCODER_H263, 8618f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10)); 8628f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury profiles->mVideoEditorExportProfiles.add( 8638f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury new ExportVideoProfile(VIDEO_ENCODER_MPEG_4_SP, 8648f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1)); 8658f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury profiles->mVideoEditorExportProfiles.add( 8668f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury new ExportVideoProfile(VIDEO_ENCODER_H264, 8678f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13)); 8688f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury} 869cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng 8701d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles* 8711d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createDefaultInstance() 8721d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 8731d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles *profiles = new MediaProfiles; 8741d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong createDefaultCamcorderProfiles(profiles); 8751d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong createDefaultVideoEncoders(profiles); 8761d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong createDefaultAudioEncoders(profiles); 8771d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong createDefaultVideoDecoders(profiles); 8781d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong createDefaultAudioDecoders(profiles); 8791d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong createDefaultEncoderOutputFileFormats(profiles); 880f5a8385649204213dc19e1a64f4693931e048d85James Dong createDefaultImageEncodingQualityLevels(profiles); 881cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng createDefaultVideoEditorCap(profiles); 8828f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury createDefaultExportVideoProfiles(profiles); 8831d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return profiles; 8841d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 8851d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 8861d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong/*static*/ MediaProfiles* 8871d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::createInstanceFromXmlFile(const char *xml) 8881d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 8891d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong FILE *fp = NULL; 8901d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK((fp = fopen(xml, "r"))); 8911d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 8921d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong XML_Parser parser = ::XML_ParserCreate(NULL); 8931d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(parser != NULL); 8941d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 8951d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong MediaProfiles *profiles = new MediaProfiles(); 8961d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ::XML_SetUserData(parser, profiles); 8971d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ::XML_SetElementHandler(parser, startElementHandler, NULL); 8981d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 8991d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong /* 9001d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong FIXME: 9011d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong expat is not compiled with -DXML_DTD. We don't have DTD parsing support. 9021d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9031d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!::XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS)) { 9041d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong LOGE("failed to enable DTD support in the xml file"); 9051d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return UNKNOWN_ERROR; 9061d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 9071d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9081d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong */ 9091d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9101d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong const int BUFF_SIZE = 512; 9111d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (;;) { 9121d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong void *buff = ::XML_GetBuffer(parser, BUFF_SIZE); 9131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (buff == NULL) { 9141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong LOGE("failed to in call to XML_GetBuffer()"); 9151d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong delete profiles; 9161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles = NULL; 9171d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong goto exit; 9181d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 9191d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9201d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong int bytes_read = ::fread(buff, 1, BUFF_SIZE, fp); 9211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (bytes_read < 0) { 9221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong LOGE("failed in call to read"); 9231d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong delete profiles; 9241d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong profiles = NULL; 9251d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong goto exit; 9261d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 9271d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9281d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK(::XML_ParseBuffer(parser, bytes_read, bytes_read == 0)); 9291d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (bytes_read == 0) break; // done parsing the xml file 9311d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 9321d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9331d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongexit: 9341d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ::XML_ParserFree(parser); 9351d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong ::fclose(fp); 9361d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return profiles; 9371d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 9381d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9391d7491b19516505e0754c66a3c8cd61811c9b6a6James DongVector<output_format> MediaProfiles::getOutputFileFormats() const 9401d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 9411d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return mEncoderOutputFileFormats; // copy out 9421d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 9431d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9441d7491b19516505e0754c66a3c8cd61811c9b6a6James DongVector<video_encoder> MediaProfiles::getVideoEncoders() const 9451d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 9461d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong Vector<video_encoder> encoders; 9471d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0; i < mVideoEncoders.size(); ++i) { 9481d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong encoders.add(mVideoEncoders[i]->mCodec); 9491d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 9501d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return encoders; // copy out 9511d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 9521d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9531d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongint MediaProfiles::getVideoEncoderParamByName(const char *name, video_encoder codec) const 9541d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 9553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("getVideoEncoderParamByName: %s for codec %d", name, codec); 9561d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong int index = -1; 9571d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0, n = mVideoEncoders.size(); i < n; ++i) { 9581d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (mVideoEncoders[i]->mCodec == codec) { 9591d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong index = i; 9601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong break; 9611d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 9621d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 9631d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (index == -1) { 9641d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong LOGE("The given video encoder %d is not found", codec); 9651d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return -1; 9661d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 9671d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9681d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.vid.width.min", name)) return mVideoEncoders[index]->mMinFrameWidth; 9691d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.vid.width.max", name)) return mVideoEncoders[index]->mMaxFrameWidth; 9701d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.vid.height.min", name)) return mVideoEncoders[index]->mMinFrameHeight; 9711d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.vid.height.max", name)) return mVideoEncoders[index]->mMaxFrameHeight; 9721d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.vid.bps.min", name)) return mVideoEncoders[index]->mMinBitRate; 9731d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.vid.bps.max", name)) return mVideoEncoders[index]->mMaxBitRate; 9741d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.vid.fps.min", name)) return mVideoEncoders[index]->mMinFrameRate; 9751d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.vid.fps.max", name)) return mVideoEncoders[index]->mMaxFrameRate; 9761d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 9771d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong LOGE("The given video encoder param name %s is not found", name); 9781d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return -1; 9791d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 9808f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowduryint MediaProfiles::getVideoEditorExportParamByName( 9818f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury const char *name, int codec) const 9828f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury{ 9833856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("getVideoEditorExportParamByName: name %s codec %d", name, codec); 9848f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury ExportVideoProfile *exportProfile = NULL; 9858f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury int index = -1; 9868f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury for (size_t i =0; i < mVideoEditorExportProfiles.size(); i++) { 9878f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury exportProfile = mVideoEditorExportProfiles[i]; 9888f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury if (exportProfile->mCodec == codec) { 9898f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury index = i; 9908f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury break; 9918f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury } 9928f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury } 9938f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury if (index == -1) { 9948f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury LOGE("The given video decoder %d is not found", codec); 9958f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury return -1; 9968f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury } 9978f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury if (!strcmp("videoeditor.export.profile", name)) 9988f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury return exportProfile->mProfile; 9998f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury if (!strcmp("videoeditor.export.level", name)) 10008f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury return exportProfile->mLevel; 10011d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 10028f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury LOGE("The given video editor export param name %s is not found", name); 10038f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury return -1; 10048f74b712fbf5c24de8bc799b7129dc802747a6f4Rajneesh Chowdury} 1005cabd5f867ec69c0dfe8333cba46323cb58917402Hong Tengint MediaProfiles::getVideoEditorCapParamByName(const char *name) const 1006cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng{ 10073856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("getVideoEditorCapParamByName: %s", name); 1008cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng 1009cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng if (mVideoEditorCap == NULL) { 1010cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng LOGE("The mVideoEditorCap is not created, then create default cap."); 1011cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng createDefaultVideoEditorCap(sInstance); 1012cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng } 1013cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng 1014cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng if (!strcmp("videoeditor.input.width.max", name)) 1015cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng return mVideoEditorCap->mMaxInputFrameWidth; 1016cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng if (!strcmp("videoeditor.input.height.max", name)) 1017cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng return mVideoEditorCap->mMaxInputFrameHeight; 1018cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng if (!strcmp("videoeditor.output.width.max", name)) 1019cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng return mVideoEditorCap->mMaxOutputFrameWidth; 1020cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng if (!strcmp("videoeditor.output.height.max", name)) 1021cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng return mVideoEditorCap->mMaxOutputFrameHeight; 1022cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng 1023cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng LOGE("The given video editor param name %s is not found", name); 1024cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng return -1; 1025cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng} 1026cabd5f867ec69c0dfe8333cba46323cb58917402Hong Teng 10271d7491b19516505e0754c66a3c8cd61811c9b6a6James DongVector<audio_encoder> MediaProfiles::getAudioEncoders() const 10281d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 10291d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong Vector<audio_encoder> encoders; 10301d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0; i < mAudioEncoders.size(); ++i) { 10311d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong encoders.add(mAudioEncoders[i]->mCodec); 10321d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 10331d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return encoders; // copy out 10341d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 10351d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 10361d7491b19516505e0754c66a3c8cd61811c9b6a6James Dongint MediaProfiles::getAudioEncoderParamByName(const char *name, audio_encoder codec) const 10371d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 10383856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("getAudioEncoderParamByName: %s for codec %d", name, codec); 10391d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong int index = -1; 10401d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0, n = mAudioEncoders.size(); i < n; ++i) { 10411d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (mAudioEncoders[i]->mCodec == codec) { 10421d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong index = i; 10431d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong break; 10441d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 10451d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 10461d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (index == -1) { 10471d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong LOGE("The given audio encoder %d is not found", codec); 10481d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return -1; 10491d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 10501d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 10511d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.aud.ch.min", name)) return mAudioEncoders[index]->mMinChannels; 10521d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.aud.ch.max", name)) return mAudioEncoders[index]->mMaxChannels; 10531d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.aud.bps.min", name)) return mAudioEncoders[index]->mMinBitRate; 10541d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.aud.bps.max", name)) return mAudioEncoders[index]->mMaxBitRate; 10551d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.aud.hz.min", name)) return mAudioEncoders[index]->mMinSampleRate; 10561d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("enc.aud.hz.max", name)) return mAudioEncoders[index]->mMaxSampleRate; 10571d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 10581d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong LOGE("The given audio encoder param name %s is not found", name); 10591d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return -1; 10601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 10611d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 10621d7491b19516505e0754c66a3c8cd61811c9b6a6James DongVector<video_decoder> MediaProfiles::getVideoDecoders() const 10631d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 10641d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong Vector<video_decoder> decoders; 10651d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0; i < mVideoDecoders.size(); ++i) { 10661d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong decoders.add(mVideoDecoders[i]->mCodec); 10671d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 10681d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return decoders; // copy out 10691d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 10701d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 10711d7491b19516505e0754c66a3c8cd61811c9b6a6James DongVector<audio_decoder> MediaProfiles::getAudioDecoders() const 10721d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 10731d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong Vector<audio_decoder> decoders; 10741d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0; i < mAudioDecoders.size(); ++i) { 10751d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong decoders.add(mAudioDecoders[i]->mCodec); 10761d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 10771d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return decoders; // copy out 10781d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 10791d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 10808bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatraint MediaProfiles::getCamcorderProfileIndex(int cameraId, camcorder_quality quality) const 10811d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 10821d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong int index = -1; 10831d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0, n = mCamcorderProfiles.size(); i < n; ++i) { 10843eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang if (mCamcorderProfiles[i]->mCameraId == cameraId && 10853eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang mCamcorderProfiles[i]->mQuality == quality) { 10861d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong index = i; 10871d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong break; 10881d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 10891d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 10908bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra return index; 10918bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra} 10928bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra 10938bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatraint MediaProfiles::getCamcorderProfileParamByName(const char *name, 10948bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra int cameraId, 10958bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra camcorder_quality quality) const 10968bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra{ 10973856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("getCamcorderProfileParamByName: %s for camera %d, quality %d", 10988bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra name, cameraId, quality); 10998bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra 11008bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra int index = getCamcorderProfileIndex(cameraId, quality); 11011d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (index == -1) { 11023eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang LOGE("The given camcorder profile camera %d quality %d is not found", 11033eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang cameraId, quality); 11041d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return -1; 11051d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 11061d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 1107f5a8385649204213dc19e1a64f4693931e048d85James Dong if (!strcmp("duration", name)) return mCamcorderProfiles[index]->mDuration; 11081d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("file.format", name)) return mCamcorderProfiles[index]->mFileFormat; 11091d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("vid.codec", name)) return mCamcorderProfiles[index]->mVideoCodec->mCodec; 11101d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("vid.width", name)) return mCamcorderProfiles[index]->mVideoCodec->mFrameWidth; 11111d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("vid.height", name)) return mCamcorderProfiles[index]->mVideoCodec->mFrameHeight; 11121d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("vid.bps", name)) return mCamcorderProfiles[index]->mVideoCodec->mBitRate; 11131d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("vid.fps", name)) return mCamcorderProfiles[index]->mVideoCodec->mFrameRate; 11141d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("aud.codec", name)) return mCamcorderProfiles[index]->mAudioCodec->mCodec; 11151d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("aud.bps", name)) return mCamcorderProfiles[index]->mAudioCodec->mBitRate; 11161d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("aud.ch", name)) return mCamcorderProfiles[index]->mAudioCodec->mChannels; 11171d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong if (!strcmp("aud.hz", name)) return mCamcorderProfiles[index]->mAudioCodec->mSampleRate; 11181d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 11193eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang LOGE("The given camcorder profile param id %d name %s is not found", cameraId, name); 11201d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong return -1; 11211d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 11221d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 11238bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatrabool MediaProfiles::hasCamcorderProfile(int cameraId, camcorder_quality quality) const 11248bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra{ 11258bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra return (getCamcorderProfileIndex(cameraId, quality) != -1); 11268bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra} 11278bb5603cc735315c8691dc9b7a81b4ad4d6e253eNipun Kwatra 11283eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung ChangVector<int> MediaProfiles::getImageEncodingQualityLevels(int cameraId) const 1129f5a8385649204213dc19e1a64f4693931e048d85James Dong{ 11303eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang Vector<int> result; 11313eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang ImageEncodingQualityLevels *levels = findImageEncodingQualityLevels(cameraId); 11323eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang if (levels != NULL) { 11333eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang result = levels->mLevels; // copy out 11343eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang } 11353eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0Chih-Chung Chang return result; 1136f5a8385649204213dc19e1a64f4693931e048d85James Dong} 1137f5a8385649204213dc19e1a64f4693931e048d85James Dong 11380f056290cb16763453f18bbef80cde673041dbbcJames Dongint MediaProfiles::getStartTimeOffsetMs(int cameraId) const { 11390f056290cb16763453f18bbef80cde673041dbbcJames Dong int offsetTimeMs = -1; 11400f056290cb16763453f18bbef80cde673041dbbcJames Dong ssize_t index = mStartTimeOffsets.indexOfKey(cameraId); 11410f056290cb16763453f18bbef80cde673041dbbcJames Dong if (index >= 0) { 11420f056290cb16763453f18bbef80cde673041dbbcJames Dong offsetTimeMs = mStartTimeOffsets.valueFor(cameraId); 11430f056290cb16763453f18bbef80cde673041dbbcJames Dong } 11443856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("offsetTime=%d ms and cameraId=%d", offsetTimeMs, cameraId); 11450f056290cb16763453f18bbef80cde673041dbbcJames Dong return offsetTimeMs; 11460f056290cb16763453f18bbef80cde673041dbbcJames Dong} 11470f056290cb16763453f18bbef80cde673041dbbcJames Dong 11481d7491b19516505e0754c66a3c8cd61811c9b6a6James DongMediaProfiles::~MediaProfiles() 11491d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong{ 11501d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong CHECK("destructor should never be called" == 0); 11511d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#if 0 11521d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0; i < mAudioEncoders.size(); ++i) { 11531d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong delete mAudioEncoders[i]; 11541d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 11551d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong mAudioEncoders.clear(); 11561d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 11571d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0; i < mVideoEncoders.size(); ++i) { 11581d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong delete mVideoEncoders[i]; 11591d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 11601d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong mVideoEncoders.clear(); 11611d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 11621d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0; i < mVideoDecoders.size(); ++i) { 11631d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong delete mVideoDecoders[i]; 11641d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 11651d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong mVideoDecoders.clear(); 11661d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 11671d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0; i < mAudioDecoders.size(); ++i) { 11681d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong delete mAudioDecoders[i]; 11691d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 11701d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong mAudioDecoders.clear(); 11711d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong 11721d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong for (size_t i = 0; i < mCamcorderProfiles.size(); ++i) { 11731d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong delete mCamcorderProfiles[i]; 11741d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong } 11751d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong mCamcorderProfiles.clear(); 11761d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong#endif 11771d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} 11781d7491b19516505e0754c66a3c8cd61811c9b6a6James Dong} // namespace android 1179