1 /* |
|
2 * Copyright (c) 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 "cxescenemodestore.h" |
|
19 #include "cxutils.h" |
|
20 #include "cxenamespace.h" |
|
21 #include "cxeautofocuscontrol.h" |
|
22 #include "cxeexception.h" |
|
23 |
|
24 using namespace Cxe; |
|
25 |
|
26 /*! |
|
27 * Constructor. |
|
28 */ |
|
29 CxeSceneModeStore::CxeSceneModeStore() |
|
30 { |
|
31 CX_DEBUG_ENTER_FUNCTION(); |
|
32 loadImageScenes(); |
|
33 loadVideoScenes(); |
|
34 |
|
35 mCurrentImageScene = mImageSceneModes[Cxe::IMAGE_SCENE_AUTO]; |
|
36 mCurrentVideoScene = mVideoSceneModes[Cxe::VIDEO_SCENE_AUTO]; |
|
37 |
|
38 CX_DEBUG_EXIT_FUNCTION(); |
|
39 } |
|
40 |
|
41 /*! |
|
42 * Destructor. |
|
43 */ |
|
44 CxeSceneModeStore::~CxeSceneModeStore() |
|
45 { |
|
46 CX_DEBUG_IN_FUNCTION(); |
|
47 } |
|
48 |
|
49 /*! |
|
50 * Returns scene setting value from current scene. |
|
51 * @param cameraMode Camera mode used to determine which scene mode to use |
|
52 * @param key Settings key |
|
53 * @param[out] value Value associated with the key |
|
54 * @return Error id. CxeError::None if no errors. |
|
55 */ |
|
56 CxeError::Id CxeSceneModeStore::sceneSettingValue(Cxe::CameraMode cameraMode, const QString &key, QVariant &value) const |
|
57 { |
|
58 CX_DEBUG_ENTER_FUNCTION(); |
|
59 |
|
60 CxeScene scene; |
|
61 CxeError::Id err = CxeError::None; |
|
62 |
|
63 if(cameraMode == Cxe::ImageMode) { |
|
64 CX_DEBUG(( "CxeSceneModeStore::sceneSettingValue - Image mode Setting")); |
|
65 scene = mCurrentImageScene; |
|
66 } else { |
|
67 CX_DEBUG(( "CxeSceneModeStore::sceneSettingValue - Video mode Setting")); |
|
68 scene = mCurrentVideoScene; |
|
69 } |
|
70 |
|
71 if (scene.contains(key)) { |
|
72 value = scene[key]; |
|
73 } else { |
|
74 err = CxeError::NotFound; |
|
75 } |
|
76 |
|
77 |
|
78 CX_DEBUG_EXIT_FUNCTION(); |
|
79 |
|
80 return err; |
|
81 } |
|
82 |
|
83 /*! |
|
84 * Sets new value to settings specific to the scene to the current scene. |
|
85 * @param cameraMode Camera mode used to determine which scene mode to use |
|
86 * @param key - setting id. |
|
87 * @param newValue - new setting value |
|
88 * @return Error id. CxeError::None if no errors. |
|
89 */ |
|
90 CxeError::Id CxeSceneModeStore::setSceneSettingValue(Cxe::CameraMode cameraMode, const QString &key, const QVariant &newValue) |
|
91 { |
|
92 CX_DEBUG_ENTER_FUNCTION(); |
|
93 |
|
94 CxeError::Id err = CxeError::None; |
|
95 CxeScene *scene(0); |
|
96 |
|
97 if (cameraMode == Cxe::ImageMode) { |
|
98 CX_DEBUG(( "CxeSettingsImp::setSceneSettingValue - Image mode Setting")); |
|
99 scene = &mCurrentImageScene; |
|
100 } else { |
|
101 CX_DEBUG(( "CxeSettingsImp::setSceneSettingValue - Video mode Setting")); |
|
102 scene = &mCurrentVideoScene; |
|
103 } |
|
104 |
|
105 if (scene && scene->contains(key)) { |
|
106 CX_DEBUG(( "CxeSettingsImp::setSceneSettingValue KEY found, writing value")); |
|
107 scene->insert(key, newValue); |
|
108 } else { |
|
109 err = CxeError::NotFound; |
|
110 } |
|
111 |
|
112 CX_DEBUG_EXIT_FUNCTION(); |
|
113 |
|
114 return err; |
|
115 } |
|
116 |
|
117 /*! |
|
118 * Returns id of current scene. |
|
119 * @param cameraMode Camera mode used to determine which scene mode to use |
|
120 * @return id of current scene mode |
|
121 */ |
|
122 QString CxeSceneModeStore::currentSceneId(Cxe::CameraMode cameraMode) const |
|
123 { |
|
124 if (cameraMode == Cxe::ImageMode) { |
|
125 return mCurrentImageScene[CxeSettingIds::SCENE_ID].toString(); |
|
126 } else { |
|
127 return mCurrentVideoScene[CxeSettingIds::SCENE_ID].toString(); |
|
128 } |
|
129 } |
|
130 /*! |
|
131 * Returns current scene mode. |
|
132 * @param cameraMode Camera mode used to determine which scene mode to use |
|
133 * @return Current scene mode |
|
134 */ |
|
135 CxeScene& CxeSceneModeStore::currentScene(Cxe::CameraMode cameraMode) |
|
136 { |
|
137 CX_DEBUG_ENTER_FUNCTION(); |
|
138 if (cameraMode == Cxe::ImageMode) { |
|
139 CX_DEBUG_EXIT_FUNCTION(); |
|
140 return mCurrentImageScene; |
|
141 } else { |
|
142 CX_DEBUG_EXIT_FUNCTION(); |
|
143 return mCurrentVideoScene; |
|
144 } |
|
145 } |
|
146 |
|
147 /*! |
|
148 * Returns current scene mode. Overloaded const version. |
|
149 */ |
|
150 const CxeScene& CxeSceneModeStore::currentScene(Cxe::CameraMode cameraMode) const |
|
151 { |
|
152 CX_DEBUG_ENTER_FUNCTION(); |
|
153 if (cameraMode == Cxe::ImageMode) { |
|
154 CX_DEBUG_EXIT_FUNCTION(); |
|
155 return mCurrentImageScene; |
|
156 } else { |
|
157 CX_DEBUG_EXIT_FUNCTION(); |
|
158 return mCurrentVideoScene; |
|
159 } |
|
160 } |
|
161 /*! |
|
162 * Set current scene mode. |
|
163 * @param cameraMode Camera mode used to determine which scene mode to use |
|
164 * @sceneId id of the scene mode to set |
|
165 */ |
|
166 void CxeSceneModeStore::setCurrentScene(Cxe::CameraMode cameraMode, const QString &sceneId) |
|
167 { |
|
168 CX_DEBUG_ENTER_FUNCTION(); |
|
169 CX_DEBUG(("Setting scene mode: %s", sceneId.toAscii().data())); |
|
170 // @todo check that scene is valid |
|
171 if (cameraMode == Cxe::ImageMode) { |
|
172 if (!mImageSceneModes.contains(sceneId)) { |
|
173 throw CxeException(CxeError::NotFound); |
|
174 } |
|
175 mCurrentImageScene = mImageSceneModes[sceneId]; |
|
176 } else { |
|
177 if (!mVideoSceneModes.contains(sceneId)) { |
|
178 throw CxeException(CxeError::NotFound); |
|
179 } |
|
180 mCurrentVideoScene = mVideoSceneModes[sceneId]; |
|
181 } |
|
182 CX_DEBUG_EXIT_FUNCTION(); |
|
183 } |
|
184 |
|
185 /*! |
|
186 * Returns scene mode based on id. |
|
187 * @param cameraMode Camera mode used to determine which scene mode to use |
|
188 * @param sceneId id of the scene mode |
|
189 * @return scene mode |
|
190 */ |
|
191 CxeScene CxeSceneModeStore::getScene(Cxe::CameraMode cameraMode, const QString &sceneId) const |
|
192 { |
|
193 CX_DEBUG_ENTER_FUNCTION(); |
|
194 CX_DEBUG(("Getting scene mode: %s", sceneId.toAscii().data())); |
|
195 if (cameraMode == Cxe::ImageMode) { |
|
196 if (!mImageSceneModes.contains(sceneId)) { |
|
197 throw CxeException(CxeError::NotFound); |
|
198 } |
|
199 CX_DEBUG_EXIT_FUNCTION(); |
|
200 return mImageSceneModes[sceneId]; |
|
201 } else { |
|
202 if (!mVideoSceneModes.contains(sceneId)) { |
|
203 throw CxeException(CxeError::NotFound); |
|
204 } |
|
205 CX_DEBUG_EXIT_FUNCTION(); |
|
206 return mVideoSceneModes[sceneId]; |
|
207 } |
|
208 } |
|
209 |
|
210 /*! |
|
211 * Loads all Image Scene Modes |
|
212 */ |
|
213 void CxeSceneModeStore::loadImageScenes() |
|
214 { |
|
215 CX_DEBUG_ENTER_FUNCTION(); |
|
216 |
|
217 mImageSceneModes.clear(); |
|
218 |
|
219 CxeScene imgSceneAuto; |
|
220 |
|
221 imgSceneAuto.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_AUTO); |
|
222 imgSceneAuto.insert(CxeSettingIds::FOCAL_RANGE, CxeAutoFocusControl::Auto); |
|
223 imgSceneAuto.insert(CxeSettingIds::WHITE_BALANCE, WhitebalanceAutomatic); |
|
224 imgSceneAuto.insert(CxeSettingIds::EXPOSURE_MODE, ExposureAuto); |
|
225 imgSceneAuto.insert(CxeSettingIds::COLOR_TONE, ColortoneNormal); |
|
226 imgSceneAuto.insert(CxeSettingIds::CONTRAST, 0); |
|
227 imgSceneAuto.insert(CxeSettingIds::SHARPNESS, SharpnessNormal); |
|
228 imgSceneAuto.insert(CxeSettingIds::LIGHT_SENSITIVITY, LightSensitivityAutomatic); |
|
229 imgSceneAuto.insert(CxeSettingIds::EV_COMPENSATION_VALUE, 0); |
|
230 imgSceneAuto.insert(CxeSettingIds::BRIGHTNESS, 0); |
|
231 imgSceneAuto.insert(CxeSettingIds::FLASH_MODE, FlashAuto); |
|
232 imgSceneAuto.insert(CxeSettingIds::FACE_TRACKING, 1); |
|
233 |
|
234 mImageSceneModes.insert(Cxe::IMAGE_SCENE_AUTO, imgSceneAuto); |
|
235 |
|
236 |
|
237 CxeScene imgSceneSports; |
|
238 |
|
239 imgSceneSports.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_SPORTS); |
|
240 imgSceneSports.insert(CxeSettingIds::FOCAL_RANGE, CxeAutoFocusControl::Hyperfocal); |
|
241 imgSceneSports.insert(CxeSettingIds::WHITE_BALANCE, WhitebalanceAutomatic); |
|
242 imgSceneSports.insert(CxeSettingIds::EXPOSURE_MODE, ExposureSport); |
|
243 imgSceneSports.insert(CxeSettingIds::COLOR_TONE, ColortoneNormal); |
|
244 imgSceneSports.insert(CxeSettingIds::CONTRAST, 0); |
|
245 imgSceneSports.insert(CxeSettingIds::SHARPNESS, SharpnessNormal); |
|
246 imgSceneSports.insert(CxeSettingIds::LIGHT_SENSITIVITY, LightSensitivityAutomatic); |
|
247 imgSceneSports.insert(CxeSettingIds::EV_COMPENSATION_VALUE, 0); |
|
248 imgSceneSports.insert(CxeSettingIds::BRIGHTNESS, 0); |
|
249 imgSceneSports.insert(CxeSettingIds::FLASH_MODE, FlashOff); |
|
250 imgSceneSports.insert(CxeSettingIds::FACE_TRACKING, 0); |
|
251 |
|
252 mImageSceneModes.insert(Cxe::IMAGE_SCENE_SPORTS, imgSceneSports); |
|
253 |
|
254 |
|
255 CxeScene imgSceneCloseUp; |
|
256 |
|
257 imgSceneCloseUp.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_MACRO); |
|
258 imgSceneCloseUp.insert(CxeSettingIds::FOCAL_RANGE, CxeAutoFocusControl::Macro); |
|
259 imgSceneCloseUp.insert(CxeSettingIds::WHITE_BALANCE, WhitebalanceAutomatic); |
|
260 imgSceneCloseUp.insert(CxeSettingIds::EXPOSURE_MODE, ExposureAuto); |
|
261 imgSceneCloseUp.insert(CxeSettingIds::COLOR_TONE, ColortoneNormal); |
|
262 imgSceneCloseUp.insert(CxeSettingIds::CONTRAST, 0); |
|
263 imgSceneCloseUp.insert(CxeSettingIds::SHARPNESS, SharpnessNormal); |
|
264 imgSceneCloseUp.insert(CxeSettingIds::LIGHT_SENSITIVITY, LightSensitivityAutomatic); |
|
265 imgSceneCloseUp.insert(CxeSettingIds::EV_COMPENSATION_VALUE, 0); |
|
266 imgSceneCloseUp.insert(CxeSettingIds::BRIGHTNESS, 0); |
|
267 imgSceneCloseUp.insert(CxeSettingIds::FLASH_MODE, FlashAuto); |
|
268 imgSceneCloseUp.insert(CxeSettingIds::FACE_TRACKING, 0); |
|
269 |
|
270 mImageSceneModes.insert(Cxe::IMAGE_SCENE_MACRO, imgSceneCloseUp); |
|
271 |
|
272 CxeScene imgPortraitscene; |
|
273 |
|
274 imgPortraitscene.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_PORTRAIT); |
|
275 imgPortraitscene.insert(CxeSettingIds::FOCAL_RANGE, CxeAutoFocusControl::Portrait); |
|
276 imgPortraitscene.insert(CxeSettingIds::WHITE_BALANCE, WhitebalanceAutomatic); |
|
277 imgPortraitscene.insert(CxeSettingIds::EXPOSURE_MODE, ExposureBacklight); |
|
278 imgPortraitscene.insert(CxeSettingIds::COLOR_TONE, ColortoneNormal); |
|
279 imgPortraitscene.insert(CxeSettingIds::CONTRAST, 0); |
|
280 imgPortraitscene.insert(CxeSettingIds::SHARPNESS, SharpnessSoft); |
|
281 imgPortraitscene.insert(CxeSettingIds::LIGHT_SENSITIVITY, LightSensitivityAutomatic); |
|
282 imgPortraitscene.insert(CxeSettingIds::EV_COMPENSATION_VALUE, 0); |
|
283 imgPortraitscene.insert(CxeSettingIds::BRIGHTNESS, 0); |
|
284 imgPortraitscene.insert(CxeSettingIds::FLASH_MODE, FlashAntiRedEye); |
|
285 imgPortraitscene.insert(CxeSettingIds::FACE_TRACKING, 1); |
|
286 |
|
287 mImageSceneModes.insert(Cxe::IMAGE_SCENE_PORTRAIT, imgPortraitscene); |
|
288 |
|
289 CxeScene imglandscapescene; |
|
290 |
|
291 imglandscapescene.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_SCENERY); |
|
292 imglandscapescene.insert(CxeSettingIds::FOCAL_RANGE, CxeAutoFocusControl::Infinity); |
|
293 imglandscapescene.insert(CxeSettingIds::WHITE_BALANCE, WhitebalanceSunny); |
|
294 imglandscapescene.insert(CxeSettingIds::EXPOSURE_MODE, ExposureAuto); |
|
295 imglandscapescene.insert(CxeSettingIds::COLOR_TONE, ColortoneNormal); |
|
296 imglandscapescene.insert(CxeSettingIds::CONTRAST, 0); |
|
297 imglandscapescene.insert(CxeSettingIds::SHARPNESS, SharpnessHard); |
|
298 imglandscapescene.insert(CxeSettingIds::LIGHT_SENSITIVITY, LightSensitivityAutomatic); |
|
299 imglandscapescene.insert(CxeSettingIds::EV_COMPENSATION_VALUE, 0); |
|
300 imglandscapescene.insert(CxeSettingIds::BRIGHTNESS, 0); |
|
301 imglandscapescene.insert(CxeSettingIds::FLASH_MODE, FlashOff); |
|
302 imglandscapescene.insert(CxeSettingIds::FACE_TRACKING, 0); |
|
303 |
|
304 mImageSceneModes.insert(Cxe::IMAGE_SCENE_SCENERY, imglandscapescene); |
|
305 |
|
306 |
|
307 CxeScene imgNightscene; |
|
308 |
|
309 imgNightscene.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_NIGHT); |
|
310 imgNightscene.insert(CxeSettingIds::FOCAL_RANGE, CxeAutoFocusControl::Auto); |
|
311 imgNightscene.insert(CxeSettingIds::WHITE_BALANCE, WhitebalanceAutomatic); |
|
312 imgNightscene.insert(CxeSettingIds::EXPOSURE_MODE, ExposureNight); |
|
313 imgNightscene.insert(CxeSettingIds::COLOR_TONE, ColortoneNormal); |
|
314 imgNightscene.insert(CxeSettingIds::CONTRAST, 0); |
|
315 imgNightscene.insert(CxeSettingIds::SHARPNESS, SharpnessNormal); |
|
316 imgNightscene.insert(CxeSettingIds::LIGHT_SENSITIVITY, LightSensitivityAutomatic); |
|
317 imgNightscene.insert(CxeSettingIds::EV_COMPENSATION_VALUE, 0); |
|
318 imgNightscene.insert(CxeSettingIds::BRIGHTNESS, 0); |
|
319 imgNightscene.insert(CxeSettingIds::FLASH_MODE, FlashOff); |
|
320 imgNightscene.insert(CxeSettingIds::FACE_TRACKING, 1); |
|
321 |
|
322 mImageSceneModes.insert(Cxe::IMAGE_SCENE_NIGHT, imgNightscene); |
|
323 |
|
324 CxeScene imgNightpotraitscene; |
|
325 |
|
326 imgNightpotraitscene.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_NIGHTPORTRAIT); |
|
327 imgNightpotraitscene.insert(CxeSettingIds::FOCAL_RANGE, CxeAutoFocusControl::Portrait); |
|
328 imgNightpotraitscene.insert(CxeSettingIds::WHITE_BALANCE, WhitebalanceAutomatic); |
|
329 imgNightpotraitscene.insert(CxeSettingIds::EXPOSURE_MODE, ExposureNight); |
|
330 imgNightpotraitscene.insert(CxeSettingIds::COLOR_TONE, ColortoneNormal); |
|
331 imgNightpotraitscene.insert(CxeSettingIds::CONTRAST, 0); |
|
332 imgNightpotraitscene.insert(CxeSettingIds::SHARPNESS, SharpnessNormal); |
|
333 imgNightpotraitscene.insert(CxeSettingIds::LIGHT_SENSITIVITY, LightSensitivityAutomatic); |
|
334 imgNightpotraitscene.insert(CxeSettingIds::EV_COMPENSATION_VALUE, 0); |
|
335 imgNightpotraitscene.insert(CxeSettingIds::BRIGHTNESS, 0); |
|
336 imgNightpotraitscene.insert(CxeSettingIds::FLASH_MODE, FlashAntiRedEye); |
|
337 imgNightpotraitscene.insert(CxeSettingIds::FACE_TRACKING, 1); |
|
338 |
|
339 mImageSceneModes.insert(Cxe::IMAGE_SCENE_NIGHTPORTRAIT, imgNightpotraitscene); |
|
340 |
|
341 CX_DEBUG_EXIT_FUNCTION(); |
|
342 } |
|
343 |
|
344 |
|
345 /*! |
|
346 * Loads all video scene modes |
|
347 */ |
|
348 void CxeSceneModeStore::loadVideoScenes() |
|
349 { |
|
350 CX_DEBUG_ENTER_FUNCTION(); |
|
351 |
|
352 mVideoSceneModes.clear(); |
|
353 |
|
354 CxeScene vidSceneAuto; |
|
355 |
|
356 vidSceneAuto.insert(CxeSettingIds::SCENE_ID, Cxe::VIDEO_SCENE_AUTO); |
|
357 vidSceneAuto.insert(CxeSettingIds::FOCAL_RANGE, CxeAutoFocusControl::Hyperfocal); |
|
358 vidSceneAuto.insert(CxeSettingIds::WHITE_BALANCE, WhitebalanceAutomatic); |
|
359 vidSceneAuto.insert(CxeSettingIds::EXPOSURE_MODE, ExposureAuto); |
|
360 vidSceneAuto.insert(CxeSettingIds::COLOR_TONE, ColortoneNormal); |
|
361 vidSceneAuto.insert(CxeSettingIds::CONTRAST, 0); |
|
362 vidSceneAuto.insert(CxeSettingIds::FRAME_RATE, 0); |
|
363 vidSceneAuto.insert(CxeSettingIds::EV_COMPENSATION_VALUE, 0); |
|
364 |
|
365 mVideoSceneModes.insert(Cxe::VIDEO_SCENE_AUTO,vidSceneAuto); |
|
366 |
|
367 |
|
368 CxeScene vidSceneNight; |
|
369 |
|
370 vidSceneNight.insert(CxeSettingIds::SCENE_ID, Cxe::VIDEO_SCENE_NIGHT); |
|
371 vidSceneNight.insert(CxeSettingIds::FOCAL_RANGE, CxeAutoFocusControl::Hyperfocal); |
|
372 vidSceneNight.insert(CxeSettingIds::WHITE_BALANCE, WhitebalanceAutomatic); |
|
373 vidSceneNight.insert(CxeSettingIds::EXPOSURE_MODE, ExposureNight); |
|
374 vidSceneNight.insert(CxeSettingIds::COLOR_TONE, ColortoneNormal); |
|
375 vidSceneNight.insert(CxeSettingIds::CONTRAST, 0); |
|
376 vidSceneNight.insert(CxeSettingIds::FRAME_RATE, 0); |
|
377 vidSceneNight.insert(CxeSettingIds::EV_COMPENSATION_VALUE, 0); |
|
378 |
|
379 mVideoSceneModes.insert(Cxe::VIDEO_SCENE_NIGHT, vidSceneNight); |
|
380 |
|
381 |
|
382 CxeScene vidSceneLowLight; |
|
383 |
|
384 vidSceneLowLight.insert(CxeSettingIds::SCENE_ID, Cxe::VIDEO_SCENE_LOWLIGHT); |
|
385 vidSceneLowLight.insert(CxeSettingIds::FOCAL_RANGE, CxeAutoFocusControl::Hyperfocal); |
|
386 vidSceneLowLight.insert(CxeSettingIds::WHITE_BALANCE, WhitebalanceAutomatic); |
|
387 vidSceneLowLight.insert(CxeSettingIds::EXPOSURE_MODE, ExposureAuto); |
|
388 vidSceneLowLight.insert(CxeSettingIds::COLOR_TONE, ColortoneNormal); |
|
389 vidSceneLowLight.insert(CxeSettingIds::CONTRAST, 0); |
|
390 vidSceneLowLight.insert(CxeSettingIds::FRAME_RATE, 15); //fps |
|
391 vidSceneLowLight.insert(CxeSettingIds::EV_COMPENSATION_VALUE, 0); |
|
392 |
|
393 mVideoSceneModes.insert(Cxe::VIDEO_SCENE_LOWLIGHT, vidSceneLowLight); |
|
394 |
|
395 |
|
396 CX_DEBUG_EXIT_FUNCTION(); |
|
397 } |
|