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". |
38 |
38 |
39 |
39 |
40 /*! |
40 /*! |
41 * Constructor |
41 * Constructor |
42 */ |
42 */ |
43 CxeSettingsControlSymbian::CxeSettingsControlSymbian(CxeCameraDevice &cameraDevice, CxeSettings &settings) |
43 CxeSettingsControlSymbian::CxeSettingsControlSymbian( |
|
44 CxeCameraDevice &cameraDevice, CxeSettings &settings) |
44 : mCameraDevice(cameraDevice), |
45 : mCameraDevice(cameraDevice), |
45 mSettings(settings) |
46 mSettings(settings) |
46 { |
47 { |
47 // connect scene / setting change callbacks to settings control |
48 // connect scene / setting change callbacks to settings control |
48 connect(&mSettings, |
49 connect(&mSettings, |
49 SIGNAL(settingValueChanged(const QString&,QVariant)), |
50 SIGNAL(settingValueChanged(const QString&,QVariant)), |
50 this, |
51 this, |
51 SLOT(handleSettingValueChanged(const QString&,QVariant))); |
52 SLOT(handleSettingValueChanged(const QString&,QVariant))); |
52 |
53 |
53 connect(&mSettings, |
54 mSettings.listenForSetting(CxeSettingIds::IMAGE_SCENE_DATA, this, SLOT(handleSceneChanged(const QVariant&))); |
54 SIGNAL(sceneChanged(CxeScene&)), |
55 mSettings.listenForSetting(CxeSettingIds::VIDEO_SCENE_DATA, this, SLOT(handleSceneChanged(const QVariant&))); |
55 this, |
56 |
56 SLOT(handleSceneChanged(CxeScene&))); |
|
57 } |
57 } |
58 |
58 |
59 /*! |
59 /*! |
60 * Destructor |
60 * Destructor |
61 */ |
61 */ |
67 * Handle new setting value. |
67 * Handle new setting value. |
68 * New value is set to camera. |
68 * New value is set to camera. |
69 * \param settingId The id of the updated setting |
69 * \param settingId The id of the updated setting |
70 * \param newValue A new value for the updated setting |
70 * \param newValue A new value for the updated setting |
71 */ |
71 */ |
72 void CxeSettingsControlSymbian::handleSettingValueChanged(const QString& settingId, QVariant newValue) |
72 void CxeSettingsControlSymbian::handleSettingValueChanged( |
|
73 const QString &settingId, QVariant newValue) |
73 { |
74 { |
74 CX_DEBUG_ENTER_FUNCTION(); |
75 CX_DEBUG_ENTER_FUNCTION(); |
75 if (settingId == CxeSettingIds::COLOR_TONE) { |
76 if (settingId == CxeSettingIds::COLOR_TONE) { |
76 updateColorToneSetting(newValue); |
77 updateColorToneSetting(newValue); |
77 } else if (settingId == CxeSettingIds::WHITE_BALANCE) { |
78 } else if (settingId == CxeSettingIds::WHITE_BALANCE) { |
104 /*! |
105 /*! |
105 * Handle new scene being set. |
106 * Handle new scene being set. |
106 * Scene settings are checked and new values are set to camera. |
107 * Scene settings are checked and new values are set to camera. |
107 * \param scene New scene containing scene specific settings. |
108 * \param scene New scene containing scene specific settings. |
108 */ |
109 */ |
109 void CxeSettingsControlSymbian::handleSceneChanged(CxeScene& scene) |
110 void CxeSettingsControlSymbian::handleSceneChanged(const QVariant &sceneData) |
110 { |
111 { |
111 CX_DEBUG_ENTER_FUNCTION(); |
112 CX_DEBUG_ENTER_FUNCTION(); |
|
113 |
|
114 CxeScene scene = sceneData.value<CxeScene>(); |
112 OstTrace0(camerax_performance, CXESETTINGSCONTROL_SCENE_1, "msg: e_CX_SCENE_SETTINGS_TO_CAMERA 1"); |
115 OstTrace0(camerax_performance, CXESETTINGSCONTROL_SCENE_1, "msg: e_CX_SCENE_SETTINGS_TO_CAMERA 1"); |
113 |
116 |
114 CX_DEBUG(("CxeSettingsControlSymbian <> new scene [%s]", |
117 CX_DEBUG(("CxeSettingsControlSymbian <> new scene [%s]", |
115 scene[CxeSettingIds::SCENE_ID].value<QString>().toAscii().constData())); |
118 scene[CxeSettingIds::SCENE_ID].value<QString>().toAscii().constData())); |
116 |
119 |
134 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA) |
137 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA) |
135 |
138 |
136 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
139 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
137 |
140 |
138 CCamera::CCameraImageProcessing::TEffect effect = |
141 CCamera::CCameraImageProcessing::TEffect effect = |
139 CxeSettingsMapperSymbian::Map2CameraEffect(newValue.toInt()); |
142 CxeSettingsMapperSymbian::Map2CameraEffect( |
140 |
143 static_cast<Cxe::Colortone>(newValue.toInt())); |
141 if (effect != mCameraDevice.imageProcessor()->TransformationValue(KUidECamEventImageProcessingEffect)) { |
144 |
142 mCameraDevice.imageProcessor()->SetTransformationValue(KUidECamEventImageProcessingEffect, effect); |
145 mCameraDevice.imageProcessor()->SetTransformationValue( |
143 } else { |
146 KUidECamEventImageProcessingEffect, effect); |
144 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
147 |
145 } |
|
146 #else |
148 #else |
147 Q_UNUSED(newValue) |
149 Q_UNUSED(newValue) |
148 #endif |
150 #endif |
149 |
151 |
150 CX_DEBUG_EXIT_FUNCTION(); |
152 CX_DEBUG_EXIT_FUNCTION(); |
157 void CxeSettingsControlSymbian::updateWhiteBalanceSetting(QVariant newValue) |
159 void CxeSettingsControlSymbian::updateWhiteBalanceSetting(QVariant newValue) |
158 { |
160 { |
159 CX_DEBUG_ENTER_FUNCTION(); |
161 CX_DEBUG_ENTER_FUNCTION(); |
160 CX_DEBUG_ASSERT(mCameraDevice.camera()); |
162 CX_DEBUG_ASSERT(mCameraDevice.camera()); |
161 |
163 |
162 CCamera::TWhiteBalance wb = CxeSettingsMapperSymbian::Map2CameraWb(newValue.toInt()); |
164 CCamera::TWhiteBalance wb = CxeSettingsMapperSymbian::Map2CameraWb( |
163 |
165 static_cast<Cxe::Whitebalance>(newValue.toInt())); |
164 if (wb != mCameraDevice.camera()->WhiteBalance()) { |
166 |
165 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; |
166 } else { |
187 } else { |
167 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
188 // Manual ISO rate |
168 } |
189 type = CCamera::CCameraAdvancedSettings::EISOManual; |
169 |
190 } |
170 CX_DEBUG_EXIT_FUNCTION(); |
191 TRAP_IGNORE(mCameraDevice.advancedSettings()->SetISORateL(type, iso)); |
171 } |
|
172 |
|
173 /*! |
|
174 * Update light sensitivity (ISO) setting value to the camera device |
|
175 * \param newValue A new value for the updated setting |
|
176 */ |
|
177 void CxeSettingsControlSymbian::updateLightSensitivitySetting(QVariant newValue) |
|
178 { |
|
179 CX_DEBUG_ENTER_FUNCTION(); |
|
180 CX_ASSERT_ALWAYS(mCameraDevice.advancedSettings()); |
|
181 |
|
182 int iso = newValue.toInt(); |
|
183 |
|
184 if (iso != mCameraDevice.advancedSettings()->IsoRate()) { |
|
185 CCamera::CCameraAdvancedSettings::TISORateType type; |
|
186 if(iso == 0) { |
|
187 // Automatic ISO rate |
|
188 type = CCamera::CCameraAdvancedSettings::EISOAutoUnPrioritised; |
|
189 } else { |
|
190 // Manual ISO rate |
|
191 type = CCamera::CCameraAdvancedSettings::EISOManual; |
|
192 } |
|
193 TRAP_IGNORE(mCameraDevice.advancedSettings()->SetISORateL(type, iso)); |
|
194 } |
|
195 |
192 |
196 CX_DEBUG_EXIT_FUNCTION(); |
193 CX_DEBUG_EXIT_FUNCTION(); |
197 } |
194 } |
198 |
195 |
199 /*! |
196 /*! |
208 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA) |
205 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA) |
209 |
206 |
210 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
207 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
211 |
208 |
212 // Scale UI values of -2..2 to ECAM range -100..100. |
209 // Scale UI values of -2..2 to ECAM range -100..100. |
213 int currentSharpness = mCameraDevice.imageProcessor()->TransformationValue(KUidECamEventImageProcessingAdjustSharpness); |
210 int newSharpness = newValue.toReal() * 50; |
214 int newSharpness = newValue.toReal()*50; |
211 |
215 |
212 CX_DEBUG(("Setting sharpness [uid:0x%08x] to value [%d]", |
216 CX_DEBUG(("Current sharpness [uid:0x%08x] value is [%d]", KUidECamEventImageProcessingAdjustSharpness, currentSharpness)); |
213 KUidECamEventImageProcessingAdjustSharpness, newSharpness)); |
217 CX_DEBUG(("Setting sharpness [uid:0x%08x] to value [%d]", KUidECamEventImageProcessingAdjustSharpness, newSharpness)); |
214 mCameraDevice.imageProcessor()->SetTransformationValue( |
218 if (newSharpness != currentSharpness) { |
215 KUidECamEventImageProcessingAdjustSharpness, newSharpness); |
219 mCameraDevice.imageProcessor()->SetTransformationValue(KUidECamEventImageProcessingAdjustSharpness, newSharpness); |
216 |
220 } else { |
|
221 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
222 } |
|
223 #else |
217 #else |
224 Q_UNUSED(newValue) |
218 Q_UNUSED(newValue) |
225 #endif |
219 #endif |
226 |
220 |
227 CX_DEBUG_EXIT_FUNCTION(); |
221 CX_DEBUG_EXIT_FUNCTION(); |
235 { |
229 { |
236 CX_DEBUG_ENTER_FUNCTION(); |
230 CX_DEBUG_ENTER_FUNCTION(); |
237 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
231 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
238 |
232 |
239 // Scale UI values of -2..2 to ECAM range -100..100. |
233 // Scale UI values of -2..2 to ECAM range -100..100. |
240 int currentContrast = mCameraDevice.imageProcessor()->TransformationValue(KUidECamEventImageProcessingAdjustContrast); |
234 int newContrast = newValue.toReal() * 50; |
241 int newContrast = newValue.toReal()*50; |
235 |
242 |
236 CX_DEBUG(("Setting contrast [uid:0x%08x] to value [%d]", |
243 CX_DEBUG(("Current contrast [uid:0x%08x] value is [%d]", KUidECamEventImageProcessingAdjustContrast, currentContrast)); |
237 KUidECamEventImageProcessingAdjustContrast, newContrast)); |
244 CX_DEBUG(("Setting contrast [uid:0x%08x] to value [%d]", KUidECamEventImageProcessingAdjustContrast, newContrast)); |
238 |
245 if (newContrast != currentContrast) { |
239 mCameraDevice.imageProcessor()->SetTransformationValue( |
246 mCameraDevice.imageProcessor()->SetTransformationValue(KUidECamEventImageProcessingAdjustContrast, newContrast); |
240 KUidECamEventImageProcessingAdjustContrast, newContrast); |
247 } else { |
|
248 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
249 } |
|
250 |
241 |
251 CX_DEBUG_EXIT_FUNCTION(); |
242 CX_DEBUG_EXIT_FUNCTION(); |
252 } |
243 } |
253 |
244 |
254 /*! |
245 /*! |
259 { |
250 { |
260 CX_DEBUG_ENTER_FUNCTION(); |
251 CX_DEBUG_ENTER_FUNCTION(); |
261 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
252 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
262 |
253 |
263 // Scale UI values of -10..10 to ECAM range -100..100. |
254 // Scale UI values of -10..10 to ECAM range -100..100. |
264 int currentBrightness = mCameraDevice.imageProcessor()->TransformationValue(KUidECamEventImageProcessingAdjustBrightness); |
255 int newBrightness = newValue.toInt() * 10; |
265 int newBrightness = newValue.toInt()*10; |
256 |
266 |
257 CX_DEBUG(("Setting brightness [uid:0x%08x] to value [%d]", |
267 CX_DEBUG(("Current brightness [uid:0x%08x] value is [%d]", KUidECamEventImageProcessingAdjustBrightness, currentBrightness)); |
258 KUidECamEventImageProcessingAdjustBrightness, newBrightness)); |
268 CX_DEBUG(("Setting brightness [uid:0x%08x] to value [%d]", KUidECamEventImageProcessingAdjustBrightness, newBrightness)); |
259 |
269 if (newBrightness != currentBrightness) { |
260 mCameraDevice.imageProcessor()->SetTransformationValue( |
270 mCameraDevice.imageProcessor()->SetTransformationValue(KUidECamEventImageProcessingAdjustBrightness, newBrightness); |
261 KUidECamEventImageProcessingAdjustBrightness, newBrightness); |
271 } else { |
|
272 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
273 } |
|
274 |
262 |
275 CX_DEBUG_EXIT_FUNCTION(); |
263 CX_DEBUG_EXIT_FUNCTION(); |
276 } |
264 } |
277 |
265 |
278 /*! |
266 /*! |
282 void CxeSettingsControlSymbian::updateExposureModeSetting(QVariant newValue) |
270 void CxeSettingsControlSymbian::updateExposureModeSetting(QVariant newValue) |
283 { |
271 { |
284 CX_DEBUG_ENTER_FUNCTION(); |
272 CX_DEBUG_ENTER_FUNCTION(); |
285 CX_DEBUG_ASSERT(mCameraDevice.advancedSettings()); |
273 CX_DEBUG_ASSERT(mCameraDevice.advancedSettings()); |
286 |
274 |
287 CCamera::TExposure exposure = CxeSettingsMapperSymbian::Map2CameraExposureMode(newValue.toInt()); |
275 CCamera::TExposure exposure = |
288 |
276 CxeSettingsMapperSymbian::Map2CameraExposureMode( |
289 if(exposure != mCameraDevice.advancedSettings()->ExposureMode()) { |
277 static_cast<Cxe::ExposureMode>(newValue.toInt())); |
290 mCameraDevice.advancedSettings()->SetExposureMode(exposure); |
278 |
291 } else { |
279 mCameraDevice.advancedSettings()->SetExposureMode(exposure); |
292 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
293 } |
|
294 |
280 |
295 CX_DEBUG_EXIT_FUNCTION(); |
281 CX_DEBUG_EXIT_FUNCTION(); |
296 } |
282 } |
297 |
283 |
298 /*! |
284 /*! |
305 CX_ASSERT_ALWAYS(mCameraDevice.advancedSettings()); |
291 CX_ASSERT_ALWAYS(mCameraDevice.advancedSettings()); |
306 |
292 |
307 // Exposure compensation is a float value, e.g. "-1.5". |
293 // Exposure compensation is a float value, e.g. "-1.5". |
308 // ECAM interface takes integer values, so KECamFineResolutionFactor from |
294 // ECAM interface takes integer values, so KECamFineResolutionFactor from |
309 // ecamconstants.h needs to be used as scaler. |
295 // ecamconstants.h needs to be used as scaler. |
310 int ev = newValue.toReal()*KECamFineResolutionFactor; |
296 int ev = newValue.toReal() * KECamFineResolutionFactor; |
311 |
297 |
312 if (ev != mCameraDevice.advancedSettings()->ExposureCompensationStep()) { |
298 mCameraDevice.advancedSettings()->SetExposureCompensationStep(ev); |
313 mCameraDevice.advancedSettings()->SetExposureCompensationStep(ev); |
|
314 } else { |
|
315 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
316 } |
|
317 |
299 |
318 CX_DEBUG_EXIT_FUNCTION(); |
300 CX_DEBUG_EXIT_FUNCTION(); |
319 } |
301 } |
320 |
302 |
321 /*! |
303 /*! |
325 void CxeSettingsControlSymbian::updateFlashSetting(QVariant newValue) |
307 void CxeSettingsControlSymbian::updateFlashSetting(QVariant newValue) |
326 { |
308 { |
327 CX_DEBUG_ENTER_FUNCTION(); |
309 CX_DEBUG_ENTER_FUNCTION(); |
328 CX_ASSERT_ALWAYS(mCameraDevice.camera()); |
310 CX_ASSERT_ALWAYS(mCameraDevice.camera()); |
329 |
311 |
330 CCamera::TFlash flash = CxeSettingsMapperSymbian::Map2CameraFlash(newValue.toInt()); |
312 CCamera::TFlash flash = CxeSettingsMapperSymbian::Map2CameraFlash( |
331 |
313 static_cast<Cxe::FlashMode>(newValue.toInt())); |
332 if (flash != mCameraDevice.camera()->Flash()) { |
314 |
333 TRAP_IGNORE(mCameraDevice.camera()->SetFlashL(flash)); |
315 TRAP_IGNORE(mCameraDevice.camera()->SetFlashL(flash)); |
334 } else { |
|
335 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
336 } |
|
337 |
316 |
338 CX_DEBUG_EXIT_FUNCTION(); |
317 CX_DEBUG_EXIT_FUNCTION(); |
339 } |
318 } |
340 |
319 |
341 /*! |
320 /*! |
344 */ |
323 */ |
345 void CxeSettingsControlSymbian::updateFaceTrackingSetting(QVariant newValue) |
324 void CxeSettingsControlSymbian::updateFaceTrackingSetting(QVariant newValue) |
346 { |
325 { |
347 CX_DEBUG_ENTER_FUNCTION(); |
326 CX_DEBUG_ENTER_FUNCTION(); |
348 MCameraFaceTracking *faceTracking = mCameraDevice.faceTracking(); |
327 MCameraFaceTracking *faceTracking = mCameraDevice.faceTracking(); |
349 if(faceTracking) { |
328 if (faceTracking) { |
350 TRAP_IGNORE(faceTracking->SetFaceTrackingL(newValue.toInt())); |
329 TRAP_IGNORE(faceTracking->SetFaceTrackingL(newValue.toInt())); |
351 } |
330 } |
352 CX_DEBUG_EXIT_FUNCTION(); |
331 CX_DEBUG_EXIT_FUNCTION(); |
353 } |
332 } |
354 |
333 |