--- a/camerauis/cameraxui/cxengine/src/cxeautofocuscontrolsymbian.cpp Thu May 13 21:30:19 2010 +0300
+++ b/camerauis/cameraxui/cxengine/src/cxeautofocuscontrolsymbian.cpp Thu Jul 15 01:55:05 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"
@@ -40,11 +40,14 @@
/*
* CxeAutoFocusControlSymbian::CxeAutoFocusControlSymbian
*/
-CxeAutoFocusControlSymbian::CxeAutoFocusControlSymbian(CxeCameraDevice &cameraDevice)
+CxeAutoFocusControlSymbian::CxeAutoFocusControlSymbian(CxeCameraDevice &cameraDevice,
+ CxeSettings &settings)
: CxeStateMachine("CxeAutoFocusControlSymbian"),
mCameraDevice(cameraDevice),
mAdvancedSettings(NULL),
- mCancelled(false)
+ mSettings(settings),
+ mCancelled(false),
+ mFaceTrackingOverride(false)
{
CX_DEBUG_ENTER_FUNCTION();
@@ -65,6 +68,13 @@
QObject::connect( &cameraDevice,
SIGNAL(prepareForRelease()),
this,SLOT(prepareForRelease()) );
+
+ // connect scene / setting change callbacks to settings control
+ QObject::connect(&mSettings,
+ SIGNAL(settingValueChanged(const QString&,QVariant)),
+ this,
+ SLOT(handleSettingValueChanged(const QString&,QVariant)));
+
OstTrace0(camerax_performance, CXEAUTOFOCUSCONTROLSYMBIAN_CREATE_MID2, "msg: e_CX_ENGINE_CONNECT_SIGNALS 0");
initializeResources();
@@ -91,25 +101,28 @@
*/
CxeError::Id CxeAutoFocusControlSymbian::start(bool soundEnabled)
{
- CX_DEBUG( ("CxeAutoFocusControlSymbian::start() <> state: %d, sound enabled: %d",
- state(), soundEnabled ) );
- mSoundEnabled = soundEnabled;
- int err = KErrNone;
-
CX_ASSERT_ALWAYS(mAdvancedSettings);
- if ( state() != CxeAutoFocusControl::InProgress && state() != CxeAutoFocusControl::Canceling ) {
- CX_DEBUG(("CxeAutoFocusControlSymbian::start() calling SetAutoFocusType"));
- mCancelled = false;
- setState(InProgress);
- setFocusRange(mAFRange);
- setFocusType(CCamera::CCameraAdvancedSettings::EAutoFocusTypeSingle);
- } else { // AF was started earlier, can't start until it completes
- err = KErrInUse;
+ CX_DEBUG( ("CxeAutoFocusControlSymbian::start() <> state: %d, sound enabled: %d",
+ state(), soundEnabled ) );
+
+ mSoundEnabled = soundEnabled;
+ CxeError::Id error = CxeError::None;
+
+ if (!isFixedFocusMode(mode())) {
+ if ( state() != CxeAutoFocusControl::InProgress && state() != CxeAutoFocusControl::Canceling ) {
+ CX_DEBUG(("CxeAutoFocusControlSymbian::start() calling SetAutoFocusType"));
+ mCancelled = false;
+ setState(InProgress);
+ setFocusRange(mAFRange);
+ setFocusType(CCamera::CCameraAdvancedSettings::EAutoFocusTypeSingle);
+ } else { // AF was started earlier, can't start until it completes
+ error = CxeError::InUse;
+ }
}
- CX_DEBUG( ("CxeAutoFocusControlSymbian::start() <= err : %d", err ) );
- return CxeErrorHandlingSymbian::map(err);
+ CX_DEBUG( ("CxeAutoFocusControlSymbian::start() <= error: %d", error ) );
+ return error;
}
@@ -123,7 +136,7 @@
CX_DEBUG_ASSERT(mAdvancedSettings);
- if (!mCancelled) {
+ if (!mCancelled && !isFixedFocusMode(mode())) {
if (state() == CxeAutoFocusControl::InProgress) {
// Need to stop current AF first. Wait for AF event to proceed.
setState(CxeAutoFocusControl::Canceling);
@@ -171,6 +184,14 @@
return mAfMode;
}
+/**
+* Is the given mode a fixed focus mode?
+*/
+bool CxeAutoFocusControlSymbian::isFixedFocusMode(CxeAutoFocusControl::Mode mode) const
+{
+ return (mode == CxeAutoFocusControl::Hyperfocal
+ || mode == CxeAutoFocusControl::Infinity);
+}
/*
* To check if Autofocus is supported
@@ -389,7 +410,15 @@
// we are interested only in the AF range.
if(scene.contains(CxeSettingIds::FOCAL_RANGE) && supported() ) {
+
setMode(static_cast<CxeAutoFocusControl::Mode>(scene[CxeSettingIds::FOCAL_RANGE].toInt()));
+
+ if (isFixedFocusMode(mode())) {
+ // Focus now if a fixed focus mode is used.
+ setFocusType(CCamera::CCameraAdvancedSettings::EAutoFocusTypeSingle);
+ // Set state to InProgress, so we know to set it ready in ECAM callback.
+ setState(CxeAutoFocusControl::InProgress);
+ }
}
CX_DEBUG_EXIT_FUNCTION();
@@ -457,4 +486,40 @@
return mSoundEnabled;
}
+/*!
+* Handle new setting value.
+* New value is set to camera.
+* \param settingId The id of the updated setting
+* \param newValue A new value for the updated setting
+*/
+void CxeAutoFocusControlSymbian::handleSettingValueChanged(const QString& settingId, QVariant newValue)
+{
+ CX_DEBUG_ENTER_FUNCTION();
+ if (settingId == CxeSettingIds::FACE_TRACKING) {
+ // Updating AF mode when face tracking is activated
+ // in scene mode which doesn't support face tracking
+ if (newValue.toInt()) {
+ //Face tracking enabled
+ if(mAfMode == CxeAutoFocusControl::Infinity ||
+ mAfMode == CxeAutoFocusControl::Hyperfocal) {
+ mPreviousAFMode = mAfMode;
+ setMode(CxeAutoFocusControl::Auto);
+ mFaceTrackingOverride = true;
+ }
+ } else {
+ //Face tracking disabled
+ if (mFaceTrackingOverride) {
+ mAfMode = mPreviousAFMode;
+ setMode(mAfMode);
+ mFaceTrackingOverride = false;
+ }
+ }
+
+ } else {
+ // do nothing
+ }
+
+ CX_DEBUG_EXIT_FUNCTION();
+}
+
// end of file