camerauis/cameraxui/cxengine/src/cxesettingscontrolsymbian.cpp
branchRCL_3
changeset 24 bac7acad7cb3
parent 23 61bc0f252b2b
child 25 2c87b2808fd7
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
     1 /*
       
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <ecam.h>
       
    19 #include <ecamadvsettings.h>
       
    20 #include <ecamimageprocessing.h>
       
    21 #include <ecam/ecamconstants.h>
       
    22 #include <ecamfacetrackingcustomapi.h>
       
    23 
       
    24 #include <QString>
       
    25 #include <QVariant>
       
    26 
       
    27 #include "cxutils.h"
       
    28 #include "cxenamespace.h"
       
    29 #include "cxecameradevice.h"
       
    30 #include "cxesettings.h"
       
    31 #include "cxesettingsmappersymbian.h"
       
    32 #include "cxesettingscontrolsymbian.h"
       
    33 
       
    34 #include "OstTraceDefinitions.h"
       
    35 #ifdef OST_TRACE_COMPILER_IN_USE
       
    36 #include "cxesettingscontrolsymbianTraces.h"
       
    37 #endif
       
    38 
       
    39 
       
    40 /*!
       
    41 * Constructor
       
    42 */
       
    43 CxeSettingsControlSymbian::CxeSettingsControlSymbian(
       
    44         CxeCameraDevice &cameraDevice, CxeSettings &settings)
       
    45     : mCameraDevice(cameraDevice),
       
    46       mSettings(settings)
       
    47 {
       
    48     // connect scene / setting change callbacks to settings control
       
    49     connect(&mSettings,
       
    50             SIGNAL(settingValueChanged(const QString&,QVariant)),
       
    51             this,
       
    52             SLOT(handleSettingValueChanged(const QString&,QVariant)));
       
    53 
       
    54     mSettings.listenForSetting(CxeSettingIds::IMAGE_SCENE_DATA, this, SLOT(handleSceneChanged(const QVariant&)));
       
    55     mSettings.listenForSetting(CxeSettingIds::VIDEO_SCENE_DATA, this, SLOT(handleSceneChanged(const QVariant&)));
       
    56 
       
    57 }
       
    58 
       
    59 /*!
       
    60 * Destructor
       
    61 */
       
    62 CxeSettingsControlSymbian::~CxeSettingsControlSymbian()
       
    63 {
       
    64 }
       
    65 
       
    66 /*!
       
    67 * Handle new setting value.
       
    68 * New value is set to camera.
       
    69 * \param settingId The id of the updated setting
       
    70 * \param newValue A new value for the updated setting
       
    71 */
       
    72 void CxeSettingsControlSymbian::handleSettingValueChanged(
       
    73         const QString &settingId, QVariant newValue)
       
    74 {
       
    75     CX_DEBUG_ENTER_FUNCTION();
       
    76     if (settingId == CxeSettingIds::COLOR_TONE) {
       
    77         updateColorToneSetting(newValue);
       
    78     } else if (settingId == CxeSettingIds::WHITE_BALANCE) {
       
    79         updateWhiteBalanceSetting(newValue);
       
    80     } else if (settingId == CxeSettingIds::LIGHT_SENSITIVITY) {
       
    81             updateLightSensitivitySetting(newValue);
       
    82     } else if (settingId == CxeSettingIds::SHARPNESS) {
       
    83         updateSharpnessSetting(newValue);
       
    84     } else if (settingId == CxeSettingIds::CONTRAST) {
       
    85         updateContrastSetting(newValue);
       
    86     } else if (settingId == CxeSettingIds::BRIGHTNESS) {
       
    87         updateBrightnessSetting(newValue);
       
    88     } else if (settingId == CxeSettingIds::EXPOSURE_MODE) {
       
    89         updateExposureModeSetting(newValue);
       
    90     } else if (settingId == CxeSettingIds::EV_COMPENSATION_VALUE) {
       
    91             updateExposureCompensationSetting(newValue);
       
    92     } else if (settingId == CxeSettingIds::FACE_TRACKING) {
       
    93             updateFaceTrackingSetting(newValue);
       
    94     } else {
       
    95         // do nothing
       
    96     }
       
    97 
       
    98     // Image mode specific
       
    99     if (settingId == CxeSettingIds::FLASH_MODE) {
       
   100         updateFlashSetting(newValue);
       
   101     }
       
   102     CX_DEBUG_EXIT_FUNCTION();
       
   103 }
       
   104 
       
   105 /*!
       
   106 * Handle new scene being set.
       
   107 * Scene settings are checked and new values are set to camera.
       
   108 * \param scene New scene containing scene specific settings.
       
   109 */
       
   110 void CxeSettingsControlSymbian::handleSceneChanged(const QVariant &sceneData)
       
   111 {
       
   112     CX_DEBUG_ENTER_FUNCTION();
       
   113 
       
   114     CxeScene scene = sceneData.value<CxeScene>();
       
   115     OstTrace0(camerax_performance, CXESETTINGSCONTROL_SCENE_1, "msg: e_CX_SCENE_SETTINGS_TO_CAMERA 1");
       
   116 
       
   117     CX_DEBUG(("CxeSettingsControlSymbian <> new scene [%s]",
       
   118               scene[CxeSettingIds::SCENE_ID].value<QString>().toAscii().constData()));
       
   119 
       
   120     foreach (const QString& settingId, scene.keys()) {
       
   121         handleSettingValueChanged(settingId, scene[settingId]);
       
   122     }
       
   123 
       
   124     OstTrace0(camerax_performance, CXESETTINGSCONTROL_SCENE_2, "msg: e_CX_SCENE_SETTINGS_TO_CAMERA 0");
       
   125     CX_DEBUG_EXIT_FUNCTION();
       
   126 }
       
   127 
       
   128 /*!
       
   129 * Update color tone setting value to the camera device
       
   130 * \param newValue A new value for the updated setting
       
   131 */
       
   132 void CxeSettingsControlSymbian::updateColorToneSetting(QVariant newValue)
       
   133 {
       
   134     CX_DEBUG_ENTER_FUNCTION();
       
   135 
       
   136 //! @todo: Should be fixed in Dummy engine
       
   137 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA)
       
   138 
       
   139     CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor());
       
   140 
       
   141     CCamera::CCameraImageProcessing::TEffect effect =
       
   142             CxeSettingsMapperSymbian::Map2CameraEffect(
       
   143                     static_cast<Cxe::Colortone>(newValue.toInt()));
       
   144 
       
   145     mCameraDevice.imageProcessor()->SetTransformationValue(
       
   146             KUidECamEventImageProcessingEffect, effect);
       
   147 
       
   148 #else
       
   149     Q_UNUSED(newValue)
       
   150 #endif
       
   151 
       
   152     CX_DEBUG_EXIT_FUNCTION();
       
   153 }
       
   154 
       
   155 /*!
       
   156 * Update white balance setting value to the camera device
       
   157 * \param newValue A new value for the updated setting
       
   158 */
       
   159 void CxeSettingsControlSymbian::updateWhiteBalanceSetting(QVariant newValue)
       
   160 {
       
   161     CX_DEBUG_ENTER_FUNCTION();
       
   162     CX_DEBUG_ASSERT(mCameraDevice.camera());
       
   163 
       
   164     CCamera::TWhiteBalance wb = CxeSettingsMapperSymbian::Map2CameraWb(
       
   165             static_cast<Cxe::Whitebalance>(newValue.toInt()));
       
   166 
       
   167     TRAP_IGNORE(mCameraDevice.camera()->SetWhiteBalanceL(wb));
       
   168 
       
   169     CX_DEBUG_EXIT_FUNCTION();
       
   170 }
       
   171 
       
   172 /*!
       
   173 * Update light sensitivity (ISO) setting value to the camera device
       
   174 * \param newValue A new value for the updated setting
       
   175 */
       
   176 void CxeSettingsControlSymbian::updateLightSensitivitySetting(QVariant newValue)
       
   177 {
       
   178     CX_DEBUG_ENTER_FUNCTION();
       
   179     CX_ASSERT_ALWAYS(mCameraDevice.advancedSettings());
       
   180 
       
   181     int iso = newValue.toInt();
       
   182 
       
   183     CCamera::CCameraAdvancedSettings::TISORateType type;
       
   184     if (iso == 0) {
       
   185         // Automatic ISO rate
       
   186         type = CCamera::CCameraAdvancedSettings::EISOAutoUnPrioritised;
       
   187     } else {
       
   188         // Manual ISO rate
       
   189         type = CCamera::CCameraAdvancedSettings::EISOManual;
       
   190     }
       
   191     TRAP_IGNORE(mCameraDevice.advancedSettings()->SetISORateL(type, iso));
       
   192 
       
   193     CX_DEBUG_EXIT_FUNCTION();
       
   194 }
       
   195 
       
   196 /*!
       
   197 * Update sharpness setting value to the camera device
       
   198 * \param newValue A new value for the updated setting
       
   199 */
       
   200 void CxeSettingsControlSymbian::updateSharpnessSetting(QVariant newValue)
       
   201 {
       
   202     CX_DEBUG_ENTER_FUNCTION();
       
   203 
       
   204 //! @todo: Should be fixed in Dummy engine
       
   205 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA)
       
   206 
       
   207     CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor());
       
   208 
       
   209     // Scale UI values of -2..2 to ECAM range -100..100.
       
   210     int newSharpness = newValue.toReal() * 50;
       
   211 
       
   212     CX_DEBUG(("Setting sharpness [uid:0x%08x] to value [%d]",
       
   213               KUidECamEventImageProcessingAdjustSharpness, newSharpness));
       
   214     mCameraDevice.imageProcessor()->SetTransformationValue(
       
   215             KUidECamEventImageProcessingAdjustSharpness, newSharpness);
       
   216 
       
   217 #else
       
   218     Q_UNUSED(newValue)
       
   219 #endif
       
   220 
       
   221    CX_DEBUG_EXIT_FUNCTION();
       
   222 }
       
   223 
       
   224 /*!
       
   225 * Update contrast setting value to the camera device
       
   226 * \param newValue A new value for the updated setting
       
   227 */
       
   228 void CxeSettingsControlSymbian::updateContrastSetting(QVariant newValue)
       
   229 {
       
   230     CX_DEBUG_ENTER_FUNCTION();
       
   231     CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor());
       
   232 
       
   233     // Scale UI values of -2..2 to ECAM range -100..100.
       
   234     int newContrast = newValue.toReal() * 50;
       
   235 
       
   236     CX_DEBUG(("Setting contrast [uid:0x%08x] to value [%d]",
       
   237               KUidECamEventImageProcessingAdjustContrast, newContrast));
       
   238 
       
   239     mCameraDevice.imageProcessor()->SetTransformationValue(
       
   240             KUidECamEventImageProcessingAdjustContrast, newContrast);
       
   241 
       
   242     CX_DEBUG_EXIT_FUNCTION();
       
   243 }
       
   244 
       
   245 /*!
       
   246 * Update brightness setting value to the camera device
       
   247 * \param newValue A new value for the updated setting
       
   248 */
       
   249 void CxeSettingsControlSymbian::updateBrightnessSetting(QVariant newValue)
       
   250 {
       
   251     CX_DEBUG_ENTER_FUNCTION();
       
   252     CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor());
       
   253 
       
   254     // Scale UI values of -10..10 to ECAM range -100..100.
       
   255     int newBrightness = newValue.toInt() * 10;
       
   256 
       
   257     CX_DEBUG(("Setting brightness [uid:0x%08x] to value [%d]",
       
   258               KUidECamEventImageProcessingAdjustBrightness, newBrightness));
       
   259 
       
   260     mCameraDevice.imageProcessor()->SetTransformationValue(
       
   261             KUidECamEventImageProcessingAdjustBrightness, newBrightness);
       
   262 
       
   263     CX_DEBUG_EXIT_FUNCTION();
       
   264 }
       
   265 
       
   266 /*!
       
   267 * Update Exposure mode to the camera device
       
   268 * \param newValue A new value for the updated setting
       
   269 */
       
   270 void CxeSettingsControlSymbian::updateExposureModeSetting(QVariant newValue)
       
   271 {
       
   272     CX_DEBUG_ENTER_FUNCTION();
       
   273     CX_DEBUG_ASSERT(mCameraDevice.advancedSettings());
       
   274 
       
   275     CCamera::TExposure exposure =
       
   276             CxeSettingsMapperSymbian::Map2CameraExposureMode(
       
   277                     static_cast<Cxe::ExposureMode>(newValue.toInt()));
       
   278 
       
   279     mCameraDevice.advancedSettings()->SetExposureMode(exposure);
       
   280 
       
   281     CX_DEBUG_EXIT_FUNCTION();
       
   282 }
       
   283 
       
   284 /*!
       
   285 * Update Exposure Compensation mode to the camera device
       
   286 * \param newValue A new value for the updated setting
       
   287 */
       
   288 void CxeSettingsControlSymbian::updateExposureCompensationSetting(QVariant newValue)
       
   289 {
       
   290     CX_DEBUG_ENTER_FUNCTION();
       
   291     CX_ASSERT_ALWAYS(mCameraDevice.advancedSettings());
       
   292 
       
   293     // Exposure compensation is a float value, e.g. "-1.5".
       
   294     // ECAM interface takes integer values, so KECamFineResolutionFactor from
       
   295     // ecamconstants.h needs to be used as scaler.
       
   296     int ev = newValue.toReal() * KECamFineResolutionFactor;
       
   297 
       
   298     mCameraDevice.advancedSettings()->SetExposureCompensationStep(ev);
       
   299 
       
   300     CX_DEBUG_EXIT_FUNCTION();
       
   301 }
       
   302 
       
   303 /*!
       
   304 * Update flash mode to the camera device
       
   305 * \param newValue A new value for the updated setting
       
   306 */
       
   307 void CxeSettingsControlSymbian::updateFlashSetting(QVariant newValue)
       
   308 {
       
   309     CX_DEBUG_ENTER_FUNCTION();
       
   310     CX_ASSERT_ALWAYS(mCameraDevice.camera());
       
   311 
       
   312     CCamera::TFlash flash = CxeSettingsMapperSymbian::Map2CameraFlash(
       
   313             static_cast<Cxe::FlashMode>(newValue.toInt()));
       
   314 
       
   315     TRAP_IGNORE(mCameraDevice.camera()->SetFlashL(flash));
       
   316 
       
   317     CX_DEBUG_EXIT_FUNCTION();
       
   318 }
       
   319 
       
   320 /*!
       
   321 * Update face tracking mode to the camera device
       
   322 * \param newValue A new value for the updated setting
       
   323 */
       
   324 void CxeSettingsControlSymbian::updateFaceTrackingSetting(QVariant newValue)
       
   325 {
       
   326     CX_DEBUG_ENTER_FUNCTION();
       
   327     MCameraFaceTracking *faceTracking = mCameraDevice.faceTracking();
       
   328     if (faceTracking) {
       
   329         TRAP_IGNORE(faceTracking->SetFaceTrackingL(newValue.toInt()));
       
   330     }
       
   331     CX_DEBUG_EXIT_FUNCTION();
       
   332 }
       
   333 
       
   334 // end of file