|
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: Camera Controller implementation. |
|
15 * : Class handles CCamera related operations. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // =========================================================================== |
|
22 // Included headers |
|
23 |
|
24 #include "camcameracontrollerflags.hrh" |
|
25 |
|
26 // ------------------------------------- |
|
27 // General |
|
28 #include <e32base.h> |
|
29 #include <e32const.h> // KNullHandle |
|
30 #include <fbs.h> |
|
31 #include <gdi.h> |
|
32 #include <aknlayoutscalable_apps.cdl.h> |
|
33 |
|
34 // ------------------------------------- |
|
35 // ECAM |
|
36 #include <ecam.h> |
|
37 #ifdef CAMERAAPP_CAPI_V2 |
|
38 #include <ecam/ecamdirectviewfinder.h> |
|
39 #include <ecam/camerahistogram.h> |
|
40 #include <ecam/cameraoverlay.h> |
|
41 #include <ecamadvsettings.h> |
|
42 #include <ecamadvsettingsuids.hrh> |
|
43 #endif |
|
44 #include <ecam/camerasnapshot.h> // KUidECamEventCameraSnapshot |
|
45 |
|
46 // ------------------------------------- |
|
47 // Camera Application Engine (CAE) |
|
48 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
49 #include <CaeEngine.h> |
|
50 #endif |
|
51 |
|
52 // ------------------------------------- |
|
53 // Custom interfaces |
|
54 #include <ECamOrientationCustomInterface2.h> |
|
55 #include <ECamUIOrientationOverrideCustomAPI.h> |
|
56 |
|
57 #include <ecamfacetrackingcustomapi.h> |
|
58 #include <akntoolbar.h> |
|
59 // ------------------------------------- |
|
60 // Own |
|
61 #include "camcameracontroller.pan" |
|
62 #include "camlogging.h" |
|
63 #include "cambuffershare.h" |
|
64 #include "cambuffersharecleanup.h" |
|
65 #include "cambuffercleanup.h" |
|
66 #include "cambuffer.h" |
|
67 |
|
68 #include "camsnapshotprovider.h" |
|
69 #include "camimageencoder.h" |
|
70 |
|
71 #include "mcamsettingprovider.h" |
|
72 #include "mcamcameraobserver.h" |
|
73 #include "camsettingconversion.h" |
|
74 #include "camcameraevents.h" |
|
75 #include "camcamerarequests.h" |
|
76 #include "camcameracontrolleractive.h" |
|
77 #include "camcameracontroller.h" |
|
78 #include "OstTraceDefinitions.h" |
|
79 #ifdef OST_TRACE_COMPILER_IN_USE |
|
80 #include "camcameracontrollerTraces.h" |
|
81 #endif |
|
82 |
|
83 #ifdef FORCE_DUMMY_ENGINE |
|
84 #include "CameraappDummyEngine.h" |
|
85 #endif // FORCE_DUMMY_ENGINE |
|
86 #ifdef CAMERAAPP_CAPI_EMULATOR |
|
87 #include "CamCamera.h" |
|
88 #endif // CAMERAAPP_CAPI_EMULATOR |
|
89 #ifdef CAMERAAPP_FLASH_SIMULATOR |
|
90 #include "camflashsimulator.h" |
|
91 #endif // CAMERAAPP_FLASH_SIMULATOR |
|
92 #ifdef CAMERAAPP_CAE_ERR_SIMULATION |
|
93 #include "CamTimer.h" |
|
94 #endif // CAMERAAPP_CAE_ERR_SIMULATION |
|
95 |
|
96 #include "CamAppUi.h" |
|
97 #include "CameraUiConfigManager.h" |
|
98 #include "CamViewBase.h" |
|
99 #include "campanic.h" |
|
100 // =========================================================================== |
|
101 // Local constants |
|
102 const TInt KIveRecoveryCountMax = 2; |
|
103 typedef CCamera::CCameraAdvancedSettings CAS; |
|
104 typedef CCamera::CCameraImageProcessing CIP; |
|
105 |
|
106 namespace NCamCameraController |
|
107 { |
|
108 static const TInt KPrimaryCameraIndex = 0; |
|
109 //static const TInt KSecondaryCameraIndex = 1; |
|
110 static const TInt KInvalidCameraIndex = -1; |
|
111 |
|
112 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
113 // static const TInt KCameraDisplayIndex = 0; |
|
114 #endif |
|
115 #ifdef CAMERAAPP_CAPI_V2 |
|
116 static const TInt KCameraClientPriority = 100; // -100...100 |
|
117 #endif |
|
118 |
|
119 static const TInt KCamCallBackPriority = EPriorityHigh; |
|
120 |
|
121 static const TInt KCamSequenceGranularity = 2; |
|
122 static const TInt KResolutionArrayGranularity = 8; |
|
123 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
124 static const TInt KAdvArrayGranularity = 5; |
|
125 #endif |
|
126 |
|
127 static const CCamera::TFormat KCamJpegAlternativeFormat1 = CCamera::EFormatFbsBitmapColor16M; |
|
128 static const CCamera::TFormat KCamJpegAlternativeFormat2 = CCamera::EFormatFbsBitmapColor64K; |
|
129 |
|
130 static const TInt KCamReserveTryAgainMaxCount = 50; |
|
131 static const TInt KCamReserveTryAgainWaitInterval = 50000; // 50 milliseconds |
|
132 #ifdef _DEBUG |
|
133 _LIT( KCamDriveModeNameBurst, "EDriveModeBurst" ); |
|
134 _LIT( KCamDriveModeNameSingle, "EDriveModeSingleShot" ); |
|
135 _LIT( KCamDriveModeNameUnknown, "Unknown drive mode!" ); |
|
136 #endif // _DEBUG |
|
137 } |
|
138 |
|
139 // =========================================================================== |
|
140 // Local methods |
|
141 |
|
142 #ifdef CAMERAAPP_PERFORMANCE_CONTROLLER |
|
143 #include "camperformancelogger.h" |
|
144 |
|
145 #define CAMERAAPP_PERF_CONTROLLER_START( AAA ) iPerformanceLogger->Requested( AAA ); |
|
146 #define CAMERAAPP_PERF_CONTROLLER_STARTNEW( AAA, BBB ) BBB = EFalse; iPerformanceLogger->Requested( AAA ); |
|
147 #define CAMERAAPP_PERF_CONTROLLER_STOP( AAA ) iPerformanceLogger->Completed( AAA ); |
|
148 #define CAMERAAPP_PERF_CONTROLLER_STOP_ONCE( AAA, BBB ) if( !BBB ) { iPerformanceLogger->Completed( AAA ); BBB = ETrue; } |
|
149 #else |
|
150 #define CAMERAAPP_PERF_CONTROLLER_START( AAA ) |
|
151 #define CAMERAAPP_PERF_CONTROLLER_STARTNEW( AAA, BBB ) |
|
152 #define CAMERAAPP_PERF_CONTROLLER_STOP( AAA ) |
|
153 #define CAMERAAPP_PERF_CONTROLLER_STOP_ONCE( AAA, BBB ) |
|
154 #endif // CAMERAAPP_PERFORMANCE_CONTROLLER |
|
155 |
|
156 // Helper methods |
|
157 #include "camflagutility.inl" |
|
158 #include "campointerutility.inl" |
|
159 |
|
160 |
|
161 namespace NCamCameraController |
|
162 { |
|
163 /* |
|
164 inline void SetFalse( TAny* aTBool ) |
|
165 { |
|
166 TBool* boolean = static_cast<TBool*>( aTBool ); |
|
167 |
|
168 if( boolean ) |
|
169 *boolean = EFalse; |
|
170 } |
|
171 */ |
|
172 |
|
173 inline void SetNotBusy( TAny* aTUint ) |
|
174 { |
|
175 TUint* flags = static_cast<TUint*>( aTUint ); |
|
176 |
|
177 if( flags ) |
|
178 *flags = ECamBusyOff; |
|
179 }; |
|
180 |
|
181 inline void ReleaseAndNull( MCameraBuffer*& aBuffer ) |
|
182 { |
|
183 if( aBuffer ) |
|
184 { |
|
185 aBuffer->Release(); |
|
186 aBuffer = NULL; |
|
187 } |
|
188 }; |
|
189 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
190 inline void ResetInfo( TAny* aInfo ) |
|
191 { |
|
192 TCamAdvancedSettingInfo* info = |
|
193 static_cast<TCamAdvancedSettingInfo*>( aInfo ); |
|
194 |
|
195 if( info ) |
|
196 { |
|
197 info->Reset(); |
|
198 } |
|
199 }; |
|
200 |
|
201 |
|
202 inline const TDesC& DriveModeName( TInt aMode ) |
|
203 { |
|
204 #ifdef _DEBUG |
|
205 switch( aMode ) |
|
206 { |
|
207 case CAS::EDriveModeBurst: return KCamDriveModeNameBurst; |
|
208 case CAS::EDriveModeSingleShot: return KCamDriveModeNameSingle; |
|
209 default: return KCamDriveModeNameUnknown; |
|
210 } |
|
211 #else |
|
212 return KNullDesC; |
|
213 #endif // _DEBUG |
|
214 }; |
|
215 #endif |
|
216 } |
|
217 using namespace NCamCameraController; |
|
218 |
|
219 // =========================================================================== |
|
220 // TCamControllerInfo class methods |
|
221 TCamControllerInfo::TCamControllerInfo() |
|
222 { |
|
223 Reset(); |
|
224 } |
|
225 |
|
226 void |
|
227 TCamControllerInfo::Reset( TBool aPreserveBusyFlag /*= EFalse*/, |
|
228 TBool aPreserveCameraIndex /*= EFalse*/ ) |
|
229 { |
|
230 // When we reset the info e.g. after reserve lost event |
|
231 // we need to keep the current camera index stored. |
|
232 if( !aPreserveCameraIndex ) |
|
233 { |
|
234 iCurrentCamera = KErrNotFound; |
|
235 } |
|
236 |
|
237 iState = ECamIdle; |
|
238 iCaptureState = ECamCaptureOff; |
|
239 iCaptureLimit = 1; |
|
240 iCaptureCount = 0; |
|
241 iSnapshotCount = 0; |
|
242 |
|
243 iVfMode = ECamViewfinderNone; |
|
244 iVfState = ECamTriIdle; |
|
245 iViewfinderSize = TSize(); |
|
246 iViewfinderFormat = CCamera::EFormatFbsBitmapColor16M; |
|
247 |
|
248 iSsState = ECamTriIdle; |
|
249 iSnapshotSize = TSize(); |
|
250 iSnapshotFormat = CCamera::EFormatFbsBitmapColor16M; |
|
251 iSnapshotAspectMaintain = EFalse; |
|
252 |
|
253 if( !aPreserveBusyFlag ) |
|
254 { |
|
255 iBusy = ECamBusyOff; |
|
256 } |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // PrintInfo |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 void |
|
264 TCamControllerInfo::PrintInfo() const |
|
265 { |
|
266 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
267 PRINT ( _L("Camera <> TCamControllerInfo") ); |
|
268 PRINT ( _L("Camera <> ") ); |
|
269 |
|
270 PRINT1( _L("Camera <> iCurrentCamera : %d" ), iCurrentCamera ); |
|
271 PRINT1( _L("Camera <> iState : %08b" ), iState ); |
|
272 |
|
273 PRINT1( _L("Camera <> iCaptureState : [%s]" ), KCamCameraCaptureStateNames[iCaptureState] ); |
|
274 PRINT1( _L("Camera <> iCaptureLimit : %d" ), iCaptureLimit ); |
|
275 PRINT1( _L("Camera <> iCaptureCount : %d" ), iCaptureCount ); |
|
276 PRINT1( _L("Camera <> iSnapshotCount : %d" ), iSnapshotCount ); |
|
277 |
|
278 PRINT1( _L("Camera <> iVfMode : [%s]" ), KCamViewfinderModeNames [iVfMode] ); |
|
279 PRINT1( _L("Camera <> iVfState : [%s]" ), KCamCameraTriStateNames [iVfState] ); |
|
280 PRINT2( _L("Camera <> iViewfinderSize : (%dx%d)"), iViewfinderSize.iWidth, iViewfinderSize.iHeight ); |
|
281 PRINT1( _L("Camera <> iViewfinderFormat : %d" ), iViewfinderFormat ); |
|
282 |
|
283 PRINT1( _L("Camera <> iSsState : [%s]" ), KCamCameraTriStateNames [iSsState] ); |
|
284 PRINT2( _L("Camera <> iSnapshotSize : (%dx%d)"), iSnapshotSize.iWidth, iSnapshotSize.iHeight ); |
|
285 PRINT1( _L("Camera <> iSnapshotFormat : %d" ), iSnapshotFormat ); |
|
286 PRINT1( _L("Camera <> iSnapshotAspectMaintain : %d" ), iSnapshotAspectMaintain ); |
|
287 |
|
288 PRINT1( _L("Camera <> iBusy : %08b" ), iBusy ); |
|
289 |
|
290 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
291 } |
|
292 |
|
293 |
|
294 // =========================================================================== |
|
295 // TCamCameraResolutionSupport class methods |
|
296 |
|
297 TCamCameraResolutionSupport::TCamCameraResolutionSupport() |
|
298 : iResolutions( KResolutionArrayGranularity ) |
|
299 { |
|
300 Reset(); |
|
301 } |
|
302 |
|
303 TCamCameraResolutionSupport::~TCamCameraResolutionSupport() |
|
304 { |
|
305 iResolutions.Close(); |
|
306 } |
|
307 |
|
308 void |
|
309 TCamCameraResolutionSupport::Reset() |
|
310 { |
|
311 iForCameraIndex = KInvalidCameraIndex; |
|
312 iForCameraFormat = -1; |
|
313 iResolutions.Reset(); |
|
314 } |
|
315 |
|
316 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
317 // =========================================================================== |
|
318 // TCamAdvancedSettingInfo class methods |
|
319 |
|
320 TCamAdvancedSettingInfo::TCamAdvancedSettingInfo() |
|
321 : iEvStepsSupport ( KAdvArrayGranularity ), |
|
322 iIsoRatesSupport( KAdvArrayGranularity ) |
|
323 { |
|
324 Reset(); |
|
325 } |
|
326 |
|
327 TCamAdvancedSettingInfo::~TCamAdvancedSettingInfo() |
|
328 { |
|
329 iEvStepsSupport.Close(); |
|
330 iIsoRatesSupport.Close(); |
|
331 } |
|
332 |
|
333 void |
|
334 TCamAdvancedSettingInfo::Reset() |
|
335 { |
|
336 iForCameraIndex = KInvalidCameraIndex; |
|
337 |
|
338 iEvModesSupport = 0; |
|
339 iEvStepsSupport.Reset(); |
|
340 iEvStepsValueInfo = ENotActive; |
|
341 |
|
342 iIsoRatesSupport.Reset(); |
|
343 |
|
344 iDigitalZoomSupport.Reset(); |
|
345 iDigitalZoomValueInfo = ENotActive; |
|
346 |
|
347 #ifdef CAMERAAPP_CAPI_V2_IP |
|
348 iColourEffectSupport.Reset(); |
|
349 iColourEffectValueInfo = ENotActive; |
|
350 |
|
351 iSharpnessSupport.Reset(); |
|
352 iSharpnessValueInfo = ENotActive; |
|
353 #endif |
|
354 |
|
355 iStabilizationModeSupport = 0; |
|
356 iStabilizationEffectSupport = 0; |
|
357 iStabilizationComplexitySupport = 0; |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------------------------- |
|
361 // PrintInfo |
|
362 // --------------------------------------------------------------------------- |
|
363 // |
|
364 void |
|
365 TCamAdvancedSettingInfo::PrintInfo() const |
|
366 { |
|
367 #ifdef _DEBUG |
|
368 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
369 PRINT ( _L("Camera <> Value infos:") ); |
|
370 PRINT1( _L("Camera <> EV value info : %04b"), iEvStepsValueInfo ); |
|
371 PRINT1( _L("Camera <> Dig zoom value info : %04b"), iDigitalZoomValueInfo ); |
|
372 #ifdef CAMERAAPP_CAPI_V2_IP |
|
373 PRINT1( _L("Camera <> Colour effct value info : %04b"), iColourEffectValueInfo ); |
|
374 PRINT1( _L("Camera <> Sharpness value info : %04b"), iSharpnessValueInfo ); |
|
375 #endif |
|
376 PRINT1( _L("Camera <> ENotActive : %04b"), ENotActive ); |
|
377 PRINT1( _L("Camera <> EBitField : %04b"), EBitField ); |
|
378 PRINT1( _L("Camera <> EDiscreteSteps : %04b"), EDiscreteSteps ); |
|
379 PRINT1( _L("Camera <> EDiscreteRangeMinMaxStep : %04b"), EDiscreteRangeMinMaxStep ); |
|
380 PRINT1( _L("Camera <> EContinuousRangeMinMax : %04b"), EContinuousRangeMinMax ); |
|
381 |
|
382 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
383 PRINT ( _L("Camera <> Dig zoom ratios:") ); |
|
384 for( TInt i = 0; i < iDigitalZoomSupport.Count(); i++ ) |
|
385 { |
|
386 PRINT2( _L("Camera <> step[%4d]: ratio[%4f]"), i, (TReal)iDigitalZoomSupport[i]/(TReal)KECamFineResolutionFactor ); |
|
387 } |
|
388 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
389 PRINT ( _L("Camera <> ISO rates supported:") ); |
|
390 for( TInt i = 0; i < iIsoRatesSupport.Count(); i++ ) |
|
391 { |
|
392 PRINT2( _L("Camera <> rate[%3d]: %4d"), i, iIsoRatesSupport[i] ); |
|
393 } |
|
394 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
395 PRINT ( _L("Camera <> EV steps supported:") ); |
|
396 for( TInt i = 0; i < iEvStepsSupport.Count(); i++ ) |
|
397 { |
|
398 PRINT2( _L("Camera <> step[%3d]: %4d"), i, iEvStepsSupport[i] ); |
|
399 } |
|
400 |
|
401 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
402 PRINT1( _L("Camera <> Advanced EV modes support : %016b"), iEvModesSupport ); |
|
403 PRINT1( _L("Camera <> EExposureAuto : %016b"), CCamera::EExposureAuto ); |
|
404 PRINT1( _L("Camera <> EExposureNight : %016b"), CCamera::EExposureNight ); |
|
405 PRINT1( _L("Camera <> EExposureBacklight : %016b"), CCamera::EExposureBacklight ); |
|
406 PRINT1( _L("Camera <> EExposureCenter : %016b"), CCamera::EExposureCenter ); |
|
407 PRINT1( _L("Camera <> EExposureSport : %016b"), CCamera::EExposureSport ); |
|
408 PRINT1( _L("Camera <> EExposureVeryLong : %016b"), CCamera::EExposureVeryLong ); |
|
409 PRINT1( _L("Camera <> EExposureSnow : %016b"), CCamera::EExposureSnow ); |
|
410 PRINT1( _L("Camera <> EExposureBeach : %016b"), CCamera::EExposureBeach ); |
|
411 PRINT1( _L("Camera <> EExposureProgram : %016b"), CCamera::EExposureProgram ); |
|
412 PRINT1( _L("Camera <> EExposureAperturePriority : %016b"), CCamera::EExposureAperturePriority ); |
|
413 PRINT1( _L("Camera <> EExposureShutterPriority : %016b"), CCamera::EExposureShutterPriority ); |
|
414 PRINT1( _L("Camera <> EExposureManual : %016b"), CCamera::EExposureManual ); |
|
415 PRINT1( _L("Camera <> EExposureSuperNight : %016b"), CCamera::EExposureSuperNight ); |
|
416 PRINT1( _L("Camera <> EExposureInfra : %016b"), CCamera::EExposureInfra ); |
|
417 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
418 |
|
419 #ifdef CAMERAAPP_CAPI_V2_IP |
|
420 PRINT ( _L("Camera <> Sharpness support:") ); |
|
421 for( TInt i = 0; i < iSharpnessSupport.Count(); i++ ) |
|
422 { |
|
423 PRINT2( _L("Camera <> step[%3d]: %4d"), i, iSharpnessSupport[i] ); |
|
424 } |
|
425 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
426 PRINT ( _L("Camera <> Colour effect support:") ); |
|
427 for( TInt i = 0; i < iColourEffectSupport.Count(); i++ ) |
|
428 { |
|
429 PRINT2( _L("Camera <> effect[%3d] : %016b"), i, iColourEffectSupport[i] ); |
|
430 } |
|
431 PRINT1( _L("Camera <> EEffectNone : %016b"), CIP::EEffectNone ); |
|
432 PRINT1( _L("Camera <> EEffectNegative : %016b"), CIP::EEffectNegative ); |
|
433 PRINT1( _L("Camera <> EEffectMonochrome : %016b"), CIP::EEffectMonochrome ); |
|
434 PRINT1( _L("Camera <> EEffectSolarize : %016b"), CIP::EEffectSolarize ); |
|
435 PRINT1( _L("Camera <> EEffectSepia : %016b"), CIP::EEffectSepia ); |
|
436 PRINT1( _L("Camera <> EEffectEmboss : %016b"), CIP::EEffectEmboss ); |
|
437 PRINT1( _L("Camera <> EEffectRedEyeReduction: %016b"), CIP::EEffectRedEyeReduction ); |
|
438 PRINT1( _L("Camera <> EEffectVivid : %016b"), CIP::EEffectVivid ); |
|
439 PRINT1( _L("Camera <> EEffectLowSharpening : %016b"), CIP::EEffectLowSharpening ); |
|
440 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
441 #endif // CAMERAAPP_CAPI_V2_IP |
|
442 |
|
443 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
444 PRINT1( _L("Camera <> Stabilization modes support : %016b"), iStabilizationModeSupport ); |
|
445 PRINT1( _L("Camera <> EStabilizationModeOff : %016b"), CAS::EStabilizationModeOff ); |
|
446 PRINT1( _L("Camera <> EStabilizationModeHorizontal : %016b"), CAS::EStabilizationModeHorizontal ); |
|
447 PRINT1( _L("Camera <> EStabilizationModeVertical : %016b"), CAS::EStabilizationModeVertical ); |
|
448 PRINT1( _L("Camera <> EStabilizationModeRotation : %016b"), CAS::EStabilizationModeRotation ); |
|
449 PRINT1( _L("Camera <> EStabilizationModeAuto : %016b"), CAS::EStabilizationModeAuto ); |
|
450 PRINT1( _L("Camera <> EStabilizationModeManual : %016b"), CAS::EStabilizationModeManual ); |
|
451 PRINT1( _L("Camera <> Stabilization fx support : %016b"), iStabilizationEffectSupport ); |
|
452 PRINT1( _L("Camera <> EStabilizationOff : %016b"), CAS::EStabilizationOff ); |
|
453 PRINT1( _L("Camera <> EStabilizationAuto : %016b"), CAS::EStabilizationAuto ); |
|
454 PRINT1( _L("Camera <> EStabilizationFine : %016b"), CAS::EStabilizationFine ); |
|
455 PRINT1( _L("Camera <> EStabilizationMedium : %016b"), CAS::EStabilizationMedium ); |
|
456 PRINT1( _L("Camera <> EStabilizationStrong : %016b"), CAS::EStabilizationStrong ); |
|
457 PRINT1( _L("Camera <> Stabilization complexity support : %016b"), iStabilizationComplexitySupport ); |
|
458 PRINT1( _L("Camera <> EStabilizationComplexityAuto : %016b"), CAS::EStabilizationComplexityAuto ); |
|
459 PRINT1( _L("Camera <> EStabilizationComplexityLow : %016b"), CAS::EStabilizationComplexityLow ); |
|
460 PRINT1( _L("Camera <> EStabilizationComplexityMedium : %016b"), CAS::EStabilizationComplexityMedium ); |
|
461 PRINT1( _L("Camera <> EStabilizationComplexityHigh : %016b"), CAS::EStabilizationComplexityHigh ); |
|
462 PRINT ( _L("Camera <> --------------------------------------------------") ); |
|
463 #endif // _DEBUG |
|
464 } |
|
465 |
|
466 #endif // CAMERAAPP_CAPI_V2_ADV |
|
467 |
|
468 |
|
469 // =========================================================================== |
|
470 // CCamCameraController class methods |
|
471 |
|
472 // --------------------------------------------------------------------------- |
|
473 // static 2-phase constructor |
|
474 // --------------------------------------------------------------------------- |
|
475 // |
|
476 CCamCameraController* |
|
477 CCamCameraController::NewL( MCamSettingProvider& aProvider, |
|
478 CCamAppController& aAppController, |
|
479 TInt aCameraIndex /*= 0*/ ) |
|
480 { |
|
481 CCamCameraController* self |
|
482 = new (ELeave) CCamCameraController( aProvider, aAppController ); |
|
483 |
|
484 CleanupStack::PushL( self ); |
|
485 self->ConstructL( aCameraIndex ); |
|
486 CleanupStack::Pop( self ); |
|
487 |
|
488 return self; |
|
489 } |
|
490 |
|
491 |
|
492 |
|
493 // --------------------------------------------------------------------------- |
|
494 // |
|
495 // --------------------------------------------------------------------------- |
|
496 // |
|
497 CCamCameraController::~CCamCameraController() |
|
498 { |
|
499 PRINT( _L("Camera => ~CCamCameraController") ); |
|
500 |
|
501 #ifdef CAMERAAPP_FLASH_SIMULATOR |
|
502 delete iFlashSimulator; |
|
503 #endif |
|
504 |
|
505 #ifdef CAMERAAPP_PERFORMANCE_CONTROLLER |
|
506 delete iPerformanceLogger; |
|
507 #endif // CAMERAAPP_PERFORMANCE_CONTROLLER |
|
508 |
|
509 delete iIdle; |
|
510 iSettingArray.Close(); |
|
511 |
|
512 // Remove all observers. |
|
513 // We do not want to broadcast events anymore in this phase. |
|
514 iObservers.Reset(); |
|
515 iObserverInterests.Reset(); |
|
516 |
|
517 ClearRequestQueue(); |
|
518 ClearSettingQueue(); |
|
519 |
|
520 |
|
521 PRINT( _L("Camera <> CCamCameraController: release current camera..") ); |
|
522 // Release and null CCamera related objects. |
|
523 ReleaseCurrentCamera(); |
|
524 PRINT( _L("Camera <> CCamCameraController: ..done") ); |
|
525 |
|
526 delete iActive; |
|
527 |
|
528 iObservers.Close(); |
|
529 iObserverInterests.Close(); |
|
530 |
|
531 #ifdef CAMERAAPP_CAE_ERR_SIMULATION |
|
532 if( iCallbackTimer ) |
|
533 { |
|
534 iCallbackTimer->Cancel(); |
|
535 delete iCallbackTimer; |
|
536 } |
|
537 #endif // CAMERAAPP_CAE_ERR_SIMULATION |
|
538 |
|
539 PRINT( _L("Camera <= ~CCamCameraController") ); |
|
540 } |
|
541 |
|
542 |
|
543 // =========================================================================== |
|
544 // MCameraObserver2 |
|
545 |
|
546 // --------------------------------------------------------------------------- |
|
547 // HandleEvent |
|
548 // --------------------------------------------------------------------------- |
|
549 // |
|
550 void |
|
551 CCamCameraController::HandleEvent( const TECAMEvent& aEvent ) |
|
552 { |
|
553 // TUid iEventType; |
|
554 // TInt iErrorCode; |
|
555 PRINT2( _L("Camera => CCamCameraController::HandleEvent, event uid(0x%08x) error(%d)"), |
|
556 aEvent.iEventType.iUid, |
|
557 aEvent.iErrorCode ); |
|
558 |
|
559 // If we are getting zoom event while saving video, |
|
560 // we must not handle the event |
|
561 TInt uidValue( aEvent.iEventType.iUid ); |
|
562 if ( uidValue == KUidECamEventCameraSettingDigitalZoomUidValue |
|
563 && IsFlagOn( iInfo.iBusy, ECamBusySingle ) ) |
|
564 { |
|
565 return; |
|
566 } |
|
567 |
|
568 #ifdef CAMERAAPP_CAPI_V2 |
|
569 |
|
570 // ------------------------------------------------------- |
|
571 if( aEvent.iEventType == KUidECamEventReserveComplete ) |
|
572 { |
|
573 HandleReserveGainEvent( aEvent.iErrorCode ); |
|
574 } |
|
575 // ------------------------------------------------------- |
|
576 else if( aEvent.iEventType == KUidECamEventPowerOnComplete ) |
|
577 { |
|
578 HandlePowerOnEvent( aEvent.iErrorCode ); |
|
579 } |
|
580 // ------------------------------------------------------- |
|
581 else if( aEvent.iEventType == KUidECamEventCameraNoLongerReserved ) |
|
582 { |
|
583 HandleReserveLostEvent( aEvent.iErrorCode ); |
|
584 } |
|
585 // ------------------------------------------------------- |
|
586 else if( !(IsFlagOn( iInfo.iState , ECamPowerOn ))) |
|
587 { |
|
588 //If camera is in background then all the rest events will be ignored. Should return without leaving |
|
589 return; |
|
590 } |
|
591 // ------------------------------------------------------- |
|
592 else if( aEvent.iEventType == KUidECamEventCameraSnapshot ) |
|
593 { |
|
594 HandleSnapshotEvent( aEvent.iErrorCode ); |
|
595 } |
|
596 // ------------------------------------------------------- |
|
597 else if( aEvent.iEventType == KUidECamEventCameraSettingsOptimalFocus |
|
598 || aEvent.iEventType == KUidECamEventCameraSettingAutoFocusType2 ) |
|
599 { |
|
600 HandleAutoFocusEvent( aEvent.iErrorCode, aEvent.iEventType ); |
|
601 } |
|
602 // ------------------------------------------------------- |
|
603 else |
|
604 { |
|
605 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
606 TInt uidValue( aEvent.iEventType.iUid ); |
|
607 switch( uidValue ) |
|
608 { |
|
609 // ------------------------------- |
|
610 // Settings |
|
611 // |
|
612 // case KUidECamEventCameraSettingTimerIntervalUidValue: |
|
613 // case KUidECamEventCameraSettingTimeLapseUidValue: |
|
614 // |
|
615 case KUidECamEventCameraSettingFlashModeUidValue: |
|
616 case KUidECamEventCameraSettingExposureCompensationStepUidValue: |
|
617 case KUidECamEventCameraSettingIsoRateTypeUidValue: |
|
618 case KUidECamEventCameraSettingWhiteBalanceModeUidValue: |
|
619 case KUidECamEventCameraSettingDigitalZoomUidValue: |
|
620 case KUidECamEventCameraSettingOpticalZoomUidValue: |
|
621 case KUidECamEventImageProcessingAdjustSharpnessUidValue: |
|
622 case KUidECamEventImageProcessingEffectUidValue: |
|
623 case KUidECamEventSettingsStabilizationAlgorithmComplexityUidValue: |
|
624 { |
|
625 TCamCameraSettingId id = |
|
626 CCamSettingConversion::Map2CameraSetting( uidValue ); |
|
627 |
|
628 HandleCallbackEvent( aEvent.iErrorCode, |
|
629 ECamCameraEventSettingsSingle, |
|
630 ECamCameraEventClassSettings, |
|
631 &id ); |
|
632 break; |
|
633 } |
|
634 // ------------------------------- |
|
635 // Flash status info |
|
636 case KUidECamEventFlashReadyUidValue: |
|
637 HandleFlashStatusEvent( aEvent.iErrorCode, ECamCameraEventFlashReady ); |
|
638 break; |
|
639 case KUidECamEventFlashNotReadyUidValue: |
|
640 HandleFlashStatusEvent( aEvent.iErrorCode, ECamCameraEventFlashNotReady ); |
|
641 break; |
|
642 // ------------------------------- |
|
643 default: |
|
644 break; |
|
645 // ------------------------------- |
|
646 } |
|
647 #endif // CAMERAAPP_CAPI_V2_ADV |
|
648 } |
|
649 |
|
650 #else // CAMERAAPP_CAPI_V2 |
|
651 |
|
652 // Only snapshot event recognized if old observer interface in |
|
653 // use towards CCamera. This one is then generated by CCamSnapshot. |
|
654 if( aEvent.iEventType == KUidECamEventCameraSnapshot ) |
|
655 { |
|
656 HandleSnapshotEvent( aEvent.iErrorCode ); |
|
657 } |
|
658 else |
|
659 { |
|
660 // ignore other events |
|
661 PRINT( _L("Camera <> CCamCameraController: Unknown event") ); |
|
662 } |
|
663 #endif |
|
664 // ------------------------------------------------------- |
|
665 PRINT( _L("Camera <= CCamCameraController::HandleEvent") ); |
|
666 } |
|
667 |
|
668 |
|
669 |
|
670 // --------------------------------------------------------------------------- |
|
671 // ViewFinderReady |
|
672 // --------------------------------------------------------------------------- |
|
673 // |
|
674 void |
|
675 CCamCameraController::ViewFinderReady( MCameraBuffer& aCameraBuffer, TInt aError ) |
|
676 { |
|
677 HandleViewfinderEvent( &aCameraBuffer, aError ); |
|
678 } |
|
679 |
|
680 |
|
681 // --------------------------------------------------------------------------- |
|
682 // ImageBufferReady |
|
683 // --------------------------------------------------------------------------- |
|
684 // |
|
685 void |
|
686 CCamCameraController::ImageBufferReady( MCameraBuffer& aCameraBuffer, TInt aError ) |
|
687 { |
|
688 HandleImageCaptureEvent( &aCameraBuffer, aError ); |
|
689 } |
|
690 |
|
691 |
|
692 // --------------------------------------------------------------------------- |
|
693 // VideoBufferReady |
|
694 // --------------------------------------------------------------------------- |
|
695 // |
|
696 void |
|
697 CCamCameraController::VideoBufferReady( MCameraBuffer& aCameraBuffer, TInt aError ) |
|
698 { |
|
699 if( KErrNone == aError ) |
|
700 { |
|
701 aCameraBuffer.Release(); |
|
702 } |
|
703 } |
|
704 |
|
705 |
|
706 |
|
707 #if !defined( CAMERAAPP_CAPI_V2 ) |
|
708 // =========================================================================== |
|
709 // MCameraObserver |
|
710 |
|
711 |
|
712 // --------------------------------------------------------------------------- |
|
713 // ReserveComplete |
|
714 // --------------------------------------------------------------------------- |
|
715 // |
|
716 void |
|
717 CCamCameraController::ReserveComplete( TInt aError ) |
|
718 { |
|
719 HandleReserveGainEvent( aError ); |
|
720 } |
|
721 |
|
722 |
|
723 // --------------------------------------------------------------------------- |
|
724 // PowerOnComplete |
|
725 // --------------------------------------------------------------------------- |
|
726 // |
|
727 void |
|
728 CCamCameraController::PowerOnComplete( TInt aError ) |
|
729 { |
|
730 HandlePowerOnEvent( aError ); |
|
731 } |
|
732 |
|
733 |
|
734 // --------------------------------------------------------------------------- |
|
735 // ViewFinderFrameReady |
|
736 // --------------------------------------------------------------------------- |
|
737 // |
|
738 void |
|
739 CCamCameraController::ViewFinderFrameReady( CFbsBitmap& aFrame ) |
|
740 { |
|
741 PRINT( _L("CamTest => CCamCameraController::ViewFinderFrameReady") ); |
|
742 |
|
743 CCamBuffer* buffer = NULL; |
|
744 |
|
745 TRAPD( error, buffer = CCamBuffer::NewL( aFrame, NULL ) ); |
|
746 |
|
747 // Releases buffer |
|
748 HandleViewfinderEvent( buffer, error ); |
|
749 |
|
750 PRINT( _L("CamTest <= CCamCameraController::ViewFinderFrameReady") ); |
|
751 } |
|
752 |
|
753 |
|
754 // --------------------------------------------------------------------------- |
|
755 // ImageReady |
|
756 // --------------------------------------------------------------------------- |
|
757 // |
|
758 void |
|
759 CCamCameraController::ImageReady( CFbsBitmap* aBitmap, |
|
760 HBufC8* aData, |
|
761 TInt aError ) |
|
762 { |
|
763 PRINT( _L("Camera => CCamCameraController::ImageReady") ); |
|
764 |
|
765 CCamBuffer* buffer = NULL; |
|
766 |
|
767 // If no error so far, wrap the data to MCameraBuffer compatible wrapper. |
|
768 // New API provides these buffers already from CCamera callbacks. |
|
769 if( KErrNone == aError ) |
|
770 { |
|
771 TRAP( aError, |
|
772 { |
|
773 CleanupStack::PushL( aData ); |
|
774 CleanupStack::PushL( aBitmap ); |
|
775 buffer = CCamBuffer::NewL( aBitmap, aData ); |
|
776 CleanupStack::Pop( 2 ); |
|
777 }); |
|
778 } |
|
779 |
|
780 // Ownership taken by buffer, or destroyed by cleanup stack. |
|
781 aData = NULL; |
|
782 aBitmap = NULL; |
|
783 |
|
784 PRINT1( _L("Camera <> status after buffer create(%d)"), aError ); |
|
785 |
|
786 // Releases buffer |
|
787 HandleImageCaptureEvent( buffer, aError ); |
|
788 |
|
789 PRINT( _L("Camera <= CCamCameraController::ImageReady") ); |
|
790 } |
|
791 |
|
792 |
|
793 // --------------------------------------------------------------------------- |
|
794 // FrameBufferReady |
|
795 // --------------------------------------------------------------------------- |
|
796 // |
|
797 void |
|
798 CCamCameraController::FrameBufferReady( MFrameBuffer* aFrameBuffer, |
|
799 TInt /*aError*/ ) |
|
800 { |
|
801 // Release the buffer if one is provided to make sure |
|
802 // CCamera can reuse it. |
|
803 if( aFrameBuffer ) |
|
804 { |
|
805 aFrameBuffer->Release(); |
|
806 } |
|
807 } |
|
808 #endif // CAMERAAPP_CAPI_V2 |
|
809 |
|
810 |
|
811 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
812 // =========================================================================== |
|
813 // From MCamAppEngineObserver |
|
814 |
|
815 // --------------------------------------------------------------------------- |
|
816 // McaeoInitComplete |
|
817 // --------------------------------------------------------------------------- |
|
818 // |
|
819 void |
|
820 CCamCameraController::McaeoInitComplete( TInt aError ) |
|
821 { |
|
822 PRINT( _L("Camera => CCamCameraController::McaeoInitComplete") ); |
|
823 // Only interested on this callback, if CCamera duplicate |
|
824 // cannot be used with CAE. Otherwise we follow this event through |
|
825 // MCameraObserver(2) interface. |
|
826 #ifdef CAMERAAPP_CAE_FIX |
|
827 HandlePowerOnEvent( aError ); |
|
828 #endif |
|
829 PRINT( _L("Camera <= CCamCameraController::McaeoInitComplete") ); |
|
830 } |
|
831 |
|
832 // --------------------------------------------------------------------------- |
|
833 // McaeoStillPrepareComplete |
|
834 // --------------------------------------------------------------------------- |
|
835 // |
|
836 void |
|
837 CCamCameraController::McaeoStillPrepareComplete( TInt /*aError*/ ) |
|
838 { |
|
839 PRINT( _L("Camera =><= CCamCameraController::McaeoStillPrepareComplete, PANIC!") ); |
|
840 // Still capture not done through CCaeEngine. |
|
841 __ASSERT_DEBUG( EFalse, Panic( ECamCameraControllerCaeUnsupported ) ); |
|
842 } |
|
843 |
|
844 // --------------------------------------------------------------------------- |
|
845 // McaeoVideoPrepareComplete |
|
846 // |
|
847 // This method is called asynchronously after a call has been made to |
|
848 // CCaeEngine::PrepareVideoRecordingL. |
|
849 // --------------------------------------------------------------------------- |
|
850 // |
|
851 void |
|
852 CCamCameraController::McaeoVideoPrepareComplete( TInt aError ) |
|
853 { |
|
854 PRINT( _L("Camera => CCamCameraController::McaeoVideoPrepareComplete") ); |
|
855 #ifdef CAMERAAPP_CAE_ERR_SIMULATION |
|
856 HandleVideoEvent( ECamCameraEventVideoInit, aError ); |
|
857 // DelayCallback( ECamCameraEventVideoInit, aError, 500000 ); |
|
858 #else |
|
859 HandleVideoEvent( ECamCameraEventVideoInit, aError ); |
|
860 #endif // CAMERAAPP_CAE_ERR_SIMULATION |
|
861 |
|
862 PRINT( _L("Camera <= CCamCameraController::McaeoVideoPrepareComplete") ); |
|
863 } |
|
864 |
|
865 // --------------------------------------------------------------------------- |
|
866 // McaeoViewFinderFrameReady |
|
867 // --------------------------------------------------------------------------- |
|
868 // |
|
869 void |
|
870 CCamCameraController::McaeoViewFinderFrameReady( CFbsBitmap& aFrame, |
|
871 TInt aError ) |
|
872 { |
|
873 PRINT( _L("Camera => CCamCameraController::McaeoViewFinderFrameReady") ); |
|
874 CCamBuffer* buffer = NULL; |
|
875 if( KErrNone == aError ) |
|
876 { |
|
877 TRAP( aError, buffer = CCamBuffer::NewL( aFrame, NULL ) ); |
|
878 } |
|
879 |
|
880 // Releases buffer if not NULL |
|
881 HandleViewfinderEvent( buffer, aError ); |
|
882 |
|
883 PRINT( _L("Camera <= CCamCameraController::McaeoViewFinderFrameReady") ); |
|
884 } |
|
885 |
|
886 // --------------------------------------------------------------------------- |
|
887 // McaeoSnapImageReady |
|
888 // --------------------------------------------------------------------------- |
|
889 // |
|
890 void |
|
891 CCamCameraController::McaeoSnapImageReady( const CFbsBitmap& aBitmap, |
|
892 TInt aError ) |
|
893 { |
|
894 PRINT1( _L("Camera => CCamCameraController::McaeoSnapImageReady, status: %d"), aError ); |
|
895 //__ASSERT_DEBUG( EFalse, Panic( ECamCameraControllerCaeUnsupported ) ); |
|
896 if( |
|
897 #ifdef CAMERAAPP_CAE_FIX |
|
898 ECamModeChangeInactive == iModeChange && |
|
899 #endif |
|
900 IsFlagOn( iInfo.iState, ECamVideoOn ) |
|
901 ) |
|
902 { |
|
903 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestSsStart ); |
|
904 |
|
905 CFbsBitmap* copy( NULL ); |
|
906 if( KErrNone == aError ) |
|
907 { |
|
908 TRAP( aError, |
|
909 { |
|
910 copy = new (ELeave) CFbsBitmap; |
|
911 User::LeaveIfError( copy->Duplicate( aBitmap.Handle() ) ); |
|
912 }); |
|
913 } |
|
914 |
|
915 NotifyObservers( aError, |
|
916 ECamCameraEventSsReady, |
|
917 ECamCameraEventClassSsData, |
|
918 copy ); |
|
919 delete copy; |
|
920 copy = NULL; |
|
921 } |
|
922 PRINT( _L("Camera <= CCamCameraController::McaeoSnapImageReady") ); |
|
923 } |
|
924 |
|
925 // --------------------------------------------------------------------------- |
|
926 // McaeoStillImageReady |
|
927 // --------------------------------------------------------------------------- |
|
928 // |
|
929 void |
|
930 CCamCameraController::McaeoStillImageReady( CFbsBitmap* /*aBitmap*/, |
|
931 HBufC8* /*aData */, |
|
932 TInt /*aError */ ) |
|
933 { |
|
934 // Still images are not captured through CCaeEngine. |
|
935 __ASSERT_DEBUG( EFalse, Panic( ECamCameraControllerCaeUnsupported ) ); |
|
936 } |
|
937 |
|
938 // --------------------------------------------------------------------------- |
|
939 // McaeoVideoRecordingOn |
|
940 // --------------------------------------------------------------------------- |
|
941 // |
|
942 void |
|
943 CCamCameraController::McaeoVideoRecordingOn( TInt aError ) |
|
944 { |
|
945 PRINT( _L("Camera => CCamCameraController::McaeoVideoRecordingOn") ); |
|
946 |
|
947 #ifdef CAMERAAPP_CAE_ERR_SIMULATION |
|
948 HandleVideoEvent( ECamCameraEventVideoStart, aError ); |
|
949 #else |
|
950 HandleVideoEvent( ECamCameraEventVideoStart, aError ); |
|
951 #endif // CAMERAAPP_CAE_ERR_SIMULATION |
|
952 |
|
953 PRINT( _L("Camera <= CCamCameraController::McaeoVideoRecordingOn") ); |
|
954 |
|
955 } |
|
956 |
|
957 // --------------------------------------------------------------------------- |
|
958 // McaeoVideoRecordingPaused |
|
959 // --------------------------------------------------------------------------- |
|
960 // |
|
961 void |
|
962 CCamCameraController::McaeoVideoRecordingPaused( TInt aError ) |
|
963 { |
|
964 PRINT( _L("Camera => CCamCameraController::McaeoVideoRecordingPaused") ); |
|
965 |
|
966 #ifdef CAMERAAPP_CAE_ERR_SIMULATION |
|
967 HandleVideoEvent( ECamCameraEventVideoPause, KErrUnknown ); |
|
968 #else |
|
969 HandleVideoEvent( ECamCameraEventVideoPause, aError ); |
|
970 #endif // CAMERAAPP_CAE_ERR_SIMULATION |
|
971 |
|
972 PRINT( _L("Camera <= CCamCameraController::McaeoVideoRecordingPaused") ); |
|
973 |
|
974 } |
|
975 |
|
976 // --------------------------------------------------------------------------- |
|
977 // McaeoVideoRecordingComplete |
|
978 // --------------------------------------------------------------------------- |
|
979 // |
|
980 void |
|
981 CCamCameraController::McaeoVideoRecordingComplete( TInt aError ) |
|
982 { |
|
983 PRINT( _L("Camera => CCamCameraController::McaeoVideoRecordingComplete") ); |
|
984 |
|
985 #ifdef CAMERAAPP_CAE_ERR_SIMULATION |
|
986 HandleVideoEvent( ECamCameraEventVideoStop, KErrUnknown ); |
|
987 #else |
|
988 HandleVideoEvent( ECamCameraEventVideoStop, aError ); |
|
989 #endif // CAMERAAPP_CAE_ERR_SIMULATION |
|
990 // Change stopping mode back to default sync mode |
|
991 if ( iAsyncVideoStopModeSupported ) |
|
992 { |
|
993 if ( iCaeEngine ) |
|
994 { |
|
995 iCaeEngine->SetAsyncVideoStopMode( EFalse ); |
|
996 } |
|
997 iAsyncVideoStopModeSupported = EFalse; |
|
998 } |
|
999 |
|
1000 PRINT( _L("Camera <= CCamCameraController::McaeoVideoRecordingComplete") ); |
|
1001 |
|
1002 } |
|
1003 |
|
1004 // --------------------------------------------------------------------------- |
|
1005 // McaeoVideoRecordingTimes |
|
1006 // --------------------------------------------------------------------------- |
|
1007 // |
|
1008 void |
|
1009 CCamCameraController::McaeoVideoRecordingTimes( |
|
1010 TTimeIntervalMicroSeconds aTimeElapsed, |
|
1011 TTimeIntervalMicroSeconds aTimeRemaining, |
|
1012 TInt aError ) |
|
1013 { |
|
1014 HandleVideoTimeEvent( aError, aTimeElapsed, aTimeRemaining ); |
|
1015 } |
|
1016 |
|
1017 // --------------------------------------------------------------------------- |
|
1018 // McaeoVideoRecordingStopped |
|
1019 // --------------------------------------------------------------------------- |
|
1020 // |
|
1021 void |
|
1022 CCamCameraController::McaeoVideoRecordingStopped() |
|
1023 { |
|
1024 PRINT( _L("Camera => CCamCameraController::McaeoVideoRecordingStopped") ); |
|
1025 |
|
1026 #ifdef CAMERAAPP_CAE_ERR_SIMULATION |
|
1027 HandleVideoEvent( ECamCameraEventVideoAsyncStop, KErrUnknown ); |
|
1028 #else |
|
1029 HandleVideoEvent( ECamCameraEventVideoAsyncStop, KErrNone ); |
|
1030 #endif // CAMERAAPP_CAE_ERR_SIMULATION |
|
1031 |
|
1032 PRINT( _L("Camera <= CCamCameraController::McaeoVideoRecordingStopped") ); |
|
1033 } |
|
1034 |
|
1035 #endif // CAMERAAPP_CAE_FOR_VIDEO |
|
1036 // =========================================================================== |
|
1037 // From MCamImageEncoderObserver |
|
1038 |
|
1039 // --------------------------------------------------------------------------- |
|
1040 // ImageEncoded |
|
1041 // --------------------------------------------------------------------------- |
|
1042 // |
|
1043 void |
|
1044 CCamCameraController::ImageEncoded( TInt aStatus, HBufC8* aData ) |
|
1045 { |
|
1046 PRINT( _L("Camera => CCamCameraController::ImageEncoded") ); |
|
1047 MCameraBuffer* buffer = NULL; |
|
1048 |
|
1049 if( KErrNone == aStatus ) |
|
1050 { |
|
1051 if( aData ) |
|
1052 { |
|
1053 TRAP( aStatus, |
|
1054 { |
|
1055 CleanupStack::PushL( aData ); |
|
1056 buffer = CCamBuffer::NewL( NULL, aData ); |
|
1057 CleanupStack::Pop( aData ); |
|
1058 aData = NULL; // ownership to buffer |
|
1059 }); |
|
1060 } |
|
1061 else |
|
1062 { |
|
1063 aStatus = KErrNotFound; |
|
1064 } |
|
1065 } |
|
1066 else |
|
1067 { |
|
1068 // Just delete on errors |
|
1069 delete aData; |
|
1070 aData = NULL; |
|
1071 } |
|
1072 |
|
1073 // Takes ownership of buffer |
|
1074 HandleImageCaptureEvent( buffer, aStatus ); |
|
1075 PRINT( _L("Camera <= CCamCameraController::ImageEncoded") ); |
|
1076 } |
|
1077 |
|
1078 |
|
1079 // =========================================================================== |
|
1080 |
|
1081 |
|
1082 // --------------------------------------------------------------------------- |
|
1083 // AttachObserverL |
|
1084 // --------------------------------------------------------------------------- |
|
1085 // |
|
1086 void |
|
1087 CCamCameraController::AttachObserverL( const MCamCameraObserver* aObserver, |
|
1088 const TUint& aInterest ) |
|
1089 { |
|
1090 // Only add the observer once. NULL pointer only checked here. |
|
1091 // Observer not added, if no notifications would be sent due to |
|
1092 // event interest being ECamCameraEventClassNone. |
|
1093 if( aObserver |
|
1094 && ECamCameraEventClassNone != aInterest |
|
1095 && KErrNotFound == iObservers.Find( aObserver ) |
|
1096 ) |
|
1097 { |
|
1098 // Try to add the observer to our list. |
|
1099 TInt error = iObservers.Append( aObserver ); |
|
1100 |
|
1101 // If we manage to add the observer, make sure the interest info gets set. |
|
1102 if( KErrNone == error ) |
|
1103 { |
|
1104 error = iObserverInterests.Append( aInterest ); |
|
1105 // If we are unable to add the interest info, |
|
1106 // remove also the observer. |
|
1107 if( KErrNone != error ) |
|
1108 { |
|
1109 iObservers.Remove( iObservers.Count() - 1 ); |
|
1110 } |
|
1111 } |
|
1112 |
|
1113 User::LeaveIfError( error ); |
|
1114 } |
|
1115 } |
|
1116 |
|
1117 // --------------------------------------------------------------------------- |
|
1118 // DetachObserver |
|
1119 // --------------------------------------------------------------------------- |
|
1120 // |
|
1121 void |
|
1122 CCamCameraController::DetachObserver( const MCamCameraObserver* aObserver ) |
|
1123 { |
|
1124 if( aObserver ) |
|
1125 { |
|
1126 // Ignore error if not found among observers |
|
1127 const TInt KObserverIndex( iObservers.Find( aObserver ) ); |
|
1128 if( KErrNotFound != KObserverIndex ) |
|
1129 { |
|
1130 iObservers.Remove( KObserverIndex ); |
|
1131 iObserverInterests.Remove( KObserverIndex ); |
|
1132 } |
|
1133 } |
|
1134 } |
|
1135 |
|
1136 |
|
1137 // --------------------------------------------------------------------------- |
|
1138 // RequestL |
|
1139 // |
|
1140 // Issue request for one operation. |
|
1141 // --------------------------------------------------------------------------- |
|
1142 // |
|
1143 void |
|
1144 CCamCameraController::RequestL( const TCamCameraRequestId& aRequestId ) |
|
1145 { |
|
1146 PRINT1( _L("Camera => CCamCameraController::RequestL, request:[%s]"), KCamRequestNames[aRequestId] ); |
|
1147 CheckEqualsL( iInfo.iBusy, ECamBusyOff, KErrInUse ); |
|
1148 SetFlags ( iInfo.iBusy, ECamBusySingle ); |
|
1149 |
|
1150 TInt proceed( ETrue ); |
|
1151 |
|
1152 // If the request leaves, need to reset busy flag. |
|
1153 CleanupStack::PushL( TCleanupItem( SetNotBusy, &iInfo.iBusy ) ); |
|
1154 PRINT( _L("Camera <> process request..") ); |
|
1155 proceed = ProcessOneRequestL( aRequestId ); |
|
1156 CleanupStack::Pop(); |
|
1157 |
|
1158 // If this request will be responded through MCameraObserver(2) callback, |
|
1159 // new requests cannot be accepted until that call arrives and |
|
1160 // notification to our observers will be sent there. |
|
1161 // Otherwise the request is fully processed from our point of view, |
|
1162 // and new request can be accepted. |
|
1163 if( proceed ) |
|
1164 { |
|
1165 PRINT( _L("Camera <> ..Request has no callback from CCamera, ready for new request.") ); |
|
1166 // Need to clear the busy flag before notification, |
|
1167 // as observer might want to issue a new request during |
|
1168 // the notification callback. |
|
1169 ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
1170 |
|
1171 if( ECamRequestVideoStop == aRequestId |
|
1172 || ECamRequestSetAsyncVideoStopMode == aRequestId |
|
1173 || ECamRequestImageCancel == aRequestId ) |
|
1174 { |
|
1175 // For video stop request, callback has already happened and notification |
|
1176 // has been given. No need to do anything here. |
|
1177 } |
|
1178 else |
|
1179 { |
|
1180 // Give notification to observers |
|
1181 TCamCameraEventId event( Request2Event( aRequestId ) ); |
|
1182 NotifyObservers( KErrNone, event, EventClass( event ) ); |
|
1183 } |
|
1184 } |
|
1185 else |
|
1186 { |
|
1187 PRINT( _L("Camera <> ..Request has callback, waiting for it.") ); |
|
1188 // Request is finalized in the MCameraObserver(2) callback. |
|
1189 } |
|
1190 PRINT( _L("Camera <= CCamCameraController::RequestL") ); |
|
1191 } |
|
1192 |
|
1193 // --------------------------------------------------------------------------- |
|
1194 // DirectRequestL |
|
1195 // |
|
1196 // Issue request even when busy. |
|
1197 // --------------------------------------------------------------------------- |
|
1198 // |
|
1199 void |
|
1200 CCamCameraController::DirectRequestL( const TCamCameraRequestId& aRequestId ) |
|
1201 { |
|
1202 PRINT( _L("Camera => CCamCameraController::DirectRequestL") ); |
|
1203 |
|
1204 TBool notify( ETrue ); |
|
1205 switch( aRequestId ) |
|
1206 { |
|
1207 // ----------------------------------------------------- |
|
1208 case ECamRequestPowerOff: |
|
1209 case ECamRequestRelease: |
|
1210 ProcessControlShutdownRequest( aRequestId ); |
|
1211 break; |
|
1212 // ----------------------------------------------------- |
|
1213 // Viewfinder |
|
1214 // This does not depend on prepare of video / image |
|
1215 // so even starting can be done during sequence. |
|
1216 case ECamRequestVfStart: |
|
1217 ProcessVfStartRequestL(); |
|
1218 break; |
|
1219 case ECamRequestVfStop: |
|
1220 ProcessVfStopRequestL(); |
|
1221 break; |
|
1222 case ECamRequestVfStopEcam: |
|
1223 ProcessVfStopEcamRequest(); |
|
1224 notify = EFalse; |
|
1225 break; |
|
1226 case ECamRequestVfRelease: |
|
1227 ProcessVfRelaseRequest(); |
|
1228 break; |
|
1229 // ----------------------------------------------------- |
|
1230 // Snapshot |
|
1231 // Just as viewfinder, this can be even started |
|
1232 // during a sequence. |
|
1233 case ECamRequestSsStart: |
|
1234 ProcessSnapshotRequestL( ECamRequestSsStart ); |
|
1235 break; |
|
1236 case ECamRequestSsStop: |
|
1237 ProcessSsStopRequest(); |
|
1238 break; |
|
1239 case ECamRequestSsRelease: |
|
1240 ProcessSsReleaseRequest(); |
|
1241 break; |
|
1242 // ----------------------------------------------------- |
|
1243 // Image capture (cancel) |
|
1244 case ECamRequestImageCancel: |
|
1245 ProcessImageShutdownRequest( ECamRequestImageCancel ); |
|
1246 notify = EFalse; |
|
1247 break; |
|
1248 // ----------------------------------------------------- |
|
1249 // Start/cancel autofocus or set range |
|
1250 case ECamRequestStartAutofocus: |
|
1251 case ECamRequestCancelAutofocus: |
|
1252 case ECamRequestSetAfRange: |
|
1253 ProcessAutofocusRequestL( aRequestId ); |
|
1254 break; |
|
1255 // ----------------------------------------------------- |
|
1256 // Initialize image quality |
|
1257 case ECamRequestImageInit: |
|
1258 ProcessImageRequestL( ECamRequestImageInit ); |
|
1259 break; |
|
1260 // ----------------------------------------------------- |
|
1261 default: |
|
1262 Panic( ECamCameraControllerUnsupported ); |
|
1263 break; |
|
1264 } |
|
1265 |
|
1266 if( notify ) |
|
1267 { |
|
1268 TCamCameraEventId event( Request2Event( aRequestId ) ); |
|
1269 NotifyObservers( KErrNone, event, EventClass( event ) ); |
|
1270 } |
|
1271 |
|
1272 PRINT( _L("Camera <= CCamCameraController::DirectRequestL") ); |
|
1273 } |
|
1274 |
|
1275 // --------------------------------------------------------------------------- |
|
1276 // RequestSequenceL |
|
1277 // |
|
1278 // Issue request for a sequence of operations. |
|
1279 // |
|
1280 // Operations done during the sequence will be notified with |
|
1281 // associated event codes to observers. If any errors happen during the |
|
1282 // sequence, the notification will reflect this with the status code. |
|
1283 // When sequence ends, observers will be notified with event |
|
1284 // ECamCameraEventSequenceEnd. No new requests are accepted before |
|
1285 // ECamCameraEventSequenceEnd notification is sent. |
|
1286 // --------------------------------------------------------------------------- |
|
1287 // |
|
1288 void |
|
1289 CCamCameraController |
|
1290 ::RequestSequenceL( const RCamRequestArray& aSequence ) |
|
1291 { |
|
1292 PRINT( _L("Camera => CCamCameraController::RequestSequence") ); |
|
1293 CheckEqualsL( iInfo.iBusy, ECamBusyOff, KErrInUse ); |
|
1294 |
|
1295 CAMERAAPP_PERF_CONTROLLER_START( ECamRequestNone ); |
|
1296 |
|
1297 ClearRequestQueue(); |
|
1298 iReserveTryAgainCount = KCamReserveTryAgainMaxCount; |
|
1299 |
|
1300 iSequenceArray.ReserveL( aSequence.Count() ); |
|
1301 for( TInt i = 0; i < aSequence.Count(); i++ ) |
|
1302 iSequenceArray.AppendL( aSequence[i] ); |
|
1303 // iSequenceArray.Compress(); |
|
1304 |
|
1305 SetFlags( iInfo.iBusy, ECamBusySequence ); // Cleared in EndSequence |
|
1306 iActive->IssueRequest(); |
|
1307 |
|
1308 PRINT( _L("Camera <= CCamCameraController::RequestSequence") ); |
|
1309 } |
|
1310 |
|
1311 |
|
1312 // --------------------------------------------------------------------------- |
|
1313 // RequestSettingsChangeL |
|
1314 // --------------------------------------------------------------------------- |
|
1315 // |
|
1316 void |
|
1317 CCamCameraController::RequestSettingsChangeL() |
|
1318 { |
|
1319 PRINT ( _L("Camera => CCamCameraController::RequestSettingsChangeL") ); |
|
1320 CheckEqualsL( iInfo.iBusy, ECamBusyOff, KErrInUse ); |
|
1321 CheckFlagOnL( iInfo.iState, ECamReserved, KErrNotReady ); |
|
1322 |
|
1323 PRINT ( _L("Camera <> Get changed settings..") ); |
|
1324 ClearSettingQueue(); |
|
1325 iSettingProvider.ProvidePendingSettingChangesL( iSettingArray ); |
|
1326 |
|
1327 PRINT ( _L("Camera <> Start processing..") ); |
|
1328 SetFlags( iInfo.iBusy, ECamBusySetting ); // Cleared in EndSequence |
|
1329 iActive->IssueRequest(); |
|
1330 |
|
1331 PRINT ( _L("Camera <= CCamCameraController::RequestSettingsChangeL") ); |
|
1332 } |
|
1333 |
|
1334 |
|
1335 // --------------------------------------------------------------------------- |
|
1336 // DirectRequestSettingsChangeL |
|
1337 // --------------------------------------------------------------------------- |
|
1338 // |
|
1339 void |
|
1340 CCamCameraController |
|
1341 ::DirectSettingsChangeL( const TCamCameraSettingId& aSettingId ) |
|
1342 { |
|
1343 PRINT ( _L("Camera => CCamCameraController::DirectSettingsChangeL") ); |
|
1344 |
|
1345 CheckFlagOnL( iInfo.iState, ECamReserved, KErrNotReady ); |
|
1346 |
|
1347 TBool callback = ProcessSettingL( aSettingId ); |
|
1348 // If there is a callback, do notification there. |
|
1349 if( !callback ) |
|
1350 { |
|
1351 TCamCameraSettingId setting = aSettingId; |
|
1352 NotifyObservers( KErrNone, |
|
1353 ECamCameraEventSettingsSingle, |
|
1354 ECamCameraEventClassSettings, |
|
1355 &setting ); |
|
1356 } |
|
1357 |
|
1358 PRINT ( _L("Camera <= CCamCameraController::DirectSettingsChangeL") ); |
|
1359 } |
|
1360 |
|
1361 |
|
1362 // --------------------------------------------------------------------------- |
|
1363 // CancelSequence |
|
1364 // --------------------------------------------------------------------------- |
|
1365 // |
|
1366 void |
|
1367 CCamCameraController::CancelSequence() |
|
1368 { |
|
1369 PRINT( _L("Camera => CCamCameraController::CancelSequence") ); |
|
1370 if( iActive && |
|
1371 iActive->IsActive() ) |
|
1372 { |
|
1373 PRINT( _L("Camera <> iActive is active, call Cancel()..") ); |
|
1374 // Results to call to iActive::DoCancel |
|
1375 // which in turn calls our EndSequence. |
|
1376 iActive->Cancel(); |
|
1377 } |
|
1378 |
|
1379 // If busy flag is not set, we either had no sequence going on or |
|
1380 // iActive::DoCancel already handled calling EndSequence(). |
|
1381 if( IsFlagOn( iInfo.iBusy, ECamBusySequence|ECamBusySetting ) ) |
|
1382 { |
|
1383 PRINT( _L("Camera <> Busy, call EndSequence()..") ); |
|
1384 // Clears busy flag, if we were processing a sequence of requests / settings. |
|
1385 // If iBusy is set because one request is on the way, |
|
1386 // we must not clear it here - when that request is processed, |
|
1387 // the flag will be cleared. |
|
1388 EndSequence( KErrCancel ); |
|
1389 } |
|
1390 PRINT( _L("Camera <= CCamCameraController::CancelSequence") ); |
|
1391 } |
|
1392 |
|
1393 // --------------------------------------------------------------------------- |
|
1394 // SwitchCameraL |
|
1395 // --------------------------------------------------------------------------- |
|
1396 // |
|
1397 void |
|
1398 CCamCameraController::SwitchCameraL( TInt aCameraIndex ) |
|
1399 { |
|
1400 PRINT1( _L("Camera => CCamCameraController::SwitchCameraL%d"),aCameraIndex ); |
|
1401 #ifdef _DEBUG |
|
1402 if( aCameraIndex == iInfo.iCurrentCamera ) |
|
1403 { |
|
1404 PRINT( _L("Camera <> CCamCameraController::SwitchCameraL - Changing Secondary camera orientation") ); |
|
1405 } |
|
1406 #endif // _DEBUG |
|
1407 |
|
1408 if( aCameraIndex < 0 || aCameraIndex >= CamerasAvailable() ) |
|
1409 { |
|
1410 User::Leave( KErrNotSupported ); |
|
1411 } |
|
1412 else |
|
1413 { |
|
1414 // ----------------------------------------------------- |
|
1415 // First free old camera resources |
|
1416 if( iCamera ) |
|
1417 { |
|
1418 ReleaseCurrentCamera(); |
|
1419 } |
|
1420 |
|
1421 // used in CompleteSwitchCamera |
|
1422 iCurrentCameraIndex = aCameraIndex; |
|
1423 |
|
1424 // ----------------------------------------------------- |
|
1425 // Then create new camera: |
|
1426 PRINT ( _L("############################################################") ); |
|
1427 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
1428 |
|
1429 PRINT1( _L("Camera <> Creating CCaeEngine, camera index: %d .."), aCameraIndex ); |
|
1430 iCaeEngine = NewCaeEngineL( aCameraIndex ); |
|
1431 |
|
1432 #else |
|
1433 |
|
1434 PRINT ( _L("Camera <> Note: CCamera only in use, no CCaeEngine") ); |
|
1435 PRINT1( _L("Camera <> Creating CCamera, camera index: %d .."), aCameraIndex ); |
|
1436 iCamera = NewCameraL( aCameraIndex ); |
|
1437 |
|
1438 #endif // CAMERAAPP_CAE_FOR_VIDEO |
|
1439 |
|
1440 |
|
1441 PRINT( _L("Camera <= CCamCameraController::SwitchCameraL") ); |
|
1442 } |
|
1443 } |
|
1444 // --------------------------------------------------------------------------- |
|
1445 // CompleteSwitchCameraL |
|
1446 // --------------------------------------------------------------------------- |
|
1447 // |
|
1448 void |
|
1449 CCamCameraController::CompleteSwitchCameraL() |
|
1450 { |
|
1451 PRINT( _L("Camera => CCamCameraController::CompleteSwitchCameraL") ); |
|
1452 if( iCurrentCameraIndex < 0 || iCurrentCameraIndex >= CamerasAvailable() ) |
|
1453 { |
|
1454 User::Leave( KErrNotSupported ); |
|
1455 } |
|
1456 else if( iCurrentCameraIndex == iInfo.iCurrentCamera ) |
|
1457 { |
|
1458 return; |
|
1459 } |
|
1460 |
|
1461 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
1462 #ifdef CAMERAAPP_CAE_FIX |
|
1463 PRINT ( _L("Camera <> Creating new CCamera..") ); |
|
1464 iCamera = NewCameraL( iCurrentCameraIndex ); |
|
1465 #else |
|
1466 PRINT1( _L("Camera <> Creating CCamera duplicate, camera handle: %d .."), iCaeEngine->CCameraHandle() ); |
|
1467 iCamera = NewDuplicateCameraL( iCaeEngine->CCameraHandle() ); |
|
1468 #endif |
|
1469 #endif // CAMERAAPP_CAE_FOR_VIDEO |
|
1470 // Get the camera info and store current camera index. |
|
1471 // Camera index needed by GetAdvancedSettingsInfoL. |
|
1472 iCamera->CameraInfo( iCameraInfo ); |
|
1473 iInfo.iCurrentCamera = iCurrentCameraIndex; |
|
1474 |
|
1475 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
1476 PRINT ( _L("Camera <> Creating CCameraAdvancedSettings..") ); |
|
1477 iAdvancedSettings = CCamera::CCameraAdvancedSettings::NewL( *iCamera ); |
|
1478 #ifdef CAMERAAPP_CAPI_V2_IP |
|
1479 if( KPrimaryCameraIndex == iInfo.iCurrentCamera ) |
|
1480 { |
|
1481 // Support only for primary camera. |
|
1482 // Ignore error in instantiation: If NewL leaves, there's no |
|
1483 // support for Image Processing available. Report error to client |
|
1484 // if settings requiring it are used. |
|
1485 PRINT ( _L("Camera <> Create CCameraImageProcessing..") ); |
|
1486 TRAP_IGNORE( iImageProcessor = CCamera::CCameraImageProcessing::NewL( *iCamera ) ); |
|
1487 PRINT1( _L("Camera <> Image Processor pointer: %d"), iImageProcessor ); |
|
1488 } |
|
1489 #endif // CAMERAAPP_CAPI_V2_IP |
|
1490 |
|
1491 // Get info on CCameraAdvancedSettings and CCameraImageProcessing |
|
1492 // support for several setting. Not supported settings will not |
|
1493 // cause this method to leave, only more serious errors. |
|
1494 GetAdvancedSettingsInfoL(); |
|
1495 |
|
1496 PRINT ( _L("Camera <> Get i/f MCameraOrientation..") ) |
|
1497 iCustomInterfaceOrientation = |
|
1498 static_cast <MCameraOrientation*>( |
|
1499 iCamera->CustomInterface( KCameraOrientationUid ) ); |
|
1500 PRINT1( _L("Camera <> Orientation custom i/f pointer:%d"), iCustomInterfaceOrientation ); |
|
1501 |
|
1502 #endif // CAMERAAPP_CAPI_V2_ADV |
|
1503 |
|
1504 PRINT ( _L("Camera <> ..done") ); |
|
1505 PRINT ( _L("############################################################") ); |
|
1506 |
|
1507 // ----------------------------------------------------- |
|
1508 #ifdef _DEBUG |
|
1509 PrintCameraInfo(); |
|
1510 #endif |
|
1511 // ----------------------------------------------------- |
|
1512 PRINT( _L("Camera <= CCamCameraController::CompleteSwitchCameraL") ); |
|
1513 } |
|
1514 |
|
1515 |
|
1516 // --------------------------------------------------------------------------- |
|
1517 // SetOrientationModeL |
|
1518 // --------------------------------------------------------------------------- |
|
1519 // |
|
1520 void |
|
1521 CCamCameraController::SetOrientationModeL( TInt aOrientation ) |
|
1522 { |
|
1523 PRINT1( _L("Camera => CCamCameraController::SetOrientationModeL %d"), aOrientation ); |
|
1524 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
1525 PRINT( _L("Camera <> CCameraController: Get i/f MUIOrientationOverride from iCaeEngine..") ) |
|
1526 iCustomInterfaceUIOrientationOverride = |
|
1527 static_cast <MCameraUIOrientationOverride*>( |
|
1528 iCaeEngine->CustomInterface( KCameraUIOrientationOverrideUid ) ); |
|
1529 #else |
|
1530 PRINT( _L("Camera <> CCameraController: Get i/f MUIOrientationOverride from iCamera..") ) |
|
1531 iCustomInterfaceUIOrientationOverride = |
|
1532 static_cast <MCameraUIOrientationOverride*>( |
|
1533 iCamera->CustomInterface( KCameraUIOrientationOverrideUid ) ); |
|
1534 #endif // CAMERAAPP_CAE_FOR_VIDEO |
|
1535 |
|
1536 PRINT1( _L("Camera <> OrientationOverride custom i/f pointer:%d"), iCustomInterfaceUIOrientationOverride ); |
|
1537 iCustomInterfaceUIOrientationOverride->SetOrientationModeL( aOrientation ); |
|
1538 |
|
1539 PRINT( _L("Camera <= CCamCameraController::SetOrientationModeL") ); |
|
1540 } |
|
1541 |
|
1542 // --------------------------------------------------------------------------- |
|
1543 // CamerasAvailable <<static>> |
|
1544 // --------------------------------------------------------------------------- |
|
1545 // |
|
1546 TInt |
|
1547 CCamCameraController::CamerasAvailable() |
|
1548 { |
|
1549 #ifndef CAMERAAPP_CAPI_EMULATOR |
|
1550 return CCamera::CamerasAvailable(); |
|
1551 #else |
|
1552 // Temporary |
|
1553 return 2; |
|
1554 #endif |
|
1555 } |
|
1556 |
|
1557 // --------------------------------------------------------------------------- |
|
1558 // CameraHandle |
|
1559 // --------------------------------------------------------------------------- |
|
1560 // |
|
1561 TInt |
|
1562 CCamCameraController::CameraHandle() |
|
1563 { |
|
1564 if( iCamera ) |
|
1565 return iCamera->Handle(); |
|
1566 else |
|
1567 return KNullHandle; |
|
1568 } |
|
1569 |
|
1570 |
|
1571 // --------------------------------------------------------------------------- |
|
1572 // CameraInfo |
|
1573 // --------------------------------------------------------------------------- |
|
1574 // |
|
1575 const TCameraInfo& |
|
1576 CCamCameraController::CameraInfo() const |
|
1577 { |
|
1578 return iCameraInfo; |
|
1579 } |
|
1580 |
|
1581 // --------------------------------------------------------------------------- |
|
1582 // ControllerInfo |
|
1583 // --------------------------------------------------------------------------- |
|
1584 // |
|
1585 const TCamControllerInfo& |
|
1586 CCamCameraController::ControllerInfo() const |
|
1587 { |
|
1588 return iInfo; |
|
1589 } |
|
1590 |
|
1591 // --------------------------------------------------------------------------- |
|
1592 // |
|
1593 // --------------------------------------------------------------------------- |
|
1594 // |
|
1595 TUint |
|
1596 CCamCameraController::State() const |
|
1597 { |
|
1598 return iInfo.iState; |
|
1599 } |
|
1600 |
|
1601 // --------------------------------------------------------------------------- |
|
1602 // |
|
1603 // --------------------------------------------------------------------------- |
|
1604 // |
|
1605 TCamViewfinderMode |
|
1606 CCamCameraController::ViewfinderMode() const |
|
1607 { |
|
1608 return iInfo.iVfMode; |
|
1609 } |
|
1610 |
|
1611 // --------------------------------------------------------------------------- |
|
1612 // |
|
1613 // --------------------------------------------------------------------------- |
|
1614 // |
|
1615 TCamCameraTriState |
|
1616 CCamCameraController::ViewfinderState() const |
|
1617 { |
|
1618 return iInfo.iVfState; |
|
1619 } |
|
1620 |
|
1621 |
|
1622 // --------------------------------------------------------------------------- |
|
1623 // |
|
1624 // --------------------------------------------------------------------------- |
|
1625 // |
|
1626 TCamCameraTriState |
|
1627 CCamCameraController::SnapshotState() const |
|
1628 { |
|
1629 return iInfo.iSsState; |
|
1630 } |
|
1631 |
|
1632 |
|
1633 // --------------------------------------------------------------------------- |
|
1634 // |
|
1635 // --------------------------------------------------------------------------- |
|
1636 // |
|
1637 TCamCameraReadyState |
|
1638 CCamCameraController::FlashState() const |
|
1639 { |
|
1640 TCamCameraReadyState state = ECamUnknown; |
|
1641 |
|
1642 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
1643 if( iAdvancedSettings ) |
|
1644 { |
|
1645 TBool ready = EFalse; |
|
1646 TInt queryStatus = iAdvancedSettings->IsFlashReady( ready ); |
|
1647 |
|
1648 if( KErrNone == queryStatus ) |
|
1649 { |
|
1650 state = ready ? ECamReady : ECamNotReady; |
|
1651 } |
|
1652 } |
|
1653 #endif // CAMERAAPP_CAPI_V2_ADV |
|
1654 return state; |
|
1655 } |
|
1656 |
|
1657 |
|
1658 |
|
1659 // --------------------------------------------------------------------------- |
|
1660 // GetCameraSettingValueL |
|
1661 // --------------------------------------------------------------------------- |
|
1662 // |
|
1663 void |
|
1664 CCamCameraController |
|
1665 ::GetCameraSettingValueL( const TCamCameraSettingId& aSettingId, |
|
1666 TAny* aSettingData ) |
|
1667 { |
|
1668 PRINT( _L("Camera => CCamCameraController::GetCameraSettingValueL") ); |
|
1669 CheckNonNullL( aSettingData, KErrArgument ); |
|
1670 |
|
1671 switch( aSettingId ) |
|
1672 { |
|
1673 // ----------------------------------------------------- |
|
1674 case ECameraSettingFlash: |
|
1675 case ECameraUserSceneSettingFlash: |
|
1676 { |
|
1677 CCamera::TFlash* flash = static_cast<CCamera::TFlash*>( aSettingData ); |
|
1678 #ifdef CAMERAAPP_CAE_FIX |
|
1679 if( iCaeInUse ) |
|
1680 *flash = iCaeEngine->FlashMode(); |
|
1681 else |
|
1682 #endif |
|
1683 { |
|
1684 *flash = iCamera->Flash(); |
|
1685 } |
|
1686 break; |
|
1687 } |
|
1688 // ----------------------------------------------------- |
|
1689 case ECameraSettingExposure: |
|
1690 case ECameraUserSceneSettingExposure: |
|
1691 { |
|
1692 TPckgBuf<TCamSettingDataExposure>* exposure = |
|
1693 static_cast<TPckgBuf<TCamSettingDataExposure>*>( aSettingData ); |
|
1694 #ifdef CAMERAAPP_CAE_FIX |
|
1695 if( iCaeInUse ) |
|
1696 (*exposure)().iExposureMode = iCaeEngine->ExposureMode(); |
|
1697 else |
|
1698 #endif // CAMERAAPP_CAE_FIX |
|
1699 { |
|
1700 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
1701 (*exposure)().iExposureMode = iAdvancedSettings->ExposureMode(); |
|
1702 (*exposure)().iExposureStep = iAdvancedSettings->ExposureCompensationStep(); |
|
1703 #else |
|
1704 (*exposure)().iExposureMode = iCamera->Exposure(); |
|
1705 #endif |
|
1706 } |
|
1707 break; |
|
1708 } |
|
1709 // ----------------------------------------------------- |
|
1710 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
1711 case ECameraSettingLightSensitivity: |
|
1712 case ECameraUserSceneSettingLightSensitivity: |
|
1713 { |
|
1714 TInt* iso = static_cast<TInt*>( aSettingData ); |
|
1715 *iso = iAdvancedSettings->IsoRate(); |
|
1716 break; |
|
1717 } |
|
1718 case ECameraSettingContAF: |
|
1719 { |
|
1720 TInt* contAF = static_cast<TInt*>( aSettingData ); |
|
1721 *contAF = iAdvancedSettings->AutoFocusType() & //bitwise |
|
1722 CAS::EAutoFocusTypeContinuous; |
|
1723 break; |
|
1724 } |
|
1725 #endif |
|
1726 // ----------------------------------------------------- |
|
1727 case ECameraSettingWhiteBalance: |
|
1728 case ECameraUserSceneSettingWhiteBalance: |
|
1729 { |
|
1730 TPckgBuf<TCamSettingDataWhiteBalance>* wb = |
|
1731 static_cast<TPckgBuf<TCamSettingDataWhiteBalance>*>( aSettingData ); |
|
1732 |
|
1733 #ifdef CAMERAAPP_CAE_FIX |
|
1734 if( iCaeInUse ) |
|
1735 (*wb)().iWhiteBalanceMode = iCaeEngine->WhiteBalanceMode(); |
|
1736 else |
|
1737 #endif // CAMERAAPP_CAE_FIX |
|
1738 { |
|
1739 (*wb)().iWhiteBalanceMode = iCamera->WhiteBalance(); |
|
1740 } |
|
1741 break; |
|
1742 } |
|
1743 // ----------------------------------------------------- |
|
1744 #ifdef CAMERAAPP_CAPI_V2_IP |
|
1745 case ECameraSettingColourEffect: |
|
1746 case ECameraUserSceneSettingColourEffect: |
|
1747 { |
|
1748 CheckNonNullL( iImageProcessor, KErrNotSupported ); |
|
1749 |
|
1750 CIP::TEffect* effect = static_cast<CIP::TEffect*>( aSettingData ); |
|
1751 *effect = |
|
1752 (CIP::TEffect) |
|
1753 iImageProcessor->TransformationValue( KUidECamEventImageProcessingEffect ); |
|
1754 break; |
|
1755 } |
|
1756 // ----------------------------------------------------- |
|
1757 case ECameraSettingSharpness: |
|
1758 case ECameraUserSceneSettingSharpness: |
|
1759 { |
|
1760 CheckNonNullL( iImageProcessor, KErrNotSupported ); |
|
1761 |
|
1762 TInt* sharpness = static_cast<TInt*>( aSettingData ); |
|
1763 *sharpness = iImageProcessor->TransformationValue( KUidECamEventImageProcessingAdjustSharpness ); |
|
1764 break; |
|
1765 } |
|
1766 #endif |
|
1767 // ----------------------------------------------------- |
|
1768 case ECameraSettingDigitalZoom: |
|
1769 { |
|
1770 TInt* zoom = static_cast<TInt*>( aSettingData ); |
|
1771 #ifdef CAMERAAPP_CAE_FIX |
|
1772 if( iCaeInUse ) |
|
1773 *zoom = iCaeEngine->ZoomValue(); |
|
1774 else |
|
1775 #endif |
|
1776 { |
|
1777 // Zoom step despite the misleading method name. |
|
1778 *zoom = iCamera->ZoomFactor(); |
|
1779 } |
|
1780 break; |
|
1781 } |
|
1782 // ----------------------------------------------------- |
|
1783 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
1784 case ECameraSettingOpticalZoom: |
|
1785 { |
|
1786 TInt* zoom = static_cast<TInt*>( aSettingData ); |
|
1787 *zoom = iAdvancedSettings->OpticalZoom(); |
|
1788 break; |
|
1789 } |
|
1790 #endif |
|
1791 // ----------------------------------------------------- |
|
1792 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
1793 case ECameraSettingFileMaxSize: |
|
1794 { |
|
1795 if( iCaeEngine ) |
|
1796 { |
|
1797 TInt* bytes = static_cast<TInt*>( aSettingData ); |
|
1798 *bytes = iCaeEngine->VideoClipMaxSize(); |
|
1799 } |
|
1800 else |
|
1801 { |
|
1802 User::Leave( KErrNotReady ); |
|
1803 } |
|
1804 break; |
|
1805 } |
|
1806 // ----------------------------------------------------- |
|
1807 case ECameraSettingFileName: |
|
1808 { |
|
1809 User::Leave( KErrNotSupported ); |
|
1810 break; |
|
1811 } |
|
1812 // ----------------------------------------------------- |
|
1813 case ECameraSettingAudioMute: |
|
1814 { |
|
1815 if( iCaeEngine ) |
|
1816 { |
|
1817 TBool* mute = static_cast<TBool*>( aSettingData ); |
|
1818 *mute = iCaeEngine->VideoAudio(); |
|
1819 } |
|
1820 else |
|
1821 { |
|
1822 User::Leave( KErrNotReady ); |
|
1823 } |
|
1824 break; |
|
1825 } |
|
1826 #endif |
|
1827 // ----------------------------------------------------- |
|
1828 case ECameraSettingFacetracking: |
|
1829 { |
|
1830 if( iCustomInterfaceFaceTracking ) |
|
1831 { |
|
1832 TBool* ftOn = static_cast<TBool*>( aSettingData ); |
|
1833 *ftOn = iCustomInterfaceFaceTracking->FaceTrackingOn(); |
|
1834 PRINT1( _L("Camera <> facetracking setting: %d"), *ftOn ) |
|
1835 } |
|
1836 else |
|
1837 { |
|
1838 User::Leave( KErrNotReady ); |
|
1839 } |
|
1840 break; |
|
1841 } |
|
1842 // ----------------------------------------------------- |
|
1843 case ECameraSettingBrightness: |
|
1844 case ECameraUserSceneSettingBrightness: |
|
1845 { |
|
1846 CCamera::TBrightness* brightness = |
|
1847 static_cast<CCamera::TBrightness*>( aSettingData ); |
|
1848 #ifdef CAMERAAPP_CAE_FIX |
|
1849 if( iCaeInUse ) |
|
1850 *brightness = (CCamera::TBrightness)iCaeEngine->Brightness(); |
|
1851 else |
|
1852 #endif |
|
1853 *brightness = (CCamera::TBrightness)iCamera->Brightness(); |
|
1854 break; |
|
1855 } |
|
1856 // ----------------------------------------------------- |
|
1857 case ECameraSettingContrast: |
|
1858 case ECameraUserSceneSettingContrast: |
|
1859 { |
|
1860 CCamera::TContrast* contrast = |
|
1861 static_cast<CCamera::TContrast*>( aSettingData ); |
|
1862 #ifdef CAMERAAPP_CAE_FIX |
|
1863 if( iCaeInUse ) |
|
1864 *contrast = (CCamera::TContrast)iCaeEngine->Contrast(); |
|
1865 else |
|
1866 #endif |
|
1867 *contrast = (CCamera::TContrast)iCamera->Contrast(); |
|
1868 break; |
|
1869 } |
|
1870 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
1871 // ----------------------------------------------------- |
|
1872 case ECameraSettingStabilization: |
|
1873 { |
|
1874 TPckgBuf<TCamSettingDataStabilization>* pckg = |
|
1875 static_cast<TPckgBuf<TCamSettingDataStabilization>*>( aSettingData ); |
|
1876 TCamSettingDataStabilization& stabilization = (*pckg)(); |
|
1877 |
|
1878 stabilization.iMode = iAdvancedSettings->StabilizationMode(); |
|
1879 stabilization.iEffect = iAdvancedSettings->StabilizationEffect(); |
|
1880 stabilization.iComplexity = iAdvancedSettings->StabilizationComplexity(); |
|
1881 break; |
|
1882 } |
|
1883 #endif // CAMERAAPP_CAPI_V2_ADV |
|
1884 // ----------------------------------------------------- |
|
1885 // Image orientation |
|
1886 case ECameraSettingOrientation: |
|
1887 { |
|
1888 CheckNonNullL( iCustomInterfaceOrientation, KErrNotSupported ); |
|
1889 |
|
1890 MCameraOrientation::TOrientation* orientation = |
|
1891 static_cast<MCameraOrientation::TOrientation*>( aSettingData ); |
|
1892 |
|
1893 *orientation = iCustomInterfaceOrientation->Orientation(); |
|
1894 break; |
|
1895 } |
|
1896 // ----------------------------------------------------- |
|
1897 case ECameraSettingFocusRange: |
|
1898 default: |
|
1899 { |
|
1900 #ifndef CAMERAAPP_EMULATOR_BUILD |
|
1901 PRINT ( _L("Camera <> Not supported, LEAVE!") ); |
|
1902 User::Leave( KErrNotSupported ); |
|
1903 #endif // not CAMERAAPP_EMULATOR_BUILD |
|
1904 break; |
|
1905 } |
|
1906 // ------------------------------- |
|
1907 } |
|
1908 } |
|
1909 |
|
1910 |
|
1911 |
|
1912 // --------------------------------------------------------------------------- |
|
1913 // ProcessNextRequestL |
|
1914 // |
|
1915 // Called from iActive::RunL. |
|
1916 // If the request made to CCamera has a callback, more calls from iActive |
|
1917 // will not be requested here, but in those callbacks. |
|
1918 // Leave here will cause iActive to call EndSequence with the error code. |
|
1919 // --------------------------------------------------------------------------- |
|
1920 // |
|
1921 TInt |
|
1922 CCamCameraController::ProcessNextRequestL() |
|
1923 { |
|
1924 PRINT( _L("Camera => CCamCameraController::ProcessNextRequestL") ); |
|
1925 TInt readyForNextStep( EFalse ); |
|
1926 |
|
1927 |
|
1928 #ifdef CAMERAAPP_CAE_FIX |
|
1929 // ------------------------------------------------------- |
|
1930 if( ECamModeChangeInactive != iModeChange ) |
|
1931 { |
|
1932 readyForNextStep = ProceedModeSwitch(); |
|
1933 } |
|
1934 else |
|
1935 #endif // CAMERAAPP_CAE_FIX |
|
1936 |
|
1937 // ------------------------------------------------------- |
|
1938 if( IsFlagOn( iInfo.iBusy, ECamBusySetting ) ) |
|
1939 { |
|
1940 PRINT( _L("Camera <> Settings ongoing") ); |
|
1941 |
|
1942 iSettingIndex++; |
|
1943 if( iSettingIndex < iSettingArray.Count() ) |
|
1944 { |
|
1945 const TCamCameraSettingId& setting( iSettingArray[iSettingIndex] ); |
|
1946 |
|
1947 readyForNextStep = ProcessSettingL( setting ); |
|
1948 // No notification sent at the moment per setting. |
|
1949 } |
|
1950 else |
|
1951 { |
|
1952 EndSequence( KErrNone ); |
|
1953 } |
|
1954 } |
|
1955 // ------------------------------------------------------- |
|
1956 else if( IsFlagOn( iInfo.iBusy, ECamBusySequence ) ) |
|
1957 { |
|
1958 PRINT( _L("Camera <> Sequence ongoing") ); |
|
1959 |
|
1960 iSequenceIndex++; |
|
1961 if( iSequenceIndex < iSequenceArray.Count() ) |
|
1962 { |
|
1963 const TCamCameraRequestId& requestId( iSequenceArray[iSequenceIndex] ); |
|
1964 |
|
1965 PRINT( _L("Camera <> process request..") ); |
|
1966 // If this request will be responded through MCameraObserver(2) callback, |
|
1967 // iActive will be requested a new callback there and also |
|
1968 // the notification to our observers will be sent there. |
|
1969 // Otherwise we do both of those right away. |
|
1970 readyForNextStep = ProcessOneRequestL( requestId ); |
|
1971 |
|
1972 if( readyForNextStep ) |
|
1973 { |
|
1974 if( ECamRequestVideoStop == requestId |
|
1975 || ECamRequestImageCancel == requestId ) |
|
1976 { |
|
1977 // For video stop request, callback has already happened and notification |
|
1978 // has been given. No need to do anything here. |
|
1979 PRINT( _L("Camera <> CCamCameraController::RequestL .. Skipping commmon notification, is done already.") ); |
|
1980 } |
|
1981 else |
|
1982 { |
|
1983 TCamCameraEventId event( Request2Event( requestId ) ); |
|
1984 NotifyObservers( KErrNone, event, EventClass( event ) ); |
|
1985 } |
|
1986 } |
|
1987 } |
|
1988 else |
|
1989 { |
|
1990 PRINT( _L("Camera <> Sequence end detected") ); |
|
1991 EndSequence( KErrNone ); |
|
1992 } |
|
1993 } |
|
1994 // ------------------------------------------------------- |
|
1995 else |
|
1996 { |
|
1997 PRINT( _L("Camera <> Nothing active!! PANIC") ); |
|
1998 __ASSERT_DEBUG( EFalse, Panic( ECamCameraControllerCorrupt ) ); |
|
1999 } |
|
2000 // ------------------------------------------------------- |
|
2001 |
|
2002 PRINT1( _L("Camera <= CCamCameraController::ProcessNextRequestL, more calls now:%d"), readyForNextStep ); |
|
2003 return readyForNextStep; |
|
2004 } |
|
2005 |
|
2006 |
|
2007 |
|
2008 // --------------------------------------------------------------------------- |
|
2009 // ProcessSettingL |
|
2010 // --------------------------------------------------------------------------- |
|
2011 // |
|
2012 TInt |
|
2013 CCamCameraController::ProcessSettingL( const TCamCameraSettingId& aSettingId ) |
|
2014 { |
|
2015 PRINT1( _L("Camera => CCamCameraController::ProcessSettingL [%s]"), |
|
2016 KCameraSettingNames[aSettingId] ); |
|
2017 |
|
2018 TInt callback( EFalse ); |
|
2019 switch( aSettingId ) |
|
2020 { |
|
2021 // ------------------------------- |
|
2022 case ECameraSettingCaptureLimit: |
|
2023 { |
|
2024 ProcessCaptureLimitSettingL(); |
|
2025 break; |
|
2026 } |
|
2027 // ------------------------------- |
|
2028 case ECameraSettingFlash: |
|
2029 case ECameraUserSceneSettingFlash: |
|
2030 { |
|
2031 if ( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
2032 { |
|
2033 CCamera::TFlash flash( CCamera::EFlashNone ); |
|
2034 TCamFlashId currentFlashSetting( ECamFlashOff ); |
|
2035 // Video light setting has values ECamFlashOff/ECamFlashForced |
|
2036 iSettingProvider.ProvideCameraSettingL( aSettingId, |
|
2037 ¤tFlashSetting ); |
|
2038 PRINT2( _L("Camera => Video Flash now = %d, new = %d"), |
|
2039 iCamera->Flash(), currentFlashSetting ); |
|
2040 // Camera uses values EFlashNone/EFlashVideoLight |
|
2041 flash = (currentFlashSetting == ECamFlashOff)? |
|
2042 CCamera::EFlashNone:CCamera::EFlashVideoLight; |
|
2043 PRINT1( _L("Camera => iCamera->SetFlashL( %d )"), flash ); |
|
2044 iCamera->SetFlashL( flash ); |
|
2045 } |
|
2046 else |
|
2047 { |
|
2048 // Still image flash |
|
2049 CCamera::TFlash flash( CCamera::EFlashAuto ); |
|
2050 iSettingProvider.ProvideCameraSettingL( aSettingId, &flash ); |
|
2051 #ifdef CAMERAAPP_CAE_FIX |
|
2052 if( iCaeInUse ) |
|
2053 { |
|
2054 iCaeEngine->SetFlashModeL( flash ); |
|
2055 } |
|
2056 else |
|
2057 #endif |
|
2058 { |
|
2059 if( iCamera->Flash() != flash ) |
|
2060 { |
|
2061 iCamera->SetFlashL( flash ); |
|
2062 #ifdef CAMERAAPP_CAPI_V2 |
|
2063 callback = ETrue; |
|
2064 #endif |
|
2065 } |
|
2066 } |
|
2067 } |
|
2068 break; |
|
2069 } |
|
2070 // ------------------------------- |
|
2071 case ECameraSettingExposure: |
|
2072 case ECameraUserSceneSettingExposure: |
|
2073 { |
|
2074 TPckgBuf<TCamSettingDataExposure> params; |
|
2075 iSettingProvider.ProvideCameraSettingL( aSettingId, ¶ms ); |
|
2076 #ifdef CAMERAAPP_CAE_FIX |
|
2077 if( iCaeInUse ) |
|
2078 iCaeEngine->SetExposureModeL( params().iExposureMode ); |
|
2079 else |
|
2080 #endif // CAMERAAPP_CAE_FIX |
|
2081 { |
|
2082 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
2083 PRINT( _L("Calling iAdvancedSettings->SetExposureMode..") ); |
|
2084 const CCamera::TExposure& mode = params().iExposureMode; |
|
2085 // Zero value is default and always supported |
|
2086 // (CCamera::EExposureAuto) |
|
2087 if( mode == CCamera::EExposureAuto || mode & iAdvancedSettingInfo.iEvModesSupport ) |
|
2088 { |
|
2089 iAdvancedSettings->SetExposureMode( mode ); |
|
2090 // iCamera->SetExposureL( mode ); |
|
2091 |
|
2092 TInt step = ResolveEvStep( params().iExposureStep ); |
|
2093 // Value needs to be multiplied by KECamFineResolutionFactor. |
|
2094 // Setting provider does this for us. |
|
2095 PRINT( _L("Calling iAdvancedSettings->SetExposureCompensationStep..") ); |
|
2096 iAdvancedSettings->SetExposureCompensationStep( step ); |
|
2097 |
|
2098 callback = ETrue; |
|
2099 } |
|
2100 else |
|
2101 { |
|
2102 User::Leave( KErrNotSupported ); |
|
2103 } |
|
2104 #else |
|
2105 iCamera->SetExposureL( params().iExposureMode ); |
|
2106 #endif // CAMERAAPP_CAPI_V2_ADV |
|
2107 } |
|
2108 break; |
|
2109 } |
|
2110 // ------------------------------- |
|
2111 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
2112 case ECameraSettingLightSensitivity: |
|
2113 case ECameraUserSceneSettingLightSensitivity: |
|
2114 { |
|
2115 TInt iso( 0 ); |
|
2116 RArray<TInt> ISOarray; |
|
2117 CleanupClosePushL( ISOarray ); |
|
2118 iAdvancedSettings->GetSupportedIsoRatesL( ISOarray ); |
|
2119 iSettingProvider.SetSupportedISORatesL( ISOarray ); |
|
2120 iSettingProvider.ProvideCameraSettingL( aSettingId, &iso ); |
|
2121 callback = ETrue; |
|
2122 CleanupStack::PopAndDestroy( &ISOarray ); |
|
2123 |
|
2124 PRINT1( _L("Camera <> Setting ISO rate to: %d"), iso ); |
|
2125 if( !iso ) |
|
2126 { |
|
2127 // ISO Auto |
|
2128 iAdvancedSettings->SetISORateL( |
|
2129 CCamera::CCameraAdvancedSettings::EISOAutoUnPrioritised, iso ); |
|
2130 } |
|
2131 else if( IsSupportedValue( iso, |
|
2132 iAdvancedSettingInfo.iIsoRatesSupport, |
|
2133 EDiscreteSteps ) ) |
|
2134 { |
|
2135 // Selected ISO rate |
|
2136 iAdvancedSettings->SetISORateL( |
|
2137 CCamera::CCameraAdvancedSettings::EISOManual, iso ); |
|
2138 } |
|
2139 else |
|
2140 { |
|
2141 User::Leave( KErrNotSupported ); |
|
2142 } |
|
2143 break; |
|
2144 } |
|
2145 #endif |
|
2146 // ------------------------------- |
|
2147 case ECameraSettingWhiteBalance: |
|
2148 case ECameraUserSceneSettingWhiteBalance: |
|
2149 { |
|
2150 TPckgBuf<TCamSettingDataWhiteBalance> params; |
|
2151 iSettingProvider.ProvideCameraSettingL( aSettingId, ¶ms ); |
|
2152 #ifdef CAMERAAPP_CAE_FIX |
|
2153 if( iCaeInUse ) |
|
2154 iCaeEngine->SetWhiteBalanceModeL( params().iWhiteBalanceMode ); |
|
2155 else |
|
2156 #endif // CAMERAAPP_CAE_FIX |
|
2157 { |
|
2158 iCamera->SetWhiteBalanceL( params().iWhiteBalanceMode ); |
|
2159 #ifdef CAMERAAPP_CAPI_V2 |
|
2160 callback = ETrue; |
|
2161 #endif |
|
2162 } |
|
2163 break; |
|
2164 } |
|
2165 // ------------------------------- |
|
2166 #ifdef CAMERAAPP_CAPI_V2_IP |
|
2167 case ECameraSettingColourEffect: |
|
2168 case ECameraUserSceneSettingColourEffect: |
|
2169 { |
|
2170 CheckNonNullL( iImageProcessor, KErrNotSupported ); |
|
2171 CIP::TEffect effect( CIP::EEffectNone ); |
|
2172 iSettingProvider.ProvideCameraSettingL( aSettingId, &effect ); |
|
2173 |
|
2174 if( IsSupportedValue( effect, |
|
2175 iAdvancedSettingInfo.iColourEffectSupport, |
|
2176 iAdvancedSettingInfo.iColourEffectValueInfo ) ) |
|
2177 { |
|
2178 iImageProcessor->SetTransformationValue( KUidECamEventImageProcessingEffect, effect ); |
|
2179 callback = ETrue; |
|
2180 } |
|
2181 else |
|
2182 User::Leave( KErrNotSupported ); |
|
2183 break; |
|
2184 } |
|
2185 // ------------------------------- |
|
2186 case ECameraSettingSharpness: |
|
2187 case ECameraUserSceneSettingSharpness: |
|
2188 { |
|
2189 CheckNonNullL( iImageProcessor, KErrNotSupported ); |
|
2190 TInt sharpness( 0 ); |
|
2191 iSettingProvider.ProvideCameraSettingL( aSettingId, &sharpness ); |
|
2192 |
|
2193 if( IsSupportedValue( sharpness, |
|
2194 iAdvancedSettingInfo.iSharpnessSupport, |
|
2195 iAdvancedSettingInfo.iSharpnessValueInfo ) ) |
|
2196 { |
|
2197 iImageProcessor->SetTransformationValue( KUidECamEventImageProcessingAdjustSharpness, sharpness ); |
|
2198 callback = ETrue; |
|
2199 } |
|
2200 else |
|
2201 User::Leave( KErrNotSupported ); |
|
2202 break; |
|
2203 } |
|
2204 #endif // CAMERAAPP_CAPI_V2_IP |
|
2205 // ------------------------------- |
|
2206 case ECameraSettingBrightness: |
|
2207 case ECameraUserSceneSettingBrightness: |
|
2208 { |
|
2209 CCamera::TBrightness brightness( CCamera::EBrightnessAuto ); |
|
2210 iSettingProvider.ProvideCameraSettingL( aSettingId, &brightness ); |
|
2211 iCamera->SetBrightnessL( brightness ); |
|
2212 break; |
|
2213 } |
|
2214 // ------------------------------- |
|
2215 case ECameraSettingContrast: |
|
2216 case ECameraUserSceneSettingContrast: |
|
2217 { |
|
2218 CCamera::TContrast contrast( CCamera::EContrastAuto ); |
|
2219 iSettingProvider.ProvideCameraSettingL( aSettingId, &contrast ); |
|
2220 iCamera->SetContrastL( contrast ); |
|
2221 break; |
|
2222 } |
|
2223 // ------------------------------- |
|
2224 case ECameraSettingDigitalZoom: |
|
2225 { |
|
2226 TInt zoom( 0 ); |
|
2227 iSettingProvider.ProvideCameraSettingL( aSettingId, &zoom ); |
|
2228 PRINT1( _L("Camera <> Setting digital zoom step to: %d"), zoom ); |
|
2229 #ifdef CAMERAAPP_CAE_FIX |
|
2230 if( iCaeInUse ) |
|
2231 iCaeEngine->SetZoomValueL( zoom ); |
|
2232 else |
|
2233 #endif |
|
2234 { |
|
2235 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
2236 if( iAdvancedSettingInfo.iDigitalZoomSupport.Count() > zoom ) |
|
2237 iAdvancedSettings->SetDigitalZoom( iAdvancedSettingInfo.iDigitalZoomSupport[zoom] ); |
|
2238 else |
|
2239 User::Leave( KErrNotSupported ); |
|
2240 callback = ETrue; |
|
2241 |
|
2242 #else |
|
2243 // Note: Even if the method is misleadingly named |
|
2244 // CCamera::SetDigitalZoomFactorL, the values are |
|
2245 // zoom steps, not zoom factors. |
|
2246 iCamera->SetDigitalZoomFactorL( zoom ); |
|
2247 #endif |
|
2248 |
|
2249 } |
|
2250 break; |
|
2251 } |
|
2252 // ------------------------------- |
|
2253 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
2254 case ECameraSettingOpticalZoom: |
|
2255 { |
|
2256 TInt zoom( 0 ); |
|
2257 iSettingProvider.ProvideCameraSettingL( aSettingId, &zoom ); |
|
2258 PRINT1( _L("Camera <> Setting optical zoom to: %d"), zoom ); |
|
2259 iAdvancedSettings->SetOpticalZoom( zoom ); |
|
2260 callback = ETrue; |
|
2261 break; |
|
2262 } |
|
2263 // ----------------------------------------------------- |
|
2264 case ECameraSettingStabilization: |
|
2265 { |
|
2266 PRINT( _L("Camera <> CCamCameraController::ProcessSettingL ECameraSettingStabilization") ); |
|
2267 TPckgBuf<TCamSettingDataStabilization> stabilization; |
|
2268 iSettingProvider.ProvideCameraSettingL( aSettingId, &stabilization ); |
|
2269 |
|
2270 // Check that the values are supported.. |
|
2271 TBool modeOk = ( CAS::EStabilizationModeOff == stabilization().iMode |
|
2272 || iAdvancedSettingInfo.iStabilizationModeSupport & stabilization().iMode ); |
|
2273 TBool effectOk = ( CAS::EStabilizationOff == stabilization().iEffect |
|
2274 || iAdvancedSettingInfo.iStabilizationEffectSupport & stabilization().iEffect ); |
|
2275 TBool complexOk = ( CAS::EStabilizationComplexityAuto == stabilization().iComplexity |
|
2276 || iAdvancedSettingInfo.iStabilizationComplexitySupport & stabilization().iComplexity ); |
|
2277 |
|
2278 if( modeOk && effectOk && complexOk ) |
|
2279 { |
|
2280 PRINT1( _L("Camera <> CCamCameraController::ProcessSettingL set stabilization mode=%d"), stabilization().iMode ); |
|
2281 iAdvancedSettings->SetStabilizationMode ( stabilization().iMode ); |
|
2282 iAdvancedSettings->SetStabilizationEffect ( stabilization().iEffect ); |
|
2283 iAdvancedSettings->SetStabilizationComplexity( stabilization().iComplexity ); |
|
2284 // Events: |
|
2285 // KUidECamEventCameraSettingStabilizationMode |
|
2286 // KUidECamEventCameraSettingsStabilizationEffect |
|
2287 // KUidECamEventSettingsStabilizationAlgorithmComplexity |
|
2288 // We use the latest one to determine when we can continue. |
|
2289 // Do not change above order unless CCamSettingConversion::Map2EventUidValue |
|
2290 // is edited.. |
|
2291 } |
|
2292 else |
|
2293 { |
|
2294 User::Leave( KErrNotSupported ); |
|
2295 } |
|
2296 |
|
2297 callback = ETrue; |
|
2298 break; |
|
2299 } |
|
2300 // ------------------------------- |
|
2301 case ECameraSettingContAF: |
|
2302 { |
|
2303 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
2304 if ( appUi->AppController().UiConfigManagerPtr()->IsContinuosAutofocusSupported() ) |
|
2305 { |
|
2306 TBool isContAFon( iAdvancedSettings->AutoFocusType() & |
|
2307 CAS::EAutoFocusTypeContinuous ); |
|
2308 if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
2309 { |
|
2310 TBool contAF( ETrue ); |
|
2311 iSettingProvider.ProvideCameraSettingL( aSettingId, &contAF ); |
|
2312 if( contAF != isContAFon ) |
|
2313 { |
|
2314 CAS::TAutoFocusType type = contAF? CAS::EAutoFocusTypeContinuous: |
|
2315 CAS::EAutoFocusTypeOff; |
|
2316 iAdvancedSettings->SetAutoFocusType( type ); |
|
2317 } |
|
2318 } |
|
2319 else |
|
2320 { |
|
2321 // Do nothing |
|
2322 } |
|
2323 } |
|
2324 break; |
|
2325 } |
|
2326 #endif // CAMERAAPP_CAPI_V2_ADV |
|
2327 // ------------------------------- |
|
2328 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
2329 case ECameraSettingFileMaxSize: |
|
2330 { |
|
2331 if( iCaeEngine ) |
|
2332 { |
|
2333 TInt bytes( 0 ); |
|
2334 iSettingProvider.ProvideCameraSettingL( aSettingId, &bytes ); |
|
2335 if( iCaeEngine->VideoClipMaxSize() != bytes ) |
|
2336 { |
|
2337 iCaeEngine->SetVideoClipMaxSizeL( bytes ); |
|
2338 callback = IsFlagOn( iInfo.iState, ECamVideoOn ); |
|
2339 } |
|
2340 } |
|
2341 else |
|
2342 { |
|
2343 // |
|
2344 PRINT( _L("Camera <> Video file size too early, NOT SET!!") ); |
|
2345 } |
|
2346 break; |
|
2347 } |
|
2348 // ------------------------------- |
|
2349 case ECameraSettingFileName: |
|
2350 { |
|
2351 if( iCaeEngine ) |
|
2352 { |
|
2353 PRINT ( _L("Camera <> processing filename setting") ); |
|
2354 |
|
2355 HBufC* filename = HBufC::NewLC( KMaxFileName ); |
|
2356 TPtr ptr = filename->Des(); |
|
2357 PRINT ( _L("Camera <> get filename from setting provider..") ); |
|
2358 iSettingProvider.ProvideCameraSettingL( aSettingId, &ptr ); |
|
2359 |
|
2360 PRINT1( _L("Camera <> set filename [%S]"), filename ); |
|
2361 iCaeEngine->SetVideoRecordingFileNameL( ptr ); |
|
2362 |
|
2363 CleanupStack::PopAndDestroy( filename ); |
|
2364 // If video has been prepared, MCaeoVideoPrepareComplete will be repeated, |
|
2365 // and needs to be waited. |
|
2366 callback = IsFlagOn( iInfo.iState, ECamVideoOn ); |
|
2367 } |
|
2368 else |
|
2369 { |
|
2370 PRINT( _L("Camera <> Video name too early, NOT SET!!") ); |
|
2371 } |
|
2372 break; |
|
2373 } |
|
2374 // ------------------------------- |
|
2375 case ECameraSettingAudioMute: |
|
2376 { |
|
2377 if( iCaeEngine ) |
|
2378 { |
|
2379 TBool isAudioOn( EFalse ); |
|
2380 iSettingProvider.ProvideCameraSettingL( aSettingId, &isAudioOn ); |
|
2381 TBool audioOn( iCaeEngine->VideoAudio() ); |
|
2382 // If we need to mute audio and audio is on |
|
2383 // or we need to enable audio and audio is off |
|
2384 if( isAudioOn != audioOn ) |
|
2385 { |
|
2386 iCaeEngine->SetVideoAudioL( isAudioOn ); |
|
2387 callback = IsFlagOn( iInfo.iState, ECamVideoOn ); |
|
2388 } |
|
2389 } |
|
2390 else |
|
2391 { |
|
2392 PRINT( _L("Camera <> Video mute too early, NOT SET!!") ); |
|
2393 } |
|
2394 break; |
|
2395 } |
|
2396 // ------------------------------- |
|
2397 case ECameraSettingFacetracking: |
|
2398 { |
|
2399 if( iCustomInterfaceFaceTracking ) |
|
2400 { |
|
2401 SetFaceTrackingL(); |
|
2402 } |
|
2403 else |
|
2404 { |
|
2405 PRINT( _L("Camera <> Facetracking too early, NOT SET!!") ); |
|
2406 } |
|
2407 break; |
|
2408 } |
|
2409 #endif |
|
2410 // ------------------------------- |
|
2411 // Image orientation |
|
2412 case ECameraSettingOrientation: |
|
2413 { |
|
2414 CheckNonNullL( iCustomInterfaceOrientation, KErrNotSupported ); |
|
2415 MCameraOrientation::TOrientation |
|
2416 orientation( MCameraOrientation::EOrientation0 ); |
|
2417 iSettingProvider.ProvideCameraSettingL( aSettingId, &orientation ); |
|
2418 |
|
2419 PRINT1( _L("Camera <> setting camera orientation to [0x%02x]"), orientation ); |
|
2420 iCustomInterfaceOrientation->SetOrientationL( orientation ); |
|
2421 break; |
|
2422 } |
|
2423 // ------------------------------- |
|
2424 case ECameraSettingFocusRange: |
|
2425 default: |
|
2426 { |
|
2427 #ifndef CAMERAAPP_EMULATOR_BUILD |
|
2428 PRINT ( _L("Camera <> Not supported, LEAVE!") ); |
|
2429 User::Leave( KErrNotSupported ); |
|
2430 #endif // not CAMERAAPP_EMULATOR_BUILD |
|
2431 break; |
|
2432 } |
|
2433 // ------------------------------- |
|
2434 } |
|
2435 |
|
2436 PRINT1( _L("Camera <= CCamCameraController::ProcessSettingL, continue now:%d"), !callback ); |
|
2437 return !callback; |
|
2438 } |
|
2439 |
|
2440 |
|
2441 // --------------------------------------------------------------------------- |
|
2442 // |
|
2443 // --------------------------------------------------------------------------- |
|
2444 // |
|
2445 TInt |
|
2446 CCamCameraController |
|
2447 ::ProcessOneRequestL( const TCamCameraRequestId& aRequestId ) |
|
2448 { |
|
2449 PRINT( _L("Camera => CCamCameraController::ProcessOneRequestL") ); |
|
2450 PRINT2( _L("Camera <> processing request [%s] id:%d "), |
|
2451 KCamRequestNames[aRequestId], |
|
2452 aRequestId ); |
|
2453 |
|
2454 TInt readyForNext( ETrue ); |
|
2455 |
|
2456 // Order from most time critical / frequent |
|
2457 // to less time critical / seldom. |
|
2458 // Handled in submethods to preserve readability. |
|
2459 // ----------------------------------------------------- |
|
2460 switch( aRequestId ) |
|
2461 { |
|
2462 // ------------------------------- |
|
2463 case ECamRequestReserve: |
|
2464 case ECamRequestPowerOn: |
|
2465 readyForNext = ProcessControlStartupRequestL( aRequestId ); |
|
2466 break; |
|
2467 case ECamRequestPowerOff: |
|
2468 case ECamRequestRelease: |
|
2469 readyForNext = ProcessControlShutdownRequest( aRequestId ); |
|
2470 break; |
|
2471 // ------------------------------- |
|
2472 case ECamRequestVfStart: |
|
2473 case ECamRequestVfStop: |
|
2474 case ECamRequestVfRelease: |
|
2475 readyForNext = ProcessVfRequestL( aRequestId ); |
|
2476 break; |
|
2477 // ------------------------------- |
|
2478 case ECamRequestSsStart: |
|
2479 case ECamRequestSsStop: |
|
2480 case ECamRequestSsRelease: |
|
2481 readyForNext = ProcessSnapshotRequestL( aRequestId ); |
|
2482 break; |
|
2483 // ------------------------------- |
|
2484 case ECamRequestImageInit: |
|
2485 case ECamRequestImageCapture: |
|
2486 readyForNext = ProcessImageRequestL( aRequestId ); |
|
2487 break; |
|
2488 case ECamRequestImageCancel: |
|
2489 case ECamRequestImageRelease: |
|
2490 readyForNext = ProcessImageShutdownRequest( aRequestId ); |
|
2491 break; |
|
2492 // ------------------------------- |
|
2493 case ECamRequestVideoInit: |
|
2494 case ECamRequestVideoStart: |
|
2495 case ECamRequestVideoPause: |
|
2496 case ECamRequestVideoStop: |
|
2497 case ECamRequestVideoRelease: |
|
2498 case ECamRequestSetAsyncVideoStopMode: |
|
2499 readyForNext = ProcessVideoRequestL( aRequestId ); |
|
2500 break; |
|
2501 // ------------------------------- |
|
2502 default: |
|
2503 Panic( ECamCameraControllerUnknownRequest ); |
|
2504 break; |
|
2505 // ------------------------------- |
|
2506 } |
|
2507 // ----------------------------------------------------- |
|
2508 PRINT( _L("Camera <= CCamCameraController::ProcessOneRequestL") ); |
|
2509 return readyForNext; |
|
2510 } |
|
2511 |
|
2512 |
|
2513 // --------------------------------------------------------------------------- |
|
2514 // ProcessControlStartupRequestL |
|
2515 // --------------------------------------------------------------------------- |
|
2516 // |
|
2517 TInt |
|
2518 CCamCameraController |
|
2519 ::ProcessControlStartupRequestL( const TCamCameraRequestId& aRequestId ) |
|
2520 { |
|
2521 PRINT1( _L("Camera => CCamCameraController::ProcessControlStartupRequestL [%s]"), |
|
2522 KCamRequestNames[aRequestId] ); |
|
2523 // ------------------------------------------------------- |
|
2524 // Reserve |
|
2525 if( ECamRequestReserve == aRequestId ) |
|
2526 { |
|
2527 CheckFlagOffL( iInfo.iState, ECamReserved, KErrInUse ); |
|
2528 |
|
2529 CAMERAAPP_PERF_CONTROLLER_START( ECamRequestReserve ); |
|
2530 iCamera->Reserve(); |
|
2531 } |
|
2532 // ------------------------------------------------------- |
|
2533 // Power on |
|
2534 else if( ECamRequestPowerOn == aRequestId ) |
|
2535 { |
|
2536 CheckFlagOnL ( iInfo.iState, ECamReserved, KErrNotReady ); |
|
2537 CheckFlagOffL( iInfo.iState, ECamPowerOn, KErrInUse ); |
|
2538 |
|
2539 CAMERAAPP_PERF_CONTROLLER_START( ECamRequestPowerOn ); |
|
2540 |
|
2541 iCamera->PowerOn(); |
|
2542 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
2543 if ( appUi->AppController().UiConfigManagerPtr()->IsUIOrientationOverrideSupported() ) |
|
2544 { |
|
2545 NotifyObservers( KErrNone, |
|
2546 ECamCameraEventPowerOnRequested, |
|
2547 ECamCameraEventClassBasicControl ); |
|
2548 } |
|
2549 |
|
2550 } |
|
2551 // ------------------------------------------------------- |
|
2552 // Unknown |
|
2553 else |
|
2554 { |
|
2555 Panic( ECamCameraControllerCorrupt ); |
|
2556 } |
|
2557 // ------------------------------------------------------- |
|
2558 iReleasedByUi = EFalse; |
|
2559 PRINT( _L("Camera <= CCamCameraController::ProcessControlStartupRequestL") ); |
|
2560 // Callback needs to be received before we can continue. |
|
2561 return EFalse; |
|
2562 } |
|
2563 |
|
2564 // --------------------------------------------------------------------------- |
|
2565 // ProcessControlShutdownRequest |
|
2566 // --------------------------------------------------------------------------- |
|
2567 // |
|
2568 TInt |
|
2569 CCamCameraController |
|
2570 ::ProcessControlShutdownRequest( const TCamCameraRequestId& aRequestId ) |
|
2571 { |
|
2572 PRINT( _L("Camera => CCamCameraController::ProcessControlShutdownRequest") ); |
|
2573 // ------------------------------------------------------- |
|
2574 // Power off |
|
2575 if( ECamRequestPowerOff == aRequestId ) |
|
2576 { |
|
2577 if( IsFlagOn( iInfo.iState, ECamPowerOn ) ) |
|
2578 { |
|
2579 // ------------------------------- |
|
2580 // Release image or video capture |
|
2581 if( IsFlagOn( iInfo.iState, ECamImageOn ) ) |
|
2582 { |
|
2583 // Leaves only if state is wrong (already checked here). |
|
2584 ProcessImageShutdownRequest( ECamRequestImageRelease ); |
|
2585 NotifyObservers( KErrNone, |
|
2586 ECamCameraEventImageRelease, |
|
2587 ECamCameraEventClassImage ); |
|
2588 } |
|
2589 else if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
2590 { |
|
2591 TRAP_IGNORE( ProcessVideoRequestL( ECamRequestVideoRelease ) ); |
|
2592 NotifyObservers( KErrNone, |
|
2593 ECamCameraEventVideoRelease, |
|
2594 ECamCameraEventClassVideo ); |
|
2595 } |
|
2596 else |
|
2597 { |
|
2598 } |
|
2599 // ------------------------------- |
|
2600 // If viewfinder is not released yet, release it now. |
|
2601 if( ECamTriIdle != iInfo.iVfState ) |
|
2602 { |
|
2603 ProcessVfRelaseRequest(); |
|
2604 NotifyObservers( KErrNone, |
|
2605 ECamCameraEventVfRelease, |
|
2606 ECamCameraEventClassVfControl ); |
|
2607 } |
|
2608 |
|
2609 // ------------------------------- |
|
2610 // If snapshot is not released yet, release it now. |
|
2611 if( ECamTriIdle != iInfo.iSsState ) |
|
2612 { |
|
2613 ProcessSsReleaseRequest(); |
|
2614 NotifyObservers( KErrNone, |
|
2615 ECamCameraEventSsRelease, |
|
2616 ECamCameraEventClassSsControl ); |
|
2617 } |
|
2618 // ------------------------------- |
|
2619 // Do the actual powering off. |
|
2620 #ifdef CAMERAAPP_CAE_FIX |
|
2621 if( iCaeInUse ) |
|
2622 { |
|
2623 iCaeEngine->PowerOff(); |
|
2624 } |
|
2625 else |
|
2626 #endif // CAMERAAPP_CAE_FIX |
|
2627 { |
|
2628 iCamera->PowerOff(); |
|
2629 } |
|
2630 // ------------------------------- |
|
2631 } |
|
2632 ClearFlags( iInfo.iState, ECamPowerOn ); |
|
2633 } |
|
2634 // ------------------------------------------------------- |
|
2635 // Release |
|
2636 else if( ECamRequestRelease == aRequestId ) |
|
2637 { |
|
2638 if( IsFlagOn( iInfo.iState, ECamReserved ) ) |
|
2639 { |
|
2640 // If power off not called yet, do it now. |
|
2641 if( IsFlagOn( iInfo.iState, ECamPowerOn ) ) |
|
2642 { |
|
2643 ProcessControlShutdownRequest( ECamRequestPowerOff ); |
|
2644 // Separate notification needed here, because operation done |
|
2645 // as part of handling other request. |
|
2646 NotifyObservers( KErrNone, |
|
2647 ECamCameraEventPowerOff, |
|
2648 ECamCameraEventClassBasicControl ); |
|
2649 } |
|
2650 #ifdef CAMERAAPP_CAE_FIX |
|
2651 if( iCaeInUse ) |
|
2652 { |
|
2653 iCaeEngine->Release(); |
|
2654 iCaeInUse = EFalse; |
|
2655 } |
|
2656 else |
|
2657 #endif // CAMERAAPP_CAE_FIX |
|
2658 { |
|
2659 iCamera->Release(); |
|
2660 iReleasedByUi = ETrue; |
|
2661 if( iIveRecoveryCount > 0 ) |
|
2662 { |
|
2663 HandleReserveLostEvent( KErrNone ); |
|
2664 } |
|
2665 } |
|
2666 } |
|
2667 PRINT( _L("Camera <> released, reset info") ); |
|
2668 |
|
2669 // Reset our info, but preserve busy flag and camera index. |
|
2670 // Sets iInfo.iState to ECamIdle. |
|
2671 iInfo.Reset( ETrue, ETrue ); |
|
2672 } |
|
2673 // ------------------------------------------------------- |
|
2674 // Unknown |
|
2675 else |
|
2676 { |
|
2677 Panic( ECamCameraControllerCorrupt ); |
|
2678 } |
|
2679 // ------------------------------------------------------- |
|
2680 PRINT( _L("Camera <= CCamCameraController::ProcessControlShutdownRequest") ); |
|
2681 |
|
2682 // No callback needs to be waited. |
|
2683 return ETrue; |
|
2684 } |
|
2685 |
|
2686 // --------------------------------------------------------------------------- |
|
2687 // ProcessViewfinderRequestL |
|
2688 // --------------------------------------------------------------------------- |
|
2689 // |
|
2690 TInt |
|
2691 CCamCameraController |
|
2692 ::ProcessVfRequestL( const TCamCameraRequestId& aRequestId ) |
|
2693 { |
|
2694 CheckFlagOnL( iInfo.iState, ECamPowerOn, KErrNotReady ); |
|
2695 |
|
2696 switch( aRequestId ) |
|
2697 { |
|
2698 // ----------------------------------------------------- |
|
2699 case ECamRequestVfStart: |
|
2700 { |
|
2701 CAMERAAPP_PERF_CONTROLLER_STARTNEW( ECamRequestVfStart, iFirstVfFrameReceived ); |
|
2702 ProcessVfStartRequestL(); |
|
2703 break; |
|
2704 } |
|
2705 // ----------------------------------------------------- |
|
2706 case ECamRequestVfStop: |
|
2707 { |
|
2708 ProcessVfStopRequestL(); |
|
2709 break; |
|
2710 } |
|
2711 // ----------------------------------------------------- |
|
2712 case ECamRequestVfRelease: |
|
2713 { |
|
2714 ProcessVfRelaseRequest(); |
|
2715 break; |
|
2716 } |
|
2717 // ----------------------------------------------------- |
|
2718 default: |
|
2719 { |
|
2720 Panic( ECamCameraControllerCorrupt ); |
|
2721 break; |
|
2722 } |
|
2723 // ----------------------------------------------------- |
|
2724 } |
|
2725 |
|
2726 // No callback to be waited |
|
2727 return ETrue; |
|
2728 } |
|
2729 |
|
2730 |
|
2731 // --------------------------------------------------------------------------- |
|
2732 // InitViewfinderL |
|
2733 // --------------------------------------------------------------------------- |
|
2734 // |
|
2735 void |
|
2736 CCamCameraController::InitViewfinderL( const TCamViewfinderMode& aMode ) |
|
2737 { |
|
2738 PRINT( _L("Camera => CCamCameraController::InitViewfinderL") ); |
|
2739 |
|
2740 // Check the old viewfinder is released now. |
|
2741 // No further checks made here. |
|
2742 __ASSERT_DEBUG( ECamTriIdle == iInfo.iVfState, Panic( ECamCameraControllerCorrupt ) ); |
|
2743 |
|
2744 // Then init the new mode |
|
2745 switch( aMode ) |
|
2746 { |
|
2747 // --------------------------------- |
|
2748 case ECamViewfinderDirect: |
|
2749 { |
|
2750 // Don't proceed if not supported by camera. |
|
2751 CheckFlagOnL( iCameraInfo.iOptionsSupported, |
|
2752 TCameraInfo::EViewFinderDirectSupported, |
|
2753 KErrNotSupported ); |
|
2754 |
|
2755 #ifdef CAMERAAPP_CAPI_V2_DVF |
|
2756 PRINT( _L("Camera <> Creating CCameraDirectViewFinder instance") ); |
|
2757 if( iDirectViewfinder ) |
|
2758 { |
|
2759 delete iDirectViewfinder; |
|
2760 iDirectViewfinder=NULL; |
|
2761 } |
|
2762 iDirectViewfinder = CCamera::CCameraDirectViewFinder::NewL( *iCamera ); |
|
2763 #else |
|
2764 // not implemented |
|
2765 Panic( ECamCameraControllerUnsupported ); |
|
2766 #endif |
|
2767 iInfo.iVfState = ECamTriInactive; |
|
2768 iInfo.iVfMode = ECamViewfinderDirect; |
|
2769 break; |
|
2770 } |
|
2771 // --------------------------------- |
|
2772 case ECamViewfinderBitmap: |
|
2773 { |
|
2774 // Don't proceed if not supported by camera. |
|
2775 CheckFlagOnL( iCameraInfo.iOptionsSupported, |
|
2776 TCameraInfo::EViewFinderBitmapsSupported, |
|
2777 KErrNotSupported ); |
|
2778 |
|
2779 iInfo.iVfState = ECamTriInactive; |
|
2780 iInfo.iVfMode = ECamViewfinderBitmap; |
|
2781 break; |
|
2782 } |
|
2783 // --------------------------------- |
|
2784 case ECamViewfinderNone: |
|
2785 // Mode is "none", so no init needed. |
|
2786 break; |
|
2787 // --------------------------------- |
|
2788 default: |
|
2789 // Unknown mode |
|
2790 Panic( ECamCameraControllerUnsupported ); |
|
2791 break; |
|
2792 // --------------------------------- |
|
2793 } |
|
2794 PRINT( _L("Camera <= CCamCameraController::InitViewfinderL") ); |
|
2795 } |
|
2796 |
|
2797 // --------------------------------------------------------------------------- |
|
2798 // --------------------------------------------------------------------------- |
|
2799 void |
|
2800 CCamCameraController |
|
2801 ::ProcessVfStartRequestL() |
|
2802 { |
|
2803 PRINT( _L("Camera => CCamCameraController::ProcessVfStartRequestL") ); |
|
2804 |
|
2805 #ifdef __WINSCW__ |
|
2806 const TCamViewfinderMode KTargetMode( ECamViewfinderBitmap ); |
|
2807 #else |
|
2808 |
|
2809 TPckgBuf<TCamViewfinderMode> mode; |
|
2810 iSettingProvider.ProvideCameraParamL( ECameraParamVfMode, &mode ); |
|
2811 |
|
2812 // If the viewfinder mode needs to be changed, |
|
2813 // first stop and release resources related to the old viewfinder type. |
|
2814 const TCamViewfinderMode KTargetMode( mode() ); |
|
2815 #endif |
|
2816 |
|
2817 if( ECamViewfinderNone != iInfo.iVfMode |
|
2818 && KTargetMode != iInfo.iVfMode ) |
|
2819 { |
|
2820 ProcessVfRelaseRequest(); |
|
2821 } |
|
2822 |
|
2823 // Check that application is still in foreground, if not then return |
|
2824 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
2825 |
|
2826 if ( !appUi->AppInBackground( ETrue ) ) |
|
2827 { |
|
2828 switch( iInfo.iVfState ) |
|
2829 { |
|
2830 // ----------------------------------------------------- |
|
2831 case ECamTriIdle: |
|
2832 PRINT( _L("Camera <> case ECamTriIdle") ); |
|
2833 |
|
2834 InitViewfinderL( KTargetMode ); |
|
2835 // << fall through >> |
|
2836 |
|
2837 case ECamTriInactive: |
|
2838 { |
|
2839 // ------------------------------- |
|
2840 PRINT( _L("Camera <> case ECamTriInactive") ); |
|
2841 |
|
2842 if( ECamViewfinderDirect == iInfo.iVfMode ) |
|
2843 #ifdef CAMERAAPP_CAPI_V2_DVF |
|
2844 { |
|
2845 switch( iDirectViewfinder->ViewFinderState() ) |
|
2846 { |
|
2847 case CCamera::CCameraDirectViewFinder::EViewFinderInActive: |
|
2848 { |
|
2849 if ( !iViewfinderWindow ) |
|
2850 { |
|
2851 PRINT( _L("Camera <> CCamCameraController::iViewfinderWindow is NULL - cannot start VF!") ); |
|
2852 User::Leave( KErrNotReady ); |
|
2853 } |
|
2854 |
|
2855 // Use the same viewfinder position and size as for bitmap viewfinder |
|
2856 TPckgBuf<TCamParamsVfBitmap> params; |
|
2857 iSettingProvider.ProvideCameraParamL( ECameraParamVfBitmap, ¶ms ); |
|
2858 |
|
2859 CEikonEnv* env = CEikonEnv::Static(); |
|
2860 |
|
2861 OstTrace0( CAMERAAPP_PERFORMANCE, CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_VF_INIT 0" ); //CCORAPP_APP_VF_INIT_END |
|
2862 OstTrace0( CAMERAAPP_PERFORMANCE, DUP1_CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_OVERLAY_INIT 0" ); //CCORAPP_APP_OVERLAY_INIT_END |
|
2863 |
|
2864 TInt orgPos = SetVfWindowOrdinal(); // Set visible |
|
2865 iCamera->StartViewFinderDirectL( |
|
2866 env->WsSession(), |
|
2867 *env->ScreenDevice(), |
|
2868 *iViewfinderWindow, |
|
2869 params().iRect ); |
|
2870 (void) SetVfWindowOrdinal( orgPos ); // back to original |
|
2871 |
|
2872 CCamAppUi* appUi = static_cast<CCamAppUi*>( env->AppUi() ); |
|
2873 if ( ECamActiveCameraSecondary == appUi->ActiveCamera() ) |
|
2874 { |
|
2875 iCamera->SetViewFinderMirrorL(ETrue); |
|
2876 } |
|
2877 // VF started succesfully, reset recovery counter |
|
2878 delete iIdle; |
|
2879 iIdle = NULL; |
|
2880 iIveRecoveryCount = KIveRecoveryCountMax; |
|
2881 break; |
|
2882 } |
|
2883 case CCamera::CCameraDirectViewFinder::EViewFinderPause: |
|
2884 { |
|
2885 iDirectViewfinder->ResumeViewFinderDirectL(); |
|
2886 break; |
|
2887 } |
|
2888 case CCamera::CCameraDirectViewFinder::EViewFinderActive: |
|
2889 { |
|
2890 // Already running. Not considered as error. |
|
2891 break; |
|
2892 } |
|
2893 default: |
|
2894 { |
|
2895 Panic( ECamCameraControllerUnsupported ); |
|
2896 break; |
|
2897 } |
|
2898 } |
|
2899 } |
|
2900 #else // CAMERAAPP_CAPI_V2_DVF |
|
2901 { |
|
2902 // No controller support for direct vf. |
|
2903 Panic( ECamCameraControllerUnsupported ); |
|
2904 } |
|
2905 #endif // CAMERAAPP_CAPI_V2_DVF |
|
2906 // ------------------------------- |
|
2907 else |
|
2908 { |
|
2909 PRINT( _L("Camera <> Get bitmap vf details..") ); |
|
2910 |
|
2911 TPckgBuf<TCamParamsVfBitmap> params; |
|
2912 iSettingProvider.ProvideCameraParamL( ECameraParamVfBitmap, ¶ms ); |
|
2913 iInfo.iViewfinderFormat = params().iFormat; |
|
2914 iInfo.iViewfinderSize = params().iRect.Size(); |
|
2915 #ifdef CAMERAAPP_CAE_FIX |
|
2916 if( iCaeInUse ) |
|
2917 { |
|
2918 PRINT( _L("Camera <> Call CCaeEngine::StartViewFinderBitmapsL..") ); |
|
2919 |
|
2920 OstTrace0( CAMERAAPP_PERFORMANCE, DUP2_CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_VF_INIT 0" ); //CCORAPP_APP_VF_INIT_END |
|
2921 OstTrace0( CAMERAAPP_PERFORMANCE, DUP3_CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_OVERLAY_INIT 0" ); //CCORAPP_APP_OVERLAY_INIT_END |
|
2922 iCaeEngine->StartViewFinderBitmapsL( iInfo.iViewfinderSize ); |
|
2923 } |
|
2924 else |
|
2925 #endif // CAMERAAPP_CAE_FIX |
|
2926 { |
|
2927 PRINT( _L("Camera <> Call CCamera::StartViewFinderBitmapsL..") ); |
|
2928 OstTrace0( CAMERAAPP_PERFORMANCE, DUP4_CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_VF_INIT 0" ); //CCORAPP_APP_VF_INIT_END |
|
2929 OstTrace0( CAMERAAPP_PERFORMANCE, DUP5_CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_OVERLAY_INIT 0" ); //CCORAPP_APP_OVERLAY_INIT_END |
|
2930 iCamera->StartViewFinderBitmapsL( iInfo.iViewfinderSize ); |
|
2931 |
|
2932 if ( params().iMirrorImage ) |
|
2933 { |
|
2934 iCamera->SetViewFinderMirrorL( params().iMirrorImage ); |
|
2935 } |
|
2936 } |
|
2937 } |
|
2938 // ------------------------------- |
|
2939 |
|
2940 iInfo.iVfState = ECamTriActive; |
|
2941 //view finder started now(set stop status as false) |
|
2942 appUi->SetViewFinderStoppedStatus( EFalse ); |
|
2943 break; |
|
2944 } |
|
2945 // ----------------------------------------------------- |
|
2946 case ECamTriActive: |
|
2947 { |
|
2948 PRINT( _L("Camera <> case ECamTriActive") ); |
|
2949 // Viewfinder started *and* the right mode |
|
2950 // no action needed. |
|
2951 break; |
|
2952 } |
|
2953 // ----------------------------------------------------- |
|
2954 default: |
|
2955 Panic( ECamCameraControllerCorrupt ); |
|
2956 break; |
|
2957 // ----------------------------------------------------- |
|
2958 } |
|
2959 } |
|
2960 PRINT( _L("Camera <= CCamCameraController::ProcessVfStartRequestL") ); |
|
2961 } |
|
2962 |
|
2963 |
|
2964 |
|
2965 // --------------------------------------------------------------------------- |
|
2966 // ProcessVfStopRequestL |
|
2967 // |
|
2968 // --------------------------------------------------------------------------- |
|
2969 // |
|
2970 void |
|
2971 CCamCameraController::ProcessVfStopRequestL() |
|
2972 { |
|
2973 PRINT( _L("Camera => CCamCameraController::ProcessVfStopRequestL") ); |
|
2974 |
|
2975 switch( iInfo.iVfState ) |
|
2976 { |
|
2977 case ECamTriActive: |
|
2978 { |
|
2979 ProcessVfStopEcamRequest(); |
|
2980 iInfo.iVfState = ECamTriInactive; |
|
2981 break; |
|
2982 } |
|
2983 case ECamTriIdle: |
|
2984 { |
|
2985 // Viewfinder not initialized. |
|
2986 // Let this pass as our "start viewfinder" handles all states. |
|
2987 break; |
|
2988 } |
|
2989 case ECamTriInactive: |
|
2990 { |
|
2991 // Already stopped. No action needed. |
|
2992 break; |
|
2993 } |
|
2994 default: |
|
2995 { |
|
2996 Panic( ECamCameraControllerCorrupt ); |
|
2997 break; |
|
2998 } |
|
2999 } |
|
3000 PRINT( _L("Camera <= CCamCameraController::ProcessVfStopRequestL") ); |
|
3001 } |
|
3002 |
|
3003 |
|
3004 // --------------------------------------------------------------------------- |
|
3005 // ProcessVfStopEcamRequest |
|
3006 // |
|
3007 // --------------------------------------------------------------------------- |
|
3008 // |
|
3009 void |
|
3010 CCamCameraController::ProcessVfStopEcamRequest() |
|
3011 { |
|
3012 PRINT( _L("Camera => CCamCameraController::ProcessVfStopEcamRequest") ); |
|
3013 |
|
3014 if( ECamViewfinderDirect == iInfo.iVfMode ) |
|
3015 { |
|
3016 #ifdef CAMERAAPP_CAPI_V2_DVF |
|
3017 if ( iCamera ) |
|
3018 { |
|
3019 PRINT( _L("Camera <> VF stop by CCamera") ); |
|
3020 iCamera->StopViewFinder(); |
|
3021 } |
|
3022 #else // CAMERAAPP_CAPI_V2_DVF |
|
3023 Panic( ECamCameraControllerUnsupported ); |
|
3024 #endif // CAMERAAPP_CAPI_V2_DVF |
|
3025 } |
|
3026 else |
|
3027 { |
|
3028 #ifdef CAMERAAPP_CAE_FIX |
|
3029 if( iCaeInUse && iCaeEngine ) |
|
3030 { |
|
3031 PRINT( _L("Camera <> stop by CAE") ); |
|
3032 iCaeEngine->StopViewFinder(); |
|
3033 } |
|
3034 else |
|
3035 #endif // CAMERAAPP_CAE_FIX |
|
3036 { |
|
3037 if ( iCamera ) |
|
3038 { |
|
3039 PRINT( _L("Camera <> stop by CCamera") ); |
|
3040 iCamera->StopViewFinder(); |
|
3041 } |
|
3042 } |
|
3043 } |
|
3044 PRINT( _L("Camera <= CCamCameraController::ProcessVfStopEcamRequest") ); |
|
3045 } |
|
3046 |
|
3047 |
|
3048 // --------------------------------------------------------------------------- |
|
3049 // |
|
3050 // --------------------------------------------------------------------------- |
|
3051 // |
|
3052 void |
|
3053 CCamCameraController |
|
3054 ::ProcessVfRelaseRequest() |
|
3055 { |
|
3056 switch( iInfo.iVfState ) |
|
3057 { |
|
3058 // ----------------------------------------------------- |
|
3059 case ECamTriActive: |
|
3060 { |
|
3061 // Do the stopping first and continue then with release. |
|
3062 // Leaves only if iVfState is ECamVfIdle, which is not the case here. |
|
3063 TRAP_IGNORE( ProcessVfStopRequestL() ); |
|
3064 |
|
3065 // Need to notify here, because done as a part of other request. |
|
3066 NotifyObservers( KErrNone, |
|
3067 ECamCameraEventVfStop, |
|
3068 ECamCameraEventClassVfControl ); |
|
3069 // << fall through >> |
|
3070 } |
|
3071 // ----------------------------------------------------- |
|
3072 case ECamTriInactive: |
|
3073 { |
|
3074 if( ECamViewfinderDirect == iInfo.iVfMode ) |
|
3075 { |
|
3076 #ifdef CAMERAAPP_CAPI_V2_DVF |
|
3077 delete iDirectViewfinder; |
|
3078 iDirectViewfinder = NULL; |
|
3079 #endif |
|
3080 } |
|
3081 else |
|
3082 { |
|
3083 // No further actions needed for bitmap viewfinding. |
|
3084 } |
|
3085 // These may very well remain as they are. |
|
3086 // Atleast for the format there is no "zero" value available. |
|
3087 // iInfo.iViewfinderSize |
|
3088 // iInfo.iViewfinderFormat |
|
3089 iInfo.iVfState = ECamTriIdle; |
|
3090 iInfo.iVfMode = ECamViewfinderNone; |
|
3091 break; |
|
3092 } |
|
3093 // ----------------------------------------------------- |
|
3094 case ECamTriIdle: |
|
3095 // Already released. |
|
3096 break; |
|
3097 // ----------------------------------------------------- |
|
3098 default: |
|
3099 Panic( ECamCameraControllerCorrupt ); |
|
3100 break; |
|
3101 // ----------------------------------------------------- |
|
3102 } |
|
3103 } |
|
3104 |
|
3105 |
|
3106 // --------------------------------------------------------------------------- |
|
3107 // ProcessImageRequestL |
|
3108 // --------------------------------------------------------------------------- |
|
3109 // |
|
3110 TInt |
|
3111 CCamCameraController |
|
3112 ::ProcessImageRequestL( const TCamCameraRequestId& aRequestId ) |
|
3113 { |
|
3114 PRINT( _L("Camera => CCamCameraController::ProcessImageRequestL") ); |
|
3115 CheckFlagOnL( iInfo.iState, ECamPowerOn, KErrNotReady ); |
|
3116 |
|
3117 TInt callback( ETrue ); |
|
3118 switch( aRequestId ) |
|
3119 { |
|
3120 // ----------------------------------------------------- |
|
3121 case ECamRequestImageInit: |
|
3122 { |
|
3123 // When camera engine still capture don't Init a new capture |
|
3124 |
|
3125 if ( ECamCaptureOn == iInfo.iCaptureState ) |
|
3126 { |
|
3127 return EFalse; |
|
3128 } |
|
3129 CAMERAAPP_PERF_CONTROLLER_START( ECamRequestImageInit ); |
|
3130 |
|
3131 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
3132 #ifdef CAMERAAPP_CAE_FIX |
|
3133 if( iCaeInUse ) |
|
3134 { |
|
3135 iModeChange = ECamModeChangeVideo2Image; |
|
3136 iModeChangePhase = ECamModeChangePhaseIdle; // incremented before first step |
|
3137 iModeChangeStatus = KErrNone; |
|
3138 iActive->IssueRequest(); |
|
3139 } |
|
3140 else |
|
3141 #else |
|
3142 if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
3143 { |
|
3144 // Release any video recording resources |
|
3145 iCaeEngine->CloseVideoRecording(); |
|
3146 ClearFlags( iInfo.iState, ECamVideoOn ); |
|
3147 } |
|
3148 #endif // CAMERAAPP_CAE_FIX |
|
3149 #endif |
|
3150 { |
|
3151 PRINT( _L("Camera <> Checking that image capture not ongoing..") ); |
|
3152 CheckEqualsL( iInfo.iCaptureState, ECamCaptureOff, KErrInUse ); |
|
3153 |
|
3154 PRINT( _L("Camera <> Checking that image capture supported..") ); |
|
3155 CheckFlagOnL( iCameraInfo.iOptionsSupported, |
|
3156 TCameraInfo::EImageCaptureSupported, |
|
3157 KErrNotSupported ); |
|
3158 |
|
3159 PRINT( _L("Camera <> Ask image parameters..") ); |
|
3160 TPckgBuf<TCamParamsImage> params; |
|
3161 iSettingProvider.ProvideCameraParamL( ECameraParamImage, ¶ms ); |
|
3162 |
|
3163 PRINT( _L("Camera <> Enumerating capture sizes..") ); |
|
3164 // Query the supported resolutions for the selected format. |
|
3165 // GetResolutionIndexL may change the format to some alternative, |
|
3166 // if we are able to convert the incoming image later to the |
|
3167 // format requested by client. |
|
3168 CCamera::TFormat format( params().iFormat ); |
|
3169 TInt index = GetResolutionIndexL( format, params().iSize ); |
|
3170 User::LeaveIfError( index ); |
|
3171 |
|
3172 PRINT( _L("Camera <> Call CCamera::PrepareImageCaptureL..") ); |
|
3173 PRINT2( _L("Camera <> Image size: (%d, %d)"), |
|
3174 params().iSize.iWidth, |
|
3175 params().iSize.iHeight ); |
|
3176 |
|
3177 OstTrace0( CAMERAAPP_PERFORMANCE, CCAMCAMERACONTROLLER_PROCESSIMAGEREQUESTL, "e_CAM_APP_CONFIGURATIONS 0" ); //CCORAPP_APP_CONFIGS_END |
|
3178 iCamera->PrepareImageCaptureL( format, index ); |
|
3179 OstTrace0( CAMERAAPP_PERFORMANCE, DUP1_CCAMCAMERACONTROLLER_PROCESSIMAGEREQUESTL, "e_CAM_APP_STILL_INIT 0" ); //CCORAPP_APP_STILL_INIT_END |
|
3180 OstTrace0( CAMERAAPP_PERFORMANCE, DUP2_CCAMCAMERACONTROLLER_PROCESSIMAGEREQUESTL, "e_CAM_APP_OVERLAY_INIT 1" ); //CCORAPP_APP_OVERLAY_INIT_START |
|
3181 |
|
3182 iCamera->SetJpegQuality( params().iQualityFactor ); |
|
3183 |
|
3184 SetFlags( iInfo.iState, ECamImageOn ); |
|
3185 |
|
3186 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
3187 // Set current autofocus range to invalid value to force focusing |
|
3188 iInfo.iCurrentFocusRange = static_cast<CAS::TFocusRange>( -1 ); |
|
3189 GetAdvancedSettingsInfoL(); |
|
3190 #endif // CAMERAAPP_CAPI_V2_ADV |
|
3191 |
|
3192 iInfo.iCaptureCount = 0; |
|
3193 iInfo.iSnapshotCount = 0; |
|
3194 callback = EFalse; // No callback to wait for. |
|
3195 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestImageInit ); |
|
3196 } |
|
3197 break; |
|
3198 } |
|
3199 // ----------------------------------------------------- |
|
3200 case ECamRequestImageCapture: |
|
3201 { |
|
3202 CheckFlagOnL( iInfo.iState, ECamImageOn, KErrNotReady ); |
|
3203 CheckEqualsL( iInfo.iCaptureState, ECamCaptureOff, KErrInUse ); |
|
3204 OstTrace0( CAMERAAPP_PERFORMANCE, DUP3_CCAMCAMERACONTROLLER_PROCESSIMAGEREQUESTL, "e_CAM_APP_CAPTURE_START 0" ); //CCORAPP_CAPTURE_START_END |
|
3205 |
|
3206 // New capture starts, reset capture and snapshot counters. |
|
3207 iInfo.iCaptureCount = 0; |
|
3208 iInfo.iSnapshotCount = 0; |
|
3209 iInfo.iCaptureState = ECamCaptureOn; |
|
3210 |
|
3211 PRINT1( _L("Camera <> CCamCameraController .. About to start capture, total shared buffers in use: %d"), CCamBufferShare::TotalBufferShareCount() ); |
|
3212 iCamera->CaptureImage(); |
|
3213 |
|
3214 // When image data is received from CCamera, |
|
3215 // an event is generated for that. We need to notify |
|
3216 // here as other places check if the request has associated |
|
3217 // callback, and send no notification yet if callback exist. |
|
3218 NotifyObservers( KErrNone, |
|
3219 ECamCameraEventImageStart, |
|
3220 ECamCameraEventClassImage ); |
|
3221 break; |
|
3222 } |
|
3223 // ----------------------------------------------------- |
|
3224 default: |
|
3225 { |
|
3226 Panic( ECamCameraControllerCorrupt ); |
|
3227 break; |
|
3228 } |
|
3229 // ----------------------------------------------------- |
|
3230 } |
|
3231 PRINT1( _L("Camera <= CCamCameraController::ProcessImageRequestL, continue now:%d"), !callback ); |
|
3232 return !callback; |
|
3233 } |
|
3234 |
|
3235 |
|
3236 // --------------------------------------------------------------------------- |
|
3237 // ProcessImageShutdownRequest |
|
3238 // --------------------------------------------------------------------------- |
|
3239 // |
|
3240 TInt |
|
3241 CCamCameraController |
|
3242 ::ProcessImageShutdownRequest( const TCamCameraRequestId& aRequestId ) |
|
3243 { |
|
3244 PRINT( _L("Camera => CCamCameraController::ProcessImageShutdownRequest") ); |
|
3245 |
|
3246 switch( aRequestId ) |
|
3247 { |
|
3248 // ----------------------------------------------------- |
|
3249 case ECamRequestImageCancel: |
|
3250 { |
|
3251 if( IsFlagOn( iInfo.iState, ECamImageOn ) |
|
3252 // && ECamCaptureOn == iInfo.iCaptureState |
|
3253 ) |
|
3254 { |
|
3255 const TCamCameraCaptureState previousState( iInfo.iCaptureState ); |
|
3256 |
|
3257 if( iEncoder ) |
|
3258 { |
|
3259 iEncoder->Cancel(); |
|
3260 |
|
3261 delete iEncoder; |
|
3262 iEncoder = NULL; |
|
3263 } |
|
3264 |
|
3265 PRINT( _L("Camera <> Calling iCamera->CancelCaptureImage()") ); |
|
3266 iCamera->CancelCaptureImage(); |
|
3267 |
|
3268 iInfo.iCaptureState = ECamCaptureOff; |
|
3269 |
|
3270 // Notify if we actually stopped the capturing here. |
|
3271 if( ECamCaptureOn == previousState ) |
|
3272 { |
|
3273 |
|
3274 // Capturing image was stopped here. |
|
3275 // If single request was ongoing, it must be "capture image". |
|
3276 ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
3277 |
|
3278 TInt fullCaptures( Min( iInfo.iCaptureCount, iInfo.iSnapshotCount ) ); |
|
3279 NotifyObservers( KErrNone, |
|
3280 ECamCameraEventImageStop, |
|
3281 ECamCameraEventClassImage, |
|
3282 &fullCaptures ); |
|
3283 } |
|
3284 } |
|
3285 break; |
|
3286 } |
|
3287 // ----------------------------------------------------- |
|
3288 case ECamRequestImageRelease: |
|
3289 { |
|
3290 // Cancel any pending capture. |
|
3291 ProcessImageShutdownRequest( ECamRequestImageCancel ); |
|
3292 |
|
3293 // Nothing else really needed for image, just set flags. |
|
3294 ClearFlags( iInfo.iState, ECamImageOn ); |
|
3295 iInfo.iCaptureCount = 0; |
|
3296 iInfo.iSnapshotCount = 0; |
|
3297 iInfo.iCaptureState = ECamCaptureOff; |
|
3298 |
|
3299 break; |
|
3300 } |
|
3301 // ----------------------------------------------------- |
|
3302 default: |
|
3303 { |
|
3304 Panic( ECamCameraControllerCorrupt ); |
|
3305 break; |
|
3306 } |
|
3307 // ----------------------------------------------------- |
|
3308 } |
|
3309 PRINT( _L("Camera <= CCamCameraController::ProcessImageShutdownRequest") ); |
|
3310 return ETrue; // can continue sequence, if needed |
|
3311 } |
|
3312 |
|
3313 |
|
3314 |
|
3315 // --------------------------------------------------------------------------- |
|
3316 // ProcessVideoRequestL |
|
3317 // --------------------------------------------------------------------------- |
|
3318 // |
|
3319 TInt |
|
3320 CCamCameraController |
|
3321 ::ProcessVideoRequestL( const TCamCameraRequestId& aRequestId ) |
|
3322 { |
|
3323 PRINT( _L("Camera => CCamCameraController::ProcessVideoRequestL") ); |
|
3324 CheckFlagOnL( iInfo.iState, ECamPowerOn, KErrNotReady ); |
|
3325 |
|
3326 TInt callback( ETrue ); |
|
3327 |
|
3328 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
3329 switch( aRequestId ) |
|
3330 { |
|
3331 // ----------------------------------------------------- |
|
3332 case ECamRequestVideoInit: |
|
3333 { |
|
3334 PRINT( _L("Camera <> case ECamRequestVideoInit") ); |
|
3335 #ifdef CAMERAAPP_CAE_FIX |
|
3336 PRINT( _L("Camera <> old CAE") ); |
|
3337 // First init for video after image mode or startup |
|
3338 if( !IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
3339 { |
|
3340 iModeChange = ECamModeChangeImage2Video; |
|
3341 iModeChangePhase = ECamModeChangePhaseIdle; // incremented before first step |
|
3342 iModeChangeStatus = KErrNone; |
|
3343 iActive->IssueRequest(); |
|
3344 } |
|
3345 // Just repeat prepare |
|
3346 else |
|
3347 #else |
|
3348 PRINT( _L("Camera <> new CAE, CCameraHandle + SetCameraReserved supported") ); |
|
3349 if( !IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
3350 { |
|
3351 PRINT( _L("Camera <> CCaeEngine::EnableVideoRecording..") ); |
|
3352 iCaeEngine->EnableVideoRecording(); |
|
3353 } |
|
3354 #endif |
|
3355 { |
|
3356 if ( iAppController.VideoInitNeeded() ) |
|
3357 { |
|
3358 PRINT( _L("Camera <> CCaeEngine::InitVideoRecorderL..") ); |
|
3359 iCaeEngine->InitVideoRecorderL(); |
|
3360 } |
|
3361 |
|
3362 PRINT( _L("Camera <> Ask filename..") ); |
|
3363 HBufC* filename( HBufC::NewLC( KMaxFileName ) ); |
|
3364 TPtr ptr ( filename->Des() ); |
|
3365 iSettingProvider.ProvideCameraSettingL( ECameraSettingFileName, &ptr ); |
|
3366 // _LIT( KTempFilename, "C:\\video.3gp" ); |
|
3367 // TPtrC ptr; |
|
3368 // ptr.Set( KTempFilename() ); |
|
3369 PRINT1( _L("Camera <> Set filename [%S]"), &ptr ); |
|
3370 iCaeEngine->SetVideoRecordingFileNameL( ptr ); |
|
3371 CleanupStack::PopAndDestroy( filename ); |
|
3372 |
|
3373 // Set max video clip size |
|
3374 ProcessSettingL( ECameraSettingFileMaxSize ); |
|
3375 |
|
3376 TPckgBuf<TCamParamsVideoCae> params; |
|
3377 PRINT( _L("Camera <> Getting params from setting provider..") ); |
|
3378 iSettingProvider.ProvideCameraParamL( ECameraParamVideoCae, ¶ms ); |
|
3379 // The audioOn value is defined On==0 and Off==1, but the engine expects |
|
3380 // ETrue if audio recording is On |
|
3381 params().iAudioOn = ( ECamSettOn == params().iAudioOn ) |
|
3382 ? ETrue |
|
3383 : EFalse; |
|
3384 PRINT( _L("Camera <> Calling PrepareVideoRecordingL..") ); |
|
3385 PRINT2( _L("Camera <> FrameSize: (%d x %d)"), params().iFrameSize.iWidth, params().iFrameSize.iHeight ); |
|
3386 if ( iAppController.VideoInitNeeded() ) |
|
3387 { |
|
3388 // McaeoVideoPrepareComplete will be called when prepare is ready. |
|
3389 // The callback is allowed to come also *during* this call. |
|
3390 iCaeEngine->PrepareVideoRecordingL( params().iFrameSize, |
|
3391 params().iFrameRate, |
|
3392 params().iVideoBitRate, |
|
3393 params().iAudioOn, |
|
3394 params().iAudioBitRate, |
|
3395 params().iMimeType, |
|
3396 params().iSupplier, |
|
3397 params().iVideoType, |
|
3398 params().iAudioType ); |
|
3399 } |
|
3400 |
|
3401 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
3402 // Set current autofocus range to invalid value to force focusing |
|
3403 iInfo.iCurrentFocusRange = static_cast<CAS::TFocusRange>( -1 ); |
|
3404 #endif // CAMERAAPP_CAPI_V2_ADV |
|
3405 |
|
3406 iAppController.SetVideoInitNeeded( EFalse ); |
|
3407 // iState is updated in the callback. |
|
3408 PRINT( _L("Camera <> ..waiting for callback") ); |
|
3409 } |
|
3410 break; |
|
3411 } |
|
3412 // ----------------------------------------------------- |
|
3413 case ECamRequestVideoStart: |
|
3414 { |
|
3415 PRINT( _L("Camera <> case ECamRequestVideoStart") ); |
|
3416 CheckFlagOnL( iInfo.iState, ECamVideoOn, KErrNotReady ); |
|
3417 switch( iInfo.iCaptureState ) |
|
3418 { |
|
3419 case ECamCaptureOn: User::Leave( KErrInUse ); break; |
|
3420 case ECamCaptureOff: iCaeEngine->StartVideoRecording(); break; |
|
3421 //case ECamCaptureOff: iCaeEngine->ResumeVideoRecording(); break; |
|
3422 case ECamCapturePaused: iCaeEngine->ResumeVideoRecording(); break; |
|
3423 default: |
|
3424 Panic( ECamCameraControllerCorrupt ); |
|
3425 break; |
|
3426 } |
|
3427 // iCaptureState is updated in McaeoVideoRecordingOn. |
|
3428 break; |
|
3429 } |
|
3430 // ----------------------------------------------------- |
|
3431 case ECamRequestVideoPause: |
|
3432 { |
|
3433 PRINT( _L("Camera <> case ECamRequestVideoPause") ); |
|
3434 CheckEqualsL( iInfo.iCaptureState, ECamCaptureOn, KErrNotReady ); |
|
3435 iCaeEngine->PauseVideoRecording(); |
|
3436 // iCaptureState is updated in McaeoVideoRecordingPaused. |
|
3437 break; |
|
3438 } |
|
3439 // ----------------------------------------------------- |
|
3440 case ECamRequestVideoStop: |
|
3441 { |
|
3442 PRINT( _L("Camera <> case ECamRequestVideoStop") ); |
|
3443 switch( iInfo.iCaptureState ) |
|
3444 { |
|
3445 case ECamCaptureOn: // << fall through >> |
|
3446 case ECamCapturePaused: |
|
3447 PRINT( _L("Camera <> call CCaeEngine::StopVideoRecording..") ); |
|
3448 iCaeEngine->StopVideoRecording(); |
|
3449 // If we got the callback during above call, |
|
3450 // we should not wait for it anymore. |
|
3451 // Check the capture state to be sure. |
|
3452 callback = (ECamCaptureOff != iInfo.iCaptureState); |
|
3453 break; |
|
3454 case ECamCaptureOff: |
|
3455 // no action, already stopped |
|
3456 break; |
|
3457 default: |
|
3458 Panic( ECamCameraControllerCorrupt ); |
|
3459 break; |
|
3460 } |
|
3461 // iCaptureState is updated in McaeoVideoRecordingComplete. |
|
3462 break; |
|
3463 } |
|
3464 // ----------------------------------------------------- |
|
3465 case ECamRequestVideoRelease: |
|
3466 { |
|
3467 // Need to be stopped. |
|
3468 CheckEqualsL( iInfo.iCaptureState, ECamCaptureOff, KErrInUse ); |
|
3469 |
|
3470 if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
3471 iCaeEngine->CloseVideoRecording(); |
|
3472 |
|
3473 ClearFlags( iInfo.iState, ECamVideoOn ); |
|
3474 callback = EFalse; |
|
3475 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
3476 GetAdvancedSettingsInfoL(); |
|
3477 #endif |
|
3478 break; |
|
3479 } |
|
3480 // ----------------------------------------------------- |
|
3481 case ECamRequestSetAsyncVideoStopMode: |
|
3482 { |
|
3483 TInt err = iCaeEngine->SetAsyncVideoStopMode( ETrue ); |
|
3484 PRINT1( _L("Camera <> CCamCameraController::ProcessVideoRequestL, engine SetAsyncVideoStopMode return code:%d"), err ); |
|
3485 iAsyncVideoStopModeSupported = !err; // Use async stop if KErrNone |
|
3486 callback = EFalse; |
|
3487 break; |
|
3488 } |
|
3489 // ----------------------------------------------------- |
|
3490 default: |
|
3491 Panic( ECamCameraControllerCorrupt ); |
|
3492 break; |
|
3493 // ----------------------------------------------------- |
|
3494 } |
|
3495 #else |
|
3496 #pragma message("CCamCameraController::ProcessVideoRequestL not implemented!") |
|
3497 PRINT( _L("Camera <> Not supported, PANIC!") ); |
|
3498 Panic( ECamCameraControllerUnsupported ); |
|
3499 #endif // CAMERAAPP_CAE_FOR_VIDEO |
|
3500 |
|
3501 PRINT1( _L("Camera <= CCamCameraController::ProcessVideoRequestL, continue now:%d"), !callback ); |
|
3502 return !callback; |
|
3503 } |
|
3504 |
|
3505 |
|
3506 |
|
3507 // --------------------------------------------------------------------------- |
|
3508 // ProcessSnapshotRequestL |
|
3509 // --------------------------------------------------------------------------- |
|
3510 // |
|
3511 TInt |
|
3512 CCamCameraController |
|
3513 ::ProcessSnapshotRequestL( const TCamCameraRequestId& aRequestId ) |
|
3514 { |
|
3515 PRINT( _L("Camera => CCamCameraController::ProcessSnapshotRequestL") ); |
|
3516 OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMCAMERACONTROLLER_PROCESSSNAPSHOTREQUESTL, "e_CCamCameraController_ProcessSnapshotRequestL 1" ); |
|
3517 CheckFlagOnL( iInfo.iState, ECamReserved, KErrNotReady ); |
|
3518 |
|
3519 switch( aRequestId ) |
|
3520 { |
|
3521 // ----------------------------------------------------- |
|
3522 case ECamRequestSsStart: |
|
3523 { |
|
3524 PRINT( _L("Camera <> case ECamRequestSsStart") ); |
|
3525 switch( iInfo.iSsState ) |
|
3526 { |
|
3527 case ECamTriIdle: |
|
3528 PRINT( _L("Camera <> ECamTriIdle") ); |
|
3529 InitSnapshotL(); |
|
3530 // << fall through >> |
|
3531 case ECamTriInactive: |
|
3532 { |
|
3533 PRINT( _L("Camera <> ECamTriInactive") ); |
|
3534 iSnapshotProvider->StartSnapshot(); |
|
3535 break; |
|
3536 } |
|
3537 case ECamTriActive: // Already active, no action |
|
3538 PRINT( _L("Camera <> ECamTriActive") ); |
|
3539 break; |
|
3540 default: |
|
3541 Panic( ECamCameraControllerCorrupt ); |
|
3542 break; |
|
3543 } |
|
3544 iInfo.iSsState = ECamTriActive; |
|
3545 break; |
|
3546 } |
|
3547 // ----------------------------------------------------- |
|
3548 case ECamRequestSsStop: |
|
3549 { |
|
3550 PRINT( _L("Camera <> case ECamRequestSsStop") ); |
|
3551 ProcessSsStopRequest(); |
|
3552 break; |
|
3553 } |
|
3554 // ----------------------------------------------------- |
|
3555 case ECamRequestSsRelease: |
|
3556 { |
|
3557 PRINT( _L("Camera <> case ECamRequestSsRelease") ); |
|
3558 ProcessSsReleaseRequest(); |
|
3559 break; |
|
3560 } |
|
3561 // ----------------------------------------------------- |
|
3562 default: |
|
3563 Panic( ECamCameraControllerCorrupt ); |
|
3564 break; |
|
3565 // ----------------------------------------------------- |
|
3566 } |
|
3567 OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMCAMERACONTROLLER_PROCESSSNAPSHOTREQUESTL, "e_CCamCameraController_ProcessSnapshotRequestL 0" ); |
|
3568 |
|
3569 PRINT( _L("Camera <= CCamCameraController::ProcessSnapshotRequestL") ); |
|
3570 |
|
3571 // No callback to wait for any of the requests => can continue now. |
|
3572 return ETrue; |
|
3573 } |
|
3574 |
|
3575 // --------------------------------------------------------------------------- |
|
3576 // ProcessSsStopRequest |
|
3577 // --------------------------------------------------------------------------- |
|
3578 // |
|
3579 void |
|
3580 CCamCameraController::ProcessSsStopRequest() |
|
3581 { |
|
3582 PRINT( _L("Camera <= CCamCameraController::ProcessSsStopRequest") ); |
|
3583 switch( iInfo.iSsState ) |
|
3584 { |
|
3585 case ECamTriIdle: // Not even initialized yet. No action needed. |
|
3586 case ECamTriInactive: // Already inactive, no action. |
|
3587 PRINT( _L("Camera <> Snapshot idle/inactive, no need to stop") ); |
|
3588 break; |
|
3589 case ECamTriActive: |
|
3590 PRINT( _L("Camera <> Snapshot ECamTriActive -> need to stop") ); |
|
3591 iSnapshotProvider->StopSnapshot(); |
|
3592 break; |
|
3593 default: |
|
3594 Panic( ECamCameraControllerCorrupt ); |
|
3595 break; |
|
3596 } |
|
3597 iInfo.iSsState = ECamTriInactive; |
|
3598 PRINT( _L("Camera <= CCamCameraController::ProcessSsStopRequest") ); |
|
3599 } |
|
3600 |
|
3601 // --------------------------------------------------------------------------- |
|
3602 // ProcessSsReleaseRequest |
|
3603 // --------------------------------------------------------------------------- |
|
3604 // |
|
3605 void |
|
3606 CCamCameraController::ProcessSsReleaseRequest() |
|
3607 { |
|
3608 PRINT( _L("Camera => CCamCameraController::ProcessSsReleaseRequest") ); |
|
3609 switch( iInfo.iSsState ) |
|
3610 { |
|
3611 case ECamTriIdle: // No action needed |
|
3612 break; |
|
3613 case ECamTriActive: |
|
3614 iSnapshotProvider->StopSnapshot(); |
|
3615 NotifyObservers( KErrNone, |
|
3616 ECamCameraEventSsStop, |
|
3617 ECamCameraEventClassSsControl ); |
|
3618 // << fall through >> |
|
3619 case ECamTriInactive: |
|
3620 delete iSnapshotProvider; |
|
3621 iSnapshotProvider = NULL; |
|
3622 break; |
|
3623 default: |
|
3624 Panic( ECamCameraControllerCorrupt ); |
|
3625 break; |
|
3626 } |
|
3627 |
|
3628 iInfo.iSsState = ECamTriIdle; |
|
3629 PRINT( _L("Camera <= CCamCameraController::ProcessSsReleaseRequest") ); |
|
3630 } |
|
3631 |
|
3632 // --------------------------------------------------------------------------- |
|
3633 // InitSnapshotL |
|
3634 // --------------------------------------------------------------------------- |
|
3635 // |
|
3636 void |
|
3637 CCamCameraController::InitSnapshotL() |
|
3638 { |
|
3639 PRINT( _L("Camera => CCamCameraController::InitSnapshotL") ); |
|
3640 |
|
3641 // Check the snapshot state here. No further checks made. |
|
3642 __ASSERT_DEBUG( ECamTriIdle == iInfo.iSsState, Panic( ECamCameraControllerCorrupt ) ); |
|
3643 |
|
3644 // ------------------------------------------------------- |
|
3645 // Create snapshot provider if not available yet. |
|
3646 if( !iSnapshotProvider ) |
|
3647 { |
|
3648 iSnapshotProvider = CCamSnapshotProvider::NewL( *iCamera, *this, *this ); |
|
3649 } |
|
3650 |
|
3651 #ifdef _DEBUG |
|
3652 PrintSnapshotInfo(); |
|
3653 #endif // _DEBUG |
|
3654 |
|
3655 |
|
3656 // ------------------------------------------------------- |
|
3657 // Initialize the snapshot parameters |
|
3658 TPckgBuf<TCamParamsSnapshot> params; |
|
3659 iSettingProvider.ProvideCameraParamL( ECameraParamSnapshot, ¶ms ); |
|
3660 |
|
3661 // Try to get the best, still supported, snapshot format. |
|
3662 iInfo.iSnapshotFormat = ResolveSnapshotFormatL( params().iFormat ); |
|
3663 iInfo.iSnapshotSize = params().iSize; |
|
3664 iInfo.iSnapshotAspectMaintain = params().iMaintainAspect; |
|
3665 |
|
3666 PRINT( _L("Camera <> Prepare snapshot..") ); |
|
3667 iSnapshotProvider->PrepareSnapshotL( iInfo.iSnapshotFormat, |
|
3668 iInfo.iSnapshotSize, |
|
3669 iInfo.iSnapshotAspectMaintain ); |
|
3670 |
|
3671 iInfo.iSsState = ECamTriInactive; |
|
3672 // ------------------------------------------------------- |
|
3673 PRINT( _L("Camera <= CCamCameraController::InitSnapshotL") ); |
|
3674 } |
|
3675 |
|
3676 |
|
3677 // --------------------------------------------------------------------------- |
|
3678 // CCamCameraController::ProcessAutofocusRequestL |
|
3679 // --------------------------------------------------------------------------- |
|
3680 // |
|
3681 void CCamCameraController::ProcessAutofocusRequestL( const TCamCameraRequestId& aRequestId ) |
|
3682 { |
|
3683 PRINT( _L("Camera => CCamCameraController::ProcessAutofocusRequestL") ); |
|
3684 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
3685 CheckNonNullL( iAdvancedSettings, KErrNotReady ); |
|
3686 if( ECamRequestStartAutofocus == aRequestId ) |
|
3687 { |
|
3688 PRINT( _L("Camera <> SetAutoFocusType( EAutoFocusTypeSingle )") ); |
|
3689 iAdvancedSettings->SetAutoFocusType( CAS::EAutoFocusTypeSingle ); |
|
3690 iAfInProgress = ETrue; |
|
3691 iFirstAfEventReceived = EFalse; |
|
3692 } |
|
3693 else if( ECamRequestCancelAutofocus == aRequestId ) |
|
3694 { |
|
3695 if( iAfInProgress ) |
|
3696 { |
|
3697 // Autofocus in progress, need to cancel it before setting range to hyperfocal |
|
3698 PRINT( _L("Camera <> Cancel ongoing autofocus request") ); |
|
3699 iAdvancedSettings->SetAutoFocusType( CAS::EAutoFocusTypeOff ); |
|
3700 iAfHyperfocalPending = ETrue; |
|
3701 } |
|
3702 else |
|
3703 { |
|
3704 // If focustype is set to continuous, need to change it to off |
|
3705 // before continuing |
|
3706 |
|
3707 PRINT( _L("Camera <> SetAutoFocusType( EAutoFocusTypeOff )") ); |
|
3708 if ( iAdvancedSettings->AutoFocusType() & CAS::EAutoFocusTypeContinuous ) |
|
3709 { |
|
3710 iAdvancedSettings->SetAutoFocusType( CAS::EAutoFocusTypeOff ); |
|
3711 } |
|
3712 |
|
3713 PRINT( _L("Camera <> Cancel autofocus - set focus range to hyperfocal") ); |
|
3714 iInfo.iCurrentFocusRange = CAS::EFocusRangeHyperfocal; |
|
3715 iAdvancedSettings->SetFocusRange( CAS::EFocusRangeHyperfocal ); |
|
3716 |
|
3717 // Then start the focus. The callback of this cancel request sets |
|
3718 // a boolean in CamAppController, so the resulting optimal |
|
3719 // focus event does not change reticule/focus state. |
|
3720 iAdvancedSettings->SetAutoFocusType( CAS::EAutoFocusTypeSingle ); |
|
3721 iAfInProgress = ETrue; |
|
3722 } |
|
3723 } |
|
3724 else if( ECamRequestSetAfRange == aRequestId ) |
|
3725 { |
|
3726 PRINT( _L("Camera <> Set autofocus range") ); |
|
3727 // Get autofocus mode from settings provider |
|
3728 |
|
3729 CAS::TFocusRange afRange; |
|
3730 iSettingProvider.ProvideCameraSettingL( ECameraSettingFocusRange, &afRange ); |
|
3731 |
|
3732 if( iInfo.iCurrentFocusRange != afRange ) |
|
3733 { |
|
3734 iAdvancedSettings->SetFocusRange( afRange ); |
|
3735 |
|
3736 // Should this be done in the callback?: |
|
3737 iInfo.iCurrentFocusRange = afRange; |
|
3738 } |
|
3739 else |
|
3740 { |
|
3741 // Correct range already set. No need to do anything. |
|
3742 } |
|
3743 } |
|
3744 else |
|
3745 { |
|
3746 // Other request must not end up here |
|
3747 __ASSERT_DEBUG( EFalse, Panic( ECamCameraControllerCorrupt ) ); |
|
3748 } |
|
3749 #endif // CAMERAAPP_CAPI_V2_ADV |
|
3750 |
|
3751 (void)aRequestId; // removes compiler warning |
|
3752 PRINT( _L("Camera <= CCamCameraController::ProcessAutofocusRequestL") ); |
|
3753 } |
|
3754 |
|
3755 |
|
3756 |
|
3757 // --------------------------------------------------------------------------- |
|
3758 // ProcessCaptureLimitSettingL |
|
3759 // --------------------------------------------------------------------------- |
|
3760 // |
|
3761 void |
|
3762 CCamCameraController::ProcessCaptureLimitSettingL() |
|
3763 { |
|
3764 PRINT ( _L("Camera => CCamCameraController::ProcessCaptureLimitSettingL") ); |
|
3765 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
3766 // Check that we are prepared for image mode. |
|
3767 CheckFlagOnL( iInfo.iState, ECamImageOn, KErrNotReady ); |
|
3768 |
|
3769 // Get requested capture count and determine current and target drive modes. |
|
3770 TInt requestedLimit( 1 ); |
|
3771 iSettingProvider.ProvideCameraSettingL( ECameraSettingCaptureLimit, &requestedLimit ); |
|
3772 if( requestedLimit < 1 ) User::Leave( KErrArgument ); |
|
3773 |
|
3774 const CAS::TDriveMode& currentMode( iAdvancedSettings->DriveMode() ); |
|
3775 const CAS::TDriveMode targetMode ( requestedLimit <= 1 |
|
3776 ? CAS::EDriveModeSingleShot |
|
3777 : CAS::EDriveModeBurst ); |
|
3778 const TInt cameraLimit( iAdvancedSettings->BurstImages() ); |
|
3779 |
|
3780 PRINT ( _L("Camera <> CCamCameraController .. --------------------------------------") ); |
|
3781 PRINT1( _L("Camera <> CCamCameraController .. requested capture limit %04d"), requestedLimit ); |
|
3782 PRINT1( _L("Camera <> CCamCameraController .. current capture limit : %04d"), iInfo.iCaptureLimit ); |
|
3783 PRINT1( _L("Camera <> CCamCameraController .. current camera's limit : %04d"), cameraLimit ); |
|
3784 PRINT1( _L("Camera <> CCamCameraController .. current capture count : %04d"), iInfo.iCaptureCount ); |
|
3785 PRINT1( _L("Camera <> CCamCameraController .. current snapshot count : %04d"), iInfo.iSnapshotCount ); |
|
3786 PRINT1( _L("Camera <> CCamCameraController .. current drive mode : [%S]"), &DriveModeName( currentMode ) ); |
|
3787 PRINT1( _L("Camera <> CCamCameraController .. target drive mode : [%S]"), &DriveModeName( targetMode ) ); |
|
3788 PRINT ( _L("Camera <> CCamCameraController .. --------------------------------------") ); |
|
3789 |
|
3790 // ------------------------------------------------------- |
|
3791 // Determine needed changes and when to issue them |
|
3792 // |
|
3793 // During burst capture, we may receive snapshots and |
|
3794 // image data on mixed order, e.g: |
|
3795 // |
|
3796 // [ ss#1 | img#1 | ss#2 | ss#3 | img2 | img3 ] |
|
3797 // --------------^^--------------------------^^ |
|
3798 // |
|
3799 // C-API starts new burst capture when we adjust the |
|
3800 // capture limit. To avoid problems and to get equal |
|
3801 // amount of snapshots and images, capture count is |
|
3802 // only changed when we image data is received, |
|
3803 // and as many images as snapshots have arrived. |
|
3804 // In the chart above ^ marks a place where capture limit |
|
3805 // can be updated. |
|
3806 TBool callback( EFalse ); |
|
3807 |
|
3808 // ----------------------------------- |
|
3809 // Capture ongoing.. |
|
3810 if( ECamCaptureOn == iInfo.iCaptureState ) |
|
3811 { |
|
3812 PRINT( _L("Camera <> CCamCameraController .. Capture ongoing..") ); |
|
3813 if( targetMode != currentMode ) |
|
3814 { |
|
3815 // Cannot change drive mode during capturing. |
|
3816 PRINT( _L("Camera <> CCamCameraController .. Drive mode update not possible now, LEAVE!") ); |
|
3817 User::Leave( KErrInUse ); |
|
3818 } |
|
3819 else if ( CAS::EDriveModeBurst == currentMode ) |
|
3820 { |
|
3821 if( cameraLimit != requestedLimit ) |
|
3822 { |
|
3823 PRINT( _L("Camera <> CCamCameraController .. Adjusting capture limit during burst..") ); |
|
3824 // Set limit locally and react on next image data event. |
|
3825 iInfo.iCaptureLimit = Min( cameraLimit, Max( requestedLimit, iInfo.iCaptureCount+1 ) ); |
|
3826 PRINT1( _L("Camera <> CCamCameraController .. Set local capture limit to %d.."), iInfo.iCaptureLimit ); |
|
3827 } |
|
3828 else |
|
3829 { |
|
3830 PRINT( _L("Camera <> CCamCameraController .. Capture limit during burst already has right value.") ); |
|
3831 } |
|
3832 } |
|
3833 else |
|
3834 { |
|
3835 // No action needed. Capture limit of 1 image kept. |
|
3836 PRINT( _L("Camera <> CCamCameraController .. Single shot mode kept, no action") ); |
|
3837 } |
|
3838 } |
|
3839 // ----------------------------------- |
|
3840 // Not capturing |
|
3841 // |
|
3842 else |
|
3843 { |
|
3844 PRINT( _L("Camera <> CCamCameraController .. No capture ongoing..") ); |
|
3845 |
|
3846 iInfo.iCaptureLimit = requestedLimit; |
|
3847 // Capture limit has changed, |
|
3848 // check if drive mode also needs to be changed.. |
|
3849 if( targetMode != currentMode ) |
|
3850 { |
|
3851 PRINT1( _L("Camera <> CCamCameraController .. Calling SetDriveMode([%S])"), &DriveModeName( targetMode ) ); |
|
3852 iAdvancedSettings->SetDriveMode( targetMode ); |
|
3853 } |
|
3854 if( CAS::EDriveModeBurst == targetMode ) |
|
3855 { |
|
3856 PRINT1( _L("Camera <> CCamCameraController .. Calling SetBurstImages(%d).."), iInfo.iCaptureLimit ); |
|
3857 iAdvancedSettings->SetBurstImages( iInfo.iCaptureLimit ); |
|
3858 } |
|
3859 } |
|
3860 |
|
3861 // ------------------------------------------------------- |
|
3862 // Notify user that the change is done |
|
3863 // or wait for camera callbacks to finish. |
|
3864 PRINT1( _L("Camera <> CCamCameraController .. Should wait callback = %d"), callback ); |
|
3865 if( !callback ) |
|
3866 { |
|
3867 TInt setting( ECameraSettingCaptureLimit ); |
|
3868 NotifyObservers( KErrNone, |
|
3869 ECamCameraEventSettingsSingle, |
|
3870 ECamCameraEventClassSettings, |
|
3871 &setting ); |
|
3872 } |
|
3873 #else |
|
3874 User::Leave( KErrNotSupported ); |
|
3875 #endif // CAMERAAPP_CAPI_V2_ADV |
|
3876 PRINT ( _L("Camera <= CCamCameraController::ProcessCaptureLimitSettingL") ); |
|
3877 } |
|
3878 |
|
3879 |
|
3880 |
|
3881 // --------------------------------------------------------------------------- |
|
3882 // EndSequence |
|
3883 // --------------------------------------------------------------------------- |
|
3884 // |
|
3885 void |
|
3886 CCamCameraController::EndSequence( TInt aStatus ) |
|
3887 { |
|
3888 PRINT1( _L("Camera => CCamCameraController::EndSequence, status:%d"), aStatus ); |
|
3889 |
|
3890 iIveRecoveryOngoing = EFalse; |
|
3891 #ifdef CAMERAAPP_CAE_FIX |
|
3892 if( ECamModeChangeInactive != iModeChange ) |
|
3893 { |
|
3894 PRINT( _L("Camera <> mode change not cleared, PANIC!!") ); |
|
3895 Panic( ECamCameraControllerUnrecovableError ); |
|
3896 } |
|
3897 #endif // CAMERAAPP_CAE_FIX |
|
3898 // ------------------------------------------------------- |
|
3899 if( IsFlagOn( iInfo.iBusy, ECamBusySequence ) ) |
|
3900 { |
|
3901 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestNone ); |
|
3902 |
|
3903 PRINT( _L("Camera <> ending sequence..") ); |
|
3904 ClearRequestQueue(); |
|
3905 iReserveTryAgainCount = KCamReserveTryAgainMaxCount; |
|
3906 |
|
3907 |
|
3908 // Need to first clear busy flag as observer might issue |
|
3909 // new requests in notification callback. |
|
3910 ClearFlags( iInfo.iBusy, ECamBusySequence ); |
|
3911 |
|
3912 PRINT( _L("Camera <> send notification..") ); |
|
3913 NotifyObservers( aStatus, |
|
3914 ECamCameraEventSequenceEnd, |
|
3915 ECamCameraEventClassBasicControl ); |
|
3916 } |
|
3917 // ------------------------------------------------------- |
|
3918 else if( IsFlagOn( iInfo.iBusy, ECamBusySetting ) ) |
|
3919 { |
|
3920 PRINT( _L("Camera <> ending settings handling..") ); |
|
3921 |
|
3922 |
|
3923 TCamCameraSettingId last( ECameraSettingNone ); |
|
3924 if( KErrNone != aStatus ) |
|
3925 { |
|
3926 if( Rng( 0, iSettingIndex, iSettingArray.Count()-1 ) ) |
|
3927 { |
|
3928 last = iSettingArray[iSettingIndex]; |
|
3929 } |
|
3930 } |
|
3931 ClearSettingQueue(); |
|
3932 |
|
3933 ClearFlags( iInfo.iBusy, ECamBusySetting ); |
|
3934 |
|
3935 NotifyObservers( aStatus, |
|
3936 ECamCameraEventSettingsDone, |
|
3937 ECamCameraEventClassSettings, |
|
3938 &last ); |
|
3939 } |
|
3940 // ------------------------------------------------------- |
|
3941 else |
|
3942 { |
|
3943 PRINT( _L("Camera <> No active operation, no action needed") ); |
|
3944 } |
|
3945 // ------------------------------------------------------- |
|
3946 PRINT( _L("Camera <= CCamCameraController::EndSequence") ); |
|
3947 } |
|
3948 |
|
3949 |
|
3950 |
|
3951 // --------------------------------------------------------------------------- |
|
3952 // ClearRequestQueue |
|
3953 // --------------------------------------------------------------------------- |
|
3954 // |
|
3955 void |
|
3956 CCamCameraController::ClearRequestQueue() |
|
3957 { |
|
3958 iSequenceArray.Reset(); |
|
3959 iSequenceIndex = -1; |
|
3960 } |
|
3961 |
|
3962 // --------------------------------------------------------------------------- |
|
3963 // ClearSettingQueue |
|
3964 // --------------------------------------------------------------------------- |
|
3965 // |
|
3966 void |
|
3967 CCamCameraController::ClearSettingQueue() |
|
3968 { |
|
3969 iSettingArray.Reset(); |
|
3970 iSettingIndex = -1; |
|
3971 } |
|
3972 |
|
3973 |
|
3974 |
|
3975 |
|
3976 // --------------------------------------------------------------------------- |
|
3977 // HandlePowerOnEvent |
|
3978 // --------------------------------------------------------------------------- |
|
3979 // |
|
3980 void |
|
3981 CCamCameraController::HandlePowerOnEvent( TInt aStatus ) |
|
3982 { |
|
3983 PRINT1( _L("Camera => CCamCameraController::HandlePowerOnEvent, status:%d"), aStatus ); |
|
3984 |
|
3985 // We should be blocking new request at the moment. |
|
3986 __ASSERT_DEBUG( iInfo.iBusy, Panic( ECamCameraControllerCorrupt ) ); |
|
3987 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestPowerOn ); |
|
3988 |
|
3989 OstTrace0( CAMERAAPP_PERFORMANCE, CCAMCAMERACONTROLLER_HANDLEPOWERONEVENT, "e_CAM_APP_INIT 0" ); //CCORAPP_APP_INIT_END |
|
3990 OstTrace0( CAMERAAPP_PERFORMANCE, DUP1_CCAMCAMERACONTROLLER_HANDLEPOWERONEVENT, "e_CAM_APP_VF_INIT 1" ); //CCORAPP_APP_VF_INIT_START |
|
3991 OstTrace0( CAMERAAPP_PERFORMANCE, DUP2_CCAMCAMERACONTROLLER_HANDLEPOWERONEVENT, "e_CAM_APP_CONFIGURATIONS 1" ); //CCORAPP_APP_CONFIGS_START |
|
3992 OstTrace0( CAMERAAPP_PERFORMANCE, DUP3_CCAMCAMERACONTROLLER_HANDLEPOWERONEVENT, "e_CAM_APP_STILL_INIT 1" ); //CCORAPP_APP_STILL_INIT_START |
|
3993 |
|
3994 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
3995 |
|
3996 if ( appUi->AppController().UiConfigManagerPtr()->IsFaceTrackingSupported() ) |
|
3997 { |
|
3998 PRINT( _L("Camera <> CCamAppController: Get i/f MCameraFaceTracking..") ) |
|
3999 iCustomInterfaceFaceTracking = |
|
4000 static_cast <MCameraFaceTracking*>( |
|
4001 iCamera->CustomInterface( KCameraFaceTrackingUid ) ); |
|
4002 PRINT1( _L("Camera <> Face Tracking custom i/f pointer:%d"), iCustomInterfaceFaceTracking ); |
|
4003 } |
|
4004 |
|
4005 if( KErrNone == aStatus ) |
|
4006 { |
|
4007 SetFlags( iInfo.iState, ECamPowerOn|ECamReserved ); |
|
4008 |
|
4009 TRAP_IGNORE( SetFaceTrackingL() ); |
|
4010 #if defined( CAMERAAPP_CAE_FOR_VIDEO ) && !defined( CAMERAAPP_CAE_FIX ) |
|
4011 // We need to tell to CCaeEngine that the CCamera has been reserved |
|
4012 // and powered on "behind its back". |
|
4013 if( iCaeEngine ) |
|
4014 { |
|
4015 iCaeEngine->EnableVideoRecording(); |
|
4016 } |
|
4017 #endif |
|
4018 } |
|
4019 else |
|
4020 { |
|
4021 ClearFlags( iInfo.iState, ECamPowerOn ); |
|
4022 } |
|
4023 |
|
4024 #ifdef CAMERAAPP_CAE_FIX |
|
4025 if( ECamModeChangeVideo2Image == iModeChange ) |
|
4026 { |
|
4027 if( ECamModeChangePhase2 == iModeChangePhase ) |
|
4028 { |
|
4029 // We have called CCamera::PowerOn in phase2 |
|
4030 PRINT( _L("Camera <> mode change image->video ongoing, continue") ); |
|
4031 iModeChangeStatus = aStatus; |
|
4032 // Handle repeative events before iActive gets to run. |
|
4033 if( !iActive->IsActive() ) |
|
4034 iActive->IssueRequest(); |
|
4035 } |
|
4036 } |
|
4037 else if( ECamModeChangeImage2Video == iModeChange ) |
|
4038 { |
|
4039 if( ECamModeChangePhase1 == iModeChangePhase ) |
|
4040 { |
|
4041 // We have called CCaeEngine::InitL in phase1 |
|
4042 PRINT( _L("Camera <> mode change image->video ongoing, continue") ); |
|
4043 iModeChangeStatus = aStatus; |
|
4044 // Handle repeative events before iActive gets to run. |
|
4045 if( !iActive->IsActive() ) |
|
4046 iActive->IssueRequest(); |
|
4047 } |
|
4048 } |
|
4049 else |
|
4050 { |
|
4051 PRINT( _L("Camera <> no mode change ongoing") ); |
|
4052 HandleCallbackEvent( aStatus, |
|
4053 ECamCameraEventPowerOn, |
|
4054 ECamCameraEventClassBasicControl ); |
|
4055 } |
|
4056 #else |
|
4057 |
|
4058 HandleCallbackEvent( aStatus, |
|
4059 ECamCameraEventPowerOn, |
|
4060 ECamCameraEventClassBasicControl ); |
|
4061 |
|
4062 #endif // CAMERAAPP_CAE_FIX |
|
4063 |
|
4064 if ( appUi->AppController().UiConfigManagerPtr()->IsOrientationSensorSupported() ) |
|
4065 { |
|
4066 PRINT( _L("Camera <> CCamCameraController: Get i/f MCameraOrientation..") ) |
|
4067 |
|
4068 if(!iCustomInterfaceOrientation ) |
|
4069 { |
|
4070 iCustomInterfaceOrientation = |
|
4071 static_cast <MCameraOrientation*>( |
|
4072 iCamera->CustomInterface( KCameraOrientationUid ) ); |
|
4073 } |
|
4074 |
|
4075 PRINT1( _L("Camera <> Orientation custom i/f pointer:%d"), iCustomInterfaceOrientation ); |
|
4076 } |
|
4077 |
|
4078 PRINT( _L("Camera <= CCamCameraController::HandlePowerOnEvent") ); |
|
4079 } |
|
4080 |
|
4081 // --------------------------------------------------------------------------- |
|
4082 // HandleReserveGainEvent |
|
4083 // --------------------------------------------------------------------------- |
|
4084 // |
|
4085 void |
|
4086 CCamCameraController::HandleReserveGainEvent( TInt aStatus ) |
|
4087 { |
|
4088 PRINT1( _L("Camera => CCamCameraController::HandleReserveGainEvent, status:%d"), aStatus ); |
|
4089 if( iIdle && iIdle->IsActive() ) |
|
4090 { |
|
4091 PRINT( _L("Camera => CCamCameraController::HandleReserveGainEvent - return, recovery in progress")); |
|
4092 return; |
|
4093 } |
|
4094 // We should be blocking new request at the moment. |
|
4095 __ASSERT_DEBUG( iInfo.iBusy, Panic( ECamCameraControllerCorrupt ) ); |
|
4096 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestReserve ); |
|
4097 |
|
4098 if( KErrNone == aStatus ) SetFlags ( iInfo.iState, ECamReserved ); |
|
4099 else ClearFlags( iInfo.iState, ECamReserved ); |
|
4100 |
|
4101 #ifdef CAMERAAPP_CAE_FIX |
|
4102 if( ECamModeChangeVideo2Image == iModeChange ) |
|
4103 { |
|
4104 if( ECamModeChangePhase1 == iModeChangePhase ) |
|
4105 { |
|
4106 // We have called CCamera::Reserve in phase1 |
|
4107 PRINT( _L("Camera <> mode change video->image ongoing, continue") ); |
|
4108 iModeChangeStatus = aStatus; |
|
4109 // Handle repeative events before iActive gets to run. |
|
4110 if( !iActive->IsActive() ) |
|
4111 iActive->IssueRequest(); |
|
4112 } |
|
4113 } |
|
4114 else if( ECamModeChangeImage2Video == iModeChange ) |
|
4115 { |
|
4116 // No action yet, wait for power on event |
|
4117 PRINT( _L("Camera <> mode change image->video ongoing, waiting for power on event") ); |
|
4118 } |
|
4119 else |
|
4120 { |
|
4121 PRINT( _L("Camera <> no mode change ongoing") ); |
|
4122 HandleCallbackEvent( aStatus, |
|
4123 ECamCameraEventReserveGain, |
|
4124 ECamCameraEventClassBasicControl ); |
|
4125 } |
|
4126 #else |
|
4127 HandleCallbackEvent( aStatus, |
|
4128 ECamCameraEventReserveGain, |
|
4129 ECamCameraEventClassBasicControl ); |
|
4130 #endif // CAMERAAPP_CAE_FIX |
|
4131 PRINT( _L("Camera <= CCamCameraController::HandleReserveGainEvent") ); |
|
4132 } |
|
4133 |
|
4134 |
|
4135 |
|
4136 // --------------------------------------------------------------------------- |
|
4137 // HandleReserveLostEvent |
|
4138 // --------------------------------------------------------------------------- |
|
4139 // |
|
4140 void |
|
4141 CCamCameraController::HandleReserveLostEvent( TInt aStatus ) |
|
4142 { |
|
4143 PRINT1( _L("Camera => CCamCameraController::HandleReserveLostEvent, status:%d"), aStatus ); |
|
4144 iInfo.iState = ECamIdle; |
|
4145 iInfo.iVfState = ECamTriIdle; |
|
4146 iInfo.iSsState = ECamTriIdle; |
|
4147 |
|
4148 #pragma message("CCamCameraController: Reserve lost event does not stop sequence") |
|
4149 |
|
4150 // These are not valid anymore. |
|
4151 ReleaseCustomInterfaces(); |
|
4152 |
|
4153 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
4154 // ------------------------------------------------------- |
|
4155 #ifdef CAMERAAPP_CAE_FIX |
|
4156 #ifdef CAMERAAPP_CAPI_V2 |
|
4157 if( ECamModeChangeVideo2Image == iModeChange ) |
|
4158 { |
|
4159 // ignore |
|
4160 } |
|
4161 else if( ECamModeChangeImage2Video == iModeChange ) |
|
4162 { |
|
4163 // ignore |
|
4164 } |
|
4165 else |
|
4166 #endif // CAMERAAPP_CAPI_V2 |
|
4167 { |
|
4168 PRINT( _L("Camera <> no mode change ongoing") ); |
|
4169 NotifyObservers( aStatus, |
|
4170 ECamCameraEventReserveLose, |
|
4171 ECamCameraEventClassBasicControl ); |
|
4172 } |
|
4173 |
|
4174 #else // CAMERAAPP_CAE_FIX |
|
4175 /* |
|
4176 // We need to tell to CCaeEngine that the CCamera |
|
4177 // has been released "behind its back". |
|
4178 if( iCaeEngine ) |
|
4179 { |
|
4180 iCaeEngine->DisableVideoRecording(); |
|
4181 } |
|
4182 */ |
|
4183 #endif // CAMERAAPP_CAE_FIX |
|
4184 // ------------------------------------------------------- |
|
4185 #else |
|
4186 |
|
4187 NotifyObservers( aStatus, |
|
4188 ECamCameraEventReserveLose, |
|
4189 ECamCameraEventClassBasicControl ); |
|
4190 // ------------------------------------------------------- |
|
4191 #endif // CAMERAAPP_CAE_FOR_VIDEO |
|
4192 |
|
4193 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
4194 TInt err = KErrNone; |
|
4195 if( !iIdle ) |
|
4196 { |
|
4197 TRAP( err, iIdle = CIdle::NewL( CActive::EPriorityIdle ) ); |
|
4198 } |
|
4199 |
|
4200 PRINT1( _L("Camera <> CCamCameraController::HandleReserveLostEvent iIveRecoveryOngoing = %d"), iIveRecoveryOngoing ); |
|
4201 if ( !err && iIdle && !iIdle->IsActive() && // Recovering already |
|
4202 iAppController.IsAppUiAvailable() && // Exit mode |
|
4203 iIveRecoveryCount && // Give up eventually |
|
4204 !appUi->AppInBackground( EFalse ) && // Only if on the foreground |
|
4205 ( !iReleasedByUi || // Try recover if unknown reason |
|
4206 appUi->StandbyStatus() ) && // or known error |
|
4207 !iAppController.InVideocallOrRinging() && // Video telephony parallel use case |
|
4208 !iIveRecoveryOngoing // processing recovery sequence |
|
4209 ) |
|
4210 { |
|
4211 PRINT( _L("Camera <> CCamCameraController::HandleReserveLostEvent - Start recovery") ); |
|
4212 NotifyObservers( aStatus, |
|
4213 ECamCameraEventReserveLose, |
|
4214 ECamCameraEventClassBasicControl ); |
|
4215 iIdle->Start( TCallBack( IdleCallback, this ) ); |
|
4216 } |
|
4217 PRINT( _L("Camera <= CCamCameraController::HandleReserveLostEvent") ); |
|
4218 } |
|
4219 |
|
4220 // --------------------------------------------------------------------------- |
|
4221 // HandleViewfinderEvent |
|
4222 // --------------------------------------------------------------------------- |
|
4223 // |
|
4224 void |
|
4225 CCamCameraController::HandleViewfinderEvent( MCameraBuffer* aCameraBuffer, |
|
4226 TInt aStatus ) |
|
4227 { |
|
4228 PRINT_FRQ1( _L("Camera => CCamCameraController::HandleViewfinderEvent, status in:%d"), aStatus ); |
|
4229 |
|
4230 CAMERAAPP_PERF_CONTROLLER_STOP_ONCE( ECamRequestVfStart, iFirstVfFrameReceived ); |
|
4231 |
|
4232 CFbsBitmap* vfFrame = NULL; |
|
4233 |
|
4234 if( KErrNone == aStatus ) |
|
4235 { |
|
4236 __ASSERT_ALWAYS( aCameraBuffer, Panic( ECamCameraControllerCorrupt ) ); |
|
4237 |
|
4238 PRINT_FRQ( _L("Camera <> get new one..") ); |
|
4239 TRAP( aStatus, |
|
4240 { |
|
4241 vfFrame = &(aCameraBuffer->BitmapL( 0 )); |
|
4242 }); |
|
4243 PRINT_FRQ1( _L("Camera <> ..status after getting bitmap data: %d"), aStatus ); |
|
4244 } |
|
4245 |
|
4246 NotifyObservers( aStatus, |
|
4247 ECamCameraEventVfFrameReady, |
|
4248 ECamCameraEventClassVfData, |
|
4249 vfFrame ); |
|
4250 |
|
4251 ReleaseAndNull( aCameraBuffer ); |
|
4252 |
|
4253 PRINT_FRQ( _L("Camera <= CCamCameraController::HandleViewfinderEvent") ); |
|
4254 } |
|
4255 |
|
4256 |
|
4257 // --------------------------------------------------------------------------- |
|
4258 // HandleImageCaptureEvent |
|
4259 // --------------------------------------------------------------------------- |
|
4260 // |
|
4261 void |
|
4262 CCamCameraController::HandleImageCaptureEvent( MCameraBuffer* aCameraBuffer, |
|
4263 TInt aStatus ) |
|
4264 { |
|
4265 PRINT1( _L("Camera => CCamCameraController::HandleImageCaptureEvent, status in: %d"), aStatus ); |
|
4266 |
|
4267 |
|
4268 // Check that we are expecting images.. |
|
4269 if( ECamCaptureOn == iInfo.iCaptureState ) |
|
4270 { |
|
4271 // Store flags |
|
4272 TUint busyFlags( iInfo.iBusy ); |
|
4273 |
|
4274 // ----------------------------------------------------- |
|
4275 // Try to get the image data. |
|
4276 if( KErrNone == aStatus ) |
|
4277 { |
|
4278 // Takes ownership of aCameraBuffer and NULLs the pointer. |
|
4279 TRAP( aStatus, HandleImageCaptureEventL( aCameraBuffer ) ); |
|
4280 PRINT1( _L("Camera <> status after handling data: %d"), aStatus ); |
|
4281 } |
|
4282 |
|
4283 // Release if not NULLed in HandleImageCaptureEventL. |
|
4284 ReleaseAndNull( aCameraBuffer ); |
|
4285 |
|
4286 // ----------------------------------------------------- |
|
4287 // Errors in or in handling |
|
4288 if( KErrNone != aStatus ) |
|
4289 { |
|
4290 PRINT( _L("Camera <> CCamCameraController ... [WARNING] error in image data event!") ); |
|
4291 iInfo.PrintInfo(); |
|
4292 |
|
4293 iInfo.iCaptureState = ECamCaptureOff; |
|
4294 |
|
4295 // See HandleCallbackEvent for comments. |
|
4296 // ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
4297 |
|
4298 NotifyObservers( aStatus, |
|
4299 ECamCameraEventImageData, |
|
4300 ECamCameraEventClassImage ); |
|
4301 } |
|
4302 // ----------------------------------------------------- |
|
4303 |
|
4304 // If capture state was just changed to OFF, |
|
4305 // send notification that capture has fully completed. |
|
4306 if( ECamCaptureOff == iInfo.iCaptureState ) |
|
4307 { |
|
4308 // See HandleCallbackEvent for comments. |
|
4309 ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
4310 |
|
4311 TInt fullCaptures( Min( iInfo.iCaptureCount, iInfo.iSnapshotCount ) ); |
|
4312 NotifyObservers( aStatus, |
|
4313 ECamCameraEventImageStop, |
|
4314 ECamCameraEventClassImage, |
|
4315 &fullCaptures ); |
|
4316 |
|
4317 // Now we can actually continue, if necessary. |
|
4318 if( IsFlagOn( busyFlags, ECamBusySequence ) ) |
|
4319 { |
|
4320 __ASSERT_DEBUG( iActive, Panic( ECamCameraControllerCorrupt ) ); |
|
4321 iActive->IssueRequest(); |
|
4322 } |
|
4323 } |
|
4324 } |
|
4325 else |
|
4326 { |
|
4327 PRINT( _L("Camera <> CCamCameraController ... [WARNING] Unexpected image data event!") ); |
|
4328 iInfo.PrintInfo(); |
|
4329 |
|
4330 // Stop capture to be safe. |
|
4331 PRINT( _L("Camera <> CCamCameraController ... Calling CancelCaptureImage..") ); |
|
4332 iCamera->CancelCaptureImage(); |
|
4333 |
|
4334 // Not expecting image data at this time. |
|
4335 // Release the buffer and ignore event. |
|
4336 ReleaseAndNull( aCameraBuffer ); |
|
4337 } |
|
4338 PRINT( _L("Camera <= CCamCameraController::HandleImageCaptureEvent") ); |
|
4339 } |
|
4340 |
|
4341 // --------------------------------------------------------------------------- |
|
4342 // HandleImageCaptureEventL |
|
4343 // --------------------------------------------------------------------------- |
|
4344 // |
|
4345 void |
|
4346 CCamCameraController::HandleImageCaptureEventL( MCameraBuffer*& aCameraBuffer ) |
|
4347 { |
|
4348 PRINT( _L("Camera => CCamCameraController::HandleImageCaptureEventL") ); |
|
4349 CheckNonNullL( aCameraBuffer, KErrNotFound ); |
|
4350 |
|
4351 MCameraBuffer* temp = aCameraBuffer; |
|
4352 aCameraBuffer = NULL; // ownership taken |
|
4353 |
|
4354 PRINT( _L("Camera <> Wrap MCameraBuffer to sharable..") ); |
|
4355 CleanupStack::PushL( TCleanupItem( CameraBufferCleanup, temp ) ); |
|
4356 CCamBufferShare* share = new (ELeave) CCamBufferShare( temp ); |
|
4357 CleanupStack::Pop(); // cleanup item |
|
4358 temp = NULL; // ownership to share |
|
4359 |
|
4360 share->Reserve(); |
|
4361 CleanupStack::PushL( TCleanupItem( CamBufferShareCleanup, share ) ); |
|
4362 |
|
4363 PRINT( _L("Camera <> CCamCameraController .. Checking encoded data availability..") ); |
|
4364 TRAPD( dataStatus, |
|
4365 { |
|
4366 TDesC8* data = share->SharedBuffer()->DataL( 0 ); |
|
4367 if( !data ) |
|
4368 User::Leave( KErrNotFound ); |
|
4369 }); |
|
4370 |
|
4371 // ------------------------------------------------------- |
|
4372 // Normal capture format case |
|
4373 if( KErrNone == dataStatus ) |
|
4374 { |
|
4375 PRINT( _L("Camera <> CCamCameraController .. Normal, encoded capture format found..") ); |
|
4376 |
|
4377 // Increase received images count. Needed in burst drive mode. |
|
4378 iInfo.iCaptureCount++; |
|
4379 PRINT1( _L("Camera <> CCamCameraController ... Incremented capture counter to: %d"), iInfo.iCaptureCount ); |
|
4380 |
|
4381 // If we have needed amount of snapshots and images, end capture. |
|
4382 if( iInfo.iCaptureCount >= iInfo.iCaptureLimit |
|
4383 && ( (iInfo.iSnapshotCount >= iInfo.iCaptureLimit) || iInfo.iSsState != ECamTriActive ) ) |
|
4384 { |
|
4385 PRINT( _L("Camera <> CCamCameraController ... Capture limit met, calling CancelCaptureImage..") ); |
|
4386 iCamera->CancelCaptureImage(); |
|
4387 |
|
4388 PRINT( _L("Camera <> CCamCameraController ... Setting capture state to OFF..") ); |
|
4389 iInfo.iCaptureState = ECamCaptureOff; |
|
4390 } |
|
4391 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
4392 // If we are in burst mode and need to increase capture limit, |
|
4393 // do it now. If we have just decreased the capture limit, |
|
4394 // we just cancel once the limit is met. |
|
4395 else if( iAdvancedSettings |
|
4396 && iAdvancedSettings->DriveMode() == CAS::EDriveModeBurst ) |
|
4397 { |
|
4398 const TInt cameraLimit( iAdvancedSettings->BurstImages() ); |
|
4399 |
|
4400 PRINT1( _L("Camera <> CCamCameraController ... Camera capture limit: %d"), cameraLimit ); |
|
4401 PRINT1( _L("Camera <> CCamCameraController ... Local capture limit: %d"), iInfo.iCaptureLimit ); |
|
4402 |
|
4403 if( cameraLimit < iInfo.iCaptureLimit ) |
|
4404 { |
|
4405 TInt startedCaptures = Max( iInfo.iSnapshotCount, iInfo.iCaptureCount ); |
|
4406 iInfo.iCaptureLimit = Max( iInfo.iCaptureLimit, startedCaptures+1 ); |
|
4407 |
|
4408 PRINT1( _L("Camera <> CCamCameraController ... Pending capture limit increase, calling SetBurstImages(%d).."), iInfo.iCaptureLimit ); |
|
4409 iAdvancedSettings->SetBurstImages( iInfo.iCaptureLimit ); |
|
4410 } |
|
4411 } |
|
4412 #endif // CAMERAAPP_CAPI_V2_ADV |
|
4413 // Normal, single capture. |
|
4414 else |
|
4415 { |
|
4416 } |
|
4417 |
|
4418 // See HandleCallbackEvent for comments. |
|
4419 // ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
4420 |
|
4421 NotifyObservers( KErrNone, |
|
4422 ECamCameraEventImageData, |
|
4423 ECamCameraEventClassImage, |
|
4424 share ); |
|
4425 } |
|
4426 // ------------------------------------------------------- |
|
4427 // Bitmap format case. Need to encode first. |
|
4428 else if( iAlternateFormatInUse ) |
|
4429 { |
|
4430 PRINT( _L("Camera <> Bitmap alternative capture format in use..") ); |
|
4431 // NOTE: We get another callback with encoded image data |
|
4432 // once encoder has done the conversion. |
|
4433 PRINT( _L("Camera <> CCamCameraController ... Starting jpeg encoding..") ); |
|
4434 if( !iEncoder ) iEncoder = CCamImageEncoder::NewL( *this ); |
|
4435 |
|
4436 // Encoder needs to call Reserve |
|
4437 iEncoder->StartConversionL( share ); |
|
4438 } |
|
4439 // ------------------------------------------------------- |
|
4440 // Encoded data missing although expected. |
|
4441 else |
|
4442 { |
|
4443 User::Leave( dataStatus ); |
|
4444 } |
|
4445 // ----------------------------------------------------- |
|
4446 CleanupStack::PopAndDestroy(); // share->Release(); |
|
4447 share = NULL; |
|
4448 |
|
4449 PRINT( _L("Camera <= CCamCameraController::HandleImageCaptureEventL") ); |
|
4450 } |
|
4451 |
|
4452 |
|
4453 // --------------------------------------------------------------------------- |
|
4454 // HandleSnapshotEvent |
|
4455 // --------------------------------------------------------------------------- |
|
4456 // |
|
4457 void |
|
4458 CCamCameraController::HandleSnapshotEvent( TInt aStatus ) |
|
4459 { |
|
4460 PRINT( _L("Camera => CCamCameraController::HandleSnapshotEvent") ); |
|
4461 |
|
4462 // Check that we are in right state to handle snapshot. |
|
4463 // CCameraSnapshot sends atleast event with KErrCancel status |
|
4464 // when releasing the camera. |
|
4465 TBool videoSsExpected( IsFlagOn( iInfo.iState, ECamVideoOn ) ); |
|
4466 TBool imageSsExpected( IsFlagOn( iInfo.iState, ECamImageOn ) |
|
4467 && ECamCaptureOn == iInfo.iCaptureState |
|
4468 && iInfo.iSnapshotCount < iInfo.iCaptureLimit ); |
|
4469 |
|
4470 if( |
|
4471 #ifdef CAMERAAPP_CAE_FIX |
|
4472 ECamModeChangeInactive == iModeChange && |
|
4473 #endif |
|
4474 (videoSsExpected||imageSsExpected) |
|
4475 ) |
|
4476 { |
|
4477 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestSsStart ); |
|
4478 |
|
4479 // ----------------------------------------------------- |
|
4480 // Try to get snapshot data |
|
4481 if( KErrNone == aStatus ) |
|
4482 { |
|
4483 TRAP( aStatus, HandleSnapshotEventL() ); |
|
4484 PRINT1( _L("Camera <> CCamCameraController ... status after handling snapshot data: %d"), aStatus ); |
|
4485 } |
|
4486 |
|
4487 // ----------------------------------------------------- |
|
4488 // If snapshot was received and notified ok, |
|
4489 // check if capture ended. |
|
4490 if( KErrNone == aStatus ) |
|
4491 { |
|
4492 // If we have needed amount of snapshots and images, end capture. |
|
4493 if( iInfo.iCaptureCount >= iInfo.iCaptureLimit |
|
4494 && iInfo.iSnapshotCount >= iInfo.iCaptureLimit ) |
|
4495 { |
|
4496 PRINT( _L("Camera <> CCamCameraController ... Setting capture state to OFF..") ); |
|
4497 iInfo.iCaptureState = ECamCaptureOff; |
|
4498 } |
|
4499 } |
|
4500 // ----------------------------------------------------- |
|
4501 // If any error, stop capture. |
|
4502 else |
|
4503 { |
|
4504 PRINT( _L("Camera <> CCamCameraController ... error encountered, notify and set capture state off..") ); |
|
4505 NotifyObservers( aStatus, |
|
4506 ECamCameraEventSsReady, |
|
4507 ECamCameraEventClassSsData ); |
|
4508 iInfo.iCaptureState = ECamCaptureOff; |
|
4509 } |
|
4510 |
|
4511 // ----------------------------------------------------- |
|
4512 // Check if we have just completed the capture. |
|
4513 // Notify observers if so. |
|
4514 if( imageSsExpected |
|
4515 && ECamCaptureOff == iInfo.iCaptureState ) |
|
4516 { |
|
4517 // See HandleCallbackEvent for comments. |
|
4518 ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
4519 |
|
4520 TInt fullCaptures( Min( iInfo.iCaptureCount, iInfo.iSnapshotCount ) ); |
|
4521 NotifyObservers( aStatus, |
|
4522 ECamCameraEventImageStop, |
|
4523 ECamCameraEventClassImage, |
|
4524 &fullCaptures ); |
|
4525 } |
|
4526 // ----------------------------------------------------- |
|
4527 } |
|
4528 else |
|
4529 { |
|
4530 // Just retrieve and release camera buffer if snapshot is not expected |
|
4531 TRAP_IGNORE( HandleSnapshotEventL( ETrue ) ); |
|
4532 |
|
4533 if( iInfo.iSnapshotCount > iInfo.iCaptureLimit ) |
|
4534 { |
|
4535 // For burst stopping: |
|
4536 // We have more snapshots already than requested.. |
|
4537 // All needed captures have to have started, |
|
4538 // so we can call cancel here. |
|
4539 // Note: |
|
4540 // Cannot use ">=" as last image might not be provided then. |
|
4541 // |
|
4542 PRINT( _L("Camera <> CCamCameraController ... Snapshot limit passed, calling CancelCaptureImage..") ); |
|
4543 iCamera->CancelCaptureImage(); |
|
4544 } |
|
4545 |
|
4546 PRINT( _L("Camera <> CCamCameraController ... [WARNING] Snapshot ignored!") ); |
|
4547 iInfo.PrintInfo(); |
|
4548 } |
|
4549 |
|
4550 PRINT( _L("Camera <= CCamCameraController::HandleSnapshotEvent") ); |
|
4551 } |
|
4552 |
|
4553 |
|
4554 // --------------------------------------------------------------------------- |
|
4555 // HandleSnapshotEventL |
|
4556 // |
|
4557 // Helper method for leaving part of HandleSnapshotEvent. |
|
4558 // --------------------------------------------------------------------------- |
|
4559 // |
|
4560 void |
|
4561 CCamCameraController::HandleSnapshotEventL( TBool aIgnore ) |
|
4562 { |
|
4563 PRINT1( _L("Camera => CCamCameraController::HandleSnapshotEventL ignore %d"),aIgnore); |
|
4564 __ASSERT_DEBUG( iSnapshotProvider, Panic( ECamCameraControllerCorrupt ) ); |
|
4565 RArray<TInt> temp; |
|
4566 CleanupClosePushL( temp ); |
|
4567 MCameraBuffer* buffer( NULL ); |
|
4568 |
|
4569 buffer = &iSnapshotProvider->SnapshotDataL( temp ); |
|
4570 |
|
4571 TInt firstImageIndex = temp.Find( 0 ); |
|
4572 CleanupStack::PopAndDestroy(); // temp.Close() |
|
4573 |
|
4574 if( !aIgnore ) |
|
4575 { |
|
4576 |
|
4577 CleanupStack::PushL( TCleanupItem( CameraBufferCleanup, buffer ) ); |
|
4578 CFbsBitmap& snapshot = buffer->BitmapL( firstImageIndex ); |
|
4579 PRINT2( _L("Camera <> CCamCameraController ... snapshot size: (%dx%d)"), |
|
4580 snapshot.SizeInPixels().iWidth, snapshot.SizeInPixels().iHeight ); |
|
4581 |
|
4582 // Increase received snapshots count. |
|
4583 // Needed in burst drive mode. |
|
4584 iInfo.iSnapshotCount++; |
|
4585 PRINT1( _L("Camera <> CCamCameraController ... Incremented snapshot counter to: %d"), iInfo.iSnapshotCount ); |
|
4586 |
|
4587 // No leaving code after notification as otherwise |
|
4588 // HandleSnapshotEvent calling this method will notify clients again. |
|
4589 NotifyObservers( KErrNone, |
|
4590 ECamCameraEventSsReady, |
|
4591 ECamCameraEventClassSsData, |
|
4592 &snapshot ); |
|
4593 |
|
4594 CleanupStack::PopAndDestroy(); // buffer->Release() |
|
4595 } |
|
4596 else |
|
4597 { |
|
4598 ReleaseAndNull(buffer); |
|
4599 } |
|
4600 PRINT( _L("Camera <= CCamCameraController::HandleSnapshotEventL")); |
|
4601 } |
|
4602 |
|
4603 |
|
4604 |
|
4605 |
|
4606 // --------------------------------------------------------------------------- |
|
4607 // HandleVideoInitEvent |
|
4608 // --------------------------------------------------------------------------- |
|
4609 // |
|
4610 void |
|
4611 CCamCameraController::HandleVideoEvent( const TCamCameraEventId& aEventId, |
|
4612 TInt aStatus ) |
|
4613 { |
|
4614 PRINT2( _L("Camera => CCamCameraController::HandleVideoEvent, status:%d, event[%s]"), |
|
4615 aStatus, |
|
4616 KCamCameraEventNames[aEventId] ); |
|
4617 |
|
4618 // Only video stop of these events may come without our explicit request. |
|
4619 /* |
|
4620 if( ECamCameraEventVideoStop != aEventId ) |
|
4621 { |
|
4622 if( ECamBusyOff != iInfo.iBusy ) |
|
4623 Panic( ECamCameraControllerCorrupt ); |
|
4624 } |
|
4625 */ |
|
4626 |
|
4627 switch( aEventId ) |
|
4628 { |
|
4629 // ----------------------------------------------------- |
|
4630 case ECamCameraEventVideoInit: |
|
4631 // Some settings repeat this event if CCaeEngine in use. |
|
4632 if( !IsFlagOn( iInfo.iBusy, ECamBusySetting ) ) |
|
4633 { |
|
4634 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestVideoInit ); |
|
4635 if( KErrNone == aStatus ) SetFlags ( iInfo.iState, ECamVideoOn ); |
|
4636 else ClearFlags( iInfo.iState, ECamVideoOn ); |
|
4637 } |
|
4638 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
4639 TRAP_IGNORE( GetAdvancedSettingsInfoL() ); |
|
4640 #endif |
|
4641 #ifdef CAMERAAPP_CAE_FIX |
|
4642 if( ECamModeChangeImage2Video == iModeChange ) |
|
4643 { |
|
4644 iModeChangeStatus = aStatus; |
|
4645 iActive->IssueRequest(); |
|
4646 return; |
|
4647 } |
|
4648 #endif // CAMERAAPP_CAE_FIX |
|
4649 break; |
|
4650 // ----------------------------------------------------- |
|
4651 case ECamCameraEventVideoStart: |
|
4652 if( KErrNone == aStatus ) |
|
4653 { |
|
4654 iInfo.iCaptureState = ECamCaptureOn; |
|
4655 } |
|
4656 break; |
|
4657 // ----------------------------------------------------- |
|
4658 case ECamCameraEventVideoPause: |
|
4659 if( KErrNone == aStatus ) |
|
4660 { |
|
4661 iInfo.iCaptureState = ECamCapturePaused; |
|
4662 } |
|
4663 else |
|
4664 { |
|
4665 // Problem with pausing. |
|
4666 // Keep our capture state unchanged. |
|
4667 } |
|
4668 break; |
|
4669 // ----------------------------------------------------- |
|
4670 case ECamCameraEventVideoStop: |
|
4671 // Even if error we have done what we can for stopping. |
|
4672 // Update internal capture state anyway. |
|
4673 iInfo.iCaptureState = ECamCaptureOff; |
|
4674 // We may receive this event from CCaeEngine, even though we have not |
|
4675 // issued a request to stop the video recording. If e.g. there is not |
|
4676 // enough space in the disk to continue recording, this event is |
|
4677 // generated without explicit request. |
|
4678 // |
|
4679 // We must not continue any pending operations if this event is not |
|
4680 // a response to our stop request. |
|
4681 // HandleCallbackEvent takes care of that. |
|
4682 break; |
|
4683 // ----------------------------------------------------- |
|
4684 case ECamCameraEventVideoAsyncStop: |
|
4685 PRINT( _L("Camera <> CCamCameraController::HandleVideoEvent case ECamCameraEventVideoAsyncStop") ); |
|
4686 // Do not change state, just play sound later |
|
4687 break; |
|
4688 // ----------------------------------------------------- |
|
4689 default: |
|
4690 { |
|
4691 Panic( ECamCameraControllerCorrupt ); |
|
4692 break; |
|
4693 } |
|
4694 // ----------------------------------------------------- |
|
4695 } |
|
4696 |
|
4697 HandleCallbackEvent( aStatus, |
|
4698 aEventId, |
|
4699 ECamCameraEventClassVideo ); |
|
4700 PRINT( _L("Camera <= CCamCameraController::HandleVideoEvent") ); |
|
4701 } |
|
4702 |
|
4703 |
|
4704 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
4705 // --------------------------------------------------------------------------- |
|
4706 // HandleVideoTimeEvent |
|
4707 // --------------------------------------------------------------------------- |
|
4708 // |
|
4709 void |
|
4710 CCamCameraController |
|
4711 ::HandleVideoTimeEvent( TInt aStatus, |
|
4712 TTimeIntervalMicroSeconds aTimeElapsed, |
|
4713 TTimeIntervalMicroSeconds aTimeRemaining ) |
|
4714 { |
|
4715 // If capture has already stopped, we don't echo this to our observers. |
|
4716 if( ECamCaptureOff != iInfo.iCaptureState ) |
|
4717 { |
|
4718 iVideoTimes.iTimeElapsed = aTimeElapsed.Int64(); |
|
4719 iVideoTimes.iTimeRemaining = aTimeRemaining.Int64(); |
|
4720 |
|
4721 NotifyObservers( aStatus, |
|
4722 ECamCameraEventVideoTimes, |
|
4723 ECamCameraEventClassVideoTimes, |
|
4724 &iVideoTimes ); |
|
4725 } |
|
4726 } |
|
4727 #endif |
|
4728 |
|
4729 // --------------------------------------------------------------------------- |
|
4730 // HandleAutoFocusEvent |
|
4731 // |
|
4732 // --------------------------------------------------------------------------- |
|
4733 // |
|
4734 void |
|
4735 CCamCameraController::HandleAutoFocusEvent( TInt aStatus, const TUid& aEventUid ) |
|
4736 { |
|
4737 PRINT1( _L("Camera => CCamCameraController::HandleAutoFocusEvent, status: %d"), aStatus ); |
|
4738 TBool proceed = EFalse; |
|
4739 |
|
4740 // ------------------------------------------------------- |
|
4741 // Check the event |
|
4742 if( KUidECamEventCameraSettingsOptimalFocus == aEventUid ) |
|
4743 { |
|
4744 PRINT( _L("Camera <> CCamCameraController: event KUidECamEventCameraSettingsOptimalFocus") ); |
|
4745 if( !iAfHyperfocalPending ) |
|
4746 { |
|
4747 proceed = ETrue; |
|
4748 iAfInProgress = EFalse; |
|
4749 iFirstAfEventReceived = EFalse; |
|
4750 } |
|
4751 } |
|
4752 else if( KUidECamEventCameraSettingAutoFocusType2 == aEventUid ) |
|
4753 { |
|
4754 PRINT( _L("Camera <> CCamCameraController: event KUidECamEventCameraSettingsAutoFocusType2") ); |
|
4755 // If AF started and canceled before finishing |
|
4756 if( iAfInProgress && iAfHyperfocalPending && iFirstAfEventReceived ) |
|
4757 { |
|
4758 // continue to set focus to hyperfocal |
|
4759 proceed = ETrue; |
|
4760 } |
|
4761 if( !iFirstAfEventReceived ) |
|
4762 { |
|
4763 // For the first time, this event means that the autofocusing has been started |
|
4764 iFirstAfEventReceived = ETrue; |
|
4765 PRINT( _L("Camera <> CCamCameraController: event KUidECamEventCameraSettingAutoFocusType2 - first time, set iFirstAfEventReceived ") ); |
|
4766 } |
|
4767 else |
|
4768 { |
|
4769 iFirstAfEventReceived = EFalse; |
|
4770 PRINT( _L("Camera <> CCamCameraController: event KUidECamEventCameraSettingAutoFocusType2 - second time") ); |
|
4771 } |
|
4772 } |
|
4773 else |
|
4774 { |
|
4775 // No other event acceptable here.. |
|
4776 __ASSERT_DEBUG( EFalse, Panic( ECamCameraControllerCorrupt ) ); |
|
4777 } |
|
4778 // ------------------------------------------------------- |
|
4779 // Proceed if right event received |
|
4780 if( proceed ) |
|
4781 { |
|
4782 TCamCameraEventId event = ( KErrNone == aStatus ) |
|
4783 ? ECamCameraEventAutofocusSuccessful |
|
4784 : ECamCameraEventAutofocusFailed; |
|
4785 if( iAfHyperfocalPending ) |
|
4786 { |
|
4787 PRINT( _L("Camera <> Cancelled active autofocus request.") ); |
|
4788 PRINT( _L("Camera <> Setting focus range to hyperfocal, no event to observers yet") ); |
|
4789 iAfHyperfocalPending = EFalse; |
|
4790 iAfInProgress = EFalse; |
|
4791 TRAP_IGNORE( ProcessAutofocusRequestL( ECamRequestCancelAutofocus ) ); |
|
4792 } |
|
4793 else |
|
4794 { |
|
4795 HandleCallbackEvent( KErrNone, |
|
4796 event, |
|
4797 ECamCameraEventClassAutofocus ); |
|
4798 } |
|
4799 |
|
4800 } |
|
4801 else if(iFirstAfEventReceived && (aStatus != KErrNone) ) |
|
4802 { |
|
4803 //There might have been error when first event was received |
|
4804 //and no further autofocus events would occur. |
|
4805 iFirstAfEventReceived = EFalse; |
|
4806 iAfInProgress = EFalse; |
|
4807 |
|
4808 if( iAfHyperfocalPending ) |
|
4809 { |
|
4810 PRINT( _L("Camera <> Cancelled active autofocus request.") ); |
|
4811 PRINT( _L("Camera <> Set focus range to hyperfocal, no event to observers yet") ); |
|
4812 iAfHyperfocalPending = EFalse; |
|
4813 TRAP_IGNORE( ProcessAutofocusRequestL( ECamRequestCancelAutofocus ) ); |
|
4814 } |
|
4815 else |
|
4816 { |
|
4817 HandleCallbackEvent( KErrNone, |
|
4818 ECamCameraEventAutofocusFailed, |
|
4819 ECamCameraEventClassAutofocus ); |
|
4820 } |
|
4821 } |
|
4822 // ------------------------------------------------------- |
|
4823 PRINT( _L("Camera <= CCamCameraController::HandleAutoFocusEvent") ); |
|
4824 } |
|
4825 |
|
4826 |
|
4827 |
|
4828 // --------------------------------------------------------------------------- |
|
4829 // |
|
4830 // HandleFlashStatusEvent |
|
4831 // |
|
4832 // Helper method to handle flash status updates. |
|
4833 // |
|
4834 // --------------------------------------------------------------------------- |
|
4835 void |
|
4836 CCamCameraController::HandleFlashStatusEvent( TInt aStatus, |
|
4837 const TCamCameraEventId& aEventId ) |
|
4838 { |
|
4839 PRINT2( _L("Camera => CCamCameraController::HandleFlashStatusEvent, event[%s] status:%d"), KCamCameraEventNames[aEventId], aStatus ); |
|
4840 NotifyObservers( aStatus, |
|
4841 aEventId, |
|
4842 EventClass( aEventId ) ); |
|
4843 PRINT ( _L("Camera <= CCamCameraController::HandleFlashStatusEvent" ) ); |
|
4844 } |
|
4845 |
|
4846 |
|
4847 |
|
4848 // --------------------------------------------------------------------------- |
|
4849 // HandleCallbackEvent |
|
4850 // |
|
4851 // Helper method to handle CCamera callback events. |
|
4852 // Notifies observers and checks if we should proceed with the sequence. |
|
4853 // --------------------------------------------------------------------------- |
|
4854 // |
|
4855 void |
|
4856 CCamCameraController |
|
4857 ::HandleCallbackEvent( TInt aStatus, |
|
4858 const TCamCameraEventId& aEventId, |
|
4859 const TCamCameraEventClassId& aEventClass, |
|
4860 TAny* aEventData /*= NULL*/ ) |
|
4861 { |
|
4862 PRINT1( _L("Camera => CCamCameraController::HandleCallbackEvent, event[%s]"), |
|
4863 KCamCameraEventNames[aEventId] ); |
|
4864 // ------------------------------------------------------- |
|
4865 // Clear single request busy flag before notification to observers, |
|
4866 // in case client wishes to issue new request during the notification. |
|
4867 // Sequence busy flag can only be cleared in EndSequence |
|
4868 ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
4869 |
|
4870 // Observers might issue a new sequence during notification. |
|
4871 // We need to decide if sequence needs to continue here |
|
4872 // based on the status *before* notification. |
|
4873 TBool proceedSequence = EFalse; |
|
4874 TBool notify = ETrue; |
|
4875 |
|
4876 // ------------------------------------------------------- |
|
4877 // Continue if: |
|
4878 // 1) Processing sequence is ongoing. |
|
4879 // 2) The received event is exact response to our request. |
|
4880 // There are events like "video stopped" or "reserve lost" |
|
4881 // that may be received without our associated request. |
|
4882 // In that case we must not proceed sequence processing now. |
|
4883 // 3) In case that aStatus is KErrInUse and the current event is |
|
4884 // Reserve, it means reserve failed for some reason |
|
4885 if( IsFlagOn( iInfo.iBusy, ECamBusySequence ) ) // 1 |
|
4886 { |
|
4887 PRINT( _L("Camera <> Sequence is active") ); |
|
4888 PRINT2( _L("Camera <> seq index: %d, seq array len: %d"), iSequenceIndex, iSequenceArray.Count() ); |
|
4889 if( KErrNone != aStatus ) |
|
4890 { |
|
4891 |
|
4892 if ( KErrInUse == aStatus // 3 |
|
4893 && aEventId == ECamCameraEventReserveGain |
|
4894 && iSequenceIndex >= 0 |
|
4895 && Request2Event( iSequenceArray[iSequenceIndex] ) == ECamCameraEventReserveGain |
|
4896 && iReserveTryAgainCount > 0 ) |
|
4897 { |
|
4898 // Handle here only if reserve gain with error is part of a sequence and try again count is not zero |
|
4899 |
|
4900 iReserveTryAgainCount--; |
|
4901 User::After( KCamReserveTryAgainWaitInterval ); |
|
4902 |
|
4903 // decrease index, to get the same request handled again |
|
4904 iSequenceIndex--; |
|
4905 notify = EFalse; |
|
4906 proceedSequence = ETrue; |
|
4907 PRINT1( _L( "Camera <> CCamCameraController::HandleCallbackEvent - %d reserve try again left" ), iReserveTryAgainCount ); |
|
4908 |
|
4909 } |
|
4910 else |
|
4911 { |
|
4912 |
|
4913 notify = EFalse; |
|
4914 proceedSequence = EFalse; |
|
4915 EndSequence( aStatus ); |
|
4916 |
|
4917 } |
|
4918 |
|
4919 } |
|
4920 else if( iSequenceIndex >= 0 && // Sequence has started |
|
4921 Request2Event( iSequenceArray[iSequenceIndex] ) == aEventId ) // 2 |
|
4922 { |
|
4923 notify = ETrue; |
|
4924 proceedSequence = ETrue; |
|
4925 } |
|
4926 else |
|
4927 { |
|
4928 // Not the event we need yet. |
|
4929 } |
|
4930 |
|
4931 } |
|
4932 // ------------------------------------------------------- |
|
4933 // Setting sequence ongoing |
|
4934 else if( IsFlagOn( iInfo.iBusy, ECamBusySetting ) |
|
4935 && iSettingIndex >= 0 ) |
|
4936 { |
|
4937 PRINT( _L("Camera <> Settings change ongoing..") ); |
|
4938 |
|
4939 // Default is no notification |
|
4940 if( aEventClass != ECamCameraEventClassAutofocus ) |
|
4941 { |
|
4942 notify = EFalse; |
|
4943 } |
|
4944 if( KErrNone != aStatus ) |
|
4945 { |
|
4946 PRINT( _L("Camera <> error in, end settings sequence!") ); |
|
4947 proceedSequence = EFalse; |
|
4948 EndSequence( aStatus ); // does one notification |
|
4949 } |
|
4950 else if( ECamCameraEventSettingsSingle == aEventId |
|
4951 && aEventData |
|
4952 && iSettingArray[iSettingIndex] == *( static_cast<TInt*>( aEventData ) ) |
|
4953 ) |
|
4954 { |
|
4955 // We have checked already in HandleEvent that this is |
|
4956 // the right event for the setting we wait to finish. |
|
4957 // Notification can be sent with the given data. |
|
4958 PRINT( _L("Camera <> One setting finished, continue sequence") ); |
|
4959 proceedSequence = ETrue; |
|
4960 } |
|
4961 // Video init event repeated when filename or max file size set |
|
4962 // after init already done |
|
4963 else if( IsFlagOn( iInfo.iState, ECamVideoOn ) |
|
4964 && ECamCameraEventVideoInit == aEventId |
|
4965 && ( ECameraSettingFileName == iSettingArray[iSettingIndex] |
|
4966 || ECameraSettingFileMaxSize == iSettingArray[iSettingIndex] |
|
4967 || ECameraSettingAudioMute == iSettingArray[iSettingIndex] ) ) |
|
4968 { |
|
4969 PRINT( _L("Camera <> One setting finished, continue sequence") ); |
|
4970 proceedSequence = ETrue; |
|
4971 } |
|
4972 else if( ECamCameraEventVideoStop == aEventId || ECamCameraEventVideoAsyncStop == aEventId ) |
|
4973 { |
|
4974 // Video stop might come whenever. |
|
4975 // Need to notify client. |
|
4976 notify = ETrue; |
|
4977 } |
|
4978 else |
|
4979 { |
|
4980 // Not event for us yet |
|
4981 } |
|
4982 } |
|
4983 // ------------------------------------------------------- |
|
4984 else |
|
4985 { |
|
4986 // Single request or no request sent |
|
4987 } |
|
4988 // ------------------------------------------------------- |
|
4989 |
|
4990 |
|
4991 // ------------------------------------------------------- |
|
4992 // Notify the observers with data from the event. |
|
4993 if( notify ) |
|
4994 { |
|
4995 NotifyObservers( aStatus, aEventId, aEventClass, aEventData ); |
|
4996 } |
|
4997 |
|
4998 // ------------------------------------------------------- |
|
4999 // If this is part of sequence, continue processing. |
|
5000 if( proceedSequence ) |
|
5001 { |
|
5002 PRINT ( _L("Camera <> proceeding with the sequence") ); |
|
5003 __ASSERT_DEBUG( iActive, Panic( ECamCameraControllerCorrupt ) ); |
|
5004 iActive->IssueRequest(); |
|
5005 } |
|
5006 // ------------------------------------------------------- |
|
5007 PRINT ( _L("Camera <= CCamCameraController::HandleCallbackEvent") ); |
|
5008 } |
|
5009 |
|
5010 |
|
5011 // =========================================================================== |
|
5012 |
|
5013 // --------------------------------------------------------------------------- |
|
5014 // Notify all our observers of an event. |
|
5015 // --------------------------------------------------------------------------- |
|
5016 // |
|
5017 void |
|
5018 CCamCameraController |
|
5019 ::NotifyObservers( TInt aStatus, |
|
5020 TCamCameraEventId aEventId, |
|
5021 TCamCameraEventClassId aEventClass, |
|
5022 TAny* aEventData /*=NULL*/ ) |
|
5023 { |
|
5024 // PRINT ( _L("Camera => CCamCameraController::NotifyObservers") ); |
|
5025 // PRINT3( _L("Camera <> status:% 3d event:% 3d class:%032b"), aStatus, aEventId, aEventClass ); |
|
5026 |
|
5027 // NOTE: |
|
5028 // We might skip an observer, if during the notification some observer |
|
5029 // is removed from the array (from smaller index than current one). |
|
5030 // This is a commmon problem for all observable classes in this application. |
|
5031 for( TInt i = 0; i < iObservers.Count(); i++ ) |
|
5032 { |
|
5033 // Observer defines which events it is interested in. |
|
5034 // PRINT1( _L("Camera <> observer interest:%032b"), iObserverInterests[i] ); |
|
5035 |
|
5036 if( iObserverInterests[i] & aEventClass ) |
|
5037 { |
|
5038 TRAP_IGNORE( iObservers[i]->HandleCameraEventL( aStatus, aEventId, aEventData ) ); |
|
5039 } |
|
5040 } |
|
5041 // PRINT ( _L("Camera <= CCamCameraController::NotifyObservers") ); |
|
5042 } |
|
5043 |
|
5044 |
|
5045 |
|
5046 // --------------------------------------------------------------------------- |
|
5047 // |
|
5048 // --------------------------------------------------------------------------- |
|
5049 // |
|
5050 void |
|
5051 CCamCameraController::ReleaseCurrentCamera() |
|
5052 { |
|
5053 PRINT( _L("Camera => CCamCameraController::ReleaseCurrentCamera") ); |
|
5054 // Cancel any outstanding sequence. |
|
5055 if( IsFlagOn( iInfo.iBusy, ECamBusySequence ) |
|
5056 #ifdef CAMERAAPP_CAE_FIX |
|
5057 // Mode change calls this method possibly in the middle |
|
5058 // of request sequence. Must not try to cancel then. |
|
5059 && ECamModeChangeInactive == iModeChange |
|
5060 #endif |
|
5061 ) |
|
5062 { |
|
5063 CancelSequence(); |
|
5064 } |
|
5065 |
|
5066 if( IsFlagOn( iInfo.iState, ECamReserved ) ) |
|
5067 { |
|
5068 // Releases viewfinder and snapshot, cancels capture, |
|
5069 // powers off and releases CCamera if needed. |
|
5070 ProcessControlShutdownRequest( ECamRequestRelease ); |
|
5071 } |
|
5072 |
|
5073 // Custom interfaces (not owned) |
|
5074 ReleaseCustomInterfaces(); |
|
5075 |
|
5076 delete iEncoder; iEncoder = NULL; |
|
5077 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
5078 delete iCaeEngine; iCaeEngine = NULL; |
|
5079 #endif // CAMERAAPP_CAE_FOR_VIDEO |
|
5080 |
|
5081 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
5082 delete iAdvancedSettings; iAdvancedSettings = NULL; |
|
5083 iAdvancedSettingInfo.Reset(); |
|
5084 #endif |
|
5085 #ifdef CAMERAAPP_CAPI_V2_DVF |
|
5086 delete iDirectViewfinder; iDirectViewfinder = NULL; |
|
5087 #endif |
|
5088 #ifdef CAMERAAPP_CAPI_V2_OL |
|
5089 delete iOverlayProvider; iOverlayProvider = NULL; |
|
5090 #endif |
|
5091 #ifdef CAMERAAPP_CAPI_V2_HG |
|
5092 delete iHistogramProvider; iHistogramProvider = NULL; |
|
5093 #endif |
|
5094 #ifdef CAMERAAPP_CAPI_V2_IP |
|
5095 delete iImageProcessor; iImageProcessor = NULL; |
|
5096 #endif |
|
5097 delete iSnapshotProvider; iSnapshotProvider = NULL; |
|
5098 |
|
5099 delete iCamera; iCamera = NULL; |
|
5100 |
|
5101 #ifdef CAMERAAPP_CAE_FIX |
|
5102 // Must not reset busy flags if this method is called |
|
5103 // because of mode switch. |
|
5104 TBool saveBusyFlags = (ECamModeChangeInactive != iModeChange); |
|
5105 iInfo.Reset( saveBusyFlags ); |
|
5106 #else |
|
5107 iInfo.Reset(); |
|
5108 #endif |
|
5109 iResolutionSupport.Reset(); |
|
5110 iInfo.iState = ECamIdle; |
|
5111 |
|
5112 PRINT( _L("Camera <= CCamCameraController::ReleaseCurrentCamera") ); |
|
5113 } |
|
5114 |
|
5115 |
|
5116 // --------------------------------------------------------------------------- |
|
5117 // ReleaseCustomInterfaces |
|
5118 // --------------------------------------------------------------------------- |
|
5119 // |
|
5120 void |
|
5121 CCamCameraController::ReleaseCustomInterfaces() |
|
5122 { |
|
5123 iCustomInterfaceOrientation = NULL; |
|
5124 } |
|
5125 |
|
5126 // --------------------------------------------------------------------------- |
|
5127 // CompareSize |
|
5128 // Compare two TSize instances |
|
5129 // --------------------------------------------------------------------------- |
|
5130 // |
|
5131 TBool CCamCameraController::CompareSize( const TSize& aA, const TSize& aB ) |
|
5132 { |
|
5133 return ( aA.iWidth == aB.iWidth && aA.iHeight == aB.iHeight ); |
|
5134 } |
|
5135 |
|
5136 |
|
5137 // --------------------------------------------------------------------------- |
|
5138 // GetResolutionIndexL |
|
5139 // |
|
5140 // Get quality index for prepare with given format and size. |
|
5141 // If current info is not for the given format, update the |
|
5142 // supported resolutions info. After the support info is up to date, |
|
5143 // find the index. Return KErrNotFound if not supported size. |
|
5144 // |
|
5145 // For JPEG format we try two alternate bitmap formats, if |
|
5146 // the given resolution is not supported in JPEG format. |
|
5147 // If support is achieved by using one of the alternate formats, |
|
5148 // the format in use is returned in aFormat. When image is then |
|
5149 // later captured, we encode the bitmap to JPEG before handing |
|
5150 // it over to clients. |
|
5151 // --------------------------------------------------------------------------- |
|
5152 // |
|
5153 TInt |
|
5154 CCamCameraController |
|
5155 ::GetResolutionIndexL( CCamera::TFormat& aFormat, |
|
5156 const TSize& aSize ) |
|
5157 { |
|
5158 PRINT ( _L("Camera => CCamCameraController::GetResolutionIndexL") ); |
|
5159 |
|
5160 if( iResolutionSupport.iForCameraFormat != aFormat |
|
5161 || iResolutionSupport.iForCameraIndex != iInfo.iCurrentCamera ) |
|
5162 { |
|
5163 iAlternateFormatInUse = EFalse; |
|
5164 |
|
5165 // Reset all old resolution info |
|
5166 iResolutionSupport.Reset(); |
|
5167 |
|
5168 // Get the resolution info for current camera with given format. |
|
5169 const TInt KResolutionCount( iCameraInfo.iNumImageSizesSupported ); |
|
5170 RArray<TSize>& resolutions( iResolutionSupport.iResolutions ); |
|
5171 |
|
5172 resolutions.ReserveL( KResolutionCount ); |
|
5173 for( TInt i = 0; i < KResolutionCount; i++ ) |
|
5174 { |
|
5175 // Reserve called, so should not leave. |
|
5176 resolutions.AppendL( TSize() ); |
|
5177 iCamera->EnumerateCaptureSizes( resolutions[i], i, aFormat ); |
|
5178 } |
|
5179 |
|
5180 // Set these after successful filling of the array |
|
5181 iResolutionSupport.iForCameraIndex = iInfo.iCurrentCamera; |
|
5182 iResolutionSupport.iForCameraFormat = aFormat; |
|
5183 } |
|
5184 |
|
5185 #ifdef _DEBUG |
|
5186 PRINT ( _L("Camera <> ==================================================") ); |
|
5187 PRINT2( _L("Camera <> Size requested : (%d,%d)"), aSize.iWidth, aSize.iHeight ); |
|
5188 PRINT1( _L("Camera <> Formats supported : %032b" ), iCameraInfo.iImageFormatsSupported ); |
|
5189 PRINT1( _L("Camera <> Sizes listed for : %032b" ), aFormat ); |
|
5190 PRINT1( _L("Camera <> EFormatJpeg : %032b" ), CCamera::EFormatJpeg ); |
|
5191 PRINT1( _L("Camera <> EFormatExif : %032b" ), CCamera::EFormatExif ); |
|
5192 PRINT1( _L("Camera <> EFormatFbsBitmapColor4K : %032b" ), CCamera::EFormatFbsBitmapColor4K ); |
|
5193 PRINT1( _L("Camera <> EFormatFbsBitmapColor64K : %032b" ), CCamera::EFormatFbsBitmapColor64K ); |
|
5194 PRINT1( _L("Camera <> EFormatFbsBitmapColor16M : %032b" ), CCamera::EFormatFbsBitmapColor16M ); |
|
5195 PRINT1( _L("Camera <> EFormatFbsBitmapColor16MU: %032b" ), CCamera::EFormatFbsBitmapColor16MU ); |
|
5196 for( TInt i = 0; i < iResolutionSupport.iResolutions.Count(); i++ ) |
|
5197 { |
|
5198 const TSize& size( iResolutionSupport.iResolutions[i] ); |
|
5199 PRINT3( _L("Camera <> Size (%d): (%d,%d)"), i, size.iWidth, size.iHeight ); |
|
5200 } |
|
5201 PRINT ( _L("Camera <> ==================================================") ); |
|
5202 #endif |
|
5203 |
|
5204 TIdentityRelation<TSize> compareFunc( CCamCameraController::CompareSize ); |
|
5205 TInt index = iResolutionSupport.iResolutions.Find( aSize, compareFunc ); |
|
5206 |
|
5207 // Exception for JPEG format: |
|
5208 // If JPEG format is not supported, but bitmap format is, |
|
5209 // pretend to support the format anyway. |
|
5210 // When capturing, we encode the JPEG from the bitmap. |
|
5211 if( CCamera::EFormatJpeg == aFormat |
|
5212 && KErrNotFound == index ) |
|
5213 { |
|
5214 PRINT ( _L("Camera <> Jpeg not supported, trying bitmap format 1..") ); |
|
5215 aFormat = KCamJpegAlternativeFormat1; |
|
5216 index = GetResolutionIndexL( aFormat, aSize ); |
|
5217 |
|
5218 if( KErrNotFound == index ) |
|
5219 { |
|
5220 PRINT ( _L("Camera <> Jpeg not supported, trying bitmap format 2..") ); |
|
5221 aFormat = KCamJpegAlternativeFormat2; |
|
5222 index = GetResolutionIndexL( aFormat, aSize ); |
|
5223 } |
|
5224 |
|
5225 if( KErrNotFound != index ) |
|
5226 { |
|
5227 iAlternateFormatInUse = ETrue; |
|
5228 } |
|
5229 else |
|
5230 { |
|
5231 // Could not find alternative. |
|
5232 aFormat = CCamera::EFormatJpeg; |
|
5233 iAlternateFormatInUse = EFalse; |
|
5234 } |
|
5235 } |
|
5236 |
|
5237 PRINT1( _L("Camera <= CCamCameraController::GetResolutionIndexL, return: %d"), index ); |
|
5238 return index; |
|
5239 } |
|
5240 |
|
5241 |
|
5242 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
5243 // --------------------------------------------------------------------------- |
|
5244 // GetAdvancedSettingsInfoL |
|
5245 // |
|
5246 // --------------------------------------------------------------------------- |
|
5247 // |
|
5248 void |
|
5249 CCamCameraController::GetAdvancedSettingsInfoL() |
|
5250 { |
|
5251 PRINT ( _L("Camera => CCamCameraController::GetAdvancedSettingsInfoL") ); |
|
5252 PRINT2( _L("Camera <> current camera:%d, latest info for:%d"), |
|
5253 iInfo.iCurrentCamera, |
|
5254 iAdvancedSettingInfo.iForCameraIndex ); |
|
5255 |
|
5256 |
|
5257 CheckNonNullL( iAdvancedSettings, KErrNotReady ); |
|
5258 iAdvancedSettingInfo.Reset(); |
|
5259 |
|
5260 TInt error( KErrNone ); |
|
5261 CleanupStack::PushL( TCleanupItem( ResetInfo, &iAdvancedSettingInfo ) ); |
|
5262 |
|
5263 // ----------------------------------------------------- |
|
5264 // Digital zoom steps support |
|
5265 PRINT( _L("Camera <> Get zoom steps..") ); |
|
5266 if( IsFlagOn( iInfo.iState, ECamImageOn ) ) |
|
5267 { |
|
5268 TPckgBuf<TCamParamsImage> params; |
|
5269 iSettingProvider.ProvideCameraParamL( ECameraParamImage, ¶ms ); |
|
5270 |
|
5271 PRINT( _L("Camera <> Enumerating capture sizes..") ); |
|
5272 CCamera::TFormat format( params().iFormat ); |
|
5273 TInt index ( GetResolutionIndexL( format, params().iSize ) ); |
|
5274 User::LeaveIfError( index ); |
|
5275 TBool isInfluencePossible; // Not used |
|
5276 |
|
5277 PRINT( _L("Camera <> Get zoom steps for image") ); |
|
5278 TRAP( error, iAdvancedSettings->GetDigitalZoomStepsForStillL ( |
|
5279 iAdvancedSettingInfo.iDigitalZoomSupport, |
|
5280 iAdvancedSettingInfo.iDigitalZoomValueInfo, |
|
5281 index, |
|
5282 format, |
|
5283 isInfluencePossible ) ); |
|
5284 |
|
5285 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5286 } |
|
5287 else if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
5288 { |
|
5289 PRINT( _L("Camera <> Get zoom steps for video") ); |
|
5290 TRAP( error, iAdvancedSettings->GetDigitalZoomStepsL( |
|
5291 iAdvancedSettingInfo.iDigitalZoomSupport, |
|
5292 iAdvancedSettingInfo.iDigitalZoomValueInfo ) ); |
|
5293 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5294 } |
|
5295 |
|
5296 // ----------------------------------------------------- |
|
5297 // EV steps multiplied by KECamFineResolutionFactor. |
|
5298 PRINT( _L("Camera <> Get EV support..") ); |
|
5299 iAdvancedSettingInfo.iEvModesSupport = |
|
5300 iAdvancedSettings->SupportedExposureModes(); |
|
5301 |
|
5302 TRAP( error, iAdvancedSettings->GetExposureCompensationStepsL( |
|
5303 iAdvancedSettingInfo.iEvStepsSupport, |
|
5304 iAdvancedSettingInfo.iEvStepsValueInfo ) ); |
|
5305 // Ignore error if just not supported. |
|
5306 // We check the support when setting is requested. |
|
5307 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5308 |
|
5309 // ----------------------------------------------------- |
|
5310 // ISO rates (.. 50, 100, 200, ..) |
|
5311 PRINT( _L("Camera <> Get ISO rates..") ); |
|
5312 TRAP( error, iAdvancedSettings->GetSupportedIsoRatesL( |
|
5313 iAdvancedSettingInfo.iIsoRatesSupport ) ); |
|
5314 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5315 |
|
5316 // ----------------------------------------------------- |
|
5317 // Stabilization |
|
5318 PRINT( _L("Camera <> Get Stabilization info..") ); |
|
5319 iAdvancedSettingInfo.iStabilizationModeSupport = |
|
5320 iAdvancedSettings->SupportedStabilizationModes(); |
|
5321 |
|
5322 iAdvancedSettingInfo.iStabilizationEffectSupport = |
|
5323 iAdvancedSettings->SupportedStabilizationEffects(); |
|
5324 |
|
5325 iAdvancedSettingInfo.iStabilizationComplexitySupport = |
|
5326 iAdvancedSettings->SupportedStabilizationComplexityValues(); |
|
5327 // ----------------------------------------------------- |
|
5328 |
|
5329 #ifdef CAMERAAPP_CAPI_V2_IP |
|
5330 // Image Processor only for primary camera |
|
5331 if( KPrimaryCameraIndex == iInfo.iCurrentCamera ) |
|
5332 { |
|
5333 PRINT( _L("Camera <> Get image processing info..") ); |
|
5334 |
|
5335 if( iImageProcessor != NULL ) |
|
5336 { |
|
5337 // ----------------------------------------------------- |
|
5338 PRINT( _L("Camera <> Get sharpness support..") ); |
|
5339 TRAP( error, iImageProcessor->GetTransformationSupportedValuesL( |
|
5340 KUidECamEventImageProcessingAdjustSharpness, |
|
5341 iAdvancedSettingInfo.iSharpnessSupport, |
|
5342 iAdvancedSettingInfo.iSharpnessValueInfo ) ); |
|
5343 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5344 |
|
5345 // ----------------------------------------------------- |
|
5346 PRINT( _L("Camera <> Get colour effect support..") ); |
|
5347 TRAP( error, iImageProcessor->GetTransformationSupportedValuesL( |
|
5348 KUidECamEventImageProcessingEffect, |
|
5349 iAdvancedSettingInfo.iColourEffectSupport, |
|
5350 iAdvancedSettingInfo.iColourEffectValueInfo ) ); |
|
5351 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5352 } |
|
5353 else |
|
5354 { |
|
5355 PRINT( _L("Camera <> [WARNING] Image processing not supported") ); |
|
5356 } |
|
5357 } |
|
5358 #endif // CAMERAAPP_CAPI_V2_IP |
|
5359 // ----------------------------------------------------- |
|
5360 PRINT( _L("Camera <> ..done") ); |
|
5361 CleanupStack::Pop(); // Cleanup item |
|
5362 |
|
5363 // Set only after successfully gathering the data |
|
5364 iAdvancedSettingInfo.iForCameraIndex = iInfo.iCurrentCamera; |
|
5365 |
|
5366 #ifdef _DEBUG |
|
5367 iAdvancedSettingInfo.PrintInfo(); |
|
5368 #endif |
|
5369 |
|
5370 PRINT ( _L("Camera <= CCamCameraController::GetAdvancedSettingsInfoL") ); |
|
5371 } |
|
5372 |
|
5373 |
|
5374 |
|
5375 // --------------------------------------------------------------------------- |
|
5376 // ResolveEvStep |
|
5377 // |
|
5378 // --------------------------------------------------------------------------- |
|
5379 // |
|
5380 TInt |
|
5381 CCamCameraController::ResolveEvStep( TInt aEvProposedStep ) const |
|
5382 { |
|
5383 PRINT1( _L("Camera => CCamCameraController::ResolveEvStep( %d )"), aEvProposedStep ); |
|
5384 |
|
5385 TInt delta ( KMaxTInt ); |
|
5386 TInt delta1( 0 ); |
|
5387 TInt step ( 0 ); |
|
5388 |
|
5389 for( TInt i = 0; i < iAdvancedSettingInfo.iEvStepsSupport.Count() && delta != 0; i++ ) |
|
5390 { |
|
5391 delta1 = Max( iAdvancedSettingInfo.iEvStepsSupport[i], aEvProposedStep ) |
|
5392 - Min( iAdvancedSettingInfo.iEvStepsSupport[i], aEvProposedStep ); |
|
5393 |
|
5394 if( delta1 < delta ) |
|
5395 { |
|
5396 delta = delta1; |
|
5397 step = iAdvancedSettingInfo.iEvStepsSupport[i]; |
|
5398 } |
|
5399 } |
|
5400 |
|
5401 PRINT1( _L("Camera <= CCamCameraController::ResolveEvStep, return %d"), step ); |
|
5402 return step; |
|
5403 } |
|
5404 |
|
5405 |
|
5406 // --------------------------------------------------------------------------- |
|
5407 // IsSupportedValue <<static>> |
|
5408 // --------------------------------------------------------------------------- |
|
5409 // |
|
5410 TBool |
|
5411 CCamCameraController::IsSupportedValue( const TInt& aValue, |
|
5412 const RArray<TInt>& aValueList, |
|
5413 const TValueInfo& aValueInfo ) |
|
5414 { |
|
5415 TBool support( EFalse ); |
|
5416 |
|
5417 switch( aValueInfo ) |
|
5418 { |
|
5419 // ----------------------------------------------------- |
|
5420 case EBitField: |
|
5421 { |
|
5422 // Supported values are described by a bitfield. |
|
5423 // Compare the support bitfield and the setting value. |
|
5424 // Default value for these settings is zero (0) and |
|
5425 // that is always supported. |
|
5426 // Array: [0] bitfield of supported bits |
|
5427 support = ( 1 <= aValueList.Count() |
|
5428 && ( !aValue |
|
5429 || (aValue & aValueList[0]) // 0 always supported |
|
5430 ) |
|
5431 ); |
|
5432 break; |
|
5433 } |
|
5434 // ----------------------------------------------------- |
|
5435 case EDiscreteSteps: |
|
5436 { |
|
5437 // All supported steps are listed, look for this one. |
|
5438 support = ( KErrNotFound != aValueList.Find( aValue ) ); |
|
5439 break; |
|
5440 } |
|
5441 // ----------------------------------------------------- |
|
5442 case EDiscreteRangeMinMaxStep: |
|
5443 { |
|
5444 // Support is described with evenly spaced steps between |
|
5445 // min and max value. Step is given. |
|
5446 // Array: [0] min supported value |
|
5447 // [1] max supported value |
|
5448 // [2] step between supported values |
|
5449 support = |
|
5450 ( 3 <= aValueList.Count() // We need 3 items. |
|
5451 && 1 <= aValueList[2] // 1 <= step |
|
5452 && aValue >= aValueList[0] // aValue >= min |
|
5453 && aValue <= aValueList[1] // aValue <= max |
|
5454 && (aValue - aValueList[0])%aValueList[2] == 0 // aValue = min + N*step |
|
5455 ); |
|
5456 break; |
|
5457 } |
|
5458 // ----------------------------------------------------- |
|
5459 case EContinuousRangeMinMax: |
|
5460 { |
|
5461 // Support is described by min and max value, |
|
5462 // continuous range of values within those two is supported. |
|
5463 // Array: [0] min supported value |
|
5464 // [1] max supported value |
|
5465 support = |
|
5466 ( 2 <= aValueList.Count() // We need 2 items. |
|
5467 && aValue >= aValueList[0] // aValue >= min |
|
5468 && aValue <= aValueList[1] // aValue <= max |
|
5469 ); |
|
5470 break; |
|
5471 } |
|
5472 // ----------------------------------------------------- |
|
5473 case ENotActive: |
|
5474 default: |
|
5475 // Not supported setting |
|
5476 support = EFalse; |
|
5477 break; |
|
5478 // ----------------------------------------------------- |
|
5479 } |
|
5480 |
|
5481 return support; |
|
5482 } |
|
5483 #endif // CAMERAAPP_CAPI_V2_ADV |
|
5484 |
|
5485 |
|
5486 // --------------------------------------------------------------------------- |
|
5487 // ResolveSnapshotFormat |
|
5488 // |
|
5489 // --------------------------------------------------------------------------- |
|
5490 // |
|
5491 CCamera::TFormat |
|
5492 CCamCameraController |
|
5493 ::ResolveSnapshotFormatL( CCamera::TFormat aPreferredFormat ) const |
|
5494 { |
|
5495 PRINT ( _L("Camera => CCamCameraController::ResolveSnapshotFormatL") ); |
|
5496 |
|
5497 CheckNonNullL( iSnapshotProvider, KErrNotReady ); |
|
5498 |
|
5499 const TUint32 support = iSnapshotProvider->SupportedFormats(); |
|
5500 CCamera::TFormat final = aPreferredFormat; |
|
5501 |
|
5502 // Return the preferred format if it is supported. |
|
5503 // Otherwise return the "best" supported format. |
|
5504 if ( support & aPreferredFormat ) final = aPreferredFormat; |
|
5505 else if ( support & CCamera::EFormatFbsBitmapColor16MU ) final = CCamera::EFormatFbsBitmapColor16MU; |
|
5506 else if ( support & CCamera::EFormatFbsBitmapColor16M ) final = CCamera::EFormatFbsBitmapColor16M; |
|
5507 else if ( support & CCamera::EFormatFbsBitmapColor64K ) final = CCamera::EFormatFbsBitmapColor64K; |
|
5508 else if ( support & CCamera::EFormatFbsBitmapColor4K ) final = CCamera::EFormatFbsBitmapColor4K; |
|
5509 else |
|
5510 { |
|
5511 // No known acceptable format supported |
|
5512 PRINT( _L("Camera <> CCamCameraController: No acceptable format available, LEAVE!") ); |
|
5513 User::Leave( KErrNotSupported ); |
|
5514 } |
|
5515 |
|
5516 PRINT1( _L("Camera <> Preferred format : %032b"), aPreferredFormat ); |
|
5517 PRINT1( _L("Camera <> Supported formats: %032b"), support ); |
|
5518 PRINT1( _L("Camera <> Selected format : %032b"), final ); |
|
5519 PRINT ( _L("Camera <= CCamCameraController::ResolveSnapshotFormatL") ); |
|
5520 return final; |
|
5521 } |
|
5522 |
|
5523 |
|
5524 |
|
5525 // --------------------------------------------------------------------------- |
|
5526 // Request2Event <<static>> |
|
5527 // |
|
5528 // Convert request id to event id |
|
5529 // --------------------------------------------------------------------------- |
|
5530 // |
|
5531 TCamCameraEventId |
|
5532 CCamCameraController::Request2Event( const TCamCameraRequestId& aType ) |
|
5533 { |
|
5534 switch( aType ) |
|
5535 { |
|
5536 // ----------------------------------------------------- |
|
5537 // Camera control |
|
5538 case ECamRequestReserve: return ECamCameraEventReserveGain; |
|
5539 case ECamRequestRelease: return ECamCameraEventReserveLose; |
|
5540 case ECamRequestPowerOn: return ECamCameraEventPowerOn; |
|
5541 case ECamRequestPowerOff: return ECamCameraEventPowerOff; |
|
5542 // ----------------------------------------------------- |
|
5543 // Viewfinder |
|
5544 case ECamRequestVfStart: return ECamCameraEventVfStart; |
|
5545 case ECamRequestVfStop: return ECamCameraEventVfStop; |
|
5546 case ECamRequestVfRelease: return ECamCameraEventVfRelease; |
|
5547 // ----------------------------------------------------- |
|
5548 // Snapshot |
|
5549 case ECamRequestSsStart: return ECamCameraEventSsStart; |
|
5550 case ECamRequestSsStop: return ECamCameraEventSsStop; |
|
5551 case ECamRequestSsRelease: return ECamCameraEventSsRelease; |
|
5552 // ----------------------------------------------------- |
|
5553 // Still capture |
|
5554 case ECamRequestImageInit: return ECamCameraEventImageInit; |
|
5555 case ECamRequestImageCapture: return ECamCameraEventImageStart; |
|
5556 case ECamRequestImageCancel: return ECamCameraEventImageStop; |
|
5557 case ECamRequestImageRelease: return ECamCameraEventImageRelease; |
|
5558 // ----------------------------------------------------- |
|
5559 // Video recording |
|
5560 case ECamRequestVideoInit: return ECamCameraEventVideoInit; |
|
5561 case ECamRequestVideoStart: return ECamCameraEventVideoStart; |
|
5562 case ECamRequestVideoPause: return ECamCameraEventVideoPause; |
|
5563 case ECamRequestVideoStop: return ECamCameraEventVideoStop; |
|
5564 case ECamRequestVideoRelease: return ECamCameraEventVideoRelease; |
|
5565 // ----------------------------------------------------- |
|
5566 // Autofocus |
|
5567 case ECamRequestStartAutofocus: return ECamCameraEventStartAutofocus; |
|
5568 case ECamRequestCancelAutofocus: return ECamCameraEventCancelAutofocus; |
|
5569 case ECamRequestSetAfRange: return ECamCameraEventSetAfRange; |
|
5570 // ----------------------------------------------------- |
|
5571 |
|
5572 // Unrecognised |
|
5573 default: |
|
5574 { |
|
5575 Panic( ECamCameraControllerUnknownRequest ); |
|
5576 return ECamCameraEventNone; |
|
5577 } |
|
5578 // ----------------------------------------------------- |
|
5579 } |
|
5580 } |
|
5581 |
|
5582 |
|
5583 // --------------------------------------------------------------------------- |
|
5584 // EventClass <<static>> |
|
5585 // |
|
5586 // Get the event class for an event |
|
5587 // --------------------------------------------------------------------------- |
|
5588 // |
|
5589 TCamCameraEventClassId |
|
5590 CCamCameraController::EventClass( const TCamCameraEventId& aEventId ) |
|
5591 { |
|
5592 switch( aEventId ) |
|
5593 { |
|
5594 // ------------------------------------------------------- |
|
5595 case ECamCameraEventSequenceEnd: |
|
5596 case ECamCameraEventReserveGain: |
|
5597 case ECamCameraEventReserveLose: |
|
5598 case ECamCameraEventPowerOn: |
|
5599 case ECamCameraEventPowerOff: |
|
5600 return ECamCameraEventClassBasicControl; |
|
5601 // ------------------------------------------------------- |
|
5602 case ECamCameraEventVfStart: |
|
5603 case ECamCameraEventVfStop: |
|
5604 case ECamCameraEventVfRelease: |
|
5605 return ECamCameraEventClassVfControl; |
|
5606 // ------------------------------------------------------- |
|
5607 case ECamCameraEventVfFrameReady: |
|
5608 return ECamCameraEventClassVfData; |
|
5609 // ------------------------------------------------------- |
|
5610 case ECamCameraEventSsStart: |
|
5611 case ECamCameraEventSsStop: |
|
5612 case ECamCameraEventSsRelease: |
|
5613 return ECamCameraEventClassSsControl; |
|
5614 // ------------------------------------------------------- |
|
5615 case ECamCameraEventSsReady: |
|
5616 return ECamCameraEventClassSsData; |
|
5617 // ------------------------------------------------------- |
|
5618 case ECamCameraEventImageInit: |
|
5619 case ECamCameraEventImageStart: |
|
5620 case ECamCameraEventImageStop: |
|
5621 case ECamCameraEventImageRelease: |
|
5622 case ECamCameraEventImageData: |
|
5623 return ECamCameraEventClassImage; |
|
5624 // ------------------------------------------------------- |
|
5625 case ECamCameraEventVideoInit: |
|
5626 case ECamCameraEventVideoStart: |
|
5627 case ECamCameraEventVideoPause: |
|
5628 case ECamCameraEventVideoStop: |
|
5629 case ECamCameraEventVideoRelease: |
|
5630 return ECamCameraEventClassVideo; |
|
5631 // ------------------------------------------------------- |
|
5632 case ECamCameraEventVideoTimes: |
|
5633 return ECamCameraEventClassVideoTimes; |
|
5634 // ------------------------------------------------------- |
|
5635 case ECamCameraEventSettingsSingle: |
|
5636 case ECamCameraEventSettingsDone: |
|
5637 return ECamCameraEventClassSettings; |
|
5638 // ------------------------------------------------------- |
|
5639 case ECamCameraEventStartAutofocus: |
|
5640 case ECamCameraEventCancelAutofocus: |
|
5641 case ECamCameraEventAutofocusSuccessful: |
|
5642 case ECamCameraEventAutofocusFailed: |
|
5643 case ECamCameraEventSetAfRange: |
|
5644 return ECamCameraEventClassAutofocus; |
|
5645 // ------------------------------------------------------- |
|
5646 case ECamCameraEventFlashReady: |
|
5647 case ECamCameraEventFlashNotReady: |
|
5648 return ECamCameraEventClassFlashStatus; |
|
5649 // ------------------------------------------------------- |
|
5650 default: |
|
5651 { |
|
5652 #ifdef _DEBUG |
|
5653 Panic( ECamCameraControllerCorrupt ); |
|
5654 #endif |
|
5655 return ECamCameraEventClassAll; |
|
5656 } |
|
5657 } |
|
5658 } |
|
5659 |
|
5660 |
|
5661 |
|
5662 // --------------------------------------------------------------------------- |
|
5663 // HasCallback |
|
5664 // --------------------------------------------------------------------------- |
|
5665 // |
|
5666 TBool |
|
5667 CCamCameraController::HasCallback( const TCamCameraRequestId& aType ) |
|
5668 { |
|
5669 TBool callback = EFalse; |
|
5670 switch( aType ) |
|
5671 { |
|
5672 // ----------------------------------------------------- |
|
5673 case ECamRequestReserve: // ReserveComplete / KUidECamEventReserveComplete |
|
5674 case ECamRequestPowerOn: // PowerOnComplete / KUidECamEventPowerOnComplete |
|
5675 |
|
5676 case ECamRequestImageCapture: // ImageReady / ImageBufferReady |
|
5677 |
|
5678 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
5679 case ECamRequestVideoInit: // McaeoVideoPrepareComplete |
|
5680 case ECamRequestVideoStart: // McaeoVideoRecordingOn |
|
5681 case ECamRequestVideoPause: // McaeoVideoRecordingPaused |
|
5682 case ECamRequestVideoStop: // McaeoVideoRecordingComplete |
|
5683 #endif |
|
5684 callback = ETrue; |
|
5685 break; |
|
5686 // ----------------------------------------------------- |
|
5687 default: |
|
5688 callback = EFalse; |
|
5689 break; |
|
5690 // ----------------------------------------------------- |
|
5691 } |
|
5692 return callback; |
|
5693 } |
|
5694 |
|
5695 // --------------------------------------------------------------------------- |
|
5696 // CurrentSettingHasCallback |
|
5697 // --------------------------------------------------------------------------- |
|
5698 // |
|
5699 TBool |
|
5700 CCamCameraController::CurrentSettingHasCallback() |
|
5701 { |
|
5702 TBool callback( EFalse ); |
|
5703 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
5704 if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
5705 { |
|
5706 switch( iSettingArray[iSettingIndex] ) |
|
5707 { |
|
5708 case ECameraSettingFileName: |
|
5709 case ECameraSettingFileMaxSize: |
|
5710 callback = ETrue; |
|
5711 break; |
|
5712 default: |
|
5713 break; |
|
5714 } |
|
5715 } |
|
5716 else |
|
5717 { |
|
5718 // no callback if not prepared for video yet. |
|
5719 } |
|
5720 #endif |
|
5721 return callback; |
|
5722 } |
|
5723 |
|
5724 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
5725 // --------------------------------------------------------------------------- |
|
5726 // NewCaeEngineL |
|
5727 // --------------------------------------------------------------------------- |
|
5728 // |
|
5729 CCaeEngine* |
|
5730 CCamCameraController::NewCaeEngineL( TInt aCameraIndex ) |
|
5731 { |
|
5732 PRINT( _L("Camera => CCamCameraController::NewCaeEngineL") ); |
|
5733 |
|
5734 #ifndef FORCE_DUMMY_ENGINE |
|
5735 CCaeEngine* engine = CCaeEngine::NewL( aCameraIndex ); |
|
5736 #else |
|
5737 (void)aCameraIndex; // remove compiler warning |
|
5738 CCaeEngine* engine = CCameraappDummyEngine::NewL(); |
|
5739 #endif |
|
5740 |
|
5741 engine->SetCamAppEngineObserver( *this ); |
|
5742 |
|
5743 PRINT( _L("Camera <= CCamCameraController::NewCaeEngineL") ); |
|
5744 return engine; |
|
5745 } |
|
5746 #endif |
|
5747 |
|
5748 // --------------------------------------------------------------------------- |
|
5749 // NewCameraL |
|
5750 // --------------------------------------------------------------------------- |
|
5751 // |
|
5752 CAMERA* |
|
5753 CCamCameraController::NewCameraL( TInt aCameraIndex ) |
|
5754 { |
|
5755 PRINT( _L("Camera => CCamCameraController::NewCameraL") ); |
|
5756 CAMERA* camera( NULL ); |
|
5757 #ifdef CAMERAAPP_CAPI_V2 |
|
5758 camera = CAMERA::New2L( *this, aCameraIndex, KCameraClientPriority ); |
|
5759 #else |
|
5760 |
|
5761 // Both v1 and v2 observer interface implemented |
|
5762 // Need to cast to avoid ambiguous call. |
|
5763 MCameraObserver* self( this ); |
|
5764 PRINT1( _L("Camera <> Give observer pointer: %d"), self ); |
|
5765 |
|
5766 camera = CAMERA::NewL ( *self, aCameraIndex ); |
|
5767 |
|
5768 #endif // CAMERAAPP_CAPI_V2 |
|
5769 |
|
5770 PRINT( _L("Camera <= CCamCameraController::NewCameraL") ); |
|
5771 return camera; |
|
5772 } |
|
5773 |
|
5774 // --------------------------------------------------------------------------- |
|
5775 // NewDuplicateCameraL |
|
5776 // --------------------------------------------------------------------------- |
|
5777 // |
|
5778 CAMERA* |
|
5779 CCamCameraController::NewDuplicateCameraL( TInt aCameraHandle ) |
|
5780 { |
|
5781 PRINT1( _L("Camera => CCamCameraController::NewDuplicateCameraL( %d )"), aCameraHandle ); |
|
5782 CAMERA* camera( NULL ); |
|
5783 |
|
5784 #ifdef CAMERAAPP_CAPI_V2 |
|
5785 PRINT( _L("Camera <> call NewDuplicate2L..") ); |
|
5786 camera = CAMERA::NewDuplicate2L( *this, aCameraHandle ); |
|
5787 #else |
|
5788 MCameraObserver* self( this ); |
|
5789 PRINT( _L("Camera <> call NewDuplicateL..") ); |
|
5790 camera = CAMERA::NewDuplicateL ( *self, aCameraHandle ); |
|
5791 #endif |
|
5792 |
|
5793 PRINT( _L("Camera <= CCamCameraController::NewCameraL") ); |
|
5794 return camera; |
|
5795 } |
|
5796 |
|
5797 |
|
5798 // =========================================================================== |
|
5799 // Constructors |
|
5800 |
|
5801 |
|
5802 // --------------------------------------------------------------------------- |
|
5803 // 2nd phase constructor |
|
5804 // --------------------------------------------------------------------------- |
|
5805 // |
|
5806 void |
|
5807 CCamCameraController::ConstructL( TInt aCameraIndex ) |
|
5808 { |
|
5809 iActive = CCamCameraControllerActive::NewL( *this, KCamCallBackPriority ); |
|
5810 iIveRecoveryCount = KIveRecoveryCountMax; |
|
5811 |
|
5812 #ifdef CAMERAAPP_PERFORMANCE_CONTROLLER |
|
5813 iPerformanceLogger = new (ELeave) CCamPerformanceLogger; |
|
5814 iFirstVfFrameReceived = EFalse; |
|
5815 #endif |
|
5816 |
|
5817 #ifdef CAMERAAPP_FLASH_SIMULATOR |
|
5818 iFlashSimulator = CCamFlashSimulator::NewL( *this ); |
|
5819 #endif |
|
5820 |
|
5821 SwitchCameraL( aCameraIndex ); |
|
5822 iAsyncVideoStopModeSupported = EFalse; |
|
5823 |
|
5824 } |
|
5825 |
|
5826 |
|
5827 |
|
5828 // --------------------------------------------------------------------------- |
|
5829 // 1st phase constructor |
|
5830 // --------------------------------------------------------------------------- |
|
5831 // |
|
5832 CCamCameraController |
|
5833 ::CCamCameraController( MCamSettingProvider& aSettingProvider, |
|
5834 CCamAppController& aAppController ) |
|
5835 : iSequenceArray ( KCamSequenceGranularity ), |
|
5836 iReserveTryAgainCount( KCamReserveTryAgainMaxCount ), |
|
5837 iSettingProvider ( aSettingProvider ), |
|
5838 iAppController ( aAppController ) |
|
5839 { |
|
5840 } |
|
5841 |
|
5842 |
|
5843 // =========================================================================== |
|
5844 // Workaround for CCaeEngine with no support for CCamera sharing |
|
5845 |
|
5846 #ifdef CAMERAAPP_CAE_FIX |
|
5847 // --------------------------------------------------------------------------- |
|
5848 // --------------------------------------------------------------------------- |
|
5849 // |
|
5850 TInt |
|
5851 CCamCameraController::ProceedModeSwitch() |
|
5852 { |
|
5853 PRINT1( _L("Camera => CCamCameraController::ProceedModeSwitch, status in:%d"), iModeChangeStatus ); |
|
5854 TInt proceed( EFalse ); |
|
5855 |
|
5856 // Update only after here, so any events arriving |
|
5857 // in the middle get ignored if wanted. |
|
5858 ++iModeChangePhase; |
|
5859 |
|
5860 if( KErrNone == iModeChangeStatus ) |
|
5861 { |
|
5862 TRAP( iModeChangeStatus, proceed = DoProceedModeSwitchL() ); |
|
5863 } |
|
5864 |
|
5865 if( KErrNone != iModeChangeStatus ) |
|
5866 { |
|
5867 PRINT1( _L("Camera <> Mode switch error: %d"), iModeChangeStatus ); |
|
5868 iModeChange = ECamModeChangeInactive; |
|
5869 iModeChangePhase = ECamModeChangePhase0; |
|
5870 iModeChangeStatus = KErrNone; |
|
5871 |
|
5872 PRINT( _L("Camera <> Deleting engine..") ); |
|
5873 delete iCaeEngine; |
|
5874 iCaeEngine = NULL; |
|
5875 |
|
5876 PRINT( _L("Camera <> Deleting camera..") ); |
|
5877 delete iCamera; |
|
5878 iCamera = NULL; |
|
5879 |
|
5880 iInfo.Reset(); |
|
5881 |
|
5882 PRINT( _L("Camera <> PANIC!!") ); |
|
5883 |
|
5884 Panic( ECamCameraControllerUnrecovableError ); |
|
5885 } |
|
5886 |
|
5887 PRINT1( _L("Camera <= CCamCameraController::ProceedModeSwitch, more calls now:%d"), proceed ); |
|
5888 return proceed; |
|
5889 } |
|
5890 |
|
5891 // --------------------------------------------------------------------------- |
|
5892 // --------------------------------------------------------------------------- |
|
5893 // |
|
5894 TInt |
|
5895 CCamCameraController::DoProceedModeSwitchL() |
|
5896 { |
|
5897 PRINT( _L("Camera => CCamCameraController::DoProceedModeSwitchL") ); |
|
5898 User::LeaveIfError( iModeChangeStatus ); |
|
5899 |
|
5900 TBool callback = ETrue; |
|
5901 |
|
5902 // ------------------------------------------------------- |
|
5903 if( ECamModeChangeImage2Video == iModeChange ) |
|
5904 { |
|
5905 PRINT( _L("Camera <> Changing mode image => video") ); |
|
5906 switch( iModeChangePhase ) |
|
5907 { |
|
5908 // First two phases only usable if CAE v1 in use. |
|
5909 // Must start from phase2 otherwise. |
|
5910 // ------------------------------- |
|
5911 case ECamModeChangePhase0: |
|
5912 { |
|
5913 PRINT( _L("Camera <> Phase0: Release camera..") ); |
|
5914 TInt cameraIndex = iInfo.iCurrentCamera; |
|
5915 ReleaseCurrentCamera(); |
|
5916 SwitchCameraL( cameraIndex ); |
|
5917 CompleteSwitchCameraL(); |
|
5918 callback = EFalse; |
|
5919 // iModeChangePhase is incremented when iActive->RunL calls |
|
5920 // ProcessNextRequestL for the next time. |
|
5921 break; |
|
5922 } |
|
5923 // ------------------------------- |
|
5924 case ECamModeChangePhase1: |
|
5925 { |
|
5926 PRINT( _L("Camera <> Phase1: calling CCaeEngine::InitL..") ); |
|
5927 iCaeEngine->InitL(); |
|
5928 iCaeInUse = ETrue; |
|
5929 // Continue mode change in callback |
|
5930 PRINT( _L("Camera <> ..waiting for to complete") ); |
|
5931 break; |
|
5932 } |
|
5933 // ------------------------------- |
|
5934 case ECamModeChangePhase2: |
|
5935 { |
|
5936 PRINT( _L("Camera <> Phase2: Prepare video..") ); |
|
5937 PRINT( _L("Camera <> Call InitVideoRecorderL..") ); |
|
5938 iCaeEngine->InitVideoRecorderL(); |
|
5939 |
|
5940 PRINT( _L("Camera <> Ask filename..") ); |
|
5941 // HBufC* filename( HBufC::NewLC( KMaxFileName ) ); |
|
5942 // TPtr ptr ( filename->Des() ); |
|
5943 // iSettingProvider.ProvideCameraSettingL( ECameraSettingFileName, &ptr ); |
|
5944 _LIT( KTempFilename, "C:\\video.3gp" ); |
|
5945 TPtrC ptr; |
|
5946 ptr.Set( KTempFilename() ); |
|
5947 #pragma message( "Camera Controller: video filename hardcoded" ) |
|
5948 PRINT1( _L("Camera <> Set filename [%S]"), &ptr ); |
|
5949 iCaeEngine->SetVideoRecordingFileNameL( ptr ); |
|
5950 // CleanupStack::PopAndDestroy( filename ); |
|
5951 |
|
5952 |
|
5953 // Set max video clip size |
|
5954 ProcessSettingL( ECameraSettingFileMaxSize ); |
|
5955 |
|
5956 |
|
5957 TPckgBuf<TCamParamsVideoCae> params; |
|
5958 iSettingProvider.ProvideCameraParamL( ECameraParamVideoCae, ¶ms ); |
|
5959 // The audioOn value is defined On==0 and Off==1, but the engine expects |
|
5960 // ETrue if audio recording is On |
|
5961 params().iAudioOn = ( ECamSettOn == params().iAudioOn ) |
|
5962 ? ETrue |
|
5963 : EFalse; |
|
5964 PRINT( _L("Camera <> Call prepare..") ); |
|
5965 // McaeoVideoPrepareComplete will be called when prepare is ready. |
|
5966 // The callback is allowed to come also *during* this call. |
|
5967 iCaeEngine->PrepareVideoRecordingL( params().iFrameSize, |
|
5968 params().iFrameRate, |
|
5969 params().iVideoBitRate, |
|
5970 params().iAudioOn, |
|
5971 params().iAudioBitRate, |
|
5972 params().iMimeType, |
|
5973 params().iSupplier, |
|
5974 params().iVideoType, |
|
5975 params().iAudioType ); |
|
5976 |
|
5977 // iCaeEngine->PrepareVideoRecordingL( 0 ); |
|
5978 |
|
5979 break; |
|
5980 } |
|
5981 // ------------------------------- |
|
5982 case ECamModeChangePhase3: |
|
5983 { |
|
5984 PRINT( _L("Camera <> Phase3: Notifying..") ); |
|
5985 iModeChange = ECamModeChangeInactive; |
|
5986 iModeChangePhase = ECamModeChangePhaseIdle; |
|
5987 callback = EFalse; |
|
5988 |
|
5989 NotifyObservers( iModeChangeStatus, |
|
5990 ECamCameraEventVideoInit, |
|
5991 ECamCameraEventClassVideo ); |
|
5992 break; |
|
5993 } |
|
5994 // ------------------------------- |
|
5995 default: |
|
5996 { |
|
5997 Panic( ECamCameraControllerCorrupt ); |
|
5998 break; |
|
5999 } |
|
6000 // ------------------------------- |
|
6001 } |
|
6002 } |
|
6003 // ------------------------------------------------------- |
|
6004 else if( ECamModeChangeVideo2Image == iModeChange ) |
|
6005 { |
|
6006 PRINT( _L("Camera <> Changing mode video => image") ); |
|
6007 switch( iModeChangePhase ) |
|
6008 { |
|
6009 // ------------------------------- |
|
6010 case ECamModeChangePhase0: |
|
6011 { |
|
6012 PRINT( _L("Camera <> Phase0: Release camera..") ); |
|
6013 TInt cameraIndex = iInfo.iCurrentCamera; |
|
6014 ReleaseCurrentCamera(); |
|
6015 SwitchCameraL( cameraIndex ); |
|
6016 CompleteSwitchCameraL(); |
|
6017 callback = EFalse; |
|
6018 break; |
|
6019 } |
|
6020 // ------------------------------- |
|
6021 case ECamModeChangePhase1: |
|
6022 { |
|
6023 PRINT( _L("Camera <> Phase1: Reserve camera..") ); |
|
6024 iCaeInUse = EFalse; |
|
6025 iCamera->Reserve(); |
|
6026 break; |
|
6027 } |
|
6028 // ------------------------------- |
|
6029 case ECamModeChangePhase2: |
|
6030 { |
|
6031 PRINT( _L("Camera <> Phase2: Power on..") ); |
|
6032 iCamera->PowerOn(); |
|
6033 break; |
|
6034 } |
|
6035 // ------------------------------- |
|
6036 case ECamModeChangePhase3: |
|
6037 { |
|
6038 PRINT( _L("Camera <> Phase3: Prepare image..") ); |
|
6039 TPckgBuf<TCamParamsImage> params; |
|
6040 iSettingProvider.ProvideCameraParamL( ECameraParamImage, ¶ms ); |
|
6041 |
|
6042 // Query the supported resolutions for the selected format. |
|
6043 TInt index = GetResolutionIndexL( params().iFormat, params().iSize ); |
|
6044 User::LeaveIfError( index ); |
|
6045 |
|
6046 PRINT2( _L("Camera <> Image size: (%d, %d)"), |
|
6047 params().iSize.iWidth, |
|
6048 params().iSize.iHeight ); |
|
6049 iCamera->PrepareImageCaptureL( params().iFormat, index ); |
|
6050 iCamera->SetJpegQuality( params().iQualityFactor ); |
|
6051 |
|
6052 SetFlags( iInfo.iState, ECamImageOn ); |
|
6053 |
|
6054 callback = EFalse; |
|
6055 break; |
|
6056 } |
|
6057 // ------------------------------- |
|
6058 case ECamModeChangePhase4: |
|
6059 { |
|
6060 PRINT( _L("Camera <> Phase4: Notifying..") ); |
|
6061 iModeChange = ECamModeChangeInactive; |
|
6062 iModeChangePhase = ECamModeChangePhaseIdle; |
|
6063 callback = EFalse; |
|
6064 |
|
6065 NotifyObservers( iModeChangeStatus, |
|
6066 ECamCameraEventImageInit, |
|
6067 ECamCameraEventClassImage ); |
|
6068 |
|
6069 break; |
|
6070 } |
|
6071 // ------------------------------- |
|
6072 default: |
|
6073 { |
|
6074 Panic( ECamCameraControllerCorrupt ); |
|
6075 break; |
|
6076 } |
|
6077 // ------------------------------- |
|
6078 } |
|
6079 } |
|
6080 // ------------------------------------------------------- |
|
6081 else |
|
6082 { |
|
6083 Panic( ECamCameraControllerCorrupt ); |
|
6084 } |
|
6085 // ------------------------------------------------------- |
|
6086 |
|
6087 PRINT1( _L("Camera <= CCamCameraController::DoProceedModeSwitchL, more calls now:%d"), !callback ); |
|
6088 return !callback; |
|
6089 } |
|
6090 #endif // CAMERAAPP_CAE_FIX |
|
6091 |
|
6092 |
|
6093 /** |
|
6094 * CCamCameraController::RemainingVideoRecordingTime() |
|
6095 * Method to retrieve Remaining Recording time from CCaeEngine |
|
6096 * which is used in AppController and AppUi during Video Rec Operation |
|
6097 */ |
|
6098 TTimeIntervalMicroSeconds |
|
6099 CCamCameraController::RemainingVideoRecordingTime() |
|
6100 { |
|
6101 if( iCaeEngine ) |
|
6102 return iCaeEngine->RemainingVideoRecordingTime(); |
|
6103 else |
|
6104 return 0; |
|
6105 } |
|
6106 |
|
6107 |
|
6108 // =========================================================================== |
|
6109 // Performance measurement related |
|
6110 |
|
6111 #ifdef CAMERAAPP_PERFORMANCE_CONTROLLER |
|
6112 |
|
6113 // --------------------------------------------------------------------------- |
|
6114 // PerformanceLogger() |
|
6115 // |
|
6116 // Return the performance logger instance. |
|
6117 // Used to record performance measurement data. |
|
6118 // --------------------------------------------------------------------------- |
|
6119 // |
|
6120 const CCamPerformanceLogger* |
|
6121 CCamCameraController::PerformanceLogger() const |
|
6122 { |
|
6123 return iPerformanceLogger; |
|
6124 } |
|
6125 |
|
6126 #endif // CAMERAAPP_PERFORMANCE_CONTROLLER |
|
6127 |
|
6128 |
|
6129 |
|
6130 // =========================================================================== |
|
6131 // Debug prints |
|
6132 |
|
6133 #ifdef _DEBUG |
|
6134 // --------------------------------------------------------------------------- |
|
6135 // PrintCameraInfo |
|
6136 // --------------------------------------------------------------------------- |
|
6137 // |
|
6138 void |
|
6139 CCamCameraController::PrintCameraInfo() const |
|
6140 { |
|
6141 PRINT ( _L("Camera <> ==================================================") ); |
|
6142 PRINT ( _L("Camera <> Camera info:") ); |
|
6143 PRINT3( _L("Camera <> Camera hw version[%d.%d.%d]"), |
|
6144 iCameraInfo.iHardwareVersion.iMajor, |
|
6145 iCameraInfo.iHardwareVersion.iMinor, |
|
6146 iCameraInfo.iHardwareVersion.iBuild ); |
|
6147 PRINT3( _L("Camera <> Camera sw version[%d.%d.%d]"), |
|
6148 iCameraInfo.iSoftwareVersion.iMajor, |
|
6149 iCameraInfo.iSoftwareVersion.iMinor, |
|
6150 iCameraInfo.iSoftwareVersion.iBuild ); |
|
6151 PRINT1( _L("Camera <> TCameraInfo.iMinZoom : %d"), iCameraInfo.iMinZoom ); |
|
6152 PRINT1( _L("Camera <> TCameraInfo.iMaxZoom : %d"), iCameraInfo.iMaxZoom ); |
|
6153 PRINT1( _L("Camera <> TCameraInfo.iMaxDigitalZoom : %d"), iCameraInfo.iMaxDigitalZoom ); |
|
6154 PRINT1( _L("Camera <> TCameraInfo.iMinZoomFactor : %f"), iCameraInfo.iMinZoomFactor ); |
|
6155 PRINT1( _L("Camera <> TCameraInfo.iMaxZoomFactor : %f"), iCameraInfo.iMaxZoomFactor ); |
|
6156 PRINT1( _L("Camera <> TCameraInfo.iMaxDigitalZoomFactor: %f"), iCameraInfo.iMaxDigitalZoomFactor ); |
|
6157 PRINT ( _L("Camera <> ==================================================") ); |
|
6158 } |
|
6159 |
|
6160 |
|
6161 // --------------------------------------------------------------------------- |
|
6162 // PrintSnapshotInfo |
|
6163 // --------------------------------------------------------------------------- |
|
6164 // |
|
6165 void |
|
6166 CCamCameraController::PrintSnapshotInfo() const |
|
6167 { |
|
6168 PRINT ( _L("Camera <> ===========================================================") ); |
|
6169 PRINT ( _L("Camera <> Snapshot info" ) ); |
|
6170 PRINT1( _L("Camera <> Formats supported (1st) : %032b" ), iSnapshotProvider->SupportedFormats() ); |
|
6171 PRINT1( _L("Camera <> EFormatFbsBitmapColor4K : %032b" ), CCamera::EFormatFbsBitmapColor4K ); |
|
6172 PRINT1( _L("Camera <> EFormatFbsBitmapColor64K : %032b" ), CCamera::EFormatFbsBitmapColor64K ); |
|
6173 PRINT1( _L("Camera <> EFormatFbsBitmapColor16M : %032b" ), CCamera::EFormatFbsBitmapColor16M ); |
|
6174 PRINT1( _L("Camera <> EFormatFbsBitmapColor16MU: %032b" ), CCamera::EFormatFbsBitmapColor16MU ); |
|
6175 PRINT ( _L("Camera <> ===========================================================") ); |
|
6176 } |
|
6177 |
|
6178 // =========================================================================== |
|
6179 #endif // _DEBUG |
|
6180 |
|
6181 // --------------------------------------------------------------------------- |
|
6182 // CCamCameraController::SettingValueUpToDateL |
|
6183 // --------------------------------------------------------------------------- |
|
6184 // |
|
6185 TBool |
|
6186 CCamCameraController::SettingValueUpToDateL( const NCamCameraController::TCamCameraSettingId& aSettingId ) |
|
6187 { |
|
6188 PRINT( _L("Camera => CCamCameraController::SettingValueUpToDate") ); |
|
6189 TBool upToDate = ETrue; |
|
6190 |
|
6191 switch( aSettingId ) |
|
6192 { |
|
6193 case ECameraSettingFlash: |
|
6194 case ECameraUserSceneSettingFlash: |
|
6195 { |
|
6196 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingFlash") ); |
|
6197 |
|
6198 // Supposed setting value from settings provider |
|
6199 CCamera::TFlash flashSetting( CCamera::EFlashNone ); |
|
6200 iSettingProvider.ProvideCameraSettingL( aSettingId, &flashSetting ); |
|
6201 |
|
6202 // Real settings value from camera |
|
6203 CCamera::TFlash flashValue( CCamera::EFlashNone ); |
|
6204 GetCameraSettingValueL( aSettingId, &flashValue ); |
|
6205 |
|
6206 PRINT2( _L("Camera <> flashValue = %d, flashSetting = %d"), flashValue, flashSetting ); |
|
6207 upToDate = ( flashValue == flashSetting ); |
|
6208 break; |
|
6209 } |
|
6210 case ECameraSettingExposure: |
|
6211 case ECameraUserSceneSettingExposure: |
|
6212 { |
|
6213 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingExposure") ); |
|
6214 TPckgBuf<TCamSettingDataExposure> exposureSetting; |
|
6215 iSettingProvider.ProvideCameraSettingL( aSettingId, &exposureSetting ); |
|
6216 |
|
6217 TPckgBuf<TCamSettingDataExposure> exposureValue; |
|
6218 GetCameraSettingValueL( aSettingId, &exposureValue ); |
|
6219 |
|
6220 if ( exposureSetting().iExposureMode != exposureValue().iExposureMode || |
|
6221 exposureSetting().iExposureStep != exposureValue().iExposureStep ) |
|
6222 { |
|
6223 upToDate = EFalse; |
|
6224 } |
|
6225 |
|
6226 break; |
|
6227 } |
|
6228 case ECameraSettingLightSensitivity: |
|
6229 case ECameraUserSceneSettingLightSensitivity: |
|
6230 { |
|
6231 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingLightSensitivity") ); |
|
6232 |
|
6233 RArray<TInt> ISOarray; |
|
6234 CleanupClosePushL( ISOarray ); |
|
6235 #ifdef CAMERAAPP_CAPI_V2 |
|
6236 iAdvancedSettings->GetSupportedIsoRatesL( ISOarray ); |
|
6237 #endif |
|
6238 iSettingProvider.SetSupportedISORatesL( ISOarray ); |
|
6239 |
|
6240 TInt* isoSetting = 0; |
|
6241 iSettingProvider.ProvideCameraSettingL( aSettingId, &isoSetting ); |
|
6242 CleanupStack::PopAndDestroy( &ISOarray ); |
|
6243 |
|
6244 |
|
6245 TInt* isoValue = 0; |
|
6246 GetCameraSettingValueL( aSettingId, &isoValue ); |
|
6247 |
|
6248 upToDate = ( isoSetting == isoValue ); |
|
6249 break; |
|
6250 } |
|
6251 case ECameraSettingWhiteBalance: |
|
6252 case ECameraUserSceneSettingWhiteBalance: |
|
6253 { |
|
6254 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingWhiteBalance") ); |
|
6255 |
|
6256 TPckgBuf<TCamSettingDataWhiteBalance> wbSetting; |
|
6257 iSettingProvider.ProvideCameraSettingL( aSettingId, &wbSetting ); |
|
6258 |
|
6259 TPckgBuf<TCamSettingDataWhiteBalance> wbValue; |
|
6260 GetCameraSettingValueL( aSettingId, &wbValue ); |
|
6261 |
|
6262 upToDate = ( wbSetting().iWhiteBalanceMode == wbValue().iWhiteBalanceMode ); |
|
6263 break; |
|
6264 } |
|
6265 case ECameraSettingColourEffect: |
|
6266 case ECameraUserSceneSettingColourEffect: |
|
6267 { |
|
6268 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingColourEffect") ); |
|
6269 |
|
6270 CIP::TEffect effectSetting( CIP::EEffectNone ); |
|
6271 iSettingProvider.ProvideCameraSettingL( aSettingId, &effectSetting ); |
|
6272 |
|
6273 CIP::TEffect effectValue( CIP::EEffectNone ); |
|
6274 // Can't leave here or other settings won't be restored |
|
6275 TRAP_IGNORE( GetCameraSettingValueL( aSettingId, &effectValue ) ); |
|
6276 |
|
6277 upToDate = ( effectSetting == effectValue ); |
|
6278 break; |
|
6279 } |
|
6280 case ECameraSettingBrightness: |
|
6281 case ECameraUserSceneSettingBrightness: |
|
6282 { |
|
6283 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingBrightness") ); |
|
6284 CCamera::TBrightness brightnessSetting; |
|
6285 iSettingProvider.ProvideCameraSettingL( aSettingId, &brightnessSetting ); |
|
6286 |
|
6287 CCamera::TBrightness brightnessValue; |
|
6288 GetCameraSettingValueL( aSettingId, &brightnessValue ); |
|
6289 |
|
6290 upToDate = ( brightnessSetting == brightnessValue ); |
|
6291 break; |
|
6292 } |
|
6293 case ECameraSettingContrast: |
|
6294 case ECameraUserSceneSettingContrast: |
|
6295 { |
|
6296 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingContrast") ); |
|
6297 CCamera::TContrast contrastSetting( CCamera::EContrastAuto ); |
|
6298 iSettingProvider.ProvideCameraSettingL( aSettingId, &contrastSetting ); |
|
6299 |
|
6300 CCamera::TContrast contrastValue( CCamera::EContrastAuto ); |
|
6301 GetCameraSettingValueL( aSettingId, &contrastValue ); |
|
6302 |
|
6303 upToDate = ( contrastSetting == contrastValue ); |
|
6304 break; |
|
6305 } |
|
6306 case ECameraSettingSharpness: |
|
6307 case ECameraUserSceneSettingSharpness: |
|
6308 { |
|
6309 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingSharpness") ); |
|
6310 TInt sharpnessSetting( 0 ); |
|
6311 iSettingProvider.ProvideCameraSettingL( aSettingId, &sharpnessSetting ); |
|
6312 |
|
6313 TInt sharpnessValue( 0 ); |
|
6314 // Can't leave here or other settings won't be restored |
|
6315 TRAP_IGNORE( GetCameraSettingValueL( aSettingId, &sharpnessValue ) ); |
|
6316 |
|
6317 upToDate = ( sharpnessSetting == sharpnessValue ); |
|
6318 break; |
|
6319 } |
|
6320 case ECameraSettingDigitalZoom: |
|
6321 { |
|
6322 TInt zoomSetting( 0 ); |
|
6323 iSettingProvider.ProvideCameraSettingL( aSettingId, &zoomSetting ); |
|
6324 |
|
6325 TInt zoomValue( 0 ); |
|
6326 GetCameraSettingValueL( aSettingId, &zoomValue ); |
|
6327 |
|
6328 upToDate = ( zoomSetting == zoomValue ); |
|
6329 break; |
|
6330 } |
|
6331 #ifdef CAMERAAPP_CAPI_V2 |
|
6332 case ECameraSettingStabilization: |
|
6333 { |
|
6334 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingStabilization") ); |
|
6335 |
|
6336 TPckgBuf<TCamSettingDataStabilization> stabilizationSetting; |
|
6337 iSettingProvider.ProvideCameraSettingL( aSettingId, &stabilizationSetting ); |
|
6338 |
|
6339 TPckgBuf<TCamSettingDataStabilization> stabilizationValue; |
|
6340 GetCameraSettingValueL( aSettingId, &stabilizationValue ); |
|
6341 if ( stabilizationSetting().iMode != stabilizationValue().iMode || |
|
6342 stabilizationSetting().iEffect != stabilizationValue().iEffect || |
|
6343 stabilizationSetting().iComplexity != stabilizationValue().iComplexity ) |
|
6344 { |
|
6345 upToDate = EFalse; |
|
6346 } |
|
6347 break; |
|
6348 } |
|
6349 case ECameraSettingContAF: |
|
6350 { |
|
6351 TBool isContAFon( iAdvancedSettings->AutoFocusType() & |
|
6352 CAS::EAutoFocusTypeContinuous ); |
|
6353 if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
6354 { |
|
6355 TBool contAF( ETrue ); |
|
6356 iSettingProvider.ProvideCameraSettingL( aSettingId, &contAF ); |
|
6357 if( contAF != isContAFon ) |
|
6358 { |
|
6359 upToDate = EFalse; |
|
6360 } |
|
6361 } |
|
6362 else |
|
6363 { |
|
6364 //Do nothing |
|
6365 |
|
6366 } |
|
6367 break; |
|
6368 } |
|
6369 #endif |
|
6370 default: |
|
6371 { |
|
6372 PRINT1( _L("CCamCameraController::SettingValueUpToDate - unknown setting id: %d"), aSettingId ); |
|
6373 } |
|
6374 |
|
6375 } |
|
6376 |
|
6377 PRINT1( _L("Camera <= CCamCameraController::SettingValueUpToDate returning %d"), upToDate ); |
|
6378 return upToDate; |
|
6379 } |
|
6380 |
|
6381 |
|
6382 |
|
6383 // --------------------------------------------------------------------------- |
|
6384 // CCamCameraController::SetViewfinderWindowHandle |
|
6385 // --------------------------------------------------------------------------- |
|
6386 // |
|
6387 void CCamCameraController::SetViewfinderWindowHandle( RWindowBase* aWindow ) |
|
6388 { |
|
6389 PRINT( _L("Camera => CCamCameraController::SetViewfinderWindowHandle") ); |
|
6390 PRINT2( _L("Camera <> aWindow=0x%08x iViewfinderWindow=0x%08x "), aWindow, iViewfinderWindow ); |
|
6391 |
|
6392 if ( aWindow != iViewfinderWindow && |
|
6393 iCamera && |
|
6394 iInfo.iVfState == ECamTriActive && |
|
6395 iInfo.iVfMode == ECamViewfinderDirect ) |
|
6396 { |
|
6397 PRINT( _L("Camera <> viewfinder active and window handle changed, restarting viewfinder...") ); |
|
6398 iCamera->StopViewFinder(); |
|
6399 iInfo.iVfState = ECamTriInactive; |
|
6400 |
|
6401 // restart viewfinder |
|
6402 //TRAP_IGNORE( ProcessVfStartRequestL() ); |
|
6403 iAppController.EnterViewfinderMode(iAppController.CurrentMode()); |
|
6404 } |
|
6405 iViewfinderWindow = aWindow; |
|
6406 |
|
6407 PRINT( _L("Camera <= CCamCameraController::SetViewfinderWindowHandle") ); |
|
6408 } |
|
6409 |
|
6410 // --------------------------------------------------------------------------- |
|
6411 // CCamCameraController::ViewfinderWindowDeleted |
|
6412 // --------------------------------------------------------------------------- |
|
6413 // |
|
6414 void CCamCameraController::ViewfinderWindowDeleted( RWindowBase* aWindow ) |
|
6415 { |
|
6416 PRINT( _L("Camera => CCamCameraController::ViewfinderWindowDeleted") ); |
|
6417 PRINT2( _L("Camera <> aWindow=0x%08x iViewfinderWindow=0x%08x "), aWindow, iViewfinderWindow ); |
|
6418 |
|
6419 if ( aWindow == iViewfinderWindow ) |
|
6420 { |
|
6421 if ( iCamera && |
|
6422 iInfo.iVfState == ECamTriActive && |
|
6423 iInfo.iVfMode == ECamViewfinderDirect ) |
|
6424 { |
|
6425 PRINT( _L("Camera <> viewfinder active and window deleted, stopping viewfinder...") ); |
|
6426 iCamera->StopViewFinder(); |
|
6427 iInfo.iVfState = ECamTriInactive; |
|
6428 } |
|
6429 iViewfinderWindow = NULL; |
|
6430 } |
|
6431 |
|
6432 PRINT( _L("Camera <= CCamCameraController::ViewfinderWindowDeleted") ); |
|
6433 } |
|
6434 |
|
6435 // --------------------------------------------------------------------------- |
|
6436 // CCamCameraController::SetVfWindowOrdinal |
|
6437 // --------------------------------------------------------------------------- |
|
6438 // |
|
6439 TInt CCamCameraController::SetVfWindowOrdinal( TInt aOrdinalPosition ) |
|
6440 { |
|
6441 TInt orgPos( KErrUnknown ); |
|
6442 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
6443 if ( iViewfinderWindow ) |
|
6444 { |
|
6445 TInt cbaPos(0); |
|
6446 TInt toolbarPos(0); |
|
6447 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
6448 orgPos = iViewfinderWindow->OrdinalPosition(); |
|
6449 if ( aOrdinalPosition != KErrUnknown) |
|
6450 { |
|
6451 // Set wanted ordinal position |
|
6452 iViewfinderWindow->SetOrdinalPosition( aOrdinalPosition ); |
|
6453 } |
|
6454 else if ( appUi ) |
|
6455 { |
|
6456 // Find out other windows ordinal positions |
|
6457 if ( cba ) |
|
6458 { |
|
6459 cbaPos = cba->DrawableWindow()->OrdinalPosition(); |
|
6460 } |
|
6461 CAknToolbar* toolbar = appUi->CurrentFixedToolbar(); |
|
6462 if ( toolbar ) |
|
6463 { |
|
6464 RDrawableWindow* toolbarwindow = toolbar->DrawableWindow(); |
|
6465 if ( toolbarwindow ) |
|
6466 { |
|
6467 toolbarPos = toolbarwindow->OrdinalPosition(); |
|
6468 } |
|
6469 } |
|
6470 // Calculate new viewfinder position, |
|
6471 // just under fixed toolbar and CBA buttons |
|
6472 TInt newPos = Max( toolbarPos, cbaPos ) + 1; |
|
6473 // Use new position if viefinder window is not visible already |
|
6474 iViewfinderWindow->SetOrdinalPosition( Min( orgPos, newPos ) ); |
|
6475 } |
|
6476 } |
|
6477 return orgPos; |
|
6478 } |
|
6479 |
|
6480 #ifdef CAMERAAPP_CAE_ERR_SIMULATION |
|
6481 |
|
6482 // --------------------------------------------------------------------------- |
|
6483 // CCamCameraController::DelayedCaeCallback |
|
6484 // Static function called when the timer expires |
|
6485 // --------------------------------------------------------------------------- |
|
6486 // |
|
6487 TInt |
|
6488 CCamCameraController::DelayedCaeCallback( TAny* aController ) |
|
6489 { |
|
6490 CCamCameraController* self = static_cast<CCamCameraController*>( aController ); |
|
6491 self->CallAppropriateCallback(); |
|
6492 |
|
6493 return KErrNone; |
|
6494 } |
|
6495 |
|
6496 // --------------------------------------------------------------------------- |
|
6497 // CCamCameraController::CallAppropriateCallback |
|
6498 // Helper function to call the appropriate callback handler. |
|
6499 // --------------------------------------------------------------------------- |
|
6500 // |
|
6501 void |
|
6502 CCamCameraController::CallAppropriateCallback( const TCamCameraEventId aEventId, |
|
6503 TInt aStatus ) |
|
6504 { |
|
6505 PRINT2( _L("Camera => CCamCameraController::CallAppropriateCallback, event:%d, status:%d"), aEventId, aStatus ) |
|
6506 |
|
6507 switch ( iSimEventId ) |
|
6508 { |
|
6509 case ECamCameraEventVideoInit: |
|
6510 case ECamCameraEventVideoStart: // fallthrough |
|
6511 case ECamCameraEventVideoPause: // fallthrough |
|
6512 case ECamCameraEventVideoStop: |
|
6513 if( aEventId == ECamCameraEventNone ) |
|
6514 { |
|
6515 PRINT( _L("Camera <> CCamCameraController::CallAppropriateCallback - calling handler after delay") ) |
|
6516 HandleVideoEvent( iSimEventId, iSimStatus ); |
|
6517 } |
|
6518 else |
|
6519 { |
|
6520 PRINT( _L("Camera <> CCamCameraController::CallAppropriateCallback - calling handler without delay") ) |
|
6521 HandleVideoEvent( aEventId, aStatus ); |
|
6522 } |
|
6523 break; |
|
6524 default: |
|
6525 break; |
|
6526 } |
|
6527 |
|
6528 // In case of being called by timer, stop and destro the timer |
|
6529 if( aEventId == ECamCameraEventNone && iCallbackTimer ) |
|
6530 { |
|
6531 iCallbackTimer->Cancel(); |
|
6532 delete iCallbackTimer; |
|
6533 iCallbackTimer = NULL; |
|
6534 } |
|
6535 |
|
6536 PRINT( _L("Camera <= CCamCameraController::CallAppropriateCallback") ) |
|
6537 } |
|
6538 |
|
6539 #endif // CAMERAAPP_CAE_ERR_SIMULATION |
|
6540 |
|
6541 // --------------------------------------------------------------------------- |
|
6542 // CCamCameraController::AsyncVideoStopModeSupported |
|
6543 // --------------------------------------------------------------------------- |
|
6544 // |
|
6545 TBool |
|
6546 CCamCameraController::AsyncVideoStopModeSupported() |
|
6547 { |
|
6548 PRINT1( _L("Camera <> CCamCameraController::AsyncVideoStopModeSupported = %d "), iAsyncVideoStopModeSupported ); |
|
6549 return( iAsyncVideoStopModeSupported ); |
|
6550 } |
|
6551 |
|
6552 // --------------------------------------------------------------------------- |
|
6553 // IdleCallback <<static>> |
|
6554 // --------------------------------------------------------------------------- |
|
6555 // |
|
6556 // static |
|
6557 TInt CCamCameraController::IdleCallback( TAny* aSelf ) |
|
6558 { |
|
6559 CCamCameraController* self( static_cast<CCamCameraController*>( aSelf ) ); |
|
6560 self->DoIveRecovery(); |
|
6561 |
|
6562 return EFalse; |
|
6563 } |
|
6564 |
|
6565 // --------------------------------------------------------------------------- |
|
6566 // CCamCameraController::DoIveRecovery |
|
6567 // --------------------------------------------------------------------------- |
|
6568 // |
|
6569 void CCamCameraController::DoIveRecovery() |
|
6570 { |
|
6571 PRINT( _L("Camera => CCamCameraController::DoIveRecovery") ) |
|
6572 if( iAppController.IsAppUiAvailable() |
|
6573 && !( iAppController.IsInShutdownMode() || iAppController.CheckExitStatus() ) ) |
|
6574 { |
|
6575 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
6576 __ASSERT_DEBUG(appUi, CamPanic(ECamPanicNullPointer)); |
|
6577 TVwsViewId activeView; |
|
6578 TInt viewErr = appUi->GetActiveViewId( activeView ); |
|
6579 CCamViewBase* view = NULL; |
|
6580 if( !viewErr ) |
|
6581 { |
|
6582 view = static_cast<CCamViewBase*>( appUi->View( activeView.iViewUid )); |
|
6583 } |
|
6584 else |
|
6585 { |
|
6586 //There was an error when getting active view ID. Propably camera |
|
6587 //application went to background. In that case just return because |
|
6588 //camera resource should be released when going to background. |
|
6589 return; |
|
6590 } |
|
6591 __ASSERT_DEBUG(view, CamPanic(ECamPanicNullPointer)); |
|
6592 if ( appUi->StandbyStatus() && view->IsInStandbyMode() ) |
|
6593 { |
|
6594 PRINT( _L("Camera <> CCamCameraController::DoIveRecovery - Standby mode active, try to exit") ) |
|
6595 TRAP_IGNORE( appUi->HandleControllerEventL( ECamEventCameraChanged, |
|
6596 KErrNone ) ); |
|
6597 } |
|
6598 else |
|
6599 { |
|
6600 PRINT( _L("Camera <> CCamCameraController::DoIveRecovery - Start recovering from beginning") ) |
|
6601 if( IsFlagOn( iInfo.iBusy, ECamBusySequence|ECamBusySetting ) ) |
|
6602 { |
|
6603 if( iActive && |
|
6604 iActive->IsActive() ) |
|
6605 { |
|
6606 iActive->Cancel(); |
|
6607 } |
|
6608 EndSequence( KErrNone ); |
|
6609 } |
|
6610 NotifyObservers( KErrNone, ECamCameraEventIveRecover, |
|
6611 ECamCameraEventClassBasicControl ); |
|
6612 } |
|
6613 iIveRecoveryCount--; |
|
6614 iIveRecoveryOngoing = ETrue; |
|
6615 } |
|
6616 PRINT1( _L("Camera <= CCamCameraController::DoIveRecovery iIveRecoveryCount%d"),iIveRecoveryCount ) |
|
6617 } |
|
6618 |
|
6619 // --------------------------------------------------------------------------- |
|
6620 // CCamCameraController::IsWaitingIveResources |
|
6621 // --------------------------------------------------------------------------- |
|
6622 // |
|
6623 TBool CCamCameraController::IsWaitingIveResources() |
|
6624 { |
|
6625 return iIdle && iIdle->IsActive(); |
|
6626 } |
|
6627 |
|
6628 |
|
6629 // --------------------------------------------------------------------------- |
|
6630 // CCamCameraController::SetFaceTrackingL |
|
6631 // --------------------------------------------------------------------------- |
|
6632 // |
|
6633 void CCamCameraController::SetFaceTrackingL() |
|
6634 { |
|
6635 if( iCustomInterfaceFaceTracking && |
|
6636 KPrimaryCameraIndex == iInfo.iCurrentCamera ) |
|
6637 { |
|
6638 TBool ftOn( EFalse ); |
|
6639 iSettingProvider.ProvideCameraSettingL( ECameraSettingFacetracking, &ftOn ); |
|
6640 PRINT1( _L("Camera <> Set facetracking: %d"), ftOn ) |
|
6641 iCustomInterfaceFaceTracking->SetFaceTrackingL( ftOn ); |
|
6642 iCustomInterfaceFaceTracking->EnableFaceIndicatorsL( ETrue ); |
|
6643 DirectRequestL( ECamRequestSetAfRange ); |
|
6644 } |
|
6645 } |
|
6646 |
|
6647 // End of file |