1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
29 #include "cxecameradevice.h" |
29 #include "cxecameradevice.h" |
30 #include "cxesettings.h" |
30 #include "cxesettings.h" |
31 #include "cxesettingsmappersymbian.h" |
31 #include "cxesettingsmappersymbian.h" |
32 #include "cxesettingscontrolsymbian.h" |
32 #include "cxesettingscontrolsymbian.h" |
33 |
33 |
|
34 #include "OstTraceDefinitions.h" |
|
35 #ifdef OST_TRACE_COMPILER_IN_USE |
|
36 #include "cxesettingscontrolsymbianTraces.h" |
|
37 #endif |
|
38 |
|
39 |
34 /*! |
40 /*! |
35 * Constructor |
41 * Constructor |
36 */ |
42 */ |
37 CxeSettingsControlSymbian::CxeSettingsControlSymbian(CxeCameraDevice &cameraDevice, CxeSettings &settings) |
43 CxeSettingsControlSymbian::CxeSettingsControlSymbian( |
|
44 CxeCameraDevice &cameraDevice, CxeSettings &settings) |
38 : mCameraDevice(cameraDevice), |
45 : mCameraDevice(cameraDevice), |
39 mSettings(settings) |
46 mSettings(settings) |
40 { |
47 { |
41 // connect scene / setting change callbacks to settings control |
48 // connect scene / setting change callbacks to settings control |
42 connect(&mSettings, |
49 connect(&mSettings, |
43 SIGNAL(settingValueChanged(const QString&,QVariant)), |
50 SIGNAL(settingValueChanged(const QString&,QVariant)), |
44 this, |
51 this, |
45 SLOT(handleSettingValueChanged(const QString&,QVariant))); |
52 SLOT(handleSettingValueChanged(const QString&,QVariant))); |
46 |
53 |
47 connect(&mSettings, |
54 mSettings.listenForSetting(CxeSettingIds::IMAGE_SCENE_DATA, this, SLOT(handleSceneChanged(const QVariant&))); |
48 SIGNAL(sceneChanged(CxeScene&)), |
55 mSettings.listenForSetting(CxeSettingIds::VIDEO_SCENE_DATA, this, SLOT(handleSceneChanged(const QVariant&))); |
49 this, |
56 |
50 SLOT(handleSceneChanged(CxeScene&))); |
|
51 } |
57 } |
52 |
58 |
53 /*! |
59 /*! |
54 * Destructor |
60 * Destructor |
55 */ |
61 */ |
61 * Handle new setting value. |
67 * Handle new setting value. |
62 * New value is set to camera. |
68 * New value is set to camera. |
63 * \param settingId The id of the updated setting |
69 * \param settingId The id of the updated setting |
64 * \param newValue A new value for the updated setting |
70 * \param newValue A new value for the updated setting |
65 */ |
71 */ |
66 void CxeSettingsControlSymbian::handleSettingValueChanged(const QString& settingId, QVariant newValue) |
72 void CxeSettingsControlSymbian::handleSettingValueChanged( |
|
73 const QString &settingId, QVariant newValue) |
67 { |
74 { |
68 CX_DEBUG_ENTER_FUNCTION(); |
75 CX_DEBUG_ENTER_FUNCTION(); |
69 if (settingId == CxeSettingIds::COLOR_TONE) { |
76 if (settingId == CxeSettingIds::COLOR_TONE) { |
70 updateColorToneSetting(newValue); |
77 updateColorToneSetting(newValue); |
71 } else if (settingId == CxeSettingIds::WHITE_BALANCE) { |
78 } else if (settingId == CxeSettingIds::WHITE_BALANCE) { |
98 /*! |
105 /*! |
99 * Handle new scene being set. |
106 * Handle new scene being set. |
100 * Scene settings are checked and new values are set to camera. |
107 * Scene settings are checked and new values are set to camera. |
101 * \param scene New scene containing scene specific settings. |
108 * \param scene New scene containing scene specific settings. |
102 */ |
109 */ |
103 void CxeSettingsControlSymbian::handleSceneChanged(CxeScene& scene) |
110 void CxeSettingsControlSymbian::handleSceneChanged(const QVariant &sceneData) |
104 { |
111 { |
105 CX_DEBUG_ENTER_FUNCTION(); |
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 |
106 CX_DEBUG(("CxeSettingsControlSymbian <> new scene [%s]", |
117 CX_DEBUG(("CxeSettingsControlSymbian <> new scene [%s]", |
107 scene[CxeSettingIds::SCENE_ID].value<QString>().toAscii().constData())); |
118 scene[CxeSettingIds::SCENE_ID].value<QString>().toAscii().constData())); |
108 |
119 |
109 foreach (const QString& settingId, scene.keys()) { |
120 foreach (const QString& settingId, scene.keys()) { |
110 handleSettingValueChanged(settingId, scene[settingId]); |
121 handleSettingValueChanged(settingId, scene[settingId]); |
111 } |
122 } |
112 |
123 |
|
124 OstTrace0(camerax_performance, CXESETTINGSCONTROL_SCENE_2, "msg: e_CX_SCENE_SETTINGS_TO_CAMERA 0"); |
113 CX_DEBUG_EXIT_FUNCTION(); |
125 CX_DEBUG_EXIT_FUNCTION(); |
114 } |
126 } |
115 |
127 |
116 /*! |
128 /*! |
117 * Update color tone setting value to the camera device |
129 * Update color tone setting value to the camera device |
125 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA) |
137 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA) |
126 |
138 |
127 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
139 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
128 |
140 |
129 CCamera::CCameraImageProcessing::TEffect effect = |
141 CCamera::CCameraImageProcessing::TEffect effect = |
130 CxeSettingsMapperSymbian::Map2CameraEffect(newValue.toInt()); |
142 CxeSettingsMapperSymbian::Map2CameraEffect( |
131 |
143 static_cast<Cxe::Colortone>(newValue.toInt())); |
132 if (effect != mCameraDevice.imageProcessor()->TransformationValue(KUidECamEventImageProcessingEffect)) { |
144 |
133 mCameraDevice.imageProcessor()->SetTransformationValue(KUidECamEventImageProcessingEffect, effect); |
145 mCameraDevice.imageProcessor()->SetTransformationValue( |
134 } else { |
146 KUidECamEventImageProcessingEffect, effect); |
135 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
147 |
136 } |
|
137 #else |
148 #else |
138 Q_UNUSED(newValue) |
149 Q_UNUSED(newValue) |
139 #endif |
150 #endif |
140 |
151 |
141 CX_DEBUG_EXIT_FUNCTION(); |
152 CX_DEBUG_EXIT_FUNCTION(); |
148 void CxeSettingsControlSymbian::updateWhiteBalanceSetting(QVariant newValue) |
159 void CxeSettingsControlSymbian::updateWhiteBalanceSetting(QVariant newValue) |
149 { |
160 { |
150 CX_DEBUG_ENTER_FUNCTION(); |
161 CX_DEBUG_ENTER_FUNCTION(); |
151 CX_DEBUG_ASSERT(mCameraDevice.camera()); |
162 CX_DEBUG_ASSERT(mCameraDevice.camera()); |
152 |
163 |
153 CCamera::TWhiteBalance wb = CxeSettingsMapperSymbian::Map2CameraWb(newValue.toInt()); |
164 CCamera::TWhiteBalance wb = CxeSettingsMapperSymbian::Map2CameraWb( |
154 |
165 static_cast<Cxe::Whitebalance>(newValue.toInt())); |
155 if (wb != mCameraDevice.camera()->WhiteBalance()) { |
166 |
156 TRAP_IGNORE( mCameraDevice.camera()->SetWhiteBalanceL(wb) ); |
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; |
157 } else { |
187 } else { |
158 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
188 // Manual ISO rate |
159 } |
189 type = CCamera::CCameraAdvancedSettings::EISOManual; |
160 |
190 } |
161 CX_DEBUG_EXIT_FUNCTION(); |
191 TRAP_IGNORE(mCameraDevice.advancedSettings()->SetISORateL(type, iso)); |
162 } |
|
163 |
|
164 /*! |
|
165 * Update light sensitivity (ISO) setting value to the camera device |
|
166 * \param newValue A new value for the updated setting |
|
167 */ |
|
168 void CxeSettingsControlSymbian::updateLightSensitivitySetting(QVariant newValue) |
|
169 { |
|
170 CX_DEBUG_ENTER_FUNCTION(); |
|
171 CX_ASSERT_ALWAYS(mCameraDevice.advancedSettings()); |
|
172 |
|
173 int iso = newValue.toInt(); |
|
174 |
|
175 if (iso != mCameraDevice.advancedSettings()->IsoRate()) { |
|
176 CCamera::CCameraAdvancedSettings::TISORateType type; |
|
177 if(iso == 0) { |
|
178 // Automatic ISO rate |
|
179 type = CCamera::CCameraAdvancedSettings::EISOAutoUnPrioritised; |
|
180 } else { |
|
181 // Manual ISO rate |
|
182 type = CCamera::CCameraAdvancedSettings::EISOManual; |
|
183 } |
|
184 TRAP_IGNORE(mCameraDevice.advancedSettings()->SetISORateL(type, iso)); |
|
185 } |
|
186 |
192 |
187 CX_DEBUG_EXIT_FUNCTION(); |
193 CX_DEBUG_EXIT_FUNCTION(); |
188 } |
194 } |
189 |
195 |
190 /*! |
196 /*! |
199 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA) |
205 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA) |
200 |
206 |
201 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
207 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
202 |
208 |
203 // Scale UI values of -2..2 to ECAM range -100..100. |
209 // Scale UI values of -2..2 to ECAM range -100..100. |
204 int currentSharpness = mCameraDevice.imageProcessor()->TransformationValue(KUidECamEventImageProcessingAdjustSharpness); |
210 int newSharpness = newValue.toReal() * 50; |
205 int newSharpness = newValue.toReal()*50; |
211 |
206 |
212 CX_DEBUG(("Setting sharpness [uid:0x%08x] to value [%d]", |
207 CX_DEBUG(("Current sharpness [uid:0x%08x] value is [%d]", KUidECamEventImageProcessingAdjustSharpness, currentSharpness)); |
213 KUidECamEventImageProcessingAdjustSharpness, newSharpness)); |
208 CX_DEBUG(("Setting sharpness [uid:0x%08x] to value [%d]", KUidECamEventImageProcessingAdjustSharpness, newSharpness)); |
214 mCameraDevice.imageProcessor()->SetTransformationValue( |
209 if (newSharpness != currentSharpness) { |
215 KUidECamEventImageProcessingAdjustSharpness, newSharpness); |
210 mCameraDevice.imageProcessor()->SetTransformationValue(KUidECamEventImageProcessingAdjustSharpness, newSharpness); |
216 |
211 } else { |
|
212 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
213 } |
|
214 #else |
217 #else |
215 Q_UNUSED(newValue) |
218 Q_UNUSED(newValue) |
216 #endif |
219 #endif |
217 |
220 |
218 CX_DEBUG_EXIT_FUNCTION(); |
221 CX_DEBUG_EXIT_FUNCTION(); |
226 { |
229 { |
227 CX_DEBUG_ENTER_FUNCTION(); |
230 CX_DEBUG_ENTER_FUNCTION(); |
228 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
231 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
229 |
232 |
230 // Scale UI values of -2..2 to ECAM range -100..100. |
233 // Scale UI values of -2..2 to ECAM range -100..100. |
231 int currentContrast = mCameraDevice.imageProcessor()->TransformationValue(KUidECamEventImageProcessingAdjustContrast); |
234 int newContrast = newValue.toReal() * 50; |
232 int newContrast = newValue.toReal()*50; |
235 |
233 |
236 CX_DEBUG(("Setting contrast [uid:0x%08x] to value [%d]", |
234 CX_DEBUG(("Current contrast [uid:0x%08x] value is [%d]", KUidECamEventImageProcessingAdjustContrast, currentContrast)); |
237 KUidECamEventImageProcessingAdjustContrast, newContrast)); |
235 CX_DEBUG(("Setting contrast [uid:0x%08x] to value [%d]", KUidECamEventImageProcessingAdjustContrast, newContrast)); |
238 |
236 if (newContrast != currentContrast) { |
239 mCameraDevice.imageProcessor()->SetTransformationValue( |
237 mCameraDevice.imageProcessor()->SetTransformationValue(KUidECamEventImageProcessingAdjustContrast, newContrast); |
240 KUidECamEventImageProcessingAdjustContrast, newContrast); |
238 } else { |
|
239 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
240 } |
|
241 |
241 |
242 CX_DEBUG_EXIT_FUNCTION(); |
242 CX_DEBUG_EXIT_FUNCTION(); |
243 } |
243 } |
244 |
244 |
245 /*! |
245 /*! |
250 { |
250 { |
251 CX_DEBUG_ENTER_FUNCTION(); |
251 CX_DEBUG_ENTER_FUNCTION(); |
252 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
252 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
253 |
253 |
254 // Scale UI values of -10..10 to ECAM range -100..100. |
254 // Scale UI values of -10..10 to ECAM range -100..100. |
255 int currentBrightness = mCameraDevice.imageProcessor()->TransformationValue(KUidECamEventImageProcessingAdjustBrightness); |
255 int newBrightness = newValue.toInt() * 10; |
256 int newBrightness = newValue.toInt()*10; |
256 |
257 |
257 CX_DEBUG(("Setting brightness [uid:0x%08x] to value [%d]", |
258 CX_DEBUG(("Current brightness [uid:0x%08x] value is [%d]", KUidECamEventImageProcessingAdjustBrightness, currentBrightness)); |
258 KUidECamEventImageProcessingAdjustBrightness, newBrightness)); |
259 CX_DEBUG(("Setting brightness [uid:0x%08x] to value [%d]", KUidECamEventImageProcessingAdjustBrightness, newBrightness)); |
259 |
260 if (newBrightness != currentBrightness) { |
260 mCameraDevice.imageProcessor()->SetTransformationValue( |
261 mCameraDevice.imageProcessor()->SetTransformationValue(KUidECamEventImageProcessingAdjustBrightness, newBrightness); |
261 KUidECamEventImageProcessingAdjustBrightness, newBrightness); |
262 } else { |
|
263 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
264 } |
|
265 |
262 |
266 CX_DEBUG_EXIT_FUNCTION(); |
263 CX_DEBUG_EXIT_FUNCTION(); |
267 } |
264 } |
268 |
265 |
269 /*! |
266 /*! |
273 void CxeSettingsControlSymbian::updateExposureModeSetting(QVariant newValue) |
270 void CxeSettingsControlSymbian::updateExposureModeSetting(QVariant newValue) |
274 { |
271 { |
275 CX_DEBUG_ENTER_FUNCTION(); |
272 CX_DEBUG_ENTER_FUNCTION(); |
276 CX_DEBUG_ASSERT(mCameraDevice.advancedSettings()); |
273 CX_DEBUG_ASSERT(mCameraDevice.advancedSettings()); |
277 |
274 |
278 CCamera::TExposure exposure = CxeSettingsMapperSymbian::Map2CameraExposureMode(newValue.toInt()); |
275 CCamera::TExposure exposure = |
279 |
276 CxeSettingsMapperSymbian::Map2CameraExposureMode( |
280 if(exposure != mCameraDevice.advancedSettings()->ExposureMode()) { |
277 static_cast<Cxe::ExposureMode>(newValue.toInt())); |
281 mCameraDevice.advancedSettings()->SetExposureMode(exposure); |
278 |
282 } else { |
279 mCameraDevice.advancedSettings()->SetExposureMode(exposure); |
283 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
284 } |
|
285 |
280 |
286 CX_DEBUG_EXIT_FUNCTION(); |
281 CX_DEBUG_EXIT_FUNCTION(); |
287 } |
282 } |
288 |
283 |
289 /*! |
284 /*! |
296 CX_ASSERT_ALWAYS(mCameraDevice.advancedSettings()); |
291 CX_ASSERT_ALWAYS(mCameraDevice.advancedSettings()); |
297 |
292 |
298 // Exposure compensation is a float value, e.g. "-1.5". |
293 // Exposure compensation is a float value, e.g. "-1.5". |
299 // ECAM interface takes integer values, so KECamFineResolutionFactor from |
294 // ECAM interface takes integer values, so KECamFineResolutionFactor from |
300 // ecamconstants.h needs to be used as scaler. |
295 // ecamconstants.h needs to be used as scaler. |
301 int ev = newValue.toReal()*KECamFineResolutionFactor; |
296 int ev = newValue.toReal() * KECamFineResolutionFactor; |
302 |
297 |
303 if (ev != mCameraDevice.advancedSettings()->ExposureCompensationStep()) { |
298 mCameraDevice.advancedSettings()->SetExposureCompensationStep(ev); |
304 mCameraDevice.advancedSettings()->SetExposureCompensationStep(ev); |
|
305 } else { |
|
306 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
307 } |
|
308 |
299 |
309 CX_DEBUG_EXIT_FUNCTION(); |
300 CX_DEBUG_EXIT_FUNCTION(); |
310 } |
301 } |
311 |
302 |
312 /*! |
303 /*! |
316 void CxeSettingsControlSymbian::updateFlashSetting(QVariant newValue) |
307 void CxeSettingsControlSymbian::updateFlashSetting(QVariant newValue) |
317 { |
308 { |
318 CX_DEBUG_ENTER_FUNCTION(); |
309 CX_DEBUG_ENTER_FUNCTION(); |
319 CX_ASSERT_ALWAYS(mCameraDevice.camera()); |
310 CX_ASSERT_ALWAYS(mCameraDevice.camera()); |
320 |
311 |
321 CCamera::TFlash flash = CxeSettingsMapperSymbian::Map2CameraFlash(newValue.toInt()); |
312 CCamera::TFlash flash = CxeSettingsMapperSymbian::Map2CameraFlash( |
322 |
313 static_cast<Cxe::FlashMode>(newValue.toInt())); |
323 if (flash != mCameraDevice.camera()->Flash()) { |
314 |
324 TRAP_IGNORE(mCameraDevice.camera()->SetFlashL(flash)); |
315 TRAP_IGNORE(mCameraDevice.camera()->SetFlashL(flash)); |
325 } else { |
|
326 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
327 } |
|
328 |
316 |
329 CX_DEBUG_EXIT_FUNCTION(); |
317 CX_DEBUG_EXIT_FUNCTION(); |
330 } |
318 } |
331 |
319 |
332 /*! |
320 /*! |
335 */ |
323 */ |
336 void CxeSettingsControlSymbian::updateFaceTrackingSetting(QVariant newValue) |
324 void CxeSettingsControlSymbian::updateFaceTrackingSetting(QVariant newValue) |
337 { |
325 { |
338 CX_DEBUG_ENTER_FUNCTION(); |
326 CX_DEBUG_ENTER_FUNCTION(); |
339 MCameraFaceTracking *faceTracking = mCameraDevice.faceTracking(); |
327 MCameraFaceTracking *faceTracking = mCameraDevice.faceTracking(); |
340 if(faceTracking) { |
328 if (faceTracking) { |
341 TRAP_IGNORE(faceTracking->SetFaceTrackingL(newValue.toInt())); |
329 TRAP_IGNORE(faceTracking->SetFaceTrackingL(newValue.toInt())); |
342 } |
330 } |
343 CX_DEBUG_EXIT_FUNCTION(); |
331 CX_DEBUG_EXIT_FUNCTION(); |
344 } |
332 } |
345 |
333 |