|
1 /* |
|
2 * Copyright (c) 2007-2009 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: Setting Provider class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // =========================================================================== |
|
20 // Includes |
|
21 |
|
22 #include "camcameracontrollerflags.hrh" |
|
23 #include <ecam.h> |
|
24 #ifdef CAMERAAPP_CAPI_V2 |
|
25 #include <ecamadvsettings.h> // KECamFineResolutionFactor |
|
26 #endif |
|
27 |
|
28 #include <ECamOrientationCustomInterface2.h> |
|
29 |
|
30 #include "camlogging.h" |
|
31 #include "camcameracontroller.pan" |
|
32 #include "CamSettingsInternal.hrh" |
|
33 #include "camcameracontrollertypes.h" |
|
34 #include "camsettingprovider.h" |
|
35 #include "CamSettingsModel.h" |
|
36 #include "camsettingconversion.h" |
|
37 #include "CamAppController.h" |
|
38 #include "campointerutility.inl" |
|
39 #include "CameraUiConfigManager.h" |
|
40 |
|
41 #include "CamAppUi.h" |
|
42 #include "CamUtility.h" |
|
43 #include "CamPSI.h" |
|
44 |
|
45 #include "CamVideoQualityLevel.h" |
|
46 |
|
47 |
|
48 // =========================================================================== |
|
49 // Types |
|
50 |
|
51 using namespace NCamCameraController; |
|
52 |
|
53 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
54 typedef CCamera::CCameraAdvancedSettings CAS; |
|
55 #endif |
|
56 #ifdef CAMERAAPP_CAPI_V2_IP |
|
57 typedef CCamera::CCameraImageProcessing CIP; |
|
58 #endif |
|
59 |
|
60 // =========================================================================== |
|
61 // Local data |
|
62 |
|
63 static const TInt KSettingArrayGranularity = 8; |
|
64 |
|
65 static const TSize KViewfinderSize = TSize(320, 240); |
|
66 static const TBool KSnapshotMaintainAspect = EFalse; |
|
67 static const TInt KEngineMultiplier = 10; |
|
68 |
|
69 // =========================================================================== |
|
70 // Methods |
|
71 |
|
72 // static |
|
73 CCamSettingProvider* |
|
74 CCamSettingProvider::NewL( CCamAppController& aController, |
|
75 MCamSettingsModel* aSettingsModel ) |
|
76 { |
|
77 CCamSettingProvider* self = |
|
78 CCamSettingProvider::NewLC( aController, aSettingsModel ); |
|
79 CleanupStack::Pop( self ); |
|
80 return self; |
|
81 } |
|
82 |
|
83 // static |
|
84 CCamSettingProvider* |
|
85 CCamSettingProvider::NewLC( CCamAppController& aController, |
|
86 MCamSettingsModel* aSettingsModel ) |
|
87 { |
|
88 CCamSettingProvider* self = |
|
89 new (ELeave) CCamSettingProvider( aController, aSettingsModel ); |
|
90 CleanupStack::PushL( self ); |
|
91 self->ConstructL(); |
|
92 return self; |
|
93 } |
|
94 |
|
95 // virtual |
|
96 CCamSettingProvider::~CCamSettingProvider() |
|
97 { |
|
98 iPendingSettingChanges.Close(); |
|
99 } |
|
100 |
|
101 |
|
102 // =========================================================================== |
|
103 // From MCamSettingProvider |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // virtual ProvideCameraParamL |
|
107 // |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 void |
|
111 CCamSettingProvider::ProvideCameraParamL( |
|
112 const NCamCameraController::TCamCameraParamId& aParamId, |
|
113 TAny* aParamData ) |
|
114 { |
|
115 __ASSERT_DEBUG( aParamData, Panic( ECamNullPointer ) ); |
|
116 switch( aParamId ) |
|
117 { |
|
118 // ----------------------------------------------------- |
|
119 case ECameraParamImage: |
|
120 { |
|
121 TPckgBuf<TCamParamsImage>* ptr = |
|
122 static_cast<TPckgBuf<TCamParamsImage>*>( aParamData ); |
|
123 CheckNonNullL( ptr, KErrNotFound ); |
|
124 TCamParamsImage& params( (*ptr)() ); |
|
125 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( CEikonEnv::Static()->AppUi() ); |
|
126 if ( appUi->ActiveCamera() == ECamActiveCameraSecondary ) |
|
127 { |
|
128 params.iFormat = CCamera::EFormatJpeg; |
|
129 } |
|
130 else // primary camera |
|
131 { |
|
132 params.iFormat = CCamera::EFormatExif; |
|
133 } |
|
134 TCamPhotoSizeId PhotoSizeIndex = iSettingsModel->CurrentPhotoResolution(); |
|
135 TSize PhotoSize = iSettingsModel->ImageResolutionFromIndex( PhotoSizeIndex ); |
|
136 params.iSize = PhotoSize; |
|
137 params.iQualityFactor = iSettingsModel->CurrentPhotoCompression(); |
|
138 break; |
|
139 } |
|
140 // ----------------------------------------------------- |
|
141 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
142 case ECameraParamVideoCae: |
|
143 { |
|
144 TPckgBuf<TCamParamsVideoCae>* ptr = |
|
145 static_cast<TPckgBuf<TCamParamsVideoCae>*>( aParamData ); |
|
146 CheckNonNullL( ptr, KErrNotFound ); |
|
147 |
|
148 TCamParamsVideoCae& params( (*ptr)() ); |
|
149 |
|
150 |
|
151 TInt videoQuality = iSettingsModel->IntegerSettingValue( ECamSettingItemVideoQuality ); |
|
152 |
|
153 PRINT1( _L("Camera <> CCamSettingProvider::ProvideCameraParamL - video quality (index): %d"), videoQuality ); |
|
154 PRINT1( _L("Camera <> CCamSettingProvider::ProvideCameraParamL - quality count: %d"), iSettingsModel->VideoQualityArray().Count() ); |
|
155 |
|
156 CCamVideoQualityLevel& level = *( iSettingsModel->VideoQualityArray() )[videoQuality]; |
|
157 TInt res = level.VideoResolution(); |
|
158 PRINT1( _L("Camera <> CCamSettingProvider::ProvideCameraParamL - video resolution (index): %d"), res ); |
|
159 PRINT1( _L("Camera <> CCamSettingProvider::ProvideCameraParamL - resolution count: %d"), iSettingsModel->VideoResolutions().Count() ); |
|
160 |
|
161 // Video resolutions array in Setting Model is set up from |
|
162 // R_CAM_VIDEO_RESOLUTION_ARRAY resource. New resolutions |
|
163 // need to be added there also, in addition to configuration files. |
|
164 TSize resolution = ( iSettingsModel->VideoResolutions() )[ res ]; |
|
165 params.iFrameSize = resolution; |
|
166 params.iFrameRate = level.FrameRate(); |
|
167 params.iVideoBitRate = level.VideoBitRate(); |
|
168 params.iAudioBitRate = level.AudioBitRate(); |
|
169 params.iAudioOn = iSettingsModel->IntegerSettingValue( ECamSettingItemVideoAudioRec ); |
|
170 params.iMimeType.Set ( level.VideoMimeType() ); |
|
171 params.iSupplier.Set ( level.PreferredSupplier() ); |
|
172 params.iVideoType.Set( level.VideoFileType() ); |
|
173 params.iAudioType.Set( level.AudioType() ); |
|
174 |
|
175 TInt framerate = -1; |
|
176 TCamSceneId videoscene = static_cast< TCamSceneId > ( |
|
177 iSettingsModel->IntegerSettingValue(ECamSettingItemDynamicVideoScene) ); |
|
178 |
|
179 framerate = iSettingsModel->SceneSettingValue(videoscene, ECamSettingItemSceneFramerate); |
|
180 |
|
181 // Change the framerate if scene has defined it to be > 0 |
|
182 if ( framerate > 0 ) |
|
183 { |
|
184 params.iFrameRate = framerate; |
|
185 } |
|
186 |
|
187 PRINT1( _L("Camera <> CCamSettingProvider::ProvideCameraParamL ECameraParamVideoCae framerate: %d"), framerate ) |
|
188 |
|
189 break; |
|
190 } |
|
191 #endif // CAMERAAPP_CAE_FOR_VIDEO |
|
192 // ----------------------------------------------------- |
|
193 case ECameraParamVfMode: |
|
194 { |
|
195 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
196 TPckgBuf<TCamViewfinderMode>* ptr = |
|
197 static_cast<TPckgBuf<TCamViewfinderMode>*>( aParamData ); |
|
198 CheckNonNullL( ptr, KErrNotFound ); |
|
199 TCamViewfinderMode& params( (*ptr)() ); |
|
200 TBool isPrimaryCamera = appUi->ActiveCamera() == ECamActiveCameraPrimary; |
|
201 |
|
202 if ( iController.IsDirectScreenVFSupported( isPrimaryCamera ) ) |
|
203 {// primary camera or 2nd camera DSVF |
|
204 PRINT( _L("Setting Provider <> provide ECameraParamVfMode == ECamViewfinderDirect") ); |
|
205 params = ECamViewfinderDirect; |
|
206 } |
|
207 else |
|
208 {// primary camera or 2nd camera bitmap view finder |
|
209 PRINT( _L("Setting Provider <> provide ECameraParamVfMode == ECamViewfinderBitmap") ); |
|
210 params = ECamViewfinderBitmap; |
|
211 } |
|
212 break; |
|
213 } |
|
214 // ----------------------------------------------------- |
|
215 case ECameraParamVfBitmap: |
|
216 { |
|
217 CCamAppUi* appUi = static_cast<CCamAppUi*>( |
|
218 CEikonEnv::Static()->AppUi() ); |
|
219 PRINT2( _L("Setting Provider <> provide ECameraParamVfBitmap. CurrentMode: (%d) TargetMode: (%d)"), iController.CurrentMode(), appUi->TargetMode() ); |
|
220 TPckgBuf<TCamParamsVfBitmap>* ptr = |
|
221 static_cast<TPckgBuf<TCamParamsVfBitmap>*>( aParamData ); |
|
222 CheckNonNullL( ptr, KErrNotFound ); |
|
223 TCamParamsVfBitmap& params( (*ptr)() ); |
|
224 |
|
225 TDisplayMode displayMode = |
|
226 CEikonEnv::Static()->ScreenDevice()->DisplayMode(); |
|
227 CCamera::TFormat viewfinderFormat = |
|
228 CCamSettingConversion::Map2CameraFormat( displayMode ); |
|
229 |
|
230 const TCamCameraMode cameraMode = iController.CurrentMode(); |
|
231 const TInt resolution = (cameraMode == ECamControllerVideo) |
|
232 ? iController.GetCurrentVideoResolution() |
|
233 : iController.GetCurrentImageResolution(); |
|
234 params.iRect = CamUtility::ViewfinderLayout( cameraMode, resolution ); |
|
235 |
|
236 params.iFormat = viewfinderFormat; |
|
237 |
|
238 // Mirror viewfinder for secondary camera |
|
239 params.iMirrorImage = ECamActiveCameraSecondary == appUi->ActiveCamera(); |
|
240 |
|
241 break; |
|
242 } |
|
243 // ----------------------------------------------------- |
|
244 case ECameraParamVfDirect: |
|
245 { |
|
246 // Not supported yet. |
|
247 User::Leave( KErrNotSupported ); |
|
248 break; |
|
249 } |
|
250 // ----------------------------------------------------- |
|
251 case ECameraParamSnapshot: |
|
252 { |
|
253 TPckgBuf<TCamParamsSnapshot>* ptr = |
|
254 static_cast<TPckgBuf<TCamParamsSnapshot>*>( aParamData ); |
|
255 CheckNonNullL( ptr, KErrNotFound ); |
|
256 TCamParamsSnapshot& params( (*ptr)() ); |
|
257 |
|
258 // Fetch the snapshot size |
|
259 TDisplayMode displayMode = CEikonEnv::Static()->ScreenDevice()->DisplayMode(); |
|
260 TCamCameraMode cameraMode = iController.CurrentMode(); |
|
261 TInt resolution = (cameraMode == ECamControllerVideo) |
|
262 ? iController.GetCurrentVideoResolution() |
|
263 : iController.GetCurrentImageResolution(); |
|
264 params.iSize = CamUtility::ViewfinderLayout( cameraMode, resolution ).Size(); |
|
265 params.iFormat = CCamSettingConversion::Map2CameraFormat(displayMode); |
|
266 params.iMaintainAspect = KSnapshotMaintainAspect; |
|
267 break; |
|
268 } |
|
269 // ----------------------------------------------------- |
|
270 default: |
|
271 { |
|
272 User::Leave( KErrNotSupported ); |
|
273 break; |
|
274 } |
|
275 // ----------------------------------------------------- |
|
276 } |
|
277 } |
|
278 |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // virtual ProvideCameraSettingL |
|
282 // |
|
283 // --------------------------------------------------------------------------- |
|
284 // |
|
285 void |
|
286 CCamSettingProvider::ProvideCameraSettingL( |
|
287 const NCamCameraController::TCamCameraSettingId& aSettingId, |
|
288 TAny* aSettingData ) |
|
289 { |
|
290 CheckNonNullL( aSettingData, KErrArgument ); |
|
291 |
|
292 TCamCameraMode mode( iController.CurrentMode() ); |
|
293 |
|
294 switch( aSettingId ) |
|
295 { |
|
296 // ----------------------------------------------------- |
|
297 // Flash |
|
298 case ECameraSettingFlash: |
|
299 case ECameraUserSceneSettingFlash: |
|
300 { |
|
301 TCamFlashId flashId = static_cast<TCamFlashId> (iSettingsModel-> |
|
302 IntegerSettingValue( ECamSettingItemDynamicPhotoFlash ) ); |
|
303 if ( mode == ECamControllerVideo ) |
|
304 { |
|
305 flashId = static_cast<TCamFlashId> (iSettingsModel-> |
|
306 IntegerSettingValue( ECamSettingItemDynamicVideoFlash ) ); |
|
307 } |
|
308 CCamera::TFlash CamFlashId = CCamSettingConversion::Map2CameraFlash( flashId ); |
|
309 CCamera::TFlash* ptr = static_cast<CCamera::TFlash*>( aSettingData ); |
|
310 *ptr = CamFlashId; |
|
311 break; |
|
312 } |
|
313 // ----------------------------------------------------- |
|
314 // Exposure (EV mode + EV compensation step) |
|
315 case ECameraSettingExposure: |
|
316 case ECameraUserSceneSettingExposure: |
|
317 { |
|
318 TPckgBuf<TCamSettingDataExposure>* ptr = |
|
319 static_cast<TPckgBuf<TCamSettingDataExposure>*>( aSettingData ); |
|
320 TCamSettingDataExposure& evData( (*ptr)() ); |
|
321 |
|
322 TInt sceneItemId = ( ECamControllerVideo == mode ) |
|
323 ? ECamSettingItemDynamicVideoScene |
|
324 : ECamSettingItemDynamicPhotoScene; |
|
325 |
|
326 TInt sceneId = iSettingsModel->IntegerSettingValue( sceneItemId ); |
|
327 |
|
328 TCamSceneAEMode evMode = |
|
329 static_cast<TCamSceneAEMode>( |
|
330 iSettingsModel->SceneSettingValue( sceneId, ECamSettingItemSceneAEMode ) ); |
|
331 |
|
332 evData.iExposureMode = CCamSettingConversion::Map2CameraExposureMode( evMode ); |
|
333 PRINT1( _L("Camera <> provide EV mode: %016b"), evData.iExposureMode ); |
|
334 #ifdef CAMERAAPP_CAPI_V2 |
|
335 TInt evKey; |
|
336 if ( ECameraUserSceneSettingExposure != aSettingId ) |
|
337 { |
|
338 evKey = ( ECamControllerVideo == mode ) |
|
339 ? ECamSettingItemDynamicVideoExposure |
|
340 : ECamSettingItemDynamicPhotoExposure; |
|
341 } |
|
342 else |
|
343 { |
|
344 evKey = ECamSettingItemUserSceneExposure; |
|
345 } |
|
346 |
|
347 TInt evValue = iSettingsModel->IntegerSettingValue( evKey ); |
|
348 if( iEvStepAsUiValue != 0 ) |
|
349 evData.iExposureStep = (evValue * KECamFineResolutionFactor) / iEvStepAsUiValue; |
|
350 else |
|
351 evData.iExposureStep = 0; |
|
352 PRINT1( _L("Camera <> provide EV compensation: %d"), evData.iExposureStep ); |
|
353 #else |
|
354 evData.iExposureStep = 0; |
|
355 #endif |
|
356 break; |
|
357 } |
|
358 // ----------------------------------------------------- |
|
359 // Light sensitivity (ISO value) |
|
360 case ECameraSettingLightSensitivity: |
|
361 case ECameraUserSceneSettingLightSensitivity: |
|
362 { |
|
363 TInt* ptr = static_cast<TInt*>( aSettingData ); |
|
364 TInt isoKey; |
|
365 |
|
366 if ( ECameraUserSceneSettingLightSensitivity != aSettingId ) |
|
367 { |
|
368 isoKey = ( ECamControllerVideo == mode ) |
|
369 ? ECamSettingItemDynamicVideoLightSensitivity |
|
370 : ECamSettingItemDynamicPhotoLightSensitivity; |
|
371 } |
|
372 else |
|
373 { |
|
374 isoKey = ECamSettingItemUserSceneLightSensitivity; |
|
375 } |
|
376 // TCamLightSensitivityId type value returned |
|
377 TCamLightSensitivityId isoId = |
|
378 static_cast<TCamLightSensitivityId>( iSettingsModel->IntegerSettingValue( isoKey ) ); |
|
379 |
|
380 *ptr = CamUtility::MapLightSensitivity2IsoValueL( isoId, iSupportedISORates ); |
|
381 PRINT1( _L("Camera <> provide ISO rate: %d"), *ptr ); |
|
382 break; |
|
383 } |
|
384 // ----------------------------------------------------- |
|
385 // White balance |
|
386 case ECameraSettingWhiteBalance: |
|
387 case ECameraUserSceneSettingWhiteBalance: |
|
388 { |
|
389 TPckgBuf<TCamSettingDataWhiteBalance>* ptr = |
|
390 static_cast<TPckgBuf<TCamSettingDataWhiteBalance>*>( aSettingData ); |
|
391 TInt key; |
|
392 |
|
393 if ( ECameraUserSceneSettingWhiteBalance != aSettingId ) |
|
394 { |
|
395 key = ( ECamControllerVideo == mode ) |
|
396 ? ECamSettingItemDynamicVideoWhiteBalance |
|
397 : ECamSettingItemDynamicPhotoWhiteBalance; |
|
398 } |
|
399 else |
|
400 { |
|
401 key = ECamSettingItemUserSceneWhitebalance; |
|
402 } |
|
403 |
|
404 TCamSettingDataWhiteBalance& wbData( (*ptr)() ); |
|
405 |
|
406 TCamWhiteBalanceId WB = static_cast<TCamWhiteBalanceId>(iSettingsModel->IntegerSettingValue( key )); |
|
407 CCamera::TWhiteBalance CamWB = CCamSettingConversion::Map2CameraWb( WB ); |
|
408 |
|
409 wbData.iWhiteBalanceMode = CamWB; |
|
410 break; |
|
411 } |
|
412 #ifdef CAMERAAPP_CAPI_V2_IP |
|
413 // ----------------------------------------------------- |
|
414 // Colour effect (colour filter: sepia/b&w/vivid/..) |
|
415 case ECameraSettingColourEffect: |
|
416 case ECameraUserSceneSettingColourEffect: |
|
417 { |
|
418 CIP::TEffect* ptr = static_cast<CIP::TEffect*>( aSettingData ); |
|
419 |
|
420 TInt key; |
|
421 |
|
422 if ( ECameraUserSceneSettingColourEffect != aSettingId ) |
|
423 { |
|
424 key = ( ECamControllerVideo == mode ) |
|
425 ? ECamSettingItemDynamicVideoColourFilter |
|
426 : ECamSettingItemDynamicPhotoColourFilter; |
|
427 } |
|
428 else |
|
429 { |
|
430 key = ECamSettingItemUserSceneColourFilter; |
|
431 } |
|
432 |
|
433 TCamColourFilterId uiValue = |
|
434 static_cast<TCamColourFilterId>( iSettingsModel->IntegerSettingValue( key ) ); |
|
435 |
|
436 CIP::TEffect effect = CCamSettingConversion::Map2CameraEffect( uiValue ); |
|
437 |
|
438 PRINT1( _L("Camera <> provide colour effect: 0x%08x"), effect ); |
|
439 *ptr = effect; |
|
440 break; |
|
441 } |
|
442 // ----------------------------------------------------- |
|
443 // Sharpness |
|
444 case ECameraSettingSharpness: |
|
445 case ECameraUserSceneSettingSharpness: |
|
446 { |
|
447 TInt* ptr = static_cast<TInt*>( aSettingData ); |
|
448 |
|
449 TInt key; |
|
450 |
|
451 if ( ECameraUserSceneSettingSharpness != aSettingId ) |
|
452 { |
|
453 key = ECamSettingItemDynamicPhotoImageSharpness; |
|
454 } |
|
455 else |
|
456 { |
|
457 key = ECamSettingItemUserSceneImageSharpness; |
|
458 } |
|
459 TCamImageSharpnessId uiValue = |
|
460 static_cast<TCamImageSharpnessId>( |
|
461 iSettingsModel->IntegerSettingValue( key ) ); |
|
462 |
|
463 TInt sharpness = CamUtility::MapSharpnessId2SharpnessValueL( uiValue ); |
|
464 PRINT1( _L("Camera <> provide sharpness: %d"), sharpness ); |
|
465 *ptr = sharpness; |
|
466 |
|
467 break; |
|
468 } |
|
469 #endif // CAMERAAPP_CAPI_V2_IP |
|
470 // ----------------------------------------------------- |
|
471 // Brightness |
|
472 case ECameraSettingBrightness: |
|
473 case ECameraUserSceneSettingBrightness: |
|
474 { |
|
475 CCamera::TBrightness* ptr = |
|
476 static_cast<CCamera::TBrightness*>( aSettingData ); |
|
477 |
|
478 TInt key; |
|
479 |
|
480 if ( ECameraUserSceneSettingBrightness != aSettingId ) |
|
481 { |
|
482 key = ( ECamControllerVideo == mode ) |
|
483 ? ECamSettingItemDynamicVideoBrightness |
|
484 : ECamSettingItemDynamicPhotoBrightness; |
|
485 } |
|
486 else |
|
487 { |
|
488 key = ECamSettingItemUserSceneBrightness; |
|
489 } |
|
490 |
|
491 TInt SettingsBrightness = iSettingsModel->IntegerSettingValue( key ); |
|
492 CCamera::TBrightness CamBrightness = CCamera::TBrightness( KEngineMultiplier * SettingsBrightness ); |
|
493 |
|
494 PRINT1( _L("Camera <> provide brightness: %d"), CamBrightness ); |
|
495 *ptr = CamBrightness; |
|
496 break; |
|
497 } |
|
498 // ----------------------------------------------------- |
|
499 // Contrast |
|
500 case ECameraSettingContrast: |
|
501 case ECameraUserSceneSettingContrast: |
|
502 { |
|
503 CCamera::TContrast* ptr = static_cast<CCamera::TContrast*>( aSettingData ); |
|
504 TInt key; |
|
505 |
|
506 if ( ECameraUserSceneSettingContrast != aSettingId ) |
|
507 { |
|
508 key = ( ECamControllerVideo == mode ) |
|
509 ? ECamSettingItemDynamicVideoContrast |
|
510 : ECamSettingItemDynamicPhotoContrast; |
|
511 } |
|
512 else |
|
513 { |
|
514 key = ECamSettingItemUserSceneContrast; |
|
515 } |
|
516 |
|
517 TInt SettingsContrast = iSettingsModel->IntegerSettingValue( key ); |
|
518 CCamera::TContrast CamContrast = CCamera::TContrast( KEngineMultiplier * SettingsContrast ); |
|
519 PRINT1( _L("Camera <> provide contrast: %d"), CamContrast ); |
|
520 *ptr = CamContrast; |
|
521 break; |
|
522 } |
|
523 // ----------------------------------------------------- |
|
524 // Digital zoom |
|
525 case ECameraSettingDigitalZoom: |
|
526 { |
|
527 TInt* ptr = static_cast<TInt*>( aSettingData ); |
|
528 CheckNonNullL( ptr, KErrArgument ); |
|
529 *ptr = iController.ZoomValue(); |
|
530 break; |
|
531 } |
|
532 // ----------------------------------------------------- |
|
533 // Optical zoom |
|
534 case ECameraSettingOpticalZoom: |
|
535 { |
|
536 User::Leave( KErrNotSupported ); |
|
537 //iSettingsModel->IntegerSettingValue( ECamSettingItemPhotoOpticalZoom ); |
|
538 break; |
|
539 } |
|
540 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
541 case ECameraSettingFocusRange: |
|
542 { |
|
543 // User::Leave( KErrNotSupported ); |
|
544 CAS::TFocusRange* ptr = static_cast<CAS::TFocusRange*>( aSettingData ); |
|
545 |
|
546 // Get current scene, from which the focus range value should be obtained |
|
547 TInt currentScene = iSettingsModel->IntegerSettingValue( ECamSettingItemDynamicPhotoScene ); |
|
548 if ( currentScene == ECamSceneUser ) |
|
549 { |
|
550 // In case of user scene, use the base scene instead |
|
551 currentScene = iSettingsModel->IntegerSettingValue( ECamSettingItemUserSceneBasedOnScene ); |
|
552 } |
|
553 PRINT1( _L("Camera <> current scene: %d"), currentScene ); |
|
554 |
|
555 // Get the autofocus mode in camera internal format |
|
556 TInt afMode = iSettingsModel->SceneSettingValue( currentScene, ECamSettingItemSceneAFMode ); |
|
557 |
|
558 PRINT1( _L("Camera <> Autofocusmode for current scene: %d"), afMode ); |
|
559 |
|
560 TCamSettingsOnOff facetrack = |
|
561 static_cast<TCamSettingsOnOff>( |
|
562 iSettingsModel->IntegerSettingValue( ECamSettingItemFaceTracking ) ); |
|
563 if ( iController.UiConfigManagerPtr() && iController.UiConfigManagerPtr()->IsFaceTrackingSupported() && |
|
564 ( ECamSettOn == facetrack ) ) |
|
565 { |
|
566 // Use CCamera::CCameraAdvancedSettings::EFocusRangeAuto if in facetracking mode. |
|
567 *ptr = CCamera::CCameraAdvancedSettings::EFocusRangeAuto; |
|
568 } |
|
569 else |
|
570 { |
|
571 // Convert it to TFocusRange |
|
572 *ptr = CCamSettingConversion::Map2CameraAutofocus( static_cast<TCamSceneAFMode>( afMode ) ); |
|
573 PRINT1( _L("Camera <> Autofocusmode mapped for CCamera: %d"), *ptr ); |
|
574 } |
|
575 //CheckNonNullL( ptr, KErrNotFound ); |
|
576 //*ptr = KFocusRange;//iSettingsModel->IntegerSettingValue( ECamSettingItemDynamicPhotoFocusRange ); |
|
577 break; |
|
578 } |
|
579 // ----------------------------------------------------- |
|
580 case ECameraSettingCaptureLimit: |
|
581 { |
|
582 TInt* ptr = static_cast<TInt*>( aSettingData ); |
|
583 *ptr = iController.CaptureLimitSetting(); |
|
584 |
|
585 PRINT1( _L("Camera <> provide capture limit: %d"), *ptr ); |
|
586 break; |
|
587 } |
|
588 // ----------------------------------------------------- |
|
589 // Stabilization setting (for video) |
|
590 case ECameraSettingStabilization: |
|
591 { |
|
592 TCamSettingDataStabilization& stabilization = |
|
593 ( *static_cast<TPckgBuf<TCamSettingDataStabilization>*>( aSettingData ) )(); |
|
594 |
|
595 TCamSettingsOnOff settingOn = |
|
596 static_cast<TCamSettingsOnOff>( iSettingsModel->IntegerSettingValue( ECamSettingItemVideoStab ) ); |
|
597 |
|
598 // These could be made product specific.. |
|
599 if( ECamSettOn == settingOn ) |
|
600 { |
|
601 PRINT( _L("Camera <> Stabilization is set ON") ); |
|
602 stabilization.iMode = CAS::EStabilizationModeAuto; |
|
603 stabilization.iEffect = CAS::EStabilizationAuto; |
|
604 stabilization.iComplexity = CAS::EStabilizationComplexityAuto; |
|
605 } |
|
606 else |
|
607 { |
|
608 PRINT( _L("Camera <> Stabilization is set OFF") ); |
|
609 stabilization.iMode = CAS::EStabilizationModeOff; |
|
610 stabilization.iEffect = CAS::EStabilizationOff; |
|
611 stabilization.iComplexity = CAS::EStabilizationComplexityAuto; |
|
612 } |
|
613 break; |
|
614 } |
|
615 #endif // CAMERAAPP_CAPI_V2_ADV |
|
616 // ----------------------------------------------------- |
|
617 // Device orientation setting |
|
618 case ECameraSettingOrientation: |
|
619 { |
|
620 MCameraOrientation::TOrientation* ptr = |
|
621 static_cast<MCameraOrientation::TOrientation*>( aSettingData ); |
|
622 |
|
623 TCamImageOrientation orientationSetting = |
|
624 static_cast<TCamImageOrientation>( iController.ImageOrientation() ); |
|
625 PRINT1( _L("Camera <> Got image orientation from ui: [%s]"), KCamOrientationNames[orientationSetting] ); |
|
626 |
|
627 *ptr = CCamSettingConversion::Map2CameraOrientation( orientationSetting ); |
|
628 PRINT1( _L("Camera <> provide camera orientation: 0x%02X"), *ptr ); |
|
629 break; |
|
630 } |
|
631 // ----------------------------------------------------- |
|
632 // Video audio mute setting |
|
633 case ECameraSettingAudioMute: |
|
634 { |
|
635 TCamSettingsOnOff mute = |
|
636 static_cast<TCamSettingsOnOff>( |
|
637 iSettingsModel->IntegerSettingValue( ECamSettingItemVideoAudioRec ) ); |
|
638 |
|
639 TBool* ptr = static_cast<TBool*>( aSettingData ); |
|
640 *ptr = (ECamSettOn == mute); |
|
641 PRINT1( _L("Camera <> provide mute on: %d"), *ptr ); |
|
642 break; |
|
643 } |
|
644 // ----------------------------------------------------- |
|
645 // Continuous autofocus setting |
|
646 case ECameraSettingContAF: |
|
647 { |
|
648 TCamSettingsOnOff caf = static_cast<TCamSettingsOnOff>( |
|
649 iSettingsModel->IntegerSettingValue( ECamSettingItemContinuousAutofocus ) ); |
|
650 |
|
651 TBool* ptr = static_cast<TBool*>( aSettingData ); |
|
652 *ptr = (ECamSettOn == caf); |
|
653 PRINT1( _L("Camera <> provide continuous autofocus on: %d"), *ptr ); |
|
654 break; |
|
655 } |
|
656 // ----------------------------------------------------- |
|
657 // facetracking setting |
|
658 case ECameraSettingFacetracking: |
|
659 { |
|
660 TCamSettingsOnOff facetrack = |
|
661 static_cast<TCamSettingsOnOff>( |
|
662 iSettingsModel->IntegerSettingValue( ECamSettingItemFaceTracking ) ); |
|
663 TBool* ptr = static_cast<TBool*>( aSettingData ); |
|
664 *ptr = (ECamSettOn == facetrack); |
|
665 PRINT1( _L("Camera <> provide facetracking on: %d"), *ptr ); |
|
666 break; |
|
667 } |
|
668 // ----------------------------------------------------- |
|
669 // Video max size in bytes |
|
670 case ECameraSettingFileMaxSize: |
|
671 { |
|
672 TCamVideoClipLength setting = |
|
673 static_cast<TCamVideoClipLength>( |
|
674 iSettingsModel->IntegerSettingValue( ECamSettingItemVideoClipLength ) ); |
|
675 |
|
676 TInt* ptr = static_cast<TInt*>( aSettingData ); |
|
677 |
|
678 *ptr = ( ECamVideoClipShort == setting ) |
|
679 ? CamUtility::MaxMmsSizeInBytesL() |
|
680 : 0; // 0 means not limited |
|
681 |
|
682 PRINT1( _L("Camera <> provide max file size: %d"), *ptr ); |
|
683 break; |
|
684 } |
|
685 // ----------------------------------------------------- |
|
686 // Video filename |
|
687 case ECameraSettingFileName: |
|
688 { |
|
689 TPtr* ptr = static_cast<TPtr*>( aSettingData ); |
|
690 //*ptr = iController.CurrentFullFileName(); |
|
691 *ptr = iController.CurrentVideoFileName(); |
|
692 break; |
|
693 } |
|
694 // ----------------------------------------------------- |
|
695 default: |
|
696 { |
|
697 #ifndef CAMERAAPP_EMULATOR_BUILD |
|
698 User::Leave( KErrNotSupported ); |
|
699 #endif // not CAMERAAPP_EMULATOR_BUILD |
|
700 break; |
|
701 } |
|
702 // ----------------------------------------------------- |
|
703 } |
|
704 } |
|
705 |
|
706 // --------------------------------------------------------------------------- |
|
707 // |
|
708 // --------------------------------------------------------------------------- |
|
709 // |
|
710 void |
|
711 CCamSettingProvider::ProvidePendingSettingChangesL( |
|
712 RArray<NCamCameraController::TCamCameraSettingId>& aSettingIds ) |
|
713 { |
|
714 PRINT( _L("Camera => CCamSettingProvider::ProvidePendingSettingChangesL") ); |
|
715 aSettingIds.Reset(); |
|
716 aSettingIds.ReserveL( iPendingSettingChanges.Count() ); |
|
717 for( TInt i = 0; i < iPendingSettingChanges.Count(); i++ ) |
|
718 { |
|
719 aSettingIds.AppendL( iPendingSettingChanges[i] ); |
|
720 } |
|
721 PRINT1( _L("Camera <> %d settings changed"), aSettingIds.Count() ); |
|
722 |
|
723 // These have been asked and delivered now. |
|
724 // Update: Reset only when asked. Enables retries. |
|
725 // iPendingSettingChanges.Reset(); |
|
726 PRINT( _L("Camera <= CCamSettingProvider::ProvidePendingSettingChangesL") ); |
|
727 } |
|
728 |
|
729 |
|
730 // --------------------------------------------------------------------------- |
|
731 // PendingSettingChangeCount |
|
732 // --------------------------------------------------------------------------- |
|
733 // |
|
734 TInt |
|
735 CCamSettingProvider::PendingSettingChangeCount() const |
|
736 { |
|
737 return iPendingSettingChanges.Count(); |
|
738 } |
|
739 |
|
740 |
|
741 // =========================================================================== |
|
742 // New methods |
|
743 |
|
744 // --------------------------------------------------------------------------- |
|
745 // Reset |
|
746 // --------------------------------------------------------------------------- |
|
747 // |
|
748 void |
|
749 CCamSettingProvider::Reset() |
|
750 { |
|
751 PRINT( _L("Camera =><= CCamSettingProvider::Reset") ); |
|
752 iPendingSettingChanges.Reset(); |
|
753 } |
|
754 |
|
755 // --------------------------------------------------------------------------- |
|
756 // AddPendingSettingChangesL |
|
757 // --------------------------------------------------------------------------- |
|
758 // |
|
759 void |
|
760 CCamSettingProvider |
|
761 ::AddPendingSettingChangesL( const RArray<TCamSettingItemIds>& aUiSettingIds ) |
|
762 { |
|
763 iPendingSettingChanges.ReserveL( aUiSettingIds.Count() |
|
764 + iPendingSettingChanges.Count() ); |
|
765 |
|
766 for( TInt i = 0; i < aUiSettingIds.Count(); i++ ) |
|
767 { |
|
768 AddPendingSettingChangeL( aUiSettingIds[i] ); |
|
769 } |
|
770 } |
|
771 |
|
772 // --------------------------------------------------------------------------- |
|
773 // AddPendingSettingChangeL |
|
774 // --------------------------------------------------------------------------- |
|
775 // |
|
776 void |
|
777 CCamSettingProvider |
|
778 ::AddPendingSettingChangeL( TCamSettingItemIds aUiSettingId ) |
|
779 { |
|
780 PRINT1( _L("Camera => CCamSettingProvider::AddPendingSettingChangeL [%s]"), |
|
781 KCamSettingItemNames[aUiSettingId] ); |
|
782 |
|
783 TCamCameraSettingId cameraId = |
|
784 CCamSettingConversion::Map2CameraControllerSettingId( aUiSettingId ); |
|
785 |
|
786 if( ECameraSettingNone != cameraId ) |
|
787 { |
|
788 // Add each setting only once |
|
789 if( KErrNotFound == iPendingSettingChanges.Find( cameraId ) ) |
|
790 { |
|
791 PRINT1( _L("Camera <> Add pending setting [%s]"), KCameraSettingNames[cameraId] ); |
|
792 iPendingSettingChanges.AppendL( cameraId ); |
|
793 } |
|
794 } |
|
795 else |
|
796 { |
|
797 User::Leave( KErrNotSupported ); |
|
798 } |
|
799 PRINT( _L("Camera <= CCamSettingProvider::AddPendingSettingChangeL") ); |
|
800 } |
|
801 |
|
802 // --------------------------------------------------------------------------- |
|
803 // SetSupportedISORatesL |
|
804 // |
|
805 // --------------------------------------------------------------------------- |
|
806 // |
|
807 void |
|
808 CCamSettingProvider::SetSupportedISORatesL( const RArray<TInt>& aSupportedIsoRates ) |
|
809 { |
|
810 iSupportedISORates = aSupportedIsoRates; |
|
811 if ( iSupportedISORates.Count() != 0 ) |
|
812 { |
|
813 iValidISORates = ETrue; |
|
814 } |
|
815 } |
|
816 |
|
817 // =========================================================================== |
|
818 // private |
|
819 |
|
820 void |
|
821 CCamSettingProvider::ConstructL() |
|
822 { |
|
823 PRINT( _L("Camera => CCamSettingProvider::ConstructL") ); |
|
824 // Get EV steps range. |
|
825 iEvStepAsUiValue = iController.EvRange().iStepsPerUnit; |
|
826 PRINT( _L("Camera <= CCamSettingProvider::ConstructL") ); |
|
827 } |
|
828 |
|
829 |
|
830 CCamSettingProvider::CCamSettingProvider( CCamAppController& aController, |
|
831 MCamSettingsModel* aSettingsModel ) |
|
832 : iSettingsModel( aSettingsModel ), |
|
833 iController ( aController ), |
|
834 iPendingSettingChanges( KSettingArrayGranularity ) |
|
835 { |
|
836 } |
|
837 |
|
838 |