--- a/camerauis/cameraxui/cxengine/src/cxesettingsmappersymbian.cpp Thu Jul 15 01:55:05 2010 +0300
+++ b/camerauis/cameraxui/cxengine/src/cxesettingsmappersymbian.cpp Fri Jul 23 11:35:41 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
@@ -14,10 +14,8 @@
* Description:
*
*/
-/*
-* Symbian specific settings handling
-*/
+#include <QRegExp>
#include <ecamadvsettingsuids.hrh>
#include "cxeautofocuscontrol.h"
@@ -27,149 +25,279 @@
using namespace Cxe;
-/*
-* Map White balance UI value to its corresponding CCamera value
+
+
+/*!
+ Map Cxe::Whitebalance value to its corresponding CCamera value.
*/
+CCamera::TWhiteBalance CxeSettingsMapperSymbian::Map2CameraWb(
+ Cxe::Whitebalance whiteBalance )
+{
+ CCamera::TWhiteBalance wb(CCamera::EWBAuto);
-CCamera::TWhiteBalance
-CxeSettingsMapperSymbian::Map2CameraWb(int wbId )
+ switch (whiteBalance) {
+ case WhitebalanceSunny:
+ wb = CCamera::EWBDaylight;
+ break;
+ case WhitebalanceCloudy:
+ wb = CCamera::EWBCloudy;
+ break;
+ case WhitebalanceIncandescent:
+ wb = CCamera::EWBTungsten;
+ break;
+ case WhitebalanceFluorescent:
+ wb = CCamera::EWBFluorescent;
+ break;
+ case WhitebalanceAutomatic:
+ default:
+ wb = CCamera::EWBAuto;
+ break;
+ }
+ return wb;
+}
+
+
+/*!
+ Map Cxe::FlashMode to its corresponding CCamera value.
+*/
+CCamera::TFlash CxeSettingsMapperSymbian::Map2CameraFlash(
+ Cxe::FlashMode flashMode)
+{
+ CCamera::TFlash flash(CCamera::EFlashAuto);
+
+ switch (flashMode) {
+ case FlashAntiRedEye:
+ flash = CCamera::EFlashRedEyeReduce;
+ break;
+ case FlashOn:
+ flash = CCamera::EFlashForced;
+ break;
+ case FlashOff:
+ flash = CCamera::EFlashNone;
+ break;
+ case FlashAuto:
+ default:
+ flash = CCamera::EFlashAuto;
+ break;
+ }
+ return flash;
+}
+
+
+/*!
+ Map Cxe::ExposureMode to its corresponding CCamera value.
+*/
+CCamera::TExposure CxeSettingsMapperSymbian::Map2CameraExposureMode(
+ Cxe::ExposureMode exposureMode)
{
- CCamera::TWhiteBalance wb( CCamera::EWBAuto );
- switch(wbId) {
- case WhitebalanceAutomatic: wb = CCamera::EWBAuto; break;
- case WhitebalanceSunny: wb = CCamera::EWBDaylight; break;
- case WhitebalanceCloudy: wb = CCamera::EWBCloudy; break;
- case WhitebalanceIncandescent: wb = CCamera::EWBTungsten; break;
- case WhitebalanceFluorescent: wb = CCamera::EWBFluorescent; break;
- default:
- break;
- }
- return wb;
+ CCamera::TExposure expo(CCamera::EExposureAuto);
+
+ switch (exposureMode) {
+ case ExposureNight:
+ expo = CCamera::EExposureNight;
+ break;
+ case ExposureBacklight:
+ expo = CCamera::EExposureBacklight;
+ break;
+ case ExposureSport:
+ expo = CCamera::EExposureSport;
+ break;
+ case ExposureAuto:
+ default:
+ expo = CCamera::EExposureAuto;
+ break;
+ }
+
+ return expo;
+}
+
+
+/*!
+ Map Cxe::ExposureMode to its corresponding CCamera value.
+*/
+CCamera::CCameraImageProcessing::TEffect
+ CxeSettingsMapperSymbian::Map2CameraEffect(Cxe::Colortone colorTone)
+{
+ CCamera::CCameraImageProcessing::TEffect effect(
+ CCamera::CCameraImageProcessing::EEffectNone);
+
+ switch(colorTone) {
+ case ColortoneBlackAndWhite:
+ effect = CCamera::CCameraImageProcessing::EEffectMonochrome;
+ break;
+ case ColortoneSepia:
+ effect = CCamera::CCameraImageProcessing::EEffectSepia;
+ break;
+ case ColortoneNegative:
+ effect = CCamera::CCameraImageProcessing::EEffectNegative;
+ break;
+ case ColortoneVivid:
+ effect = CCamera::CCameraImageProcessing::EEffectVivid;
+ break;
+ case ColortoneNormal:
+ default:
+ effect = CCamera::CCameraImageProcessing::EEffectNone;
+ break;
+ }
+ return effect;
+}
+
+/*!
+ Map CxeAutoFocusControl::Mode to its corresponding CCamera value.
+*/
+CCamera::CCameraAdvancedSettings::TFocusRange
+CxeSettingsMapperSymbian::Map2CameraAutofocus(CxeAutoFocusControl::Mode afMode)
+{
+ CCamera::CCameraAdvancedSettings::TFocusRange value;
+
+ switch (afMode) {
+ case CxeAutoFocusControl::Macro:
+ value = CCamera::CCameraAdvancedSettings::EFocusRangeMacro;
+ break;
+ case CxeAutoFocusControl::Portrait:
+ value = CCamera::CCameraAdvancedSettings::EFocusRangeAuto;
+ break;
+ case CxeAutoFocusControl::Infinity:
+ value = CCamera::CCameraAdvancedSettings::EFocusRangeInfinite;
+ break;
+ case CxeAutoFocusControl::Hyperfocal:
+ value = CCamera::CCameraAdvancedSettings::EFocusRangeHyperfocal;
+ break;
+ case CxeAutoFocusControl::Auto: // Fall through
+ default:
+ value = CCamera::CCameraAdvancedSettings::EFocusRangeAuto;
+ break;
+ }
+ return value;
}
-// Map2CameraFlash
-
-CCamera::TFlash
-CxeSettingsMapperSymbian::Map2CameraFlash(int flashId)
+/*!
+ Map Cxe::DeviceOrientation to MCameraOrientation.
+*/
+MCameraOrientation::TOrientation
+ CxeSettingsMapperSymbian::Map2CameraOrientation(Cxe::DeviceOrientation
+ uiOrientation)
{
- CCamera::TFlash flash( CCamera::EFlashAuto );
- switch (flashId) {
- case FlashAuto: flash = CCamera::EFlashAuto; break;
- case FlashAntiRedEye: flash = CCamera::EFlashRedEyeReduce; break;
- case FlashOn: flash = CCamera::EFlashForced; break;
- case FlashOff: flash = CCamera::EFlashNone; break;
- default:
- break;
- }
- return flash;
+ MCameraOrientation::TOrientation cameraOrientation;
+
+ switch (uiOrientation) {
+ case Orientation90:
+ cameraOrientation = MCameraOrientation::EOrientation90;
+ break;
+ case Orientation180:
+ cameraOrientation = MCameraOrientation::EOrientation180;
+ break;
+ case Orientation270:
+ cameraOrientation = MCameraOrientation::EOrientation270;
+ break;
+ case Orientation0: // default
+ default:
+ cameraOrientation = MCameraOrientation::EOrientation0;
+ break;
+ }
+ return cameraOrientation;
}
-
-// ---------------------------------------------------------------------------
-// Map2CameraExposureMode
-// ---------------------------------------------------------------------------
-//
-CCamera::TExposure
-CxeSettingsMapperSymbian::Map2CameraExposureMode(int expModeId )
- {
- CCamera::TExposure expo( CCamera::EExposureAuto );
-
- switch ( expModeId )
+/*!
+ Helper data structure to define how MIME types are mapped to
+ MCameraUseCaseHint enumerations.
+*/
+class CxeCodecMapping
+{
+public:
+ CxeCodecMapping(const char *regexp, MCameraUseCaseHint::TVideoCodec codec,
+ MCameraUseCaseHint::TVideoProfile profile) :
+ mRegExp(regexp),
+ mCodec(codec),
+ mProfile(profile)
{
- case ExposureAuto: expo = CCamera::EExposureAuto; break;
- case ExposureNight: expo = CCamera::EExposureNight; break;
- case ExposureBacklight: expo = CCamera::EExposureBacklight; break;
- case ExposureSport: expo = CCamera::EExposureSport; break;
- default:
- break;
+ // No implementation needed
}
- return expo;
- }
-
-
-
+public:
+ QString mRegExp;
+ MCameraUseCaseHint::TVideoCodec mCodec;
+ MCameraUseCaseHint::TVideoProfile mProfile;
+};
-// ---------------------------------------------------------------------------
-// Map2CameraEffect
-// ---------------------------------------------------------------------------
-//
-CCamera::CCameraImageProcessing::TEffect
-CxeSettingsMapperSymbian::Map2CameraEffect(int colourFilterId)
- {
- CCamera::CCameraImageProcessing::TEffect effect(
- CCamera::CCameraImageProcessing::EEffectNone );
+/*!
+ Map video codec MIME type from ICM to enumerations used by the
+ MCameraUseCaseHint custom interface
- switch( colourFilterId )
- {
- case ColortoneNormal: effect = CCamera::CCameraImageProcessing::EEffectNone; break;
- case ColortoneBlackAndWhite: effect = CCamera::CCameraImageProcessing::EEffectMonochrome; break;
- case ColortoneSepia: effect = CCamera::CCameraImageProcessing::EEffectSepia; break;
- case ColortoneNegative: effect = CCamera::CCameraImageProcessing::EEffectNegative; break;
- case ColortoneVivid: effect = CCamera::CCameraImageProcessing::EEffectVivid; break;
- default:
- break;
- }
- return effect;
- }
-
-
-
-// ---------------------------------------------------------------------------
-// CxeSettingsMapperSymbian::Map2CameraAutofocus
-// ---------------------------------------------------------------------------
-//
-CCamera::CCameraAdvancedSettings::TFocusRange
-CxeSettingsMapperSymbian::Map2CameraAutofocus(CxeAutoFocusControl::Mode afMode )
+ \param[in] videoDetails CxeVideoDetails defining the current video quality.
+ \param[out] codec Reference where to store the video codec info.
+ MCameraUseCaseHint::ECodecUnknown if not known.
+ \param[out] profile Reference where to store the video profile info.
+ MCameraUseCaseHint::EProfileUnknown if not known.
+*/
+void CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(
+ const CxeVideoDetails &videoDetails,
+ MCameraUseCaseHint::TVideoCodec &codec,
+ MCameraUseCaseHint::TVideoProfile &profile)
{
- CCamera::CCameraAdvancedSettings::TFocusRange value;
- switch( afMode ) {
- case CxeAutoFocusControl::Macro:
- value = CCamera::CCameraAdvancedSettings::EFocusRangeMacro;
- break;
- case CxeAutoFocusControl::Portrait:
- value = CCamera::CCameraAdvancedSettings::EFocusRangeAuto;
- break;
- case CxeAutoFocusControl::Infinity:
- value = CCamera::CCameraAdvancedSettings::EFocusRangeInfinite;
- break;
- case CxeAutoFocusControl::Hyperfocal:
- value = CCamera::CCameraAdvancedSettings::EFocusRangeHyperfocal;
- break;
- case CxeAutoFocusControl::Auto: // Fall through
- default:
- value = CCamera::CCameraAdvancedSettings::EFocusRangeAuto;
- break;
- }
- return value;
-}
+ typedef QPair<MCameraUseCaseHint::TVideoCodec,
+ MCameraUseCaseHint::TVideoProfile> CxeCodecAndProfile;
+
+ codec = MCameraUseCaseHint::ECodecUnknown;
+ profile = MCameraUseCaseHint::EProfileUnknown;
+
+ // Create a mapping table for mapping from the MIME type string
+ // to MCameraUseCaseHint codec and profile enums using QRegExp. Specific
+ // rules should be before more generic ones because the map is iterated in
+ // order.
+ QList<CxeCodecMapping> mappingTable;
+ mappingTable << CxeCodecMapping("^video/H263-2000",
+ MCameraUseCaseHint::ECodecH263,
+ MCameraUseCaseHint::EProfileH263P0L10)
+
+ << CxeCodecMapping("^video/H264.*profile-level-id=42801E",
+ MCameraUseCaseHint::ECodecH264,
+ MCameraUseCaseHint::EProfileH264BpL3)
+
+ << CxeCodecMapping("^video/H264.*profile-level-id=42801F",
+ MCameraUseCaseHint::ECodecH264,
+ MCameraUseCaseHint::EProfileH264BpL3_1)
+
+ << CxeCodecMapping("^video/H264", // Other H.264 profile
+ MCameraUseCaseHint::ECodecH264,
+ MCameraUseCaseHint::EProfileUnknown)
+ << CxeCodecMapping("^video/mp4v-es.*profile-level-id=2",
+ MCameraUseCaseHint::ECodecMpeg4,
+ MCameraUseCaseHint::EProfileMPEG4SpL2)
-// CxeSettingsMapperSymbian::Map2CameraOrientation
+ << CxeCodecMapping("^video/mp4v-es.*profile-level-id=3",
+ MCameraUseCaseHint::ECodecMpeg4,
+ MCameraUseCaseHint::EProfileMPEG4SpL3)
+
+ << CxeCodecMapping("^video/mp4v-es.*profile-level-id=4",
+ MCameraUseCaseHint::ECodecMpeg4,
+ MCameraUseCaseHint::EProfileMPEG4SpL4a)
+
+ << CxeCodecMapping("^video/mp4v-es", // Other MPEG-4 profile
+ MCameraUseCaseHint::ECodecMpeg4,
+ MCameraUseCaseHint::EProfileUnknown);
-MCameraOrientation::TOrientation
-CxeSettingsMapperSymbian::Map2CameraOrientation(DeviceOrientation uiOrientation)
-{
- MCameraOrientation::TOrientation cameraOrientation;
- switch(uiOrientation) {
- case Orientation90:
- cameraOrientation = MCameraOrientation::EOrientation90;
- break;
- case Orientation180:
- cameraOrientation = MCameraOrientation::EOrientation180;
- break;
- case Orientation270:
- cameraOrientation = MCameraOrientation::EOrientation270;
- break;
- case Orientation0: // default
- default:
- cameraOrientation = MCameraOrientation::EOrientation0;
- break;
+ bool found = false;
+ for (int i = 0; i < mappingTable.count() && !found; i++) {
+ QRegExp regExp(mappingTable[i].mRegExp, Qt::CaseInsensitive);
+ if (regExp.indexIn(videoDetails.mVideoCodecMimeType) >= 0) {
+ found = true;
+ codec = mappingTable[i].mCodec;
+ profile = mappingTable[i].mProfile;
+
+ CX_DEBUG(("Matched codec %d, profile 0x%x for '%s'", codec, profile,
+ videoDetails.mVideoCodecMimeType.toAscii().constData()));
+ }
}
- return cameraOrientation;
+
+ if (!found) {
+ CX_DEBUG(("No codec/profile found for '%s'",
+ videoDetails.mVideoCodecMimeType.toAscii().constData()));
+ }
}
// end of file