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 TRAP_IGNORE(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 if ( iInfo.iCurrentCamera != KPrimaryCameraIndex && |
|
2420 orientation == MCameraOrientation::EOrientation90 ) |
|
2421 { |
|
2422 PRINT( _L("Camera <> Rotate portrait secondary camera image 270 degrees") ); |
|
2423 orientation = MCameraOrientation::EOrientation270; |
|
2424 } |
|
2425 |
|
2426 PRINT1( _L("Camera <> setting camera orientation to [0x%02x]"), orientation ); |
|
2427 iCustomInterfaceOrientation->SetOrientationL( orientation ); |
|
2428 break; |
|
2429 } |
|
2430 // ------------------------------- |
|
2431 case ECameraSettingFocusRange: |
|
2432 default: |
|
2433 { |
|
2434 #ifndef CAMERAAPP_EMULATOR_BUILD |
|
2435 PRINT ( _L("Camera <> Not supported, LEAVE!") ); |
|
2436 User::Leave( KErrNotSupported ); |
|
2437 #endif // not CAMERAAPP_EMULATOR_BUILD |
|
2438 break; |
|
2439 } |
|
2440 // ------------------------------- |
|
2441 } |
|
2442 |
|
2443 PRINT1( _L("Camera <= CCamCameraController::ProcessSettingL, continue now:%d"), !callback ); |
|
2444 return !callback; |
|
2445 } |
|
2446 |
|
2447 |
|
2448 // --------------------------------------------------------------------------- |
|
2449 // |
|
2450 // --------------------------------------------------------------------------- |
|
2451 // |
|
2452 TInt |
|
2453 CCamCameraController |
|
2454 ::ProcessOneRequestL( const TCamCameraRequestId& aRequestId ) |
|
2455 { |
|
2456 PRINT( _L("Camera => CCamCameraController::ProcessOneRequestL") ); |
|
2457 PRINT2( _L("Camera <> processing request [%s] id:%d "), |
|
2458 KCamRequestNames[aRequestId], |
|
2459 aRequestId ); |
|
2460 |
|
2461 TInt readyForNext( ETrue ); |
|
2462 |
|
2463 // Order from most time critical / frequent |
|
2464 // to less time critical / seldom. |
|
2465 // Handled in submethods to preserve readability. |
|
2466 // ----------------------------------------------------- |
|
2467 switch( aRequestId ) |
|
2468 { |
|
2469 // ------------------------------- |
|
2470 case ECamRequestReserve: |
|
2471 case ECamRequestPowerOn: |
|
2472 readyForNext = ProcessControlStartupRequestL( aRequestId ); |
|
2473 break; |
|
2474 case ECamRequestPowerOff: |
|
2475 case ECamRequestRelease: |
|
2476 readyForNext = ProcessControlShutdownRequest( aRequestId ); |
|
2477 break; |
|
2478 // ------------------------------- |
|
2479 case ECamRequestVfStart: |
|
2480 case ECamRequestVfStop: |
|
2481 case ECamRequestVfRelease: |
|
2482 readyForNext = ProcessVfRequestL( aRequestId ); |
|
2483 break; |
|
2484 // ------------------------------- |
|
2485 case ECamRequestSsStart: |
|
2486 case ECamRequestSsStop: |
|
2487 case ECamRequestSsRelease: |
|
2488 readyForNext = ProcessSnapshotRequestL( aRequestId ); |
|
2489 break; |
|
2490 // ------------------------------- |
|
2491 case ECamRequestImageInit: |
|
2492 case ECamRequestImageCapture: |
|
2493 readyForNext = ProcessImageRequestL( aRequestId ); |
|
2494 break; |
|
2495 case ECamRequestImageCancel: |
|
2496 case ECamRequestImageRelease: |
|
2497 readyForNext = ProcessImageShutdownRequest( aRequestId ); |
|
2498 break; |
|
2499 // ------------------------------- |
|
2500 case ECamRequestVideoInit: |
|
2501 case ECamRequestVideoStart: |
|
2502 case ECamRequestVideoPause: |
|
2503 case ECamRequestVideoStop: |
|
2504 case ECamRequestVideoRelease: |
|
2505 case ECamRequestSetAsyncVideoStopMode: |
|
2506 readyForNext = ProcessVideoRequestL( aRequestId ); |
|
2507 break; |
|
2508 // ------------------------------- |
|
2509 default: |
|
2510 Panic( ECamCameraControllerUnknownRequest ); |
|
2511 break; |
|
2512 // ------------------------------- |
|
2513 } |
|
2514 // ----------------------------------------------------- |
|
2515 PRINT( _L("Camera <= CCamCameraController::ProcessOneRequestL") ); |
|
2516 return readyForNext; |
|
2517 } |
|
2518 |
|
2519 |
|
2520 // --------------------------------------------------------------------------- |
|
2521 // ProcessControlStartupRequestL |
|
2522 // --------------------------------------------------------------------------- |
|
2523 // |
|
2524 TInt |
|
2525 CCamCameraController |
|
2526 ::ProcessControlStartupRequestL( const TCamCameraRequestId& aRequestId ) |
|
2527 { |
|
2528 PRINT1( _L("Camera => CCamCameraController::ProcessControlStartupRequestL [%s]"), |
|
2529 KCamRequestNames[aRequestId] ); |
|
2530 // ------------------------------------------------------- |
|
2531 // Reserve |
|
2532 if( ECamRequestReserve == aRequestId ) |
|
2533 { |
|
2534 CheckFlagOffL( iInfo.iState, ECamReserved, KErrInUse ); |
|
2535 |
|
2536 CAMERAAPP_PERF_CONTROLLER_START( ECamRequestReserve ); |
|
2537 iCamera->Reserve(); |
|
2538 // If UIOrientationOverrideAPI is used, ui construction is completed while |
|
2539 // waiting for Reserve to complete, event sent here to continue ui construction |
|
2540 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
2541 if ( appUi->AppController().UiConfigManagerPtr()->IsUIOrientationOverrideSupported() ) |
|
2542 { |
|
2543 NotifyObservers( KErrNone, |
|
2544 ECamCameraEventReserveRequested, |
|
2545 ECamCameraEventClassBasicControl ); |
|
2546 } |
|
2547 } |
|
2548 // ------------------------------------------------------- |
|
2549 // Power on |
|
2550 else if( ECamRequestPowerOn == aRequestId ) |
|
2551 { |
|
2552 CheckFlagOnL ( iInfo.iState, ECamReserved, KErrNotReady ); |
|
2553 CheckFlagOffL( iInfo.iState, ECamPowerOn, KErrInUse ); |
|
2554 |
|
2555 CAMERAAPP_PERF_CONTROLLER_START( ECamRequestPowerOn ); |
|
2556 |
|
2557 iCamera->PowerOn(); |
|
2558 } |
|
2559 // ------------------------------------------------------- |
|
2560 // Unknown |
|
2561 else |
|
2562 { |
|
2563 Panic( ECamCameraControllerCorrupt ); |
|
2564 } |
|
2565 // ------------------------------------------------------- |
|
2566 iReleasedByUi = EFalse; |
|
2567 PRINT( _L("Camera <= CCamCameraController::ProcessControlStartupRequestL") ); |
|
2568 // Callback needs to be received before we can continue. |
|
2569 return EFalse; |
|
2570 } |
|
2571 |
|
2572 // --------------------------------------------------------------------------- |
|
2573 // ProcessControlShutdownRequest |
|
2574 // --------------------------------------------------------------------------- |
|
2575 // |
|
2576 TInt |
|
2577 CCamCameraController |
|
2578 ::ProcessControlShutdownRequest( const TCamCameraRequestId& aRequestId ) |
|
2579 { |
|
2580 PRINT( _L("Camera => CCamCameraController::ProcessControlShutdownRequest") ); |
|
2581 // ------------------------------------------------------- |
|
2582 // Power off |
|
2583 if( ECamRequestPowerOff == aRequestId ) |
|
2584 { |
|
2585 if( IsFlagOn( iInfo.iState, ECamPowerOn ) ) |
|
2586 { |
|
2587 // ------------------------------- |
|
2588 // Release image or video capture |
|
2589 if( IsFlagOn( iInfo.iState, ECamImageOn ) ) |
|
2590 { |
|
2591 // Leaves only if state is wrong (already checked here). |
|
2592 ProcessImageShutdownRequest( ECamRequestImageRelease ); |
|
2593 NotifyObservers( KErrNone, |
|
2594 ECamCameraEventImageRelease, |
|
2595 ECamCameraEventClassImage ); |
|
2596 } |
|
2597 else if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
2598 { |
|
2599 TRAP_IGNORE( ProcessVideoRequestL( ECamRequestVideoRelease ) ); |
|
2600 NotifyObservers( KErrNone, |
|
2601 ECamCameraEventVideoRelease, |
|
2602 ECamCameraEventClassVideo ); |
|
2603 } |
|
2604 else |
|
2605 { |
|
2606 } |
|
2607 // ------------------------------- |
|
2608 // If viewfinder is not released yet, release it now. |
|
2609 if( ECamTriIdle != iInfo.iVfState ) |
|
2610 { |
|
2611 ProcessVfRelaseRequest(); |
|
2612 NotifyObservers( KErrNone, |
|
2613 ECamCameraEventVfRelease, |
|
2614 ECamCameraEventClassVfControl ); |
|
2615 } |
|
2616 |
|
2617 // ------------------------------- |
|
2618 // If snapshot is not released yet, release it now. |
|
2619 if( ECamTriIdle != iInfo.iSsState ) |
|
2620 { |
|
2621 ProcessSsReleaseRequest(); |
|
2622 NotifyObservers( KErrNone, |
|
2623 ECamCameraEventSsRelease, |
|
2624 ECamCameraEventClassSsControl ); |
|
2625 } |
|
2626 // ------------------------------- |
|
2627 // Do the actual powering off. |
|
2628 #ifdef CAMERAAPP_CAE_FIX |
|
2629 if( iCaeInUse ) |
|
2630 { |
|
2631 iCaeEngine->PowerOff(); |
|
2632 } |
|
2633 else |
|
2634 #endif // CAMERAAPP_CAE_FIX |
|
2635 { |
|
2636 iCamera->PowerOff(); |
|
2637 } |
|
2638 // ------------------------------- |
|
2639 } |
|
2640 ClearFlags( iInfo.iState, ECamPowerOn ); |
|
2641 } |
|
2642 // ------------------------------------------------------- |
|
2643 // Release |
|
2644 else if( ECamRequestRelease == aRequestId ) |
|
2645 { |
|
2646 if( IsFlagOn( iInfo.iState, ECamReserved ) ) |
|
2647 { |
|
2648 // If power off not called yet, do it now. |
|
2649 if( IsFlagOn( iInfo.iState, ECamPowerOn ) ) |
|
2650 { |
|
2651 ProcessControlShutdownRequest( ECamRequestPowerOff ); |
|
2652 // Separate notification needed here, because operation done |
|
2653 // as part of handling other request. |
|
2654 NotifyObservers( KErrNone, |
|
2655 ECamCameraEventPowerOff, |
|
2656 ECamCameraEventClassBasicControl ); |
|
2657 } |
|
2658 #ifdef CAMERAAPP_CAE_FIX |
|
2659 if( iCaeInUse ) |
|
2660 { |
|
2661 iCaeEngine->Release(); |
|
2662 iCaeInUse = EFalse; |
|
2663 } |
|
2664 else |
|
2665 #endif // CAMERAAPP_CAE_FIX |
|
2666 { |
|
2667 iCamera->Release(); |
|
2668 iReleasedByUi = ETrue; |
|
2669 if( iIveRecoveryCount > 0 ) |
|
2670 { |
|
2671 HandleReserveLostEvent( KErrNone ); |
|
2672 } |
|
2673 } |
|
2674 } |
|
2675 PRINT( _L("Camera <> released, reset info") ); |
|
2676 |
|
2677 // Reset our info, but preserve busy flag and camera index. |
|
2678 // Sets iInfo.iState to ECamIdle. |
|
2679 iInfo.Reset( ETrue, ETrue ); |
|
2680 } |
|
2681 // ------------------------------------------------------- |
|
2682 // Unknown |
|
2683 else |
|
2684 { |
|
2685 Panic( ECamCameraControllerCorrupt ); |
|
2686 } |
|
2687 // ------------------------------------------------------- |
|
2688 PRINT( _L("Camera <= CCamCameraController::ProcessControlShutdownRequest") ); |
|
2689 |
|
2690 // No callback needs to be waited. |
|
2691 return ETrue; |
|
2692 } |
|
2693 |
|
2694 // --------------------------------------------------------------------------- |
|
2695 // ProcessViewfinderRequestL |
|
2696 // --------------------------------------------------------------------------- |
|
2697 // |
|
2698 TInt |
|
2699 CCamCameraController |
|
2700 ::ProcessVfRequestL( const TCamCameraRequestId& aRequestId ) |
|
2701 { |
|
2702 CheckFlagOnL( iInfo.iState, ECamPowerOn, KErrNotReady ); |
|
2703 |
|
2704 switch( aRequestId ) |
|
2705 { |
|
2706 // ----------------------------------------------------- |
|
2707 case ECamRequestVfStart: |
|
2708 { |
|
2709 CAMERAAPP_PERF_CONTROLLER_STARTNEW( ECamRequestVfStart, iFirstVfFrameReceived ); |
|
2710 ProcessVfStartRequestL(); |
|
2711 break; |
|
2712 } |
|
2713 // ----------------------------------------------------- |
|
2714 case ECamRequestVfStop: |
|
2715 { |
|
2716 ProcessVfStopRequestL(); |
|
2717 break; |
|
2718 } |
|
2719 // ----------------------------------------------------- |
|
2720 case ECamRequestVfRelease: |
|
2721 { |
|
2722 ProcessVfRelaseRequest(); |
|
2723 break; |
|
2724 } |
|
2725 // ----------------------------------------------------- |
|
2726 default: |
|
2727 { |
|
2728 Panic( ECamCameraControllerCorrupt ); |
|
2729 break; |
|
2730 } |
|
2731 // ----------------------------------------------------- |
|
2732 } |
|
2733 |
|
2734 // No callback to be waited |
|
2735 return ETrue; |
|
2736 } |
|
2737 |
|
2738 |
|
2739 // --------------------------------------------------------------------------- |
|
2740 // InitViewfinderL |
|
2741 // --------------------------------------------------------------------------- |
|
2742 // |
|
2743 void |
|
2744 CCamCameraController::InitViewfinderL( const TCamViewfinderMode& aMode ) |
|
2745 { |
|
2746 PRINT( _L("Camera => CCamCameraController::InitViewfinderL") ); |
|
2747 |
|
2748 // Check the old viewfinder is released now. |
|
2749 // No further checks made here. |
|
2750 __ASSERT_DEBUG( ECamTriIdle == iInfo.iVfState, Panic( ECamCameraControllerCorrupt ) ); |
|
2751 |
|
2752 // Then init the new mode |
|
2753 switch( aMode ) |
|
2754 { |
|
2755 // --------------------------------- |
|
2756 case ECamViewfinderDirect: |
|
2757 { |
|
2758 // Don't proceed if not supported by camera. |
|
2759 CheckFlagOnL( iCameraInfo.iOptionsSupported, |
|
2760 TCameraInfo::EViewFinderDirectSupported, |
|
2761 KErrNotSupported ); |
|
2762 |
|
2763 #ifdef CAMERAAPP_CAPI_V2_DVF |
|
2764 PRINT( _L("Camera <> Creating CCameraDirectViewFinder instance") ); |
|
2765 if( iDirectViewfinder ) |
|
2766 { |
|
2767 delete iDirectViewfinder; |
|
2768 iDirectViewfinder=NULL; |
|
2769 } |
|
2770 iDirectViewfinder = CCamera::CCameraDirectViewFinder::NewL( *iCamera ); |
|
2771 #else |
|
2772 // not implemented |
|
2773 Panic( ECamCameraControllerUnsupported ); |
|
2774 #endif |
|
2775 iInfo.iVfState = ECamTriInactive; |
|
2776 iInfo.iVfMode = ECamViewfinderDirect; |
|
2777 break; |
|
2778 } |
|
2779 // --------------------------------- |
|
2780 case ECamViewfinderBitmap: |
|
2781 { |
|
2782 // Don't proceed if not supported by camera. |
|
2783 CheckFlagOnL( iCameraInfo.iOptionsSupported, |
|
2784 TCameraInfo::EViewFinderBitmapsSupported, |
|
2785 KErrNotSupported ); |
|
2786 |
|
2787 iInfo.iVfState = ECamTriInactive; |
|
2788 iInfo.iVfMode = ECamViewfinderBitmap; |
|
2789 break; |
|
2790 } |
|
2791 // --------------------------------- |
|
2792 case ECamViewfinderNone: |
|
2793 // Mode is "none", so no init needed. |
|
2794 break; |
|
2795 // --------------------------------- |
|
2796 default: |
|
2797 // Unknown mode |
|
2798 Panic( ECamCameraControllerUnsupported ); |
|
2799 break; |
|
2800 // --------------------------------- |
|
2801 } |
|
2802 PRINT( _L("Camera <= CCamCameraController::InitViewfinderL") ); |
|
2803 } |
|
2804 |
|
2805 // --------------------------------------------------------------------------- |
|
2806 // --------------------------------------------------------------------------- |
|
2807 void |
|
2808 CCamCameraController |
|
2809 ::ProcessVfStartRequestL() |
|
2810 { |
|
2811 PRINT( _L("Camera => CCamCameraController::ProcessVfStartRequestL") ); |
|
2812 |
|
2813 #ifdef __WINSCW__ |
|
2814 const TCamViewfinderMode KTargetMode( ECamViewfinderBitmap ); |
|
2815 #else |
|
2816 |
|
2817 TPckgBuf<TCamViewfinderMode> mode; |
|
2818 iSettingProvider.ProvideCameraParamL( ECameraParamVfMode, &mode ); |
|
2819 |
|
2820 // If the viewfinder mode needs to be changed, |
|
2821 // first stop and release resources related to the old viewfinder type. |
|
2822 const TCamViewfinderMode KTargetMode( mode() ); |
|
2823 #endif |
|
2824 |
|
2825 if( ECamViewfinderNone != iInfo.iVfMode |
|
2826 && KTargetMode != iInfo.iVfMode ) |
|
2827 { |
|
2828 ProcessVfRelaseRequest(); |
|
2829 } |
|
2830 |
|
2831 // Check that application is still in foreground, if not then return |
|
2832 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
2833 |
|
2834 if ( !appUi->AppInBackground( ETrue ) ) |
|
2835 { |
|
2836 switch( iInfo.iVfState ) |
|
2837 { |
|
2838 // ----------------------------------------------------- |
|
2839 case ECamTriIdle: |
|
2840 PRINT( _L("Camera <> case ECamTriIdle") ); |
|
2841 |
|
2842 InitViewfinderL( KTargetMode ); |
|
2843 // << fall through >> |
|
2844 |
|
2845 case ECamTriInactive: |
|
2846 { |
|
2847 // ------------------------------- |
|
2848 PRINT( _L("Camera <> case ECamTriInactive") ); |
|
2849 |
|
2850 if( ECamViewfinderDirect == iInfo.iVfMode ) |
|
2851 #ifdef CAMERAAPP_CAPI_V2_DVF |
|
2852 { |
|
2853 switch( iDirectViewfinder->ViewFinderState() ) |
|
2854 { |
|
2855 case CCamera::CCameraDirectViewFinder::EViewFinderInActive: |
|
2856 { |
|
2857 if ( !iViewfinderWindow ) |
|
2858 { |
|
2859 PRINT( _L("Camera <> CCamCameraController::iViewfinderWindow is NULL - cannot start VF!") ); |
|
2860 User::Leave( KErrNotReady ); |
|
2861 } |
|
2862 |
|
2863 // Use the same viewfinder position and size as for bitmap viewfinder |
|
2864 TPckgBuf<TCamParamsVfBitmap> params; |
|
2865 iSettingProvider.ProvideCameraParamL( ECameraParamVfBitmap, ¶ms ); |
|
2866 |
|
2867 CEikonEnv* env = CEikonEnv::Static(); |
|
2868 |
|
2869 OstTrace0( CAMERAAPP_PERFORMANCE, CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_VF_INIT 0" ); //CCORAPP_APP_VF_INIT_END |
|
2870 OstTrace0( CAMERAAPP_PERFORMANCE, DUP1_CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_OVERLAY_INIT 0" ); //CCORAPP_APP_OVERLAY_INIT_END |
|
2871 |
|
2872 TInt orgPos = SetVfWindowOrdinal(); // Set visible |
|
2873 iCamera->StartViewFinderDirectL( |
|
2874 env->WsSession(), |
|
2875 *env->ScreenDevice(), |
|
2876 *iViewfinderWindow, |
|
2877 params().iRect ); |
|
2878 (void) SetVfWindowOrdinal( orgPos ); // back to original |
|
2879 |
|
2880 CCamAppUi* appUi = static_cast<CCamAppUi*>( env->AppUi() ); |
|
2881 if ( ECamActiveCameraSecondary == appUi->ActiveCamera() ) |
|
2882 { |
|
2883 iCamera->SetViewFinderMirrorL(ETrue); |
|
2884 } |
|
2885 // VF started succesfully, reset recovery counter |
|
2886 delete iIdle; |
|
2887 iIdle = NULL; |
|
2888 iIveRecoveryCount = KIveRecoveryCountMax; |
|
2889 break; |
|
2890 } |
|
2891 case CCamera::CCameraDirectViewFinder::EViewFinderPause: |
|
2892 { |
|
2893 iDirectViewfinder->ResumeViewFinderDirectL(); |
|
2894 break; |
|
2895 } |
|
2896 case CCamera::CCameraDirectViewFinder::EViewFinderActive: |
|
2897 { |
|
2898 // Already running. Not considered as error. |
|
2899 break; |
|
2900 } |
|
2901 default: |
|
2902 { |
|
2903 Panic( ECamCameraControllerUnsupported ); |
|
2904 break; |
|
2905 } |
|
2906 } |
|
2907 } |
|
2908 #else // CAMERAAPP_CAPI_V2_DVF |
|
2909 { |
|
2910 // No controller support for direct vf. |
|
2911 Panic( ECamCameraControllerUnsupported ); |
|
2912 } |
|
2913 #endif // CAMERAAPP_CAPI_V2_DVF |
|
2914 // ------------------------------- |
|
2915 else |
|
2916 { |
|
2917 PRINT( _L("Camera <> Get bitmap vf details..") ); |
|
2918 |
|
2919 TPckgBuf<TCamParamsVfBitmap> params; |
|
2920 iSettingProvider.ProvideCameraParamL( ECameraParamVfBitmap, ¶ms ); |
|
2921 iInfo.iViewfinderFormat = params().iFormat; |
|
2922 iInfo.iViewfinderSize = params().iRect.Size(); |
|
2923 #ifdef CAMERAAPP_CAE_FIX |
|
2924 if( iCaeInUse ) |
|
2925 { |
|
2926 PRINT( _L("Camera <> Call CCaeEngine::StartViewFinderBitmapsL..") ); |
|
2927 |
|
2928 OstTrace0( CAMERAAPP_PERFORMANCE, DUP2_CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_VF_INIT 0" ); //CCORAPP_APP_VF_INIT_END |
|
2929 OstTrace0( CAMERAAPP_PERFORMANCE, DUP3_CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_OVERLAY_INIT 0" ); //CCORAPP_APP_OVERLAY_INIT_END |
|
2930 iCaeEngine->StartViewFinderBitmapsL( iInfo.iViewfinderSize ); |
|
2931 } |
|
2932 else |
|
2933 #endif // CAMERAAPP_CAE_FIX |
|
2934 { |
|
2935 PRINT( _L("Camera <> Call CCamera::StartViewFinderBitmapsL..") ); |
|
2936 OstTrace0( CAMERAAPP_PERFORMANCE, DUP4_CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_VF_INIT 0" ); //CCORAPP_APP_VF_INIT_END |
|
2937 OstTrace0( CAMERAAPP_PERFORMANCE, DUP5_CCAMCAMERACONTROLLER_PROCESSVFSTARTREQUESTL, "e_CAM_APP_OVERLAY_INIT 0" ); //CCORAPP_APP_OVERLAY_INIT_END |
|
2938 iCamera->StartViewFinderBitmapsL( iInfo.iViewfinderSize ); |
|
2939 |
|
2940 if ( params().iMirrorImage ) |
|
2941 { |
|
2942 iCamera->SetViewFinderMirrorL( params().iMirrorImage ); |
|
2943 } |
|
2944 } |
|
2945 } |
|
2946 // ------------------------------- |
|
2947 |
|
2948 iInfo.iVfState = ECamTriActive; |
|
2949 //view finder started now(set stop status as false) |
|
2950 appUi->SetViewFinderStoppedStatus( EFalse ); |
|
2951 break; |
|
2952 } |
|
2953 // ----------------------------------------------------- |
|
2954 case ECamTriActive: |
|
2955 { |
|
2956 PRINT( _L("Camera <> case ECamTriActive") ); |
|
2957 // Viewfinder started *and* the right mode |
|
2958 // no action needed. |
|
2959 break; |
|
2960 } |
|
2961 // ----------------------------------------------------- |
|
2962 default: |
|
2963 Panic( ECamCameraControllerCorrupt ); |
|
2964 break; |
|
2965 // ----------------------------------------------------- |
|
2966 } |
|
2967 } |
|
2968 PRINT( _L("Camera <= CCamCameraController::ProcessVfStartRequestL") ); |
|
2969 } |
|
2970 |
|
2971 |
|
2972 |
|
2973 // --------------------------------------------------------------------------- |
|
2974 // ProcessVfStopRequestL |
|
2975 // |
|
2976 // --------------------------------------------------------------------------- |
|
2977 // |
|
2978 void |
|
2979 CCamCameraController::ProcessVfStopRequestL() |
|
2980 { |
|
2981 PRINT( _L("Camera => CCamCameraController::ProcessVfStopRequestL") ); |
|
2982 |
|
2983 switch( iInfo.iVfState ) |
|
2984 { |
|
2985 case ECamTriActive: |
|
2986 { |
|
2987 ProcessVfStopEcamRequest(); |
|
2988 iInfo.iVfState = ECamTriInactive; |
|
2989 break; |
|
2990 } |
|
2991 case ECamTriIdle: |
|
2992 { |
|
2993 // Viewfinder not initialized. |
|
2994 // Let this pass as our "start viewfinder" handles all states. |
|
2995 break; |
|
2996 } |
|
2997 case ECamTriInactive: |
|
2998 { |
|
2999 // Already stopped. No action needed. |
|
3000 break; |
|
3001 } |
|
3002 default: |
|
3003 { |
|
3004 Panic( ECamCameraControllerCorrupt ); |
|
3005 break; |
|
3006 } |
|
3007 } |
|
3008 PRINT( _L("Camera <= CCamCameraController::ProcessVfStopRequestL") ); |
|
3009 } |
|
3010 |
|
3011 |
|
3012 // --------------------------------------------------------------------------- |
|
3013 // ProcessVfStopEcamRequest |
|
3014 // |
|
3015 // --------------------------------------------------------------------------- |
|
3016 // |
|
3017 void |
|
3018 CCamCameraController::ProcessVfStopEcamRequest() |
|
3019 { |
|
3020 PRINT( _L("Camera => CCamCameraController::ProcessVfStopEcamRequest") ); |
|
3021 |
|
3022 if( ECamViewfinderDirect == iInfo.iVfMode ) |
|
3023 { |
|
3024 #ifdef CAMERAAPP_CAPI_V2_DVF |
|
3025 if ( iCamera ) |
|
3026 { |
|
3027 PRINT( _L("Camera <> VF stop by CCamera") ); |
|
3028 iCamera->StopViewFinder(); |
|
3029 } |
|
3030 #else // CAMERAAPP_CAPI_V2_DVF |
|
3031 Panic( ECamCameraControllerUnsupported ); |
|
3032 #endif // CAMERAAPP_CAPI_V2_DVF |
|
3033 } |
|
3034 else |
|
3035 { |
|
3036 #ifdef CAMERAAPP_CAE_FIX |
|
3037 if( iCaeInUse && iCaeEngine ) |
|
3038 { |
|
3039 PRINT( _L("Camera <> stop by CAE") ); |
|
3040 iCaeEngine->StopViewFinder(); |
|
3041 } |
|
3042 else |
|
3043 #endif // CAMERAAPP_CAE_FIX |
|
3044 { |
|
3045 if ( iCamera ) |
|
3046 { |
|
3047 PRINT( _L("Camera <> stop by CCamera") ); |
|
3048 iCamera->StopViewFinder(); |
|
3049 } |
|
3050 } |
|
3051 } |
|
3052 PRINT( _L("Camera <= CCamCameraController::ProcessVfStopEcamRequest") ); |
|
3053 } |
|
3054 |
|
3055 |
|
3056 // --------------------------------------------------------------------------- |
|
3057 // |
|
3058 // --------------------------------------------------------------------------- |
|
3059 // |
|
3060 void |
|
3061 CCamCameraController |
|
3062 ::ProcessVfRelaseRequest() |
|
3063 { |
|
3064 switch( iInfo.iVfState ) |
|
3065 { |
|
3066 // ----------------------------------------------------- |
|
3067 case ECamTriActive: |
|
3068 { |
|
3069 // Do the stopping first and continue then with release. |
|
3070 // Leaves only if iVfState is ECamVfIdle, which is not the case here. |
|
3071 TRAP_IGNORE( ProcessVfStopRequestL() ); |
|
3072 |
|
3073 // Need to notify here, because done as a part of other request. |
|
3074 NotifyObservers( KErrNone, |
|
3075 ECamCameraEventVfStop, |
|
3076 ECamCameraEventClassVfControl ); |
|
3077 // << fall through >> |
|
3078 } |
|
3079 // ----------------------------------------------------- |
|
3080 case ECamTriInactive: |
|
3081 { |
|
3082 if( ECamViewfinderDirect == iInfo.iVfMode ) |
|
3083 { |
|
3084 #ifdef CAMERAAPP_CAPI_V2_DVF |
|
3085 delete iDirectViewfinder; |
|
3086 iDirectViewfinder = NULL; |
|
3087 #endif |
|
3088 } |
|
3089 else |
|
3090 { |
|
3091 // No further actions needed for bitmap viewfinding. |
|
3092 } |
|
3093 // These may very well remain as they are. |
|
3094 // Atleast for the format there is no "zero" value available. |
|
3095 // iInfo.iViewfinderSize |
|
3096 // iInfo.iViewfinderFormat |
|
3097 iInfo.iVfState = ECamTriIdle; |
|
3098 iInfo.iVfMode = ECamViewfinderNone; |
|
3099 break; |
|
3100 } |
|
3101 // ----------------------------------------------------- |
|
3102 case ECamTriIdle: |
|
3103 // Already released. |
|
3104 break; |
|
3105 // ----------------------------------------------------- |
|
3106 default: |
|
3107 Panic( ECamCameraControllerCorrupt ); |
|
3108 break; |
|
3109 // ----------------------------------------------------- |
|
3110 } |
|
3111 } |
|
3112 |
|
3113 |
|
3114 // --------------------------------------------------------------------------- |
|
3115 // ProcessImageRequestL |
|
3116 // --------------------------------------------------------------------------- |
|
3117 // |
|
3118 TInt |
|
3119 CCamCameraController |
|
3120 ::ProcessImageRequestL( const TCamCameraRequestId& aRequestId ) |
|
3121 { |
|
3122 PRINT( _L("Camera => CCamCameraController::ProcessImageRequestL") ); |
|
3123 CheckFlagOnL( iInfo.iState, ECamPowerOn, KErrNotReady ); |
|
3124 |
|
3125 TInt callback( ETrue ); |
|
3126 switch( aRequestId ) |
|
3127 { |
|
3128 // ----------------------------------------------------- |
|
3129 case ECamRequestImageInit: |
|
3130 { |
|
3131 // When camera engine still capture don't Init a new capture |
|
3132 |
|
3133 if ( ECamCaptureOn == iInfo.iCaptureState ) |
|
3134 { |
|
3135 return EFalse; |
|
3136 } |
|
3137 CAMERAAPP_PERF_CONTROLLER_START( ECamRequestImageInit ); |
|
3138 |
|
3139 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
3140 #ifdef CAMERAAPP_CAE_FIX |
|
3141 if( iCaeInUse ) |
|
3142 { |
|
3143 iModeChange = ECamModeChangeVideo2Image; |
|
3144 iModeChangePhase = ECamModeChangePhaseIdle; // incremented before first step |
|
3145 iModeChangeStatus = KErrNone; |
|
3146 iActive->IssueRequest(); |
|
3147 } |
|
3148 else |
|
3149 #else |
|
3150 if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
3151 { |
|
3152 // Release any video recording resources |
|
3153 iCaeEngine->CloseVideoRecording(); |
|
3154 ClearFlags( iInfo.iState, ECamVideoOn ); |
|
3155 } |
|
3156 #endif // CAMERAAPP_CAE_FIX |
|
3157 #endif |
|
3158 { |
|
3159 PRINT( _L("Camera <> Checking that image capture not ongoing..") ); |
|
3160 CheckEqualsL( iInfo.iCaptureState, ECamCaptureOff, KErrInUse ); |
|
3161 |
|
3162 PRINT( _L("Camera <> Checking that image capture supported..") ); |
|
3163 CheckFlagOnL( iCameraInfo.iOptionsSupported, |
|
3164 TCameraInfo::EImageCaptureSupported, |
|
3165 KErrNotSupported ); |
|
3166 |
|
3167 PRINT( _L("Camera <> Ask image parameters..") ); |
|
3168 TPckgBuf<TCamParamsImage> params; |
|
3169 iSettingProvider.ProvideCameraParamL( ECameraParamImage, ¶ms ); |
|
3170 |
|
3171 PRINT( _L("Camera <> Enumerating capture sizes..") ); |
|
3172 // Query the supported resolutions for the selected format. |
|
3173 // GetResolutionIndexL may change the format to some alternative, |
|
3174 // if we are able to convert the incoming image later to the |
|
3175 // format requested by client. |
|
3176 CCamera::TFormat format( params().iFormat ); |
|
3177 TInt index = GetResolutionIndexL( format, params().iSize ); |
|
3178 User::LeaveIfError( index ); |
|
3179 |
|
3180 PRINT( _L("Camera <> Call CCamera::PrepareImageCaptureL..") ); |
|
3181 PRINT2( _L("Camera <> Image size: (%d, %d)"), |
|
3182 params().iSize.iWidth, |
|
3183 params().iSize.iHeight ); |
|
3184 |
|
3185 OstTrace0( CAMERAAPP_PERFORMANCE, CCAMCAMERACONTROLLER_PROCESSIMAGEREQUESTL, "e_CAM_APP_CONFIGURATIONS 0" ); //CCORAPP_APP_CONFIGS_END |
|
3186 iCamera->PrepareImageCaptureL( format, index ); |
|
3187 OstTrace0( CAMERAAPP_PERFORMANCE, DUP1_CCAMCAMERACONTROLLER_PROCESSIMAGEREQUESTL, "e_CAM_APP_STILL_INIT 0" ); //CCORAPP_APP_STILL_INIT_END |
|
3188 OstTrace0( CAMERAAPP_PERFORMANCE, DUP2_CCAMCAMERACONTROLLER_PROCESSIMAGEREQUESTL, "e_CAM_APP_OVERLAY_INIT 1" ); //CCORAPP_APP_OVERLAY_INIT_START |
|
3189 |
|
3190 iCamera->SetJpegQuality( params().iQualityFactor ); |
|
3191 |
|
3192 SetFlags( iInfo.iState, ECamImageOn ); |
|
3193 |
|
3194 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
3195 // Set current autofocus range to invalid value to force focusing |
|
3196 iInfo.iCurrentFocusRange = static_cast<CAS::TFocusRange>( -1 ); |
|
3197 GetAdvancedSettingsInfoL(); |
|
3198 #endif // CAMERAAPP_CAPI_V2_ADV |
|
3199 |
|
3200 iInfo.iCaptureCount = 0; |
|
3201 iInfo.iSnapshotCount = 0; |
|
3202 callback = EFalse; // No callback to wait for. |
|
3203 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestImageInit ); |
|
3204 } |
|
3205 break; |
|
3206 } |
|
3207 // ----------------------------------------------------- |
|
3208 case ECamRequestImageCapture: |
|
3209 { |
|
3210 CheckFlagOnL( iInfo.iState, ECamImageOn, KErrNotReady ); |
|
3211 CheckEqualsL( iInfo.iCaptureState, ECamCaptureOff, KErrInUse ); |
|
3212 OstTrace0( CAMERAAPP_PERFORMANCE, DUP3_CCAMCAMERACONTROLLER_PROCESSIMAGEREQUESTL, "e_CAM_APP_CAPTURE_START 0" ); //CCORAPP_CAPTURE_START_END |
|
3213 |
|
3214 // New capture starts, reset capture and snapshot counters. |
|
3215 iInfo.iCaptureCount = 0; |
|
3216 iInfo.iSnapshotCount = 0; |
|
3217 iInfo.iCaptureState = ECamCaptureOn; |
|
3218 |
|
3219 PRINT1( _L("Camera <> CCamCameraController .. About to start capture, total shared buffers in use: %d"), CCamBufferShare::TotalBufferShareCount() ); |
|
3220 iCamera->CaptureImage(); |
|
3221 |
|
3222 // When image data is received from CCamera, |
|
3223 // an event is generated for that. We need to notify |
|
3224 // here as other places check if the request has associated |
|
3225 // callback, and send no notification yet if callback exist. |
|
3226 NotifyObservers( KErrNone, |
|
3227 ECamCameraEventImageStart, |
|
3228 ECamCameraEventClassImage ); |
|
3229 break; |
|
3230 } |
|
3231 // ----------------------------------------------------- |
|
3232 default: |
|
3233 { |
|
3234 Panic( ECamCameraControllerCorrupt ); |
|
3235 break; |
|
3236 } |
|
3237 // ----------------------------------------------------- |
|
3238 } |
|
3239 PRINT1( _L("Camera <= CCamCameraController::ProcessImageRequestL, continue now:%d"), !callback ); |
|
3240 return !callback; |
|
3241 } |
|
3242 |
|
3243 |
|
3244 // --------------------------------------------------------------------------- |
|
3245 // ProcessImageShutdownRequest |
|
3246 // --------------------------------------------------------------------------- |
|
3247 // |
|
3248 TInt |
|
3249 CCamCameraController |
|
3250 ::ProcessImageShutdownRequest( const TCamCameraRequestId& aRequestId ) |
|
3251 { |
|
3252 PRINT( _L("Camera => CCamCameraController::ProcessImageShutdownRequest") ); |
|
3253 |
|
3254 switch( aRequestId ) |
|
3255 { |
|
3256 // ----------------------------------------------------- |
|
3257 case ECamRequestImageCancel: |
|
3258 { |
|
3259 if( IsFlagOn( iInfo.iState, ECamImageOn ) |
|
3260 // && ECamCaptureOn == iInfo.iCaptureState |
|
3261 ) |
|
3262 { |
|
3263 const TCamCameraCaptureState previousState( iInfo.iCaptureState ); |
|
3264 |
|
3265 if( iEncoder ) |
|
3266 { |
|
3267 iEncoder->Cancel(); |
|
3268 |
|
3269 delete iEncoder; |
|
3270 iEncoder = NULL; |
|
3271 } |
|
3272 |
|
3273 PRINT( _L("Camera <> Calling iCamera->CancelCaptureImage()") ); |
|
3274 iCamera->CancelCaptureImage(); |
|
3275 |
|
3276 iInfo.iCaptureState = ECamCaptureOff; |
|
3277 |
|
3278 // Notify if we actually stopped the capturing here. |
|
3279 if( ECamCaptureOn == previousState ) |
|
3280 { |
|
3281 |
|
3282 // Capturing image was stopped here. |
|
3283 // If single request was ongoing, it must be "capture image". |
|
3284 ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
3285 |
|
3286 TInt fullCaptures( Min( iInfo.iCaptureCount, iInfo.iSnapshotCount ) ); |
|
3287 NotifyObservers( KErrNone, |
|
3288 ECamCameraEventImageStop, |
|
3289 ECamCameraEventClassImage, |
|
3290 &fullCaptures ); |
|
3291 } |
|
3292 } |
|
3293 break; |
|
3294 } |
|
3295 // ----------------------------------------------------- |
|
3296 case ECamRequestImageRelease: |
|
3297 { |
|
3298 // Cancel any pending capture. |
|
3299 ProcessImageShutdownRequest( ECamRequestImageCancel ); |
|
3300 |
|
3301 // Nothing else really needed for image, just set flags. |
|
3302 ClearFlags( iInfo.iState, ECamImageOn ); |
|
3303 iInfo.iCaptureCount = 0; |
|
3304 iInfo.iSnapshotCount = 0; |
|
3305 iInfo.iCaptureState = ECamCaptureOff; |
|
3306 |
|
3307 break; |
|
3308 } |
|
3309 // ----------------------------------------------------- |
|
3310 default: |
|
3311 { |
|
3312 Panic( ECamCameraControllerCorrupt ); |
|
3313 break; |
|
3314 } |
|
3315 // ----------------------------------------------------- |
|
3316 } |
|
3317 PRINT( _L("Camera <= CCamCameraController::ProcessImageShutdownRequest") ); |
|
3318 return ETrue; // can continue sequence, if needed |
|
3319 } |
|
3320 |
|
3321 |
|
3322 |
|
3323 // --------------------------------------------------------------------------- |
|
3324 // ProcessVideoRequestL |
|
3325 // --------------------------------------------------------------------------- |
|
3326 // |
|
3327 TInt |
|
3328 CCamCameraController |
|
3329 ::ProcessVideoRequestL( const TCamCameraRequestId& aRequestId ) |
|
3330 { |
|
3331 PRINT( _L("Camera => CCamCameraController::ProcessVideoRequestL") ); |
|
3332 CheckFlagOnL( iInfo.iState, ECamPowerOn, KErrNotReady ); |
|
3333 |
|
3334 TInt callback( ETrue ); |
|
3335 |
|
3336 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
3337 switch( aRequestId ) |
|
3338 { |
|
3339 // ----------------------------------------------------- |
|
3340 case ECamRequestVideoInit: |
|
3341 { |
|
3342 PRINT( _L("Camera <> case ECamRequestVideoInit") ); |
|
3343 #ifdef CAMERAAPP_CAE_FIX |
|
3344 PRINT( _L("Camera <> old CAE") ); |
|
3345 // First init for video after image mode or startup |
|
3346 if( !IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
3347 { |
|
3348 iModeChange = ECamModeChangeImage2Video; |
|
3349 iModeChangePhase = ECamModeChangePhaseIdle; // incremented before first step |
|
3350 iModeChangeStatus = KErrNone; |
|
3351 iActive->IssueRequest(); |
|
3352 } |
|
3353 // Just repeat prepare |
|
3354 else |
|
3355 #else |
|
3356 PRINT( _L("Camera <> new CAE, CCameraHandle + SetCameraReserved supported") ); |
|
3357 if( !IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
3358 { |
|
3359 PRINT( _L("Camera <> CCaeEngine::EnableVideoRecording..") ); |
|
3360 iCaeEngine->EnableVideoRecording(); |
|
3361 } |
|
3362 #endif |
|
3363 { |
|
3364 if ( iAppController.VideoInitNeeded() ) |
|
3365 { |
|
3366 PRINT( _L("Camera <> CCaeEngine::InitVideoRecorderL..") ); |
|
3367 iCaeEngine->InitVideoRecorderL(); |
|
3368 } |
|
3369 |
|
3370 PRINT( _L("Camera <> Ask filename..") ); |
|
3371 HBufC* filename( HBufC::NewLC( KMaxFileName ) ); |
|
3372 TPtr ptr ( filename->Des() ); |
|
3373 iSettingProvider.ProvideCameraSettingL( ECameraSettingFileName, &ptr ); |
|
3374 // _LIT( KTempFilename, "C:\\video.3gp" ); |
|
3375 // TPtrC ptr; |
|
3376 // ptr.Set( KTempFilename() ); |
|
3377 PRINT1( _L("Camera <> Set filename [%S]"), &ptr ); |
|
3378 iCaeEngine->SetVideoRecordingFileNameL( ptr ); |
|
3379 CleanupStack::PopAndDestroy( filename ); |
|
3380 |
|
3381 // Set max video clip size |
|
3382 ProcessSettingL( ECameraSettingFileMaxSize ); |
|
3383 |
|
3384 TPckgBuf<TCamParamsVideoCae> params; |
|
3385 PRINT( _L("Camera <> Getting params from setting provider..") ); |
|
3386 iSettingProvider.ProvideCameraParamL( ECameraParamVideoCae, ¶ms ); |
|
3387 // The audioOn value is defined On==0 and Off==1, but the engine expects |
|
3388 // ETrue if audio recording is On |
|
3389 params().iAudioOn = ( ECamSettOn == params().iAudioOn ) |
|
3390 ? ETrue |
|
3391 : EFalse; |
|
3392 PRINT( _L("Camera <> Calling PrepareVideoRecordingL..") ); |
|
3393 PRINT2( _L("Camera <> FrameSize: (%d x %d)"), params().iFrameSize.iWidth, params().iFrameSize.iHeight ); |
|
3394 if ( iAppController.VideoInitNeeded() ) |
|
3395 { |
|
3396 // McaeoVideoPrepareComplete will be called when prepare is ready. |
|
3397 // The callback is allowed to come also *during* this call. |
|
3398 iCaeEngine->PrepareVideoRecordingL( params().iFrameSize, |
|
3399 params().iFrameRate, |
|
3400 params().iVideoBitRate, |
|
3401 params().iAudioOn, |
|
3402 params().iAudioBitRate, |
|
3403 params().iMimeType, |
|
3404 params().iSupplier, |
|
3405 params().iVideoType, |
|
3406 params().iAudioType ); |
|
3407 } |
|
3408 |
|
3409 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
3410 // Set current autofocus range to invalid value to force focusing |
|
3411 iInfo.iCurrentFocusRange = static_cast<CAS::TFocusRange>( -1 ); |
|
3412 #endif // CAMERAAPP_CAPI_V2_ADV |
|
3413 |
|
3414 iAppController.SetVideoInitNeeded( EFalse ); |
|
3415 // iState is updated in the callback. |
|
3416 PRINT( _L("Camera <> ..waiting for callback") ); |
|
3417 } |
|
3418 break; |
|
3419 } |
|
3420 // ----------------------------------------------------- |
|
3421 case ECamRequestVideoStart: |
|
3422 { |
|
3423 PRINT( _L("Camera <> case ECamRequestVideoStart") ); |
|
3424 CheckFlagOnL( iInfo.iState, ECamVideoOn, KErrNotReady ); |
|
3425 switch( iInfo.iCaptureState ) |
|
3426 { |
|
3427 case ECamCaptureOn: User::Leave( KErrInUse ); break; |
|
3428 case ECamCaptureOff: iCaeEngine->StartVideoRecording(); break; |
|
3429 //case ECamCaptureOff: iCaeEngine->ResumeVideoRecording(); break; |
|
3430 case ECamCapturePaused: iCaeEngine->ResumeVideoRecording(); break; |
|
3431 default: |
|
3432 Panic( ECamCameraControllerCorrupt ); |
|
3433 break; |
|
3434 } |
|
3435 // iCaptureState is updated in McaeoVideoRecordingOn. |
|
3436 break; |
|
3437 } |
|
3438 // ----------------------------------------------------- |
|
3439 case ECamRequestVideoPause: |
|
3440 { |
|
3441 PRINT( _L("Camera <> case ECamRequestVideoPause") ); |
|
3442 CheckEqualsL( iInfo.iCaptureState, ECamCaptureOn, KErrNotReady ); |
|
3443 iCaeEngine->PauseVideoRecording(); |
|
3444 // iCaptureState is updated in McaeoVideoRecordingPaused. |
|
3445 break; |
|
3446 } |
|
3447 // ----------------------------------------------------- |
|
3448 case ECamRequestVideoStop: |
|
3449 { |
|
3450 PRINT( _L("Camera <> case ECamRequestVideoStop") ); |
|
3451 switch( iInfo.iCaptureState ) |
|
3452 { |
|
3453 case ECamCaptureOn: // << fall through >> |
|
3454 case ECamCapturePaused: |
|
3455 PRINT( _L("Camera <> call CCaeEngine::StopVideoRecording..") ); |
|
3456 iCaeEngine->StopVideoRecording(); |
|
3457 // If we got the callback during above call, |
|
3458 // we should not wait for it anymore. |
|
3459 // Check the capture state to be sure. |
|
3460 callback = (ECamCaptureOff != iInfo.iCaptureState); |
|
3461 break; |
|
3462 case ECamCaptureOff: |
|
3463 // no action, already stopped |
|
3464 break; |
|
3465 default: |
|
3466 Panic( ECamCameraControllerCorrupt ); |
|
3467 break; |
|
3468 } |
|
3469 // iCaptureState is updated in McaeoVideoRecordingComplete. |
|
3470 break; |
|
3471 } |
|
3472 // ----------------------------------------------------- |
|
3473 case ECamRequestVideoRelease: |
|
3474 { |
|
3475 // Need to be stopped. |
|
3476 CheckEqualsL( iInfo.iCaptureState, ECamCaptureOff, KErrInUse ); |
|
3477 |
|
3478 if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
3479 iCaeEngine->CloseVideoRecording(); |
|
3480 |
|
3481 ClearFlags( iInfo.iState, ECamVideoOn ); |
|
3482 callback = EFalse; |
|
3483 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
3484 GetAdvancedSettingsInfoL(); |
|
3485 #endif |
|
3486 break; |
|
3487 } |
|
3488 // ----------------------------------------------------- |
|
3489 case ECamRequestSetAsyncVideoStopMode: |
|
3490 { |
|
3491 TInt err = iCaeEngine->SetAsyncVideoStopMode( ETrue ); |
|
3492 PRINT1( _L("Camera <> CCamCameraController::ProcessVideoRequestL, engine SetAsyncVideoStopMode return code:%d"), err ); |
|
3493 iAsyncVideoStopModeSupported = !err; // Use async stop if KErrNone |
|
3494 callback = EFalse; |
|
3495 break; |
|
3496 } |
|
3497 // ----------------------------------------------------- |
|
3498 default: |
|
3499 Panic( ECamCameraControllerCorrupt ); |
|
3500 break; |
|
3501 // ----------------------------------------------------- |
|
3502 } |
|
3503 #else |
|
3504 #pragma message("CCamCameraController::ProcessVideoRequestL not implemented!") |
|
3505 PRINT( _L("Camera <> Not supported, PANIC!") ); |
|
3506 Panic( ECamCameraControllerUnsupported ); |
|
3507 #endif // CAMERAAPP_CAE_FOR_VIDEO |
|
3508 |
|
3509 PRINT1( _L("Camera <= CCamCameraController::ProcessVideoRequestL, continue now:%d"), !callback ); |
|
3510 return !callback; |
|
3511 } |
|
3512 |
|
3513 |
|
3514 |
|
3515 // --------------------------------------------------------------------------- |
|
3516 // ProcessSnapshotRequestL |
|
3517 // --------------------------------------------------------------------------- |
|
3518 // |
|
3519 TInt |
|
3520 CCamCameraController |
|
3521 ::ProcessSnapshotRequestL( const TCamCameraRequestId& aRequestId ) |
|
3522 { |
|
3523 PRINT( _L("Camera => CCamCameraController::ProcessSnapshotRequestL") ); |
|
3524 OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMCAMERACONTROLLER_PROCESSSNAPSHOTREQUESTL, "e_CCamCameraController_ProcessSnapshotRequestL 1" ); |
|
3525 CheckFlagOnL( iInfo.iState, ECamReserved, KErrNotReady ); |
|
3526 |
|
3527 switch( aRequestId ) |
|
3528 { |
|
3529 // ----------------------------------------------------- |
|
3530 case ECamRequestSsStart: |
|
3531 { |
|
3532 PRINT( _L("Camera <> case ECamRequestSsStart") ); |
|
3533 switch( iInfo.iSsState ) |
|
3534 { |
|
3535 case ECamTriIdle: |
|
3536 PRINT( _L("Camera <> ECamTriIdle") ); |
|
3537 InitSnapshotL(); |
|
3538 // << fall through >> |
|
3539 case ECamTriInactive: |
|
3540 { |
|
3541 PRINT( _L("Camera <> ECamTriInactive") ); |
|
3542 iSnapshotProvider->StartSnapshot(); |
|
3543 break; |
|
3544 } |
|
3545 case ECamTriActive: // Already active, no action |
|
3546 PRINT( _L("Camera <> ECamTriActive") ); |
|
3547 break; |
|
3548 default: |
|
3549 Panic( ECamCameraControllerCorrupt ); |
|
3550 break; |
|
3551 } |
|
3552 iInfo.iSsState = ECamTriActive; |
|
3553 break; |
|
3554 } |
|
3555 // ----------------------------------------------------- |
|
3556 case ECamRequestSsStop: |
|
3557 { |
|
3558 PRINT( _L("Camera <> case ECamRequestSsStop") ); |
|
3559 ProcessSsStopRequest(); |
|
3560 break; |
|
3561 } |
|
3562 // ----------------------------------------------------- |
|
3563 case ECamRequestSsRelease: |
|
3564 { |
|
3565 PRINT( _L("Camera <> case ECamRequestSsRelease") ); |
|
3566 ProcessSsReleaseRequest(); |
|
3567 break; |
|
3568 } |
|
3569 // ----------------------------------------------------- |
|
3570 default: |
|
3571 Panic( ECamCameraControllerCorrupt ); |
|
3572 break; |
|
3573 // ----------------------------------------------------- |
|
3574 } |
|
3575 OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMCAMERACONTROLLER_PROCESSSNAPSHOTREQUESTL, "e_CCamCameraController_ProcessSnapshotRequestL 0" ); |
|
3576 |
|
3577 PRINT( _L("Camera <= CCamCameraController::ProcessSnapshotRequestL") ); |
|
3578 |
|
3579 // No callback to wait for any of the requests => can continue now. |
|
3580 return ETrue; |
|
3581 } |
|
3582 |
|
3583 // --------------------------------------------------------------------------- |
|
3584 // ProcessSsStopRequest |
|
3585 // --------------------------------------------------------------------------- |
|
3586 // |
|
3587 void |
|
3588 CCamCameraController::ProcessSsStopRequest() |
|
3589 { |
|
3590 PRINT( _L("Camera <= CCamCameraController::ProcessSsStopRequest") ); |
|
3591 switch( iInfo.iSsState ) |
|
3592 { |
|
3593 case ECamTriIdle: // Not even initialized yet. No action needed. |
|
3594 case ECamTriInactive: // Already inactive, no action. |
|
3595 PRINT( _L("Camera <> Snapshot idle/inactive, no need to stop") ); |
|
3596 break; |
|
3597 case ECamTriActive: |
|
3598 PRINT( _L("Camera <> Snapshot ECamTriActive -> need to stop") ); |
|
3599 iSnapshotProvider->StopSnapshot(); |
|
3600 break; |
|
3601 default: |
|
3602 Panic( ECamCameraControllerCorrupt ); |
|
3603 break; |
|
3604 } |
|
3605 iInfo.iSsState = ECamTriInactive; |
|
3606 PRINT( _L("Camera <= CCamCameraController::ProcessSsStopRequest") ); |
|
3607 } |
|
3608 |
|
3609 // --------------------------------------------------------------------------- |
|
3610 // ProcessSsReleaseRequest |
|
3611 // --------------------------------------------------------------------------- |
|
3612 // |
|
3613 void |
|
3614 CCamCameraController::ProcessSsReleaseRequest() |
|
3615 { |
|
3616 PRINT( _L("Camera => CCamCameraController::ProcessSsReleaseRequest") ); |
|
3617 switch( iInfo.iSsState ) |
|
3618 { |
|
3619 case ECamTriIdle: // No action needed |
|
3620 break; |
|
3621 case ECamTriActive: |
|
3622 iSnapshotProvider->StopSnapshot(); |
|
3623 NotifyObservers( KErrNone, |
|
3624 ECamCameraEventSsStop, |
|
3625 ECamCameraEventClassSsControl ); |
|
3626 // << fall through >> |
|
3627 case ECamTriInactive: |
|
3628 delete iSnapshotProvider; |
|
3629 iSnapshotProvider = NULL; |
|
3630 break; |
|
3631 default: |
|
3632 Panic( ECamCameraControllerCorrupt ); |
|
3633 break; |
|
3634 } |
|
3635 |
|
3636 iInfo.iSsState = ECamTriIdle; |
|
3637 PRINT( _L("Camera <= CCamCameraController::ProcessSsReleaseRequest") ); |
|
3638 } |
|
3639 |
|
3640 // --------------------------------------------------------------------------- |
|
3641 // InitSnapshotL |
|
3642 // --------------------------------------------------------------------------- |
|
3643 // |
|
3644 void |
|
3645 CCamCameraController::InitSnapshotL() |
|
3646 { |
|
3647 PRINT( _L("Camera => CCamCameraController::InitSnapshotL") ); |
|
3648 |
|
3649 // Check the snapshot state here. No further checks made. |
|
3650 __ASSERT_DEBUG( ECamTriIdle == iInfo.iSsState, Panic( ECamCameraControllerCorrupt ) ); |
|
3651 |
|
3652 // ------------------------------------------------------- |
|
3653 // Create snapshot provider if not available yet. |
|
3654 if( !iSnapshotProvider ) |
|
3655 { |
|
3656 iSnapshotProvider = CCamSnapshotProvider::NewL( *iCamera, *this, *this ); |
|
3657 } |
|
3658 |
|
3659 #ifdef _DEBUG |
|
3660 PrintSnapshotInfo(); |
|
3661 #endif // _DEBUG |
|
3662 |
|
3663 |
|
3664 // ------------------------------------------------------- |
|
3665 // Initialize the snapshot parameters |
|
3666 TPckgBuf<TCamParamsSnapshot> params; |
|
3667 iSettingProvider.ProvideCameraParamL( ECameraParamSnapshot, ¶ms ); |
|
3668 |
|
3669 // Try to get the best, still supported, snapshot format. |
|
3670 iInfo.iSnapshotFormat = ResolveSnapshotFormatL( params().iFormat ); |
|
3671 iInfo.iSnapshotSize = params().iSize; |
|
3672 iInfo.iSnapshotAspectMaintain = params().iMaintainAspect; |
|
3673 |
|
3674 PRINT( _L("Camera <> Prepare snapshot..") ); |
|
3675 iSnapshotProvider->PrepareSnapshotL( iInfo.iSnapshotFormat, |
|
3676 iInfo.iSnapshotSize, |
|
3677 iInfo.iSnapshotAspectMaintain ); |
|
3678 |
|
3679 iInfo.iSsState = ECamTriInactive; |
|
3680 // ------------------------------------------------------- |
|
3681 PRINT( _L("Camera <= CCamCameraController::InitSnapshotL") ); |
|
3682 } |
|
3683 |
|
3684 |
|
3685 // --------------------------------------------------------------------------- |
|
3686 // CCamCameraController::ProcessAutofocusRequestL |
|
3687 // --------------------------------------------------------------------------- |
|
3688 // |
|
3689 void CCamCameraController::ProcessAutofocusRequestL( const TCamCameraRequestId& aRequestId ) |
|
3690 { |
|
3691 PRINT( _L("Camera => CCamCameraController::ProcessAutofocusRequestL") ); |
|
3692 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
3693 CheckNonNullL( iAdvancedSettings, KErrNotReady ); |
|
3694 if( ECamRequestStartAutofocus == aRequestId ) |
|
3695 { |
|
3696 PRINT( _L("Camera <> SetAutoFocusType( EAutoFocusTypeSingle )") ); |
|
3697 iAdvancedSettings->SetAutoFocusType( CAS::EAutoFocusTypeSingle ); |
|
3698 iAfInProgress = ETrue; |
|
3699 iFirstAfEventReceived = EFalse; |
|
3700 } |
|
3701 else if( ECamRequestCancelAutofocus == aRequestId ) |
|
3702 { |
|
3703 if( iAfInProgress ) |
|
3704 { |
|
3705 // Autofocus in progress, need to cancel it before setting range to hyperfocal |
|
3706 PRINT( _L("Camera <> Cancel ongoing autofocus request") ); |
|
3707 iAdvancedSettings->SetAutoFocusType( CAS::EAutoFocusTypeOff ); |
|
3708 iAfHyperfocalPending = ETrue; |
|
3709 } |
|
3710 else |
|
3711 { |
|
3712 // If focustype is set to continuous, need to change it to off |
|
3713 // before continuing |
|
3714 |
|
3715 PRINT( _L("Camera <> SetAutoFocusType( EAutoFocusTypeOff )") ); |
|
3716 if ( iAdvancedSettings->AutoFocusType() & CAS::EAutoFocusTypeContinuous ) |
|
3717 { |
|
3718 iAdvancedSettings->SetAutoFocusType( CAS::EAutoFocusTypeOff ); |
|
3719 } |
|
3720 |
|
3721 PRINT( _L("Camera <> Cancel autofocus - set focus range to hyperfocal") ); |
|
3722 iInfo.iCurrentFocusRange = CAS::EFocusRangeHyperfocal; |
|
3723 iAdvancedSettings->SetFocusRange( CAS::EFocusRangeHyperfocal ); |
|
3724 |
|
3725 // Then start the focus. The callback of this cancel request sets |
|
3726 // a boolean in CamAppController, so the resulting optimal |
|
3727 // focus event does not change reticule/focus state. |
|
3728 iAdvancedSettings->SetAutoFocusType( CAS::EAutoFocusTypeSingle ); |
|
3729 iAfInProgress = ETrue; |
|
3730 } |
|
3731 } |
|
3732 else if( ECamRequestSetAfRange == aRequestId ) |
|
3733 { |
|
3734 PRINT( _L("Camera <> Set autofocus range") ); |
|
3735 // Get autofocus mode from settings provider |
|
3736 |
|
3737 CAS::TFocusRange afRange; |
|
3738 iSettingProvider.ProvideCameraSettingL( ECameraSettingFocusRange, &afRange ); |
|
3739 |
|
3740 if( iInfo.iCurrentFocusRange != afRange ) |
|
3741 { |
|
3742 iAdvancedSettings->SetFocusRange( afRange ); |
|
3743 |
|
3744 // Should this be done in the callback?: |
|
3745 iInfo.iCurrentFocusRange = afRange; |
|
3746 } |
|
3747 else |
|
3748 { |
|
3749 // Correct range already set. No need to do anything. |
|
3750 } |
|
3751 } |
|
3752 else |
|
3753 { |
|
3754 // Other request must not end up here |
|
3755 __ASSERT_DEBUG( EFalse, Panic( ECamCameraControllerCorrupt ) ); |
|
3756 } |
|
3757 #endif // CAMERAAPP_CAPI_V2_ADV |
|
3758 |
|
3759 (void)aRequestId; // removes compiler warning |
|
3760 PRINT( _L("Camera <= CCamCameraController::ProcessAutofocusRequestL") ); |
|
3761 } |
|
3762 |
|
3763 |
|
3764 |
|
3765 // --------------------------------------------------------------------------- |
|
3766 // ProcessCaptureLimitSettingL |
|
3767 // --------------------------------------------------------------------------- |
|
3768 // |
|
3769 void |
|
3770 CCamCameraController::ProcessCaptureLimitSettingL() |
|
3771 { |
|
3772 PRINT ( _L("Camera => CCamCameraController::ProcessCaptureLimitSettingL") ); |
|
3773 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
3774 // Check that we are prepared for image mode. |
|
3775 CheckFlagOnL( iInfo.iState, ECamImageOn, KErrNotReady ); |
|
3776 |
|
3777 // Get requested capture count and determine current and target drive modes. |
|
3778 TInt requestedLimit( 1 ); |
|
3779 iSettingProvider.ProvideCameraSettingL( ECameraSettingCaptureLimit, &requestedLimit ); |
|
3780 if( requestedLimit < 1 ) User::Leave( KErrArgument ); |
|
3781 |
|
3782 const CAS::TDriveMode& currentMode( iAdvancedSettings->DriveMode() ); |
|
3783 const CAS::TDriveMode targetMode ( requestedLimit <= 1 |
|
3784 ? CAS::EDriveModeSingleShot |
|
3785 : CAS::EDriveModeBurst ); |
|
3786 const TInt cameraLimit( iAdvancedSettings->BurstImages() ); |
|
3787 |
|
3788 PRINT ( _L("Camera <> CCamCameraController .. --------------------------------------") ); |
|
3789 PRINT1( _L("Camera <> CCamCameraController .. requested capture limit %04d"), requestedLimit ); |
|
3790 PRINT1( _L("Camera <> CCamCameraController .. current capture limit : %04d"), iInfo.iCaptureLimit ); |
|
3791 PRINT1( _L("Camera <> CCamCameraController .. current camera's limit : %04d"), cameraLimit ); |
|
3792 PRINT1( _L("Camera <> CCamCameraController .. current capture count : %04d"), iInfo.iCaptureCount ); |
|
3793 PRINT1( _L("Camera <> CCamCameraController .. current snapshot count : %04d"), iInfo.iSnapshotCount ); |
|
3794 PRINT1( _L("Camera <> CCamCameraController .. current drive mode : [%S]"), &DriveModeName( currentMode ) ); |
|
3795 PRINT1( _L("Camera <> CCamCameraController .. target drive mode : [%S]"), &DriveModeName( targetMode ) ); |
|
3796 PRINT ( _L("Camera <> CCamCameraController .. --------------------------------------") ); |
|
3797 |
|
3798 // ------------------------------------------------------- |
|
3799 // Determine needed changes and when to issue them |
|
3800 // |
|
3801 // During burst capture, we may receive snapshots and |
|
3802 // image data on mixed order, e.g: |
|
3803 // |
|
3804 // [ ss#1 | img#1 | ss#2 | ss#3 | img2 | img3 ] |
|
3805 // --------------^^--------------------------^^ |
|
3806 // |
|
3807 // C-API starts new burst capture when we adjust the |
|
3808 // capture limit. To avoid problems and to get equal |
|
3809 // amount of snapshots and images, capture count is |
|
3810 // only changed when we image data is received, |
|
3811 // and as many images as snapshots have arrived. |
|
3812 // In the chart above ^ marks a place where capture limit |
|
3813 // can be updated. |
|
3814 TBool callback( EFalse ); |
|
3815 |
|
3816 // ----------------------------------- |
|
3817 // Capture ongoing.. |
|
3818 if( ECamCaptureOn == iInfo.iCaptureState ) |
|
3819 { |
|
3820 PRINT( _L("Camera <> CCamCameraController .. Capture ongoing..") ); |
|
3821 if( targetMode != currentMode ) |
|
3822 { |
|
3823 // Cannot change drive mode during capturing. |
|
3824 PRINT( _L("Camera <> CCamCameraController .. Drive mode update not possible now, LEAVE!") ); |
|
3825 User::Leave( KErrInUse ); |
|
3826 } |
|
3827 else if ( CAS::EDriveModeBurst == currentMode ) |
|
3828 { |
|
3829 if( cameraLimit != requestedLimit ) |
|
3830 { |
|
3831 PRINT( _L("Camera <> CCamCameraController .. Adjusting capture limit during burst..") ); |
|
3832 // Set limit locally and react on next image data event. |
|
3833 iInfo.iCaptureLimit = Min( cameraLimit, Max( requestedLimit, iInfo.iCaptureCount+1 ) ); |
|
3834 PRINT1( _L("Camera <> CCamCameraController .. Set local capture limit to %d.."), iInfo.iCaptureLimit ); |
|
3835 } |
|
3836 else |
|
3837 { |
|
3838 PRINT( _L("Camera <> CCamCameraController .. Capture limit during burst already has right value.") ); |
|
3839 } |
|
3840 } |
|
3841 else |
|
3842 { |
|
3843 // No action needed. Capture limit of 1 image kept. |
|
3844 PRINT( _L("Camera <> CCamCameraController .. Single shot mode kept, no action") ); |
|
3845 } |
|
3846 } |
|
3847 // ----------------------------------- |
|
3848 // Not capturing |
|
3849 // |
|
3850 else |
|
3851 { |
|
3852 PRINT( _L("Camera <> CCamCameraController .. No capture ongoing..") ); |
|
3853 |
|
3854 iInfo.iCaptureLimit = requestedLimit; |
|
3855 // Capture limit has changed, |
|
3856 // check if drive mode also needs to be changed.. |
|
3857 if( targetMode != currentMode ) |
|
3858 { |
|
3859 PRINT1( _L("Camera <> CCamCameraController .. Calling SetDriveMode([%S])"), &DriveModeName( targetMode ) ); |
|
3860 iAdvancedSettings->SetDriveMode( targetMode ); |
|
3861 } |
|
3862 if( CAS::EDriveModeBurst == targetMode ) |
|
3863 { |
|
3864 PRINT1( _L("Camera <> CCamCameraController .. Calling SetBurstImages(%d).."), iInfo.iCaptureLimit ); |
|
3865 iAdvancedSettings->SetBurstImages( iInfo.iCaptureLimit ); |
|
3866 } |
|
3867 } |
|
3868 |
|
3869 // ------------------------------------------------------- |
|
3870 // Notify user that the change is done |
|
3871 // or wait for camera callbacks to finish. |
|
3872 PRINT1( _L("Camera <> CCamCameraController .. Should wait callback = %d"), callback ); |
|
3873 if( !callback ) |
|
3874 { |
|
3875 TInt setting( ECameraSettingCaptureLimit ); |
|
3876 NotifyObservers( KErrNone, |
|
3877 ECamCameraEventSettingsSingle, |
|
3878 ECamCameraEventClassSettings, |
|
3879 &setting ); |
|
3880 } |
|
3881 #else |
|
3882 User::Leave( KErrNotSupported ); |
|
3883 #endif // CAMERAAPP_CAPI_V2_ADV |
|
3884 PRINT ( _L("Camera <= CCamCameraController::ProcessCaptureLimitSettingL") ); |
|
3885 } |
|
3886 |
|
3887 |
|
3888 |
|
3889 // --------------------------------------------------------------------------- |
|
3890 // EndSequence |
|
3891 // --------------------------------------------------------------------------- |
|
3892 // |
|
3893 void |
|
3894 CCamCameraController::EndSequence( TInt aStatus ) |
|
3895 { |
|
3896 PRINT1( _L("Camera => CCamCameraController::EndSequence, status:%d"), aStatus ); |
|
3897 |
|
3898 iIveRecoveryOngoing = EFalse; |
|
3899 #ifdef CAMERAAPP_CAE_FIX |
|
3900 if( ECamModeChangeInactive != iModeChange ) |
|
3901 { |
|
3902 PRINT( _L("Camera <> mode change not cleared, PANIC!!") ); |
|
3903 Panic( ECamCameraControllerUnrecovableError ); |
|
3904 } |
|
3905 #endif // CAMERAAPP_CAE_FIX |
|
3906 // ------------------------------------------------------- |
|
3907 if( IsFlagOn( iInfo.iBusy, ECamBusySequence ) ) |
|
3908 { |
|
3909 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestNone ); |
|
3910 |
|
3911 PRINT( _L("Camera <> ending sequence..") ); |
|
3912 ClearRequestQueue(); |
|
3913 iReserveTryAgainCount = KCamReserveTryAgainMaxCount; |
|
3914 |
|
3915 |
|
3916 // Need to first clear busy flag as observer might issue |
|
3917 // new requests in notification callback. |
|
3918 ClearFlags( iInfo.iBusy, ECamBusySequence ); |
|
3919 |
|
3920 PRINT( _L("Camera <> send notification..") ); |
|
3921 NotifyObservers( aStatus, |
|
3922 ECamCameraEventSequenceEnd, |
|
3923 ECamCameraEventClassBasicControl ); |
|
3924 } |
|
3925 // ------------------------------------------------------- |
|
3926 else if( IsFlagOn( iInfo.iBusy, ECamBusySetting ) ) |
|
3927 { |
|
3928 PRINT( _L("Camera <> ending settings handling..") ); |
|
3929 |
|
3930 |
|
3931 TCamCameraSettingId last( ECameraSettingNone ); |
|
3932 if( KErrNone != aStatus ) |
|
3933 { |
|
3934 if( Rng( 0, iSettingIndex, iSettingArray.Count()-1 ) ) |
|
3935 { |
|
3936 last = iSettingArray[iSettingIndex]; |
|
3937 } |
|
3938 } |
|
3939 ClearSettingQueue(); |
|
3940 |
|
3941 ClearFlags( iInfo.iBusy, ECamBusySetting ); |
|
3942 |
|
3943 NotifyObservers( aStatus, |
|
3944 ECamCameraEventSettingsDone, |
|
3945 ECamCameraEventClassSettings, |
|
3946 &last ); |
|
3947 } |
|
3948 // ------------------------------------------------------- |
|
3949 else |
|
3950 { |
|
3951 PRINT( _L("Camera <> No active operation, no action needed") ); |
|
3952 } |
|
3953 // ------------------------------------------------------- |
|
3954 PRINT( _L("Camera <= CCamCameraController::EndSequence") ); |
|
3955 } |
|
3956 |
|
3957 |
|
3958 |
|
3959 // --------------------------------------------------------------------------- |
|
3960 // ClearRequestQueue |
|
3961 // --------------------------------------------------------------------------- |
|
3962 // |
|
3963 void |
|
3964 CCamCameraController::ClearRequestQueue() |
|
3965 { |
|
3966 iSequenceArray.Reset(); |
|
3967 iSequenceIndex = -1; |
|
3968 } |
|
3969 |
|
3970 // --------------------------------------------------------------------------- |
|
3971 // ClearSettingQueue |
|
3972 // --------------------------------------------------------------------------- |
|
3973 // |
|
3974 void |
|
3975 CCamCameraController::ClearSettingQueue() |
|
3976 { |
|
3977 iSettingArray.Reset(); |
|
3978 iSettingIndex = -1; |
|
3979 } |
|
3980 |
|
3981 |
|
3982 |
|
3983 |
|
3984 // --------------------------------------------------------------------------- |
|
3985 // HandlePowerOnEvent |
|
3986 // --------------------------------------------------------------------------- |
|
3987 // |
|
3988 void |
|
3989 CCamCameraController::HandlePowerOnEvent( TInt aStatus ) |
|
3990 { |
|
3991 PRINT1( _L("Camera => CCamCameraController::HandlePowerOnEvent, status:%d"), aStatus ); |
|
3992 |
|
3993 // We should be blocking new request at the moment. |
|
3994 __ASSERT_DEBUG( iInfo.iBusy, Panic( ECamCameraControllerCorrupt ) ); |
|
3995 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestPowerOn ); |
|
3996 |
|
3997 OstTrace0( CAMERAAPP_PERFORMANCE, CCAMCAMERACONTROLLER_HANDLEPOWERONEVENT, "e_CAM_APP_INIT 0" ); //CCORAPP_APP_INIT_END |
|
3998 OstTrace0( CAMERAAPP_PERFORMANCE, DUP1_CCAMCAMERACONTROLLER_HANDLEPOWERONEVENT, "e_CAM_APP_VF_INIT 1" ); //CCORAPP_APP_VF_INIT_START |
|
3999 OstTrace0( CAMERAAPP_PERFORMANCE, DUP2_CCAMCAMERACONTROLLER_HANDLEPOWERONEVENT, "e_CAM_APP_CONFIGURATIONS 1" ); //CCORAPP_APP_CONFIGS_START |
|
4000 OstTrace0( CAMERAAPP_PERFORMANCE, DUP3_CCAMCAMERACONTROLLER_HANDLEPOWERONEVENT, "e_CAM_APP_STILL_INIT 1" ); //CCORAPP_APP_STILL_INIT_START |
|
4001 |
|
4002 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
4003 |
|
4004 if ( appUi->AppController().UiConfigManagerPtr()->IsFaceTrackingSupported() ) |
|
4005 { |
|
4006 PRINT( _L("Camera <> CCamAppController: Get i/f MCameraFaceTracking..") ) |
|
4007 iCustomInterfaceFaceTracking = |
|
4008 static_cast <MCameraFaceTracking*>( |
|
4009 iCamera->CustomInterface( KCameraFaceTrackingUid ) ); |
|
4010 PRINT1( _L("Camera <> Face Tracking custom i/f pointer:%d"), iCustomInterfaceFaceTracking ); |
|
4011 } |
|
4012 |
|
4013 if( KErrNone == aStatus ) |
|
4014 { |
|
4015 SetFlags( iInfo.iState, ECamPowerOn|ECamReserved ); |
|
4016 |
|
4017 TRAP_IGNORE( SetFaceTrackingL() ); |
|
4018 #if defined( CAMERAAPP_CAE_FOR_VIDEO ) && !defined( CAMERAAPP_CAE_FIX ) |
|
4019 // We need to tell to CCaeEngine that the CCamera has been reserved |
|
4020 // and powered on "behind its back". |
|
4021 if( iCaeEngine ) |
|
4022 { |
|
4023 iCaeEngine->EnableVideoRecording(); |
|
4024 } |
|
4025 #endif |
|
4026 } |
|
4027 else |
|
4028 { |
|
4029 ClearFlags( iInfo.iState, ECamPowerOn ); |
|
4030 } |
|
4031 |
|
4032 #ifdef CAMERAAPP_CAE_FIX |
|
4033 if( ECamModeChangeVideo2Image == iModeChange ) |
|
4034 { |
|
4035 if( ECamModeChangePhase2 == iModeChangePhase ) |
|
4036 { |
|
4037 // We have called CCamera::PowerOn in phase2 |
|
4038 PRINT( _L("Camera <> mode change image->video ongoing, continue") ); |
|
4039 iModeChangeStatus = aStatus; |
|
4040 // Handle repeative events before iActive gets to run. |
|
4041 if( !iActive->IsActive() ) |
|
4042 iActive->IssueRequest(); |
|
4043 } |
|
4044 } |
|
4045 else if( ECamModeChangeImage2Video == iModeChange ) |
|
4046 { |
|
4047 if( ECamModeChangePhase1 == iModeChangePhase ) |
|
4048 { |
|
4049 // We have called CCaeEngine::InitL in phase1 |
|
4050 PRINT( _L("Camera <> mode change image->video ongoing, continue") ); |
|
4051 iModeChangeStatus = aStatus; |
|
4052 // Handle repeative events before iActive gets to run. |
|
4053 if( !iActive->IsActive() ) |
|
4054 iActive->IssueRequest(); |
|
4055 } |
|
4056 } |
|
4057 else |
|
4058 { |
|
4059 PRINT( _L("Camera <> no mode change ongoing") ); |
|
4060 HandleCallbackEvent( aStatus, |
|
4061 ECamCameraEventPowerOn, |
|
4062 ECamCameraEventClassBasicControl ); |
|
4063 } |
|
4064 #else |
|
4065 |
|
4066 HandleCallbackEvent( aStatus, |
|
4067 ECamCameraEventPowerOn, |
|
4068 ECamCameraEventClassBasicControl ); |
|
4069 |
|
4070 #endif // CAMERAAPP_CAE_FIX |
|
4071 |
|
4072 if ( appUi->AppController().UiConfigManagerPtr()->IsOrientationSensorSupported() ) |
|
4073 { |
|
4074 PRINT( _L("Camera <> CCamCameraController: Get i/f MCameraOrientation..") ) |
|
4075 |
|
4076 if(!iCustomInterfaceOrientation ) |
|
4077 { |
|
4078 iCustomInterfaceOrientation = |
|
4079 static_cast <MCameraOrientation*>( |
|
4080 iCamera->CustomInterface( KCameraOrientationUid ) ); |
|
4081 } |
|
4082 |
|
4083 PRINT1( _L("Camera <> Orientation custom i/f pointer:%d"), iCustomInterfaceOrientation ); |
|
4084 } |
|
4085 |
|
4086 PRINT( _L("Camera <= CCamCameraController::HandlePowerOnEvent") ); |
|
4087 } |
|
4088 |
|
4089 // --------------------------------------------------------------------------- |
|
4090 // HandleReserveGainEvent |
|
4091 // --------------------------------------------------------------------------- |
|
4092 // |
|
4093 void |
|
4094 CCamCameraController::HandleReserveGainEvent( TInt aStatus ) |
|
4095 { |
|
4096 PRINT1( _L("Camera => CCamCameraController::HandleReserveGainEvent, status:%d"), aStatus ); |
|
4097 if( iIdle && iIdle->IsActive() ) |
|
4098 { |
|
4099 PRINT( _L("Camera => CCamCameraController::HandleReserveGainEvent - return, recovery in progress")); |
|
4100 return; |
|
4101 } |
|
4102 // We should be blocking new request at the moment. |
|
4103 __ASSERT_DEBUG( iInfo.iBusy, Panic( ECamCameraControllerCorrupt ) ); |
|
4104 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestReserve ); |
|
4105 |
|
4106 if( KErrNone == aStatus ) SetFlags ( iInfo.iState, ECamReserved ); |
|
4107 else ClearFlags( iInfo.iState, ECamReserved ); |
|
4108 |
|
4109 #ifdef CAMERAAPP_CAE_FIX |
|
4110 if( ECamModeChangeVideo2Image == iModeChange ) |
|
4111 { |
|
4112 if( ECamModeChangePhase1 == iModeChangePhase ) |
|
4113 { |
|
4114 // We have called CCamera::Reserve in phase1 |
|
4115 PRINT( _L("Camera <> mode change video->image ongoing, continue") ); |
|
4116 iModeChangeStatus = aStatus; |
|
4117 // Handle repeative events before iActive gets to run. |
|
4118 if( !iActive->IsActive() ) |
|
4119 iActive->IssueRequest(); |
|
4120 } |
|
4121 } |
|
4122 else if( ECamModeChangeImage2Video == iModeChange ) |
|
4123 { |
|
4124 // No action yet, wait for power on event |
|
4125 PRINT( _L("Camera <> mode change image->video ongoing, waiting for power on event") ); |
|
4126 } |
|
4127 else |
|
4128 { |
|
4129 PRINT( _L("Camera <> no mode change ongoing") ); |
|
4130 HandleCallbackEvent( aStatus, |
|
4131 ECamCameraEventReserveGain, |
|
4132 ECamCameraEventClassBasicControl ); |
|
4133 } |
|
4134 #else |
|
4135 HandleCallbackEvent( aStatus, |
|
4136 ECamCameraEventReserveGain, |
|
4137 ECamCameraEventClassBasicControl ); |
|
4138 #endif // CAMERAAPP_CAE_FIX |
|
4139 PRINT( _L("Camera <= CCamCameraController::HandleReserveGainEvent") ); |
|
4140 } |
|
4141 |
|
4142 |
|
4143 |
|
4144 // --------------------------------------------------------------------------- |
|
4145 // HandleReserveLostEvent |
|
4146 // --------------------------------------------------------------------------- |
|
4147 // |
|
4148 void |
|
4149 CCamCameraController::HandleReserveLostEvent( TInt aStatus ) |
|
4150 { |
|
4151 PRINT1( _L("Camera => CCamCameraController::HandleReserveLostEvent, status:%d"), aStatus ); |
|
4152 iInfo.iState = ECamIdle; |
|
4153 iInfo.iVfState = ECamTriIdle; |
|
4154 iInfo.iSsState = ECamTriIdle; |
|
4155 |
|
4156 #pragma message("CCamCameraController: Reserve lost event does not stop sequence") |
|
4157 |
|
4158 // These are not valid anymore. |
|
4159 ReleaseCustomInterfaces(); |
|
4160 |
|
4161 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
4162 // ------------------------------------------------------- |
|
4163 #ifdef CAMERAAPP_CAE_FIX |
|
4164 #ifdef CAMERAAPP_CAPI_V2 |
|
4165 if( ECamModeChangeVideo2Image == iModeChange ) |
|
4166 { |
|
4167 // ignore |
|
4168 } |
|
4169 else if( ECamModeChangeImage2Video == iModeChange ) |
|
4170 { |
|
4171 // ignore |
|
4172 } |
|
4173 else |
|
4174 #endif // CAMERAAPP_CAPI_V2 |
|
4175 { |
|
4176 PRINT( _L("Camera <> no mode change ongoing") ); |
|
4177 NotifyObservers( aStatus, |
|
4178 ECamCameraEventReserveLose, |
|
4179 ECamCameraEventClassBasicControl ); |
|
4180 } |
|
4181 |
|
4182 #else // CAMERAAPP_CAE_FIX |
|
4183 /* |
|
4184 // We need to tell to CCaeEngine that the CCamera |
|
4185 // has been released "behind its back". |
|
4186 if( iCaeEngine ) |
|
4187 { |
|
4188 iCaeEngine->DisableVideoRecording(); |
|
4189 } |
|
4190 */ |
|
4191 #endif // CAMERAAPP_CAE_FIX |
|
4192 // ------------------------------------------------------- |
|
4193 #else |
|
4194 |
|
4195 NotifyObservers( aStatus, |
|
4196 ECamCameraEventReserveLose, |
|
4197 ECamCameraEventClassBasicControl ); |
|
4198 // ------------------------------------------------------- |
|
4199 #endif // CAMERAAPP_CAE_FOR_VIDEO |
|
4200 |
|
4201 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
4202 TInt err = KErrNone; |
|
4203 if( !iIdle ) |
|
4204 { |
|
4205 TRAP( err, iIdle = CIdle::NewL( CActive::EPriorityIdle ) ); |
|
4206 } |
|
4207 |
|
4208 PRINT1( _L("Camera <> CCamCameraController::HandleReserveLostEvent iIveRecoveryOngoing = %d"), iIveRecoveryOngoing ); |
|
4209 if ( !err && iIdle && !iIdle->IsActive() && // Recovering already |
|
4210 iAppController.IsAppUiAvailable() && // Exit mode |
|
4211 iIveRecoveryCount && // Give up eventually |
|
4212 !appUi->AppInBackground( EFalse ) && // Only if on the foreground |
|
4213 ( !iReleasedByUi || // Try recover if unknown reason |
|
4214 appUi->StandbyStatus() ) && // or known error |
|
4215 !iAppController.InVideocallOrRinging() && // Video telephony parallel use case |
|
4216 !iIveRecoveryOngoing // processing recovery sequence |
|
4217 ) |
|
4218 { |
|
4219 PRINT( _L("Camera <> CCamCameraController::HandleReserveLostEvent - Start recovery") ); |
|
4220 NotifyObservers( aStatus, |
|
4221 ECamCameraEventReserveLose, |
|
4222 ECamCameraEventClassBasicControl ); |
|
4223 iIdle->Start( TCallBack( IdleCallback, this ) ); |
|
4224 } |
|
4225 PRINT( _L("Camera <= CCamCameraController::HandleReserveLostEvent") ); |
|
4226 } |
|
4227 |
|
4228 // --------------------------------------------------------------------------- |
|
4229 // HandleViewfinderEvent |
|
4230 // --------------------------------------------------------------------------- |
|
4231 // |
|
4232 void |
|
4233 CCamCameraController::HandleViewfinderEvent( MCameraBuffer* aCameraBuffer, |
|
4234 TInt aStatus ) |
|
4235 { |
|
4236 PRINT_FRQ1( _L("Camera => CCamCameraController::HandleViewfinderEvent, status in:%d"), aStatus ); |
|
4237 |
|
4238 CAMERAAPP_PERF_CONTROLLER_STOP_ONCE( ECamRequestVfStart, iFirstVfFrameReceived ); |
|
4239 |
|
4240 CFbsBitmap* vfFrame = NULL; |
|
4241 |
|
4242 if( KErrNone == aStatus ) |
|
4243 { |
|
4244 __ASSERT_ALWAYS( aCameraBuffer, Panic( ECamCameraControllerCorrupt ) ); |
|
4245 |
|
4246 PRINT_FRQ( _L("Camera <> get new one..") ); |
|
4247 TRAP( aStatus, |
|
4248 { |
|
4249 vfFrame = &(aCameraBuffer->BitmapL( 0 )); |
|
4250 }); |
|
4251 PRINT_FRQ1( _L("Camera <> ..status after getting bitmap data: %d"), aStatus ); |
|
4252 } |
|
4253 |
|
4254 NotifyObservers( aStatus, |
|
4255 ECamCameraEventVfFrameReady, |
|
4256 ECamCameraEventClassVfData, |
|
4257 vfFrame ); |
|
4258 |
|
4259 ReleaseAndNull( aCameraBuffer ); |
|
4260 |
|
4261 PRINT_FRQ( _L("Camera <= CCamCameraController::HandleViewfinderEvent") ); |
|
4262 } |
|
4263 |
|
4264 |
|
4265 // --------------------------------------------------------------------------- |
|
4266 // HandleImageCaptureEvent |
|
4267 // --------------------------------------------------------------------------- |
|
4268 // |
|
4269 void |
|
4270 CCamCameraController::HandleImageCaptureEvent( MCameraBuffer* aCameraBuffer, |
|
4271 TInt aStatus ) |
|
4272 { |
|
4273 PRINT1( _L("Camera => CCamCameraController::HandleImageCaptureEvent, status in: %d"), aStatus ); |
|
4274 |
|
4275 |
|
4276 // Check that we are expecting images.. |
|
4277 if( ECamCaptureOn == iInfo.iCaptureState ) |
|
4278 { |
|
4279 // Store flags |
|
4280 TUint busyFlags( iInfo.iBusy ); |
|
4281 |
|
4282 // ----------------------------------------------------- |
|
4283 // Try to get the image data. |
|
4284 if( KErrNone == aStatus ) |
|
4285 { |
|
4286 // Takes ownership of aCameraBuffer and NULLs the pointer. |
|
4287 TRAP( aStatus, HandleImageCaptureEventL( aCameraBuffer ) ); |
|
4288 PRINT1( _L("Camera <> status after handling data: %d"), aStatus ); |
|
4289 } |
|
4290 |
|
4291 // Release if not NULLed in HandleImageCaptureEventL. |
|
4292 ReleaseAndNull( aCameraBuffer ); |
|
4293 |
|
4294 // ----------------------------------------------------- |
|
4295 // Errors in or in handling |
|
4296 if( KErrNone != aStatus ) |
|
4297 { |
|
4298 PRINT( _L("Camera <> CCamCameraController ... [WARNING] error in image data event!") ); |
|
4299 iInfo.PrintInfo(); |
|
4300 |
|
4301 iInfo.iCaptureState = ECamCaptureOff; |
|
4302 |
|
4303 // See HandleCallbackEvent for comments. |
|
4304 // ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
4305 |
|
4306 NotifyObservers( aStatus, |
|
4307 ECamCameraEventImageData, |
|
4308 ECamCameraEventClassImage ); |
|
4309 } |
|
4310 // ----------------------------------------------------- |
|
4311 |
|
4312 // If capture state was just changed to OFF, |
|
4313 // send notification that capture has fully completed. |
|
4314 if( ECamCaptureOff == iInfo.iCaptureState ) |
|
4315 { |
|
4316 // See HandleCallbackEvent for comments. |
|
4317 ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
4318 |
|
4319 TInt fullCaptures( Min( iInfo.iCaptureCount, iInfo.iSnapshotCount ) ); |
|
4320 NotifyObservers( aStatus, |
|
4321 ECamCameraEventImageStop, |
|
4322 ECamCameraEventClassImage, |
|
4323 &fullCaptures ); |
|
4324 |
|
4325 // Now we can actually continue, if necessary. |
|
4326 if( IsFlagOn( busyFlags, ECamBusySequence ) ) |
|
4327 { |
|
4328 __ASSERT_DEBUG( iActive, Panic( ECamCameraControllerCorrupt ) ); |
|
4329 iActive->IssueRequest(); |
|
4330 } |
|
4331 } |
|
4332 } |
|
4333 else |
|
4334 { |
|
4335 PRINT( _L("Camera <> CCamCameraController ... [WARNING] Unexpected image data event!") ); |
|
4336 iInfo.PrintInfo(); |
|
4337 |
|
4338 // Stop capture to be safe. |
|
4339 PRINT( _L("Camera <> CCamCameraController ... Calling CancelCaptureImage..") ); |
|
4340 iCamera->CancelCaptureImage(); |
|
4341 |
|
4342 // Not expecting image data at this time. |
|
4343 // Release the buffer and ignore event. |
|
4344 ReleaseAndNull( aCameraBuffer ); |
|
4345 } |
|
4346 PRINT( _L("Camera <= CCamCameraController::HandleImageCaptureEvent") ); |
|
4347 } |
|
4348 |
|
4349 // --------------------------------------------------------------------------- |
|
4350 // HandleImageCaptureEventL |
|
4351 // --------------------------------------------------------------------------- |
|
4352 // |
|
4353 void |
|
4354 CCamCameraController::HandleImageCaptureEventL( MCameraBuffer*& aCameraBuffer ) |
|
4355 { |
|
4356 PRINT( _L("Camera => CCamCameraController::HandleImageCaptureEventL") ); |
|
4357 CheckNonNullL( aCameraBuffer, KErrNotFound ); |
|
4358 |
|
4359 MCameraBuffer* temp = aCameraBuffer; |
|
4360 aCameraBuffer = NULL; // ownership taken |
|
4361 |
|
4362 PRINT( _L("Camera <> Wrap MCameraBuffer to sharable..") ); |
|
4363 CleanupStack::PushL( TCleanupItem( CameraBufferCleanup, temp ) ); |
|
4364 CCamBufferShare* share = new (ELeave) CCamBufferShare( temp ); |
|
4365 CleanupStack::Pop(); // cleanup item |
|
4366 temp = NULL; // ownership to share |
|
4367 |
|
4368 share->Reserve(); |
|
4369 CleanupStack::PushL( TCleanupItem( CamBufferShareCleanup, share ) ); |
|
4370 |
|
4371 PRINT( _L("Camera <> CCamCameraController .. Checking encoded data availability..") ); |
|
4372 TRAPD( dataStatus, |
|
4373 { |
|
4374 TDesC8* data = share->SharedBuffer()->DataL( 0 ); |
|
4375 if( !data ) |
|
4376 User::Leave( KErrNotFound ); |
|
4377 }); |
|
4378 |
|
4379 // ------------------------------------------------------- |
|
4380 // Normal capture format case |
|
4381 if( KErrNone == dataStatus ) |
|
4382 { |
|
4383 PRINT( _L("Camera <> CCamCameraController .. Normal, encoded capture format found..") ); |
|
4384 |
|
4385 // Increase received images count. Needed in burst drive mode. |
|
4386 iInfo.iCaptureCount++; |
|
4387 PRINT1( _L("Camera <> CCamCameraController ... Incremented capture counter to: %d"), iInfo.iCaptureCount ); |
|
4388 |
|
4389 // If we have needed amount of snapshots and images, end capture. |
|
4390 if( iInfo.iCaptureCount >= iInfo.iCaptureLimit |
|
4391 && ( (iInfo.iSnapshotCount >= iInfo.iCaptureLimit) || iInfo.iSsState != ECamTriActive ) ) |
|
4392 { |
|
4393 PRINT( _L("Camera <> CCamCameraController ... Capture limit met, calling CancelCaptureImage..") ); |
|
4394 iCamera->CancelCaptureImage(); |
|
4395 |
|
4396 PRINT( _L("Camera <> CCamCameraController ... Setting capture state to OFF..") ); |
|
4397 iInfo.iCaptureState = ECamCaptureOff; |
|
4398 } |
|
4399 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
4400 // If we are in burst mode and need to increase capture limit, |
|
4401 // do it now. If we have just decreased the capture limit, |
|
4402 // we just cancel once the limit is met. |
|
4403 else if( iAdvancedSettings |
|
4404 && iAdvancedSettings->DriveMode() == CAS::EDriveModeBurst ) |
|
4405 { |
|
4406 const TInt cameraLimit( iAdvancedSettings->BurstImages() ); |
|
4407 |
|
4408 PRINT1( _L("Camera <> CCamCameraController ... Camera capture limit: %d"), cameraLimit ); |
|
4409 PRINT1( _L("Camera <> CCamCameraController ... Local capture limit: %d"), iInfo.iCaptureLimit ); |
|
4410 |
|
4411 if( cameraLimit < iInfo.iCaptureLimit ) |
|
4412 { |
|
4413 TInt startedCaptures = Max( iInfo.iSnapshotCount, iInfo.iCaptureCount ); |
|
4414 iInfo.iCaptureLimit = Max( iInfo.iCaptureLimit, startedCaptures+1 ); |
|
4415 |
|
4416 PRINT1( _L("Camera <> CCamCameraController ... Pending capture limit increase, calling SetBurstImages(%d).."), iInfo.iCaptureLimit ); |
|
4417 iAdvancedSettings->SetBurstImages( iInfo.iCaptureLimit ); |
|
4418 } |
|
4419 } |
|
4420 #endif // CAMERAAPP_CAPI_V2_ADV |
|
4421 // Normal, single capture. |
|
4422 else |
|
4423 { |
|
4424 } |
|
4425 |
|
4426 // See HandleCallbackEvent for comments. |
|
4427 // ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
4428 |
|
4429 NotifyObservers( KErrNone, |
|
4430 ECamCameraEventImageData, |
|
4431 ECamCameraEventClassImage, |
|
4432 share ); |
|
4433 } |
|
4434 // ------------------------------------------------------- |
|
4435 // Bitmap format case. Need to encode first. |
|
4436 else if( iAlternateFormatInUse ) |
|
4437 { |
|
4438 PRINT( _L("Camera <> Bitmap alternative capture format in use..") ); |
|
4439 // NOTE: We get another callback with encoded image data |
|
4440 // once encoder has done the conversion. |
|
4441 PRINT( _L("Camera <> CCamCameraController ... Starting jpeg encoding..") ); |
|
4442 if( !iEncoder ) iEncoder = CCamImageEncoder::NewL( *this ); |
|
4443 |
|
4444 // Encoder needs to call Reserve |
|
4445 iEncoder->StartConversionL( share ); |
|
4446 } |
|
4447 // ------------------------------------------------------- |
|
4448 // Encoded data missing although expected. |
|
4449 else |
|
4450 { |
|
4451 User::Leave( dataStatus ); |
|
4452 } |
|
4453 // ----------------------------------------------------- |
|
4454 CleanupStack::PopAndDestroy(); // share->Release(); |
|
4455 share = NULL; |
|
4456 |
|
4457 PRINT( _L("Camera <= CCamCameraController::HandleImageCaptureEventL") ); |
|
4458 } |
|
4459 |
|
4460 |
|
4461 // --------------------------------------------------------------------------- |
|
4462 // HandleSnapshotEvent |
|
4463 // --------------------------------------------------------------------------- |
|
4464 // |
|
4465 void |
|
4466 CCamCameraController::HandleSnapshotEvent( TInt aStatus ) |
|
4467 { |
|
4468 PRINT( _L("Camera => CCamCameraController::HandleSnapshotEvent") ); |
|
4469 |
|
4470 // Check that we are in right state to handle snapshot. |
|
4471 // CCameraSnapshot sends atleast event with KErrCancel status |
|
4472 // when releasing the camera. |
|
4473 TBool videoSsExpected( IsFlagOn( iInfo.iState, ECamVideoOn ) ); |
|
4474 TBool imageSsExpected( IsFlagOn( iInfo.iState, ECamImageOn ) |
|
4475 && ECamCaptureOn == iInfo.iCaptureState |
|
4476 && iInfo.iSnapshotCount < iInfo.iCaptureLimit ); |
|
4477 |
|
4478 if( |
|
4479 #ifdef CAMERAAPP_CAE_FIX |
|
4480 ECamModeChangeInactive == iModeChange && |
|
4481 #endif |
|
4482 (videoSsExpected||imageSsExpected) |
|
4483 ) |
|
4484 { |
|
4485 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestSsStart ); |
|
4486 |
|
4487 // ----------------------------------------------------- |
|
4488 // Try to get snapshot data |
|
4489 if( KErrNone == aStatus ) |
|
4490 { |
|
4491 TRAP( aStatus, HandleSnapshotEventL() ); |
|
4492 PRINT1( _L("Camera <> CCamCameraController ... status after handling snapshot data: %d"), aStatus ); |
|
4493 } |
|
4494 |
|
4495 // ----------------------------------------------------- |
|
4496 // If snapshot was received and notified ok, |
|
4497 // check if capture ended. |
|
4498 if( KErrNone == aStatus ) |
|
4499 { |
|
4500 // If we have needed amount of snapshots and images, end capture. |
|
4501 if( iInfo.iCaptureCount >= iInfo.iCaptureLimit |
|
4502 && iInfo.iSnapshotCount >= iInfo.iCaptureLimit ) |
|
4503 { |
|
4504 PRINT( _L("Camera <> CCamCameraController ... Setting capture state to OFF..") ); |
|
4505 iInfo.iCaptureState = ECamCaptureOff; |
|
4506 } |
|
4507 } |
|
4508 // ----------------------------------------------------- |
|
4509 // If any error, stop capture. |
|
4510 else |
|
4511 { |
|
4512 PRINT( _L("Camera <> CCamCameraController ... error encountered, notify and set capture state off..") ); |
|
4513 NotifyObservers( aStatus, |
|
4514 ECamCameraEventSsReady, |
|
4515 ECamCameraEventClassSsData ); |
|
4516 iInfo.iCaptureState = ECamCaptureOff; |
|
4517 } |
|
4518 |
|
4519 // ----------------------------------------------------- |
|
4520 // Check if we have just completed the capture. |
|
4521 // Notify observers if so. |
|
4522 if( imageSsExpected |
|
4523 && ECamCaptureOff == iInfo.iCaptureState ) |
|
4524 { |
|
4525 // See HandleCallbackEvent for comments. |
|
4526 ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
4527 |
|
4528 TInt fullCaptures( Min( iInfo.iCaptureCount, iInfo.iSnapshotCount ) ); |
|
4529 NotifyObservers( aStatus, |
|
4530 ECamCameraEventImageStop, |
|
4531 ECamCameraEventClassImage, |
|
4532 &fullCaptures ); |
|
4533 } |
|
4534 // ----------------------------------------------------- |
|
4535 } |
|
4536 else |
|
4537 { |
|
4538 // Just retrieve and release camera buffer if snapshot is not expected |
|
4539 TRAP_IGNORE( HandleSnapshotEventL( ETrue ) ); |
|
4540 |
|
4541 if( iInfo.iSnapshotCount > iInfo.iCaptureLimit ) |
|
4542 { |
|
4543 // For burst stopping: |
|
4544 // We have more snapshots already than requested.. |
|
4545 // All needed captures have to have started, |
|
4546 // so we can call cancel here. |
|
4547 // Note: |
|
4548 // Cannot use ">=" as last image might not be provided then. |
|
4549 // |
|
4550 PRINT( _L("Camera <> CCamCameraController ... Snapshot limit passed, calling CancelCaptureImage..") ); |
|
4551 iCamera->CancelCaptureImage(); |
|
4552 } |
|
4553 |
|
4554 PRINT( _L("Camera <> CCamCameraController ... [WARNING] Snapshot ignored!") ); |
|
4555 iInfo.PrintInfo(); |
|
4556 } |
|
4557 |
|
4558 PRINT( _L("Camera <= CCamCameraController::HandleSnapshotEvent") ); |
|
4559 } |
|
4560 |
|
4561 |
|
4562 // --------------------------------------------------------------------------- |
|
4563 // HandleSnapshotEventL |
|
4564 // |
|
4565 // Helper method for leaving part of HandleSnapshotEvent. |
|
4566 // --------------------------------------------------------------------------- |
|
4567 // |
|
4568 void |
|
4569 CCamCameraController::HandleSnapshotEventL( TBool aIgnore ) |
|
4570 { |
|
4571 PRINT1( _L("Camera => CCamCameraController::HandleSnapshotEventL ignore %d"),aIgnore); |
|
4572 __ASSERT_DEBUG( iSnapshotProvider, Panic( ECamCameraControllerCorrupt ) ); |
|
4573 RArray<TInt> temp; |
|
4574 CleanupClosePushL( temp ); |
|
4575 MCameraBuffer* buffer( NULL ); |
|
4576 |
|
4577 buffer = &iSnapshotProvider->SnapshotDataL( temp ); |
|
4578 |
|
4579 TInt firstImageIndex = temp.Find( 0 ); |
|
4580 CleanupStack::PopAndDestroy(); // temp.Close() |
|
4581 |
|
4582 if( !aIgnore ) |
|
4583 { |
|
4584 |
|
4585 CleanupStack::PushL( TCleanupItem( CameraBufferCleanup, buffer ) ); |
|
4586 CFbsBitmap& snapshot = buffer->BitmapL( firstImageIndex ); |
|
4587 PRINT2( _L("Camera <> CCamCameraController ... snapshot size: (%dx%d)"), |
|
4588 snapshot.SizeInPixels().iWidth, snapshot.SizeInPixels().iHeight ); |
|
4589 |
|
4590 // Increase received snapshots count. |
|
4591 // Needed in burst drive mode. |
|
4592 iInfo.iSnapshotCount++; |
|
4593 PRINT1( _L("Camera <> CCamCameraController ... Incremented snapshot counter to: %d"), iInfo.iSnapshotCount ); |
|
4594 |
|
4595 // No leaving code after notification as otherwise |
|
4596 // HandleSnapshotEvent calling this method will notify clients again. |
|
4597 NotifyObservers( KErrNone, |
|
4598 ECamCameraEventSsReady, |
|
4599 ECamCameraEventClassSsData, |
|
4600 &snapshot ); |
|
4601 |
|
4602 CleanupStack::PopAndDestroy(); // buffer->Release() |
|
4603 } |
|
4604 else |
|
4605 { |
|
4606 ReleaseAndNull(buffer); |
|
4607 } |
|
4608 PRINT( _L("Camera <= CCamCameraController::HandleSnapshotEventL")); |
|
4609 } |
|
4610 |
|
4611 |
|
4612 |
|
4613 |
|
4614 // --------------------------------------------------------------------------- |
|
4615 // HandleVideoInitEvent |
|
4616 // --------------------------------------------------------------------------- |
|
4617 // |
|
4618 void |
|
4619 CCamCameraController::HandleVideoEvent( const TCamCameraEventId& aEventId, |
|
4620 TInt aStatus ) |
|
4621 { |
|
4622 PRINT2( _L("Camera => CCamCameraController::HandleVideoEvent, status:%d, event[%s]"), |
|
4623 aStatus, |
|
4624 KCamCameraEventNames[aEventId] ); |
|
4625 |
|
4626 // Only video stop of these events may come without our explicit request. |
|
4627 /* |
|
4628 if( ECamCameraEventVideoStop != aEventId ) |
|
4629 { |
|
4630 if( ECamBusyOff != iInfo.iBusy ) |
|
4631 Panic( ECamCameraControllerCorrupt ); |
|
4632 } |
|
4633 */ |
|
4634 |
|
4635 switch( aEventId ) |
|
4636 { |
|
4637 // ----------------------------------------------------- |
|
4638 case ECamCameraEventVideoInit: |
|
4639 // Some settings repeat this event if CCaeEngine in use. |
|
4640 if( !IsFlagOn( iInfo.iBusy, ECamBusySetting ) ) |
|
4641 { |
|
4642 CAMERAAPP_PERF_CONTROLLER_STOP( ECamRequestVideoInit ); |
|
4643 if( KErrNone == aStatus ) SetFlags ( iInfo.iState, ECamVideoOn ); |
|
4644 else ClearFlags( iInfo.iState, ECamVideoOn ); |
|
4645 } |
|
4646 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
4647 TRAP_IGNORE( GetAdvancedSettingsInfoL() ); |
|
4648 #endif |
|
4649 #ifdef CAMERAAPP_CAE_FIX |
|
4650 if( ECamModeChangeImage2Video == iModeChange ) |
|
4651 { |
|
4652 iModeChangeStatus = aStatus; |
|
4653 iActive->IssueRequest(); |
|
4654 return; |
|
4655 } |
|
4656 #endif // CAMERAAPP_CAE_FIX |
|
4657 break; |
|
4658 // ----------------------------------------------------- |
|
4659 case ECamCameraEventVideoStart: |
|
4660 if( KErrNone == aStatus ) |
|
4661 { |
|
4662 iInfo.iCaptureState = ECamCaptureOn; |
|
4663 } |
|
4664 break; |
|
4665 // ----------------------------------------------------- |
|
4666 case ECamCameraEventVideoPause: |
|
4667 if( KErrNone == aStatus ) |
|
4668 { |
|
4669 iInfo.iCaptureState = ECamCapturePaused; |
|
4670 } |
|
4671 else |
|
4672 { |
|
4673 // Problem with pausing. |
|
4674 // Keep our capture state unchanged. |
|
4675 } |
|
4676 break; |
|
4677 // ----------------------------------------------------- |
|
4678 case ECamCameraEventVideoStop: |
|
4679 // Even if error we have done what we can for stopping. |
|
4680 // Update internal capture state anyway. |
|
4681 iInfo.iCaptureState = ECamCaptureOff; |
|
4682 // We may receive this event from CCaeEngine, even though we have not |
|
4683 // issued a request to stop the video recording. If e.g. there is not |
|
4684 // enough space in the disk to continue recording, this event is |
|
4685 // generated without explicit request. |
|
4686 // |
|
4687 // We must not continue any pending operations if this event is not |
|
4688 // a response to our stop request. |
|
4689 // HandleCallbackEvent takes care of that. |
|
4690 break; |
|
4691 // ----------------------------------------------------- |
|
4692 case ECamCameraEventVideoAsyncStop: |
|
4693 PRINT( _L("Camera <> CCamCameraController::HandleVideoEvent case ECamCameraEventVideoAsyncStop") ); |
|
4694 // Do not change state, just play sound later |
|
4695 break; |
|
4696 // ----------------------------------------------------- |
|
4697 default: |
|
4698 { |
|
4699 Panic( ECamCameraControllerCorrupt ); |
|
4700 break; |
|
4701 } |
|
4702 // ----------------------------------------------------- |
|
4703 } |
|
4704 |
|
4705 HandleCallbackEvent( aStatus, |
|
4706 aEventId, |
|
4707 ECamCameraEventClassVideo ); |
|
4708 PRINT( _L("Camera <= CCamCameraController::HandleVideoEvent") ); |
|
4709 } |
|
4710 |
|
4711 |
|
4712 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
4713 // --------------------------------------------------------------------------- |
|
4714 // HandleVideoTimeEvent |
|
4715 // --------------------------------------------------------------------------- |
|
4716 // |
|
4717 void |
|
4718 CCamCameraController |
|
4719 ::HandleVideoTimeEvent( TInt aStatus, |
|
4720 TTimeIntervalMicroSeconds aTimeElapsed, |
|
4721 TTimeIntervalMicroSeconds aTimeRemaining ) |
|
4722 { |
|
4723 // If capture has already stopped, we don't echo this to our observers. |
|
4724 if( ECamCaptureOff != iInfo.iCaptureState ) |
|
4725 { |
|
4726 iVideoTimes.iTimeElapsed = aTimeElapsed.Int64(); |
|
4727 iVideoTimes.iTimeRemaining = aTimeRemaining.Int64(); |
|
4728 |
|
4729 NotifyObservers( aStatus, |
|
4730 ECamCameraEventVideoTimes, |
|
4731 ECamCameraEventClassVideoTimes, |
|
4732 &iVideoTimes ); |
|
4733 } |
|
4734 } |
|
4735 #endif |
|
4736 |
|
4737 // --------------------------------------------------------------------------- |
|
4738 // HandleAutoFocusEvent |
|
4739 // |
|
4740 // --------------------------------------------------------------------------- |
|
4741 // |
|
4742 void |
|
4743 CCamCameraController::HandleAutoFocusEvent( TInt aStatus, const TUid& aEventUid ) |
|
4744 { |
|
4745 PRINT1( _L("Camera => CCamCameraController::HandleAutoFocusEvent, status: %d"), aStatus ); |
|
4746 TBool proceed = EFalse; |
|
4747 |
|
4748 // ------------------------------------------------------- |
|
4749 // Check the event |
|
4750 if( KUidECamEventCameraSettingsOptimalFocus == aEventUid ) |
|
4751 { |
|
4752 PRINT( _L("Camera <> CCamCameraController: event KUidECamEventCameraSettingsOptimalFocus") ); |
|
4753 if( !iAfHyperfocalPending ) |
|
4754 { |
|
4755 proceed = ETrue; |
|
4756 iAfInProgress = EFalse; |
|
4757 iFirstAfEventReceived = EFalse; |
|
4758 } |
|
4759 } |
|
4760 else if( KUidECamEventCameraSettingAutoFocusType2 == aEventUid ) |
|
4761 { |
|
4762 PRINT( _L("Camera <> CCamCameraController: event KUidECamEventCameraSettingsAutoFocusType2") ); |
|
4763 // If AF started and canceled before finishing |
|
4764 if( iAfInProgress && iAfHyperfocalPending && iFirstAfEventReceived ) |
|
4765 { |
|
4766 // continue to set focus to hyperfocal |
|
4767 proceed = ETrue; |
|
4768 } |
|
4769 if( !iFirstAfEventReceived ) |
|
4770 { |
|
4771 // For the first time, this event means that the autofocusing has been started |
|
4772 iFirstAfEventReceived = ETrue; |
|
4773 PRINT( _L("Camera <> CCamCameraController: event KUidECamEventCameraSettingAutoFocusType2 - first time, set iFirstAfEventReceived ") ); |
|
4774 } |
|
4775 else |
|
4776 { |
|
4777 iFirstAfEventReceived = EFalse; |
|
4778 PRINT( _L("Camera <> CCamCameraController: event KUidECamEventCameraSettingAutoFocusType2 - second time") ); |
|
4779 } |
|
4780 } |
|
4781 else |
|
4782 { |
|
4783 // No other event acceptable here.. |
|
4784 __ASSERT_DEBUG( EFalse, Panic( ECamCameraControllerCorrupt ) ); |
|
4785 } |
|
4786 // ------------------------------------------------------- |
|
4787 // Proceed if right event received |
|
4788 if( proceed ) |
|
4789 { |
|
4790 TCamCameraEventId event = ( KErrNone == aStatus ) |
|
4791 ? ECamCameraEventAutofocusSuccessful |
|
4792 : ECamCameraEventAutofocusFailed; |
|
4793 if( iAfHyperfocalPending ) |
|
4794 { |
|
4795 PRINT( _L("Camera <> Cancelled active autofocus request.") ); |
|
4796 PRINT( _L("Camera <> Setting focus range to hyperfocal, no event to observers yet") ); |
|
4797 iAfHyperfocalPending = EFalse; |
|
4798 iAfInProgress = EFalse; |
|
4799 TRAP_IGNORE( ProcessAutofocusRequestL( ECamRequestCancelAutofocus ) ); |
|
4800 } |
|
4801 else |
|
4802 { |
|
4803 HandleCallbackEvent( KErrNone, |
|
4804 event, |
|
4805 ECamCameraEventClassAutofocus ); |
|
4806 } |
|
4807 |
|
4808 } |
|
4809 else if(iFirstAfEventReceived && (aStatus != KErrNone) ) |
|
4810 { |
|
4811 //There might have been error when first event was received |
|
4812 //and no further autofocus events would occur. |
|
4813 iFirstAfEventReceived = EFalse; |
|
4814 iAfInProgress = EFalse; |
|
4815 |
|
4816 if( iAfHyperfocalPending ) |
|
4817 { |
|
4818 PRINT( _L("Camera <> Cancelled active autofocus request.") ); |
|
4819 PRINT( _L("Camera <> Set focus range to hyperfocal, no event to observers yet") ); |
|
4820 iAfHyperfocalPending = EFalse; |
|
4821 TRAP_IGNORE( ProcessAutofocusRequestL( ECamRequestCancelAutofocus ) ); |
|
4822 } |
|
4823 else |
|
4824 { |
|
4825 HandleCallbackEvent( KErrNone, |
|
4826 ECamCameraEventAutofocusFailed, |
|
4827 ECamCameraEventClassAutofocus ); |
|
4828 } |
|
4829 } |
|
4830 // ------------------------------------------------------- |
|
4831 PRINT( _L("Camera <= CCamCameraController::HandleAutoFocusEvent") ); |
|
4832 } |
|
4833 |
|
4834 |
|
4835 |
|
4836 // --------------------------------------------------------------------------- |
|
4837 // |
|
4838 // HandleFlashStatusEvent |
|
4839 // |
|
4840 // Helper method to handle flash status updates. |
|
4841 // |
|
4842 // --------------------------------------------------------------------------- |
|
4843 void |
|
4844 CCamCameraController::HandleFlashStatusEvent( TInt aStatus, |
|
4845 const TCamCameraEventId& aEventId ) |
|
4846 { |
|
4847 PRINT2( _L("Camera => CCamCameraController::HandleFlashStatusEvent, event[%s] status:%d"), KCamCameraEventNames[aEventId], aStatus ); |
|
4848 NotifyObservers( aStatus, |
|
4849 aEventId, |
|
4850 EventClass( aEventId ) ); |
|
4851 PRINT ( _L("Camera <= CCamCameraController::HandleFlashStatusEvent" ) ); |
|
4852 } |
|
4853 |
|
4854 |
|
4855 |
|
4856 // --------------------------------------------------------------------------- |
|
4857 // HandleCallbackEvent |
|
4858 // |
|
4859 // Helper method to handle CCamera callback events. |
|
4860 // Notifies observers and checks if we should proceed with the sequence. |
|
4861 // --------------------------------------------------------------------------- |
|
4862 // |
|
4863 void |
|
4864 CCamCameraController |
|
4865 ::HandleCallbackEvent( TInt aStatus, |
|
4866 const TCamCameraEventId& aEventId, |
|
4867 const TCamCameraEventClassId& aEventClass, |
|
4868 TAny* aEventData /*= NULL*/ ) |
|
4869 { |
|
4870 PRINT1( _L("Camera => CCamCameraController::HandleCallbackEvent, event[%s]"), |
|
4871 KCamCameraEventNames[aEventId] ); |
|
4872 // ------------------------------------------------------- |
|
4873 // Clear single request busy flag before notification to observers, |
|
4874 // in case client wishes to issue new request during the notification. |
|
4875 // Sequence busy flag can only be cleared in EndSequence |
|
4876 ClearFlags( iInfo.iBusy, ECamBusySingle ); |
|
4877 |
|
4878 // Observers might issue a new sequence during notification. |
|
4879 // We need to decide if sequence needs to continue here |
|
4880 // based on the status *before* notification. |
|
4881 TBool proceedSequence = EFalse; |
|
4882 TBool notify = ETrue; |
|
4883 |
|
4884 // ------------------------------------------------------- |
|
4885 // Continue if: |
|
4886 // 1) Processing sequence is ongoing. |
|
4887 // 2) The received event is exact response to our request. |
|
4888 // There are events like "video stopped" or "reserve lost" |
|
4889 // that may be received without our associated request. |
|
4890 // In that case we must not proceed sequence processing now. |
|
4891 // 3) In case that aStatus is KErrInUse and the current event is |
|
4892 // Reserve, it means reserve failed for some reason |
|
4893 if( IsFlagOn( iInfo.iBusy, ECamBusySequence ) ) // 1 |
|
4894 { |
|
4895 PRINT( _L("Camera <> Sequence is active") ); |
|
4896 PRINT2( _L("Camera <> seq index: %d, seq array len: %d"), iSequenceIndex, iSequenceArray.Count() ); |
|
4897 if( KErrNone != aStatus ) |
|
4898 { |
|
4899 |
|
4900 if ( KErrInUse == aStatus // 3 |
|
4901 && aEventId == ECamCameraEventReserveGain |
|
4902 && iSequenceIndex >= 0 |
|
4903 && Request2Event( iSequenceArray[iSequenceIndex] ) == ECamCameraEventReserveGain |
|
4904 && iReserveTryAgainCount > 0 ) |
|
4905 { |
|
4906 // Handle here only if reserve gain with error is part of a sequence and try again count is not zero |
|
4907 |
|
4908 iReserveTryAgainCount--; |
|
4909 User::After( KCamReserveTryAgainWaitInterval ); |
|
4910 |
|
4911 // decrease index, to get the same request handled again |
|
4912 iSequenceIndex--; |
|
4913 notify = EFalse; |
|
4914 proceedSequence = ETrue; |
|
4915 PRINT1( _L( "Camera <> CCamCameraController::HandleCallbackEvent - %d reserve try again left" ), iReserveTryAgainCount ); |
|
4916 |
|
4917 } |
|
4918 else |
|
4919 { |
|
4920 |
|
4921 notify = EFalse; |
|
4922 proceedSequence = EFalse; |
|
4923 EndSequence( aStatus ); |
|
4924 |
|
4925 } |
|
4926 |
|
4927 } |
|
4928 else if( iSequenceIndex >= 0 && // Sequence has started |
|
4929 Request2Event( iSequenceArray[iSequenceIndex] ) == aEventId ) // 2 |
|
4930 { |
|
4931 notify = ETrue; |
|
4932 proceedSequence = ETrue; |
|
4933 } |
|
4934 else |
|
4935 { |
|
4936 // Not the event we need yet. |
|
4937 } |
|
4938 |
|
4939 } |
|
4940 // ------------------------------------------------------- |
|
4941 // Setting sequence ongoing |
|
4942 else if( IsFlagOn( iInfo.iBusy, ECamBusySetting ) |
|
4943 && iSettingIndex >= 0 ) |
|
4944 { |
|
4945 PRINT( _L("Camera <> Settings change ongoing..") ); |
|
4946 |
|
4947 // Default is no notification |
|
4948 if( aEventClass != ECamCameraEventClassAutofocus ) |
|
4949 { |
|
4950 notify = EFalse; |
|
4951 } |
|
4952 if( KErrNone != aStatus ) |
|
4953 { |
|
4954 PRINT( _L("Camera <> error in, end settings sequence!") ); |
|
4955 proceedSequence = EFalse; |
|
4956 EndSequence( aStatus ); // does one notification |
|
4957 } |
|
4958 else if( ECamCameraEventSettingsSingle == aEventId |
|
4959 && aEventData |
|
4960 && iSettingArray[iSettingIndex] == *( static_cast<TInt*>( aEventData ) ) |
|
4961 ) |
|
4962 { |
|
4963 // We have checked already in HandleEvent that this is |
|
4964 // the right event for the setting we wait to finish. |
|
4965 // Notification can be sent with the given data. |
|
4966 PRINT( _L("Camera <> One setting finished, continue sequence") ); |
|
4967 proceedSequence = ETrue; |
|
4968 } |
|
4969 // Video init event repeated when filename or max file size set |
|
4970 // after init already done |
|
4971 else if( IsFlagOn( iInfo.iState, ECamVideoOn ) |
|
4972 && ECamCameraEventVideoInit == aEventId |
|
4973 && ( ECameraSettingFileName == iSettingArray[iSettingIndex] |
|
4974 || ECameraSettingFileMaxSize == iSettingArray[iSettingIndex] |
|
4975 || ECameraSettingAudioMute == iSettingArray[iSettingIndex] ) ) |
|
4976 { |
|
4977 PRINT( _L("Camera <> One setting finished, continue sequence") ); |
|
4978 proceedSequence = ETrue; |
|
4979 } |
|
4980 else if( ECamCameraEventVideoStop == aEventId || ECamCameraEventVideoAsyncStop == aEventId ) |
|
4981 { |
|
4982 // Video stop might come whenever. |
|
4983 // Need to notify client. |
|
4984 notify = ETrue; |
|
4985 } |
|
4986 else |
|
4987 { |
|
4988 // Not event for us yet |
|
4989 } |
|
4990 } |
|
4991 // ------------------------------------------------------- |
|
4992 else |
|
4993 { |
|
4994 // Single request or no request sent |
|
4995 } |
|
4996 // ------------------------------------------------------- |
|
4997 |
|
4998 |
|
4999 // ------------------------------------------------------- |
|
5000 // Notify the observers with data from the event. |
|
5001 if( notify ) |
|
5002 { |
|
5003 NotifyObservers( aStatus, aEventId, aEventClass, aEventData ); |
|
5004 } |
|
5005 |
|
5006 // ------------------------------------------------------- |
|
5007 // If this is part of sequence, continue processing. |
|
5008 if( proceedSequence ) |
|
5009 { |
|
5010 PRINT ( _L("Camera <> proceeding with the sequence") ); |
|
5011 __ASSERT_DEBUG( iActive, Panic( ECamCameraControllerCorrupt ) ); |
|
5012 iActive->IssueRequest(); |
|
5013 } |
|
5014 // ------------------------------------------------------- |
|
5015 PRINT ( _L("Camera <= CCamCameraController::HandleCallbackEvent") ); |
|
5016 } |
|
5017 |
|
5018 |
|
5019 // =========================================================================== |
|
5020 |
|
5021 // --------------------------------------------------------------------------- |
|
5022 // Notify all our observers of an event. |
|
5023 // --------------------------------------------------------------------------- |
|
5024 // |
|
5025 void |
|
5026 CCamCameraController |
|
5027 ::NotifyObservers( TInt aStatus, |
|
5028 TCamCameraEventId aEventId, |
|
5029 TCamCameraEventClassId aEventClass, |
|
5030 TAny* aEventData /*=NULL*/ ) |
|
5031 { |
|
5032 // PRINT ( _L("Camera => CCamCameraController::NotifyObservers") ); |
|
5033 // PRINT3( _L("Camera <> status:% 3d event:% 3d class:%032b"), aStatus, aEventId, aEventClass ); |
|
5034 |
|
5035 // NOTE: |
|
5036 // We might skip an observer, if during the notification some observer |
|
5037 // is removed from the array (from smaller index than current one). |
|
5038 // This is a commmon problem for all observable classes in this application. |
|
5039 for( TInt i = 0; i < iObservers.Count(); i++ ) |
|
5040 { |
|
5041 // Observer defines which events it is interested in. |
|
5042 // PRINT1( _L("Camera <> observer interest:%032b"), iObserverInterests[i] ); |
|
5043 |
|
5044 if( iObserverInterests[i] & aEventClass ) |
|
5045 { |
|
5046 TRAP_IGNORE( iObservers[i]->HandleCameraEventL( aStatus, aEventId, aEventData ) ); |
|
5047 } |
|
5048 } |
|
5049 // PRINT ( _L("Camera <= CCamCameraController::NotifyObservers") ); |
|
5050 } |
|
5051 |
|
5052 |
|
5053 |
|
5054 // --------------------------------------------------------------------------- |
|
5055 // |
|
5056 // --------------------------------------------------------------------------- |
|
5057 // |
|
5058 void |
|
5059 CCamCameraController::ReleaseCurrentCamera() |
|
5060 { |
|
5061 PRINT( _L("Camera => CCamCameraController::ReleaseCurrentCamera") ); |
|
5062 // Cancel any outstanding sequence. |
|
5063 if( IsFlagOn( iInfo.iBusy, ECamBusySequence ) |
|
5064 #ifdef CAMERAAPP_CAE_FIX |
|
5065 // Mode change calls this method possibly in the middle |
|
5066 // of request sequence. Must not try to cancel then. |
|
5067 && ECamModeChangeInactive == iModeChange |
|
5068 #endif |
|
5069 ) |
|
5070 { |
|
5071 CancelSequence(); |
|
5072 } |
|
5073 |
|
5074 if( IsFlagOn( iInfo.iState, ECamReserved ) ) |
|
5075 { |
|
5076 // Releases viewfinder and snapshot, cancels capture, |
|
5077 // powers off and releases CCamera if needed. |
|
5078 ProcessControlShutdownRequest( ECamRequestRelease ); |
|
5079 } |
|
5080 |
|
5081 // Custom interfaces (not owned) |
|
5082 ReleaseCustomInterfaces(); |
|
5083 |
|
5084 delete iEncoder; iEncoder = NULL; |
|
5085 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
5086 delete iCaeEngine; iCaeEngine = NULL; |
|
5087 #endif // CAMERAAPP_CAE_FOR_VIDEO |
|
5088 |
|
5089 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
5090 delete iAdvancedSettings; iAdvancedSettings = NULL; |
|
5091 iAdvancedSettingInfo.Reset(); |
|
5092 #endif |
|
5093 #ifdef CAMERAAPP_CAPI_V2_DVF |
|
5094 delete iDirectViewfinder; iDirectViewfinder = NULL; |
|
5095 #endif |
|
5096 #ifdef CAMERAAPP_CAPI_V2_OL |
|
5097 delete iOverlayProvider; iOverlayProvider = NULL; |
|
5098 #endif |
|
5099 #ifdef CAMERAAPP_CAPI_V2_HG |
|
5100 delete iHistogramProvider; iHistogramProvider = NULL; |
|
5101 #endif |
|
5102 #ifdef CAMERAAPP_CAPI_V2_IP |
|
5103 delete iImageProcessor; iImageProcessor = NULL; |
|
5104 #endif |
|
5105 delete iSnapshotProvider; iSnapshotProvider = NULL; |
|
5106 |
|
5107 delete iCamera; iCamera = NULL; |
|
5108 |
|
5109 #ifdef CAMERAAPP_CAE_FIX |
|
5110 // Must not reset busy flags if this method is called |
|
5111 // because of mode switch. |
|
5112 TBool saveBusyFlags = (ECamModeChangeInactive != iModeChange); |
|
5113 iInfo.Reset( saveBusyFlags ); |
|
5114 #else |
|
5115 iInfo.Reset(); |
|
5116 #endif |
|
5117 iResolutionSupport.Reset(); |
|
5118 iInfo.iState = ECamIdle; |
|
5119 |
|
5120 PRINT( _L("Camera <= CCamCameraController::ReleaseCurrentCamera") ); |
|
5121 } |
|
5122 |
|
5123 |
|
5124 // --------------------------------------------------------------------------- |
|
5125 // ReleaseCustomInterfaces |
|
5126 // --------------------------------------------------------------------------- |
|
5127 // |
|
5128 void |
|
5129 CCamCameraController::ReleaseCustomInterfaces() |
|
5130 { |
|
5131 iCustomInterfaceOrientation = NULL; |
|
5132 } |
|
5133 |
|
5134 // --------------------------------------------------------------------------- |
|
5135 // CompareSize |
|
5136 // Compare two TSize instances |
|
5137 // --------------------------------------------------------------------------- |
|
5138 // |
|
5139 TBool CCamCameraController::CompareSize( const TSize& aA, const TSize& aB ) |
|
5140 { |
|
5141 return ( aA.iWidth == aB.iWidth && aA.iHeight == aB.iHeight ); |
|
5142 } |
|
5143 |
|
5144 |
|
5145 // --------------------------------------------------------------------------- |
|
5146 // GetResolutionIndexL |
|
5147 // |
|
5148 // Get quality index for prepare with given format and size. |
|
5149 // If current info is not for the given format, update the |
|
5150 // supported resolutions info. After the support info is up to date, |
|
5151 // find the index. Return KErrNotFound if not supported size. |
|
5152 // |
|
5153 // For JPEG format we try two alternate bitmap formats, if |
|
5154 // the given resolution is not supported in JPEG format. |
|
5155 // If support is achieved by using one of the alternate formats, |
|
5156 // the format in use is returned in aFormat. When image is then |
|
5157 // later captured, we encode the bitmap to JPEG before handing |
|
5158 // it over to clients. |
|
5159 // --------------------------------------------------------------------------- |
|
5160 // |
|
5161 TInt |
|
5162 CCamCameraController |
|
5163 ::GetResolutionIndexL( CCamera::TFormat& aFormat, |
|
5164 const TSize& aSize ) |
|
5165 { |
|
5166 PRINT ( _L("Camera => CCamCameraController::GetResolutionIndexL") ); |
|
5167 |
|
5168 if( iResolutionSupport.iForCameraFormat != aFormat |
|
5169 || iResolutionSupport.iForCameraIndex != iInfo.iCurrentCamera ) |
|
5170 { |
|
5171 iAlternateFormatInUse = EFalse; |
|
5172 |
|
5173 // Reset all old resolution info |
|
5174 iResolutionSupport.Reset(); |
|
5175 |
|
5176 // Get the resolution info for current camera with given format. |
|
5177 const TInt KResolutionCount( iCameraInfo.iNumImageSizesSupported ); |
|
5178 RArray<TSize>& resolutions( iResolutionSupport.iResolutions ); |
|
5179 |
|
5180 resolutions.ReserveL( KResolutionCount ); |
|
5181 for( TInt i = 0; i < KResolutionCount; i++ ) |
|
5182 { |
|
5183 // Reserve called, so should not leave. |
|
5184 resolutions.AppendL( TSize() ); |
|
5185 iCamera->EnumerateCaptureSizes( resolutions[i], i, aFormat ); |
|
5186 } |
|
5187 |
|
5188 // Set these after successful filling of the array |
|
5189 iResolutionSupport.iForCameraIndex = iInfo.iCurrentCamera; |
|
5190 iResolutionSupport.iForCameraFormat = aFormat; |
|
5191 } |
|
5192 |
|
5193 #ifdef _DEBUG |
|
5194 PRINT ( _L("Camera <> ==================================================") ); |
|
5195 PRINT2( _L("Camera <> Size requested : (%d,%d)"), aSize.iWidth, aSize.iHeight ); |
|
5196 PRINT1( _L("Camera <> Formats supported : %032b" ), iCameraInfo.iImageFormatsSupported ); |
|
5197 PRINT1( _L("Camera <> Sizes listed for : %032b" ), aFormat ); |
|
5198 PRINT1( _L("Camera <> EFormatJpeg : %032b" ), CCamera::EFormatJpeg ); |
|
5199 PRINT1( _L("Camera <> EFormatExif : %032b" ), CCamera::EFormatExif ); |
|
5200 PRINT1( _L("Camera <> EFormatFbsBitmapColor4K : %032b" ), CCamera::EFormatFbsBitmapColor4K ); |
|
5201 PRINT1( _L("Camera <> EFormatFbsBitmapColor64K : %032b" ), CCamera::EFormatFbsBitmapColor64K ); |
|
5202 PRINT1( _L("Camera <> EFormatFbsBitmapColor16M : %032b" ), CCamera::EFormatFbsBitmapColor16M ); |
|
5203 PRINT1( _L("Camera <> EFormatFbsBitmapColor16MU: %032b" ), CCamera::EFormatFbsBitmapColor16MU ); |
|
5204 for( TInt i = 0; i < iResolutionSupport.iResolutions.Count(); i++ ) |
|
5205 { |
|
5206 const TSize& size( iResolutionSupport.iResolutions[i] ); |
|
5207 PRINT3( _L("Camera <> Size (%d): (%d,%d)"), i, size.iWidth, size.iHeight ); |
|
5208 } |
|
5209 PRINT ( _L("Camera <> ==================================================") ); |
|
5210 #endif |
|
5211 |
|
5212 TIdentityRelation<TSize> compareFunc( CCamCameraController::CompareSize ); |
|
5213 TInt index = iResolutionSupport.iResolutions.Find( aSize, compareFunc ); |
|
5214 |
|
5215 // Exception for JPEG format: |
|
5216 // If JPEG format is not supported, but bitmap format is, |
|
5217 // pretend to support the format anyway. |
|
5218 // When capturing, we encode the JPEG from the bitmap. |
|
5219 if( CCamera::EFormatJpeg == aFormat |
|
5220 && KErrNotFound == index ) |
|
5221 { |
|
5222 PRINT ( _L("Camera <> Jpeg not supported, trying bitmap format 1..") ); |
|
5223 aFormat = KCamJpegAlternativeFormat1; |
|
5224 index = GetResolutionIndexL( aFormat, aSize ); |
|
5225 |
|
5226 if( KErrNotFound == index ) |
|
5227 { |
|
5228 PRINT ( _L("Camera <> Jpeg not supported, trying bitmap format 2..") ); |
|
5229 aFormat = KCamJpegAlternativeFormat2; |
|
5230 index = GetResolutionIndexL( aFormat, aSize ); |
|
5231 } |
|
5232 |
|
5233 if( KErrNotFound != index ) |
|
5234 { |
|
5235 iAlternateFormatInUse = ETrue; |
|
5236 } |
|
5237 else |
|
5238 { |
|
5239 // Could not find alternative. |
|
5240 aFormat = CCamera::EFormatJpeg; |
|
5241 iAlternateFormatInUse = EFalse; |
|
5242 } |
|
5243 } |
|
5244 |
|
5245 PRINT1( _L("Camera <= CCamCameraController::GetResolutionIndexL, return: %d"), index ); |
|
5246 return index; |
|
5247 } |
|
5248 |
|
5249 |
|
5250 #ifdef CAMERAAPP_CAPI_V2_ADV |
|
5251 // --------------------------------------------------------------------------- |
|
5252 // GetAdvancedSettingsInfoL |
|
5253 // |
|
5254 // --------------------------------------------------------------------------- |
|
5255 // |
|
5256 void |
|
5257 CCamCameraController::GetAdvancedSettingsInfoL() |
|
5258 { |
|
5259 PRINT ( _L("Camera => CCamCameraController::GetAdvancedSettingsInfoL") ); |
|
5260 PRINT2( _L("Camera <> current camera:%d, latest info for:%d"), |
|
5261 iInfo.iCurrentCamera, |
|
5262 iAdvancedSettingInfo.iForCameraIndex ); |
|
5263 |
|
5264 |
|
5265 CheckNonNullL( iAdvancedSettings, KErrNotReady ); |
|
5266 iAdvancedSettingInfo.Reset(); |
|
5267 |
|
5268 TInt error( KErrNone ); |
|
5269 CleanupStack::PushL( TCleanupItem( ResetInfo, &iAdvancedSettingInfo ) ); |
|
5270 |
|
5271 // ----------------------------------------------------- |
|
5272 // Digital zoom steps support |
|
5273 PRINT( _L("Camera <> Get zoom steps..") ); |
|
5274 if( IsFlagOn( iInfo.iState, ECamImageOn ) ) |
|
5275 { |
|
5276 TPckgBuf<TCamParamsImage> params; |
|
5277 iSettingProvider.ProvideCameraParamL( ECameraParamImage, ¶ms ); |
|
5278 |
|
5279 PRINT( _L("Camera <> Enumerating capture sizes..") ); |
|
5280 CCamera::TFormat format( params().iFormat ); |
|
5281 TInt index ( GetResolutionIndexL( format, params().iSize ) ); |
|
5282 User::LeaveIfError( index ); |
|
5283 TBool isInfluencePossible; // Not used |
|
5284 |
|
5285 PRINT( _L("Camera <> Get zoom steps for image") ); |
|
5286 TRAP( error, iAdvancedSettings->GetDigitalZoomStepsForStillL ( |
|
5287 iAdvancedSettingInfo.iDigitalZoomSupport, |
|
5288 iAdvancedSettingInfo.iDigitalZoomValueInfo, |
|
5289 index, |
|
5290 format, |
|
5291 isInfluencePossible ) ); |
|
5292 |
|
5293 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5294 } |
|
5295 else if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
5296 { |
|
5297 PRINT( _L("Camera <> Get zoom steps for video") ); |
|
5298 TRAP( error, iAdvancedSettings->GetDigitalZoomStepsL( |
|
5299 iAdvancedSettingInfo.iDigitalZoomSupport, |
|
5300 iAdvancedSettingInfo.iDigitalZoomValueInfo ) ); |
|
5301 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5302 } |
|
5303 |
|
5304 // ----------------------------------------------------- |
|
5305 // EV steps multiplied by KECamFineResolutionFactor. |
|
5306 PRINT( _L("Camera <> Get EV support..") ); |
|
5307 iAdvancedSettingInfo.iEvModesSupport = |
|
5308 iAdvancedSettings->SupportedExposureModes(); |
|
5309 |
|
5310 TRAP( error, iAdvancedSettings->GetExposureCompensationStepsL( |
|
5311 iAdvancedSettingInfo.iEvStepsSupport, |
|
5312 iAdvancedSettingInfo.iEvStepsValueInfo ) ); |
|
5313 // Ignore error if just not supported. |
|
5314 // We check the support when setting is requested. |
|
5315 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5316 |
|
5317 // ----------------------------------------------------- |
|
5318 // ISO rates (.. 50, 100, 200, ..) |
|
5319 PRINT( _L("Camera <> Get ISO rates..") ); |
|
5320 TRAP( error, iAdvancedSettings->GetSupportedIsoRatesL( |
|
5321 iAdvancedSettingInfo.iIsoRatesSupport ) ); |
|
5322 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5323 |
|
5324 // ----------------------------------------------------- |
|
5325 // Stabilization |
|
5326 PRINT( _L("Camera <> Get Stabilization info..") ); |
|
5327 iAdvancedSettingInfo.iStabilizationModeSupport = |
|
5328 iAdvancedSettings->SupportedStabilizationModes(); |
|
5329 |
|
5330 iAdvancedSettingInfo.iStabilizationEffectSupport = |
|
5331 iAdvancedSettings->SupportedStabilizationEffects(); |
|
5332 |
|
5333 iAdvancedSettingInfo.iStabilizationComplexitySupport = |
|
5334 iAdvancedSettings->SupportedStabilizationComplexityValues(); |
|
5335 // ----------------------------------------------------- |
|
5336 |
|
5337 #ifdef CAMERAAPP_CAPI_V2_IP |
|
5338 // Image Processor only for primary camera |
|
5339 if( KPrimaryCameraIndex == iInfo.iCurrentCamera ) |
|
5340 { |
|
5341 PRINT( _L("Camera <> Get image processing info..") ); |
|
5342 |
|
5343 if( iImageProcessor != NULL ) |
|
5344 { |
|
5345 // ----------------------------------------------------- |
|
5346 PRINT( _L("Camera <> Get sharpness support..") ); |
|
5347 TRAP( error, iImageProcessor->GetTransformationSupportedValuesL( |
|
5348 KUidECamEventImageProcessingAdjustSharpness, |
|
5349 iAdvancedSettingInfo.iSharpnessSupport, |
|
5350 iAdvancedSettingInfo.iSharpnessValueInfo ) ); |
|
5351 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5352 |
|
5353 // ----------------------------------------------------- |
|
5354 PRINT( _L("Camera <> Get colour effect support..") ); |
|
5355 TRAP( error, iImageProcessor->GetTransformationSupportedValuesL( |
|
5356 KUidECamEventImageProcessingEffect, |
|
5357 iAdvancedSettingInfo.iColourEffectSupport, |
|
5358 iAdvancedSettingInfo.iColourEffectValueInfo ) ); |
|
5359 if( KErrNotSupported != error ) User::LeaveIfError( error ); |
|
5360 } |
|
5361 else |
|
5362 { |
|
5363 PRINT( _L("Camera <> [WARNING] Image processing not supported") ); |
|
5364 } |
|
5365 } |
|
5366 #endif // CAMERAAPP_CAPI_V2_IP |
|
5367 // ----------------------------------------------------- |
|
5368 PRINT( _L("Camera <> ..done") ); |
|
5369 CleanupStack::Pop(); // Cleanup item |
|
5370 |
|
5371 // Set only after successfully gathering the data |
|
5372 iAdvancedSettingInfo.iForCameraIndex = iInfo.iCurrentCamera; |
|
5373 |
|
5374 #ifdef _DEBUG |
|
5375 iAdvancedSettingInfo.PrintInfo(); |
|
5376 #endif |
|
5377 |
|
5378 PRINT ( _L("Camera <= CCamCameraController::GetAdvancedSettingsInfoL") ); |
|
5379 } |
|
5380 |
|
5381 |
|
5382 |
|
5383 // --------------------------------------------------------------------------- |
|
5384 // ResolveEvStep |
|
5385 // |
|
5386 // --------------------------------------------------------------------------- |
|
5387 // |
|
5388 TInt |
|
5389 CCamCameraController::ResolveEvStep( TInt aEvProposedStep ) const |
|
5390 { |
|
5391 PRINT1( _L("Camera => CCamCameraController::ResolveEvStep( %d )"), aEvProposedStep ); |
|
5392 |
|
5393 TInt delta ( KMaxTInt ); |
|
5394 TInt delta1( 0 ); |
|
5395 TInt step ( 0 ); |
|
5396 |
|
5397 for( TInt i = 0; i < iAdvancedSettingInfo.iEvStepsSupport.Count() && delta != 0; i++ ) |
|
5398 { |
|
5399 delta1 = Max( iAdvancedSettingInfo.iEvStepsSupport[i], aEvProposedStep ) |
|
5400 - Min( iAdvancedSettingInfo.iEvStepsSupport[i], aEvProposedStep ); |
|
5401 |
|
5402 if( delta1 < delta ) |
|
5403 { |
|
5404 delta = delta1; |
|
5405 step = iAdvancedSettingInfo.iEvStepsSupport[i]; |
|
5406 } |
|
5407 } |
|
5408 |
|
5409 PRINT1( _L("Camera <= CCamCameraController::ResolveEvStep, return %d"), step ); |
|
5410 return step; |
|
5411 } |
|
5412 |
|
5413 |
|
5414 // --------------------------------------------------------------------------- |
|
5415 // IsSupportedValue <<static>> |
|
5416 // --------------------------------------------------------------------------- |
|
5417 // |
|
5418 TBool |
|
5419 CCamCameraController::IsSupportedValue( const TInt& aValue, |
|
5420 const RArray<TInt>& aValueList, |
|
5421 const TValueInfo& aValueInfo ) |
|
5422 { |
|
5423 TBool support( EFalse ); |
|
5424 |
|
5425 switch( aValueInfo ) |
|
5426 { |
|
5427 // ----------------------------------------------------- |
|
5428 case EBitField: |
|
5429 { |
|
5430 // Supported values are described by a bitfield. |
|
5431 // Compare the support bitfield and the setting value. |
|
5432 // Default value for these settings is zero (0) and |
|
5433 // that is always supported. |
|
5434 // Array: [0] bitfield of supported bits |
|
5435 support = ( 1 <= aValueList.Count() |
|
5436 && ( !aValue |
|
5437 || (aValue & aValueList[0]) // 0 always supported |
|
5438 ) |
|
5439 ); |
|
5440 break; |
|
5441 } |
|
5442 // ----------------------------------------------------- |
|
5443 case EDiscreteSteps: |
|
5444 { |
|
5445 // All supported steps are listed, look for this one. |
|
5446 support = ( KErrNotFound != aValueList.Find( aValue ) ); |
|
5447 break; |
|
5448 } |
|
5449 // ----------------------------------------------------- |
|
5450 case EDiscreteRangeMinMaxStep: |
|
5451 { |
|
5452 // Support is described with evenly spaced steps between |
|
5453 // min and max value. Step is given. |
|
5454 // Array: [0] min supported value |
|
5455 // [1] max supported value |
|
5456 // [2] step between supported values |
|
5457 support = |
|
5458 ( 3 <= aValueList.Count() // We need 3 items. |
|
5459 && 1 <= aValueList[2] // 1 <= step |
|
5460 && aValue >= aValueList[0] // aValue >= min |
|
5461 && aValue <= aValueList[1] // aValue <= max |
|
5462 && (aValue - aValueList[0])%aValueList[2] == 0 // aValue = min + N*step |
|
5463 ); |
|
5464 break; |
|
5465 } |
|
5466 // ----------------------------------------------------- |
|
5467 case EContinuousRangeMinMax: |
|
5468 { |
|
5469 // Support is described by min and max value, |
|
5470 // continuous range of values within those two is supported. |
|
5471 // Array: [0] min supported value |
|
5472 // [1] max supported value |
|
5473 support = |
|
5474 ( 2 <= aValueList.Count() // We need 2 items. |
|
5475 && aValue >= aValueList[0] // aValue >= min |
|
5476 && aValue <= aValueList[1] // aValue <= max |
|
5477 ); |
|
5478 break; |
|
5479 } |
|
5480 // ----------------------------------------------------- |
|
5481 case ENotActive: |
|
5482 default: |
|
5483 // Not supported setting |
|
5484 support = EFalse; |
|
5485 break; |
|
5486 // ----------------------------------------------------- |
|
5487 } |
|
5488 |
|
5489 return support; |
|
5490 } |
|
5491 #endif // CAMERAAPP_CAPI_V2_ADV |
|
5492 |
|
5493 |
|
5494 // --------------------------------------------------------------------------- |
|
5495 // ResolveSnapshotFormat |
|
5496 // |
|
5497 // --------------------------------------------------------------------------- |
|
5498 // |
|
5499 CCamera::TFormat |
|
5500 CCamCameraController |
|
5501 ::ResolveSnapshotFormatL( CCamera::TFormat aPreferredFormat ) const |
|
5502 { |
|
5503 PRINT ( _L("Camera => CCamCameraController::ResolveSnapshotFormatL") ); |
|
5504 |
|
5505 CheckNonNullL( iSnapshotProvider, KErrNotReady ); |
|
5506 |
|
5507 const TUint32 support = iSnapshotProvider->SupportedFormats(); |
|
5508 CCamera::TFormat final = aPreferredFormat; |
|
5509 |
|
5510 // Return the preferred format if it is supported. |
|
5511 // Otherwise return the "best" supported format. |
|
5512 if ( support & aPreferredFormat ) final = aPreferredFormat; |
|
5513 else if ( support & CCamera::EFormatFbsBitmapColor16MU ) final = CCamera::EFormatFbsBitmapColor16MU; |
|
5514 else if ( support & CCamera::EFormatFbsBitmapColor16M ) final = CCamera::EFormatFbsBitmapColor16M; |
|
5515 else if ( support & CCamera::EFormatFbsBitmapColor64K ) final = CCamera::EFormatFbsBitmapColor64K; |
|
5516 else if ( support & CCamera::EFormatFbsBitmapColor4K ) final = CCamera::EFormatFbsBitmapColor4K; |
|
5517 else |
|
5518 { |
|
5519 // No known acceptable format supported |
|
5520 PRINT( _L("Camera <> CCamCameraController: No acceptable format available, LEAVE!") ); |
|
5521 User::Leave( KErrNotSupported ); |
|
5522 } |
|
5523 |
|
5524 PRINT1( _L("Camera <> Preferred format : %032b"), aPreferredFormat ); |
|
5525 PRINT1( _L("Camera <> Supported formats: %032b"), support ); |
|
5526 PRINT1( _L("Camera <> Selected format : %032b"), final ); |
|
5527 PRINT ( _L("Camera <= CCamCameraController::ResolveSnapshotFormatL") ); |
|
5528 return final; |
|
5529 } |
|
5530 |
|
5531 |
|
5532 |
|
5533 // --------------------------------------------------------------------------- |
|
5534 // Request2Event <<static>> |
|
5535 // |
|
5536 // Convert request id to event id |
|
5537 // --------------------------------------------------------------------------- |
|
5538 // |
|
5539 TCamCameraEventId |
|
5540 CCamCameraController::Request2Event( const TCamCameraRequestId& aType ) |
|
5541 { |
|
5542 switch( aType ) |
|
5543 { |
|
5544 // ----------------------------------------------------- |
|
5545 // Camera control |
|
5546 case ECamRequestReserve: return ECamCameraEventReserveGain; |
|
5547 case ECamRequestRelease: return ECamCameraEventReserveLose; |
|
5548 case ECamRequestPowerOn: return ECamCameraEventPowerOn; |
|
5549 case ECamRequestPowerOff: return ECamCameraEventPowerOff; |
|
5550 // ----------------------------------------------------- |
|
5551 // Viewfinder |
|
5552 case ECamRequestVfStart: return ECamCameraEventVfStart; |
|
5553 case ECamRequestVfStop: return ECamCameraEventVfStop; |
|
5554 case ECamRequestVfRelease: return ECamCameraEventVfRelease; |
|
5555 // ----------------------------------------------------- |
|
5556 // Snapshot |
|
5557 case ECamRequestSsStart: return ECamCameraEventSsStart; |
|
5558 case ECamRequestSsStop: return ECamCameraEventSsStop; |
|
5559 case ECamRequestSsRelease: return ECamCameraEventSsRelease; |
|
5560 // ----------------------------------------------------- |
|
5561 // Still capture |
|
5562 case ECamRequestImageInit: return ECamCameraEventImageInit; |
|
5563 case ECamRequestImageCapture: return ECamCameraEventImageStart; |
|
5564 case ECamRequestImageCancel: return ECamCameraEventImageStop; |
|
5565 case ECamRequestImageRelease: return ECamCameraEventImageRelease; |
|
5566 // ----------------------------------------------------- |
|
5567 // Video recording |
|
5568 case ECamRequestVideoInit: return ECamCameraEventVideoInit; |
|
5569 case ECamRequestVideoStart: return ECamCameraEventVideoStart; |
|
5570 case ECamRequestVideoPause: return ECamCameraEventVideoPause; |
|
5571 case ECamRequestVideoStop: return ECamCameraEventVideoStop; |
|
5572 case ECamRequestVideoRelease: return ECamCameraEventVideoRelease; |
|
5573 // ----------------------------------------------------- |
|
5574 // Autofocus |
|
5575 case ECamRequestStartAutofocus: return ECamCameraEventStartAutofocus; |
|
5576 case ECamRequestCancelAutofocus: return ECamCameraEventCancelAutofocus; |
|
5577 case ECamRequestSetAfRange: return ECamCameraEventSetAfRange; |
|
5578 // ----------------------------------------------------- |
|
5579 |
|
5580 // Unrecognised |
|
5581 default: |
|
5582 { |
|
5583 Panic( ECamCameraControllerUnknownRequest ); |
|
5584 return ECamCameraEventNone; |
|
5585 } |
|
5586 // ----------------------------------------------------- |
|
5587 } |
|
5588 } |
|
5589 |
|
5590 |
|
5591 // --------------------------------------------------------------------------- |
|
5592 // EventClass <<static>> |
|
5593 // |
|
5594 // Get the event class for an event |
|
5595 // --------------------------------------------------------------------------- |
|
5596 // |
|
5597 TCamCameraEventClassId |
|
5598 CCamCameraController::EventClass( const TCamCameraEventId& aEventId ) |
|
5599 { |
|
5600 switch( aEventId ) |
|
5601 { |
|
5602 // ------------------------------------------------------- |
|
5603 case ECamCameraEventSequenceEnd: |
|
5604 case ECamCameraEventReserveGain: |
|
5605 case ECamCameraEventReserveLose: |
|
5606 case ECamCameraEventPowerOn: |
|
5607 case ECamCameraEventPowerOff: |
|
5608 return ECamCameraEventClassBasicControl; |
|
5609 // ------------------------------------------------------- |
|
5610 case ECamCameraEventVfStart: |
|
5611 case ECamCameraEventVfStop: |
|
5612 case ECamCameraEventVfRelease: |
|
5613 return ECamCameraEventClassVfControl; |
|
5614 // ------------------------------------------------------- |
|
5615 case ECamCameraEventVfFrameReady: |
|
5616 return ECamCameraEventClassVfData; |
|
5617 // ------------------------------------------------------- |
|
5618 case ECamCameraEventSsStart: |
|
5619 case ECamCameraEventSsStop: |
|
5620 case ECamCameraEventSsRelease: |
|
5621 return ECamCameraEventClassSsControl; |
|
5622 // ------------------------------------------------------- |
|
5623 case ECamCameraEventSsReady: |
|
5624 return ECamCameraEventClassSsData; |
|
5625 // ------------------------------------------------------- |
|
5626 case ECamCameraEventImageInit: |
|
5627 case ECamCameraEventImageStart: |
|
5628 case ECamCameraEventImageStop: |
|
5629 case ECamCameraEventImageRelease: |
|
5630 case ECamCameraEventImageData: |
|
5631 return ECamCameraEventClassImage; |
|
5632 // ------------------------------------------------------- |
|
5633 case ECamCameraEventVideoInit: |
|
5634 case ECamCameraEventVideoStart: |
|
5635 case ECamCameraEventVideoPause: |
|
5636 case ECamCameraEventVideoStop: |
|
5637 case ECamCameraEventVideoRelease: |
|
5638 return ECamCameraEventClassVideo; |
|
5639 // ------------------------------------------------------- |
|
5640 case ECamCameraEventVideoTimes: |
|
5641 return ECamCameraEventClassVideoTimes; |
|
5642 // ------------------------------------------------------- |
|
5643 case ECamCameraEventSettingsSingle: |
|
5644 case ECamCameraEventSettingsDone: |
|
5645 return ECamCameraEventClassSettings; |
|
5646 // ------------------------------------------------------- |
|
5647 case ECamCameraEventStartAutofocus: |
|
5648 case ECamCameraEventCancelAutofocus: |
|
5649 case ECamCameraEventAutofocusSuccessful: |
|
5650 case ECamCameraEventAutofocusFailed: |
|
5651 case ECamCameraEventSetAfRange: |
|
5652 return ECamCameraEventClassAutofocus; |
|
5653 // ------------------------------------------------------- |
|
5654 case ECamCameraEventFlashReady: |
|
5655 case ECamCameraEventFlashNotReady: |
|
5656 return ECamCameraEventClassFlashStatus; |
|
5657 // ------------------------------------------------------- |
|
5658 default: |
|
5659 { |
|
5660 #ifdef _DEBUG |
|
5661 Panic( ECamCameraControllerCorrupt ); |
|
5662 #endif |
|
5663 return ECamCameraEventClassAll; |
|
5664 } |
|
5665 } |
|
5666 } |
|
5667 |
|
5668 |
|
5669 |
|
5670 // --------------------------------------------------------------------------- |
|
5671 // HasCallback |
|
5672 // --------------------------------------------------------------------------- |
|
5673 // |
|
5674 TBool |
|
5675 CCamCameraController::HasCallback( const TCamCameraRequestId& aType ) |
|
5676 { |
|
5677 TBool callback = EFalse; |
|
5678 switch( aType ) |
|
5679 { |
|
5680 // ----------------------------------------------------- |
|
5681 case ECamRequestReserve: // ReserveComplete / KUidECamEventReserveComplete |
|
5682 case ECamRequestPowerOn: // PowerOnComplete / KUidECamEventPowerOnComplete |
|
5683 |
|
5684 case ECamRequestImageCapture: // ImageReady / ImageBufferReady |
|
5685 |
|
5686 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
5687 case ECamRequestVideoInit: // McaeoVideoPrepareComplete |
|
5688 case ECamRequestVideoStart: // McaeoVideoRecordingOn |
|
5689 case ECamRequestVideoPause: // McaeoVideoRecordingPaused |
|
5690 case ECamRequestVideoStop: // McaeoVideoRecordingComplete |
|
5691 #endif |
|
5692 callback = ETrue; |
|
5693 break; |
|
5694 // ----------------------------------------------------- |
|
5695 default: |
|
5696 callback = EFalse; |
|
5697 break; |
|
5698 // ----------------------------------------------------- |
|
5699 } |
|
5700 return callback; |
|
5701 } |
|
5702 |
|
5703 // --------------------------------------------------------------------------- |
|
5704 // CurrentSettingHasCallback |
|
5705 // --------------------------------------------------------------------------- |
|
5706 // |
|
5707 TBool |
|
5708 CCamCameraController::CurrentSettingHasCallback() |
|
5709 { |
|
5710 TBool callback( EFalse ); |
|
5711 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
5712 if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
5713 { |
|
5714 switch( iSettingArray[iSettingIndex] ) |
|
5715 { |
|
5716 case ECameraSettingFileName: |
|
5717 case ECameraSettingFileMaxSize: |
|
5718 callback = ETrue; |
|
5719 break; |
|
5720 default: |
|
5721 break; |
|
5722 } |
|
5723 } |
|
5724 else |
|
5725 { |
|
5726 // no callback if not prepared for video yet. |
|
5727 } |
|
5728 #endif |
|
5729 return callback; |
|
5730 } |
|
5731 |
|
5732 #ifdef CAMERAAPP_CAE_FOR_VIDEO |
|
5733 // --------------------------------------------------------------------------- |
|
5734 // NewCaeEngineL |
|
5735 // --------------------------------------------------------------------------- |
|
5736 // |
|
5737 CCaeEngine* |
|
5738 CCamCameraController::NewCaeEngineL( TInt aCameraIndex ) |
|
5739 { |
|
5740 PRINT( _L("Camera => CCamCameraController::NewCaeEngineL") ); |
|
5741 |
|
5742 #ifndef FORCE_DUMMY_ENGINE |
|
5743 CCaeEngine* engine = CCaeEngine::NewL( aCameraIndex ); |
|
5744 #else |
|
5745 (void)aCameraIndex; // remove compiler warning |
|
5746 CCaeEngine* engine = CCameraappDummyEngine::NewL(); |
|
5747 #endif |
|
5748 |
|
5749 engine->SetCamAppEngineObserver( *this ); |
|
5750 |
|
5751 PRINT( _L("Camera <= CCamCameraController::NewCaeEngineL") ); |
|
5752 return engine; |
|
5753 } |
|
5754 #endif |
|
5755 |
|
5756 // --------------------------------------------------------------------------- |
|
5757 // NewCameraL |
|
5758 // --------------------------------------------------------------------------- |
|
5759 // |
|
5760 CAMERA* |
|
5761 CCamCameraController::NewCameraL( TInt aCameraIndex ) |
|
5762 { |
|
5763 PRINT( _L("Camera => CCamCameraController::NewCameraL") ); |
|
5764 CAMERA* camera( NULL ); |
|
5765 #ifdef CAMERAAPP_CAPI_V2 |
|
5766 camera = CAMERA::New2L( *this, aCameraIndex, KCameraClientPriority ); |
|
5767 #else |
|
5768 |
|
5769 // Both v1 and v2 observer interface implemented |
|
5770 // Need to cast to avoid ambiguous call. |
|
5771 MCameraObserver* self( this ); |
|
5772 PRINT1( _L("Camera <> Give observer pointer: %d"), self ); |
|
5773 |
|
5774 camera = CAMERA::NewL ( *self, aCameraIndex ); |
|
5775 |
|
5776 #endif // CAMERAAPP_CAPI_V2 |
|
5777 |
|
5778 PRINT( _L("Camera <= CCamCameraController::NewCameraL") ); |
|
5779 return camera; |
|
5780 } |
|
5781 |
|
5782 // --------------------------------------------------------------------------- |
|
5783 // NewDuplicateCameraL |
|
5784 // --------------------------------------------------------------------------- |
|
5785 // |
|
5786 CAMERA* |
|
5787 CCamCameraController::NewDuplicateCameraL( TInt aCameraHandle ) |
|
5788 { |
|
5789 PRINT1( _L("Camera => CCamCameraController::NewDuplicateCameraL( %d )"), aCameraHandle ); |
|
5790 CAMERA* camera( NULL ); |
|
5791 |
|
5792 #ifdef CAMERAAPP_CAPI_V2 |
|
5793 PRINT( _L("Camera <> call NewDuplicate2L..") ); |
|
5794 camera = CAMERA::NewDuplicate2L( *this, aCameraHandle ); |
|
5795 #else |
|
5796 MCameraObserver* self( this ); |
|
5797 PRINT( _L("Camera <> call NewDuplicateL..") ); |
|
5798 camera = CAMERA::NewDuplicateL ( *self, aCameraHandle ); |
|
5799 #endif |
|
5800 |
|
5801 PRINT( _L("Camera <= CCamCameraController::NewCameraL") ); |
|
5802 return camera; |
|
5803 } |
|
5804 |
|
5805 |
|
5806 // =========================================================================== |
|
5807 // Constructors |
|
5808 |
|
5809 |
|
5810 // --------------------------------------------------------------------------- |
|
5811 // 2nd phase constructor |
|
5812 // --------------------------------------------------------------------------- |
|
5813 // |
|
5814 void |
|
5815 CCamCameraController::ConstructL( TInt aCameraIndex ) |
|
5816 { |
|
5817 iActive = CCamCameraControllerActive::NewL( *this, KCamCallBackPriority ); |
|
5818 iIveRecoveryCount = KIveRecoveryCountMax; |
|
5819 |
|
5820 #ifdef CAMERAAPP_PERFORMANCE_CONTROLLER |
|
5821 iPerformanceLogger = new (ELeave) CCamPerformanceLogger; |
|
5822 iFirstVfFrameReceived = EFalse; |
|
5823 #endif |
|
5824 |
|
5825 #ifdef CAMERAAPP_FLASH_SIMULATOR |
|
5826 iFlashSimulator = CCamFlashSimulator::NewL( *this ); |
|
5827 #endif |
|
5828 |
|
5829 SwitchCameraL( aCameraIndex ); |
|
5830 iAsyncVideoStopModeSupported = EFalse; |
|
5831 |
|
5832 } |
|
5833 |
|
5834 |
|
5835 |
|
5836 // --------------------------------------------------------------------------- |
|
5837 // 1st phase constructor |
|
5838 // --------------------------------------------------------------------------- |
|
5839 // |
|
5840 CCamCameraController |
|
5841 ::CCamCameraController( MCamSettingProvider& aSettingProvider, |
|
5842 CCamAppController& aAppController ) |
|
5843 : iSequenceArray ( KCamSequenceGranularity ), |
|
5844 iReserveTryAgainCount( KCamReserveTryAgainMaxCount ), |
|
5845 iSettingProvider ( aSettingProvider ), |
|
5846 iAppController ( aAppController ) |
|
5847 { |
|
5848 } |
|
5849 |
|
5850 |
|
5851 // =========================================================================== |
|
5852 // Workaround for CCaeEngine with no support for CCamera sharing |
|
5853 |
|
5854 #ifdef CAMERAAPP_CAE_FIX |
|
5855 // --------------------------------------------------------------------------- |
|
5856 // --------------------------------------------------------------------------- |
|
5857 // |
|
5858 TInt |
|
5859 CCamCameraController::ProceedModeSwitch() |
|
5860 { |
|
5861 PRINT1( _L("Camera => CCamCameraController::ProceedModeSwitch, status in:%d"), iModeChangeStatus ); |
|
5862 TInt proceed( EFalse ); |
|
5863 |
|
5864 // Update only after here, so any events arriving |
|
5865 // in the middle get ignored if wanted. |
|
5866 ++iModeChangePhase; |
|
5867 |
|
5868 if( KErrNone == iModeChangeStatus ) |
|
5869 { |
|
5870 TRAP( iModeChangeStatus, proceed = DoProceedModeSwitchL() ); |
|
5871 } |
|
5872 |
|
5873 if( KErrNone != iModeChangeStatus ) |
|
5874 { |
|
5875 PRINT1( _L("Camera <> Mode switch error: %d"), iModeChangeStatus ); |
|
5876 iModeChange = ECamModeChangeInactive; |
|
5877 iModeChangePhase = ECamModeChangePhase0; |
|
5878 iModeChangeStatus = KErrNone; |
|
5879 |
|
5880 PRINT( _L("Camera <> Deleting engine..") ); |
|
5881 delete iCaeEngine; |
|
5882 iCaeEngine = NULL; |
|
5883 |
|
5884 PRINT( _L("Camera <> Deleting camera..") ); |
|
5885 delete iCamera; |
|
5886 iCamera = NULL; |
|
5887 |
|
5888 iInfo.Reset(); |
|
5889 |
|
5890 PRINT( _L("Camera <> PANIC!!") ); |
|
5891 |
|
5892 Panic( ECamCameraControllerUnrecovableError ); |
|
5893 } |
|
5894 |
|
5895 PRINT1( _L("Camera <= CCamCameraController::ProceedModeSwitch, more calls now:%d"), proceed ); |
|
5896 return proceed; |
|
5897 } |
|
5898 |
|
5899 // --------------------------------------------------------------------------- |
|
5900 // --------------------------------------------------------------------------- |
|
5901 // |
|
5902 TInt |
|
5903 CCamCameraController::DoProceedModeSwitchL() |
|
5904 { |
|
5905 PRINT( _L("Camera => CCamCameraController::DoProceedModeSwitchL") ); |
|
5906 User::LeaveIfError( iModeChangeStatus ); |
|
5907 |
|
5908 TBool callback = ETrue; |
|
5909 |
|
5910 // ------------------------------------------------------- |
|
5911 if( ECamModeChangeImage2Video == iModeChange ) |
|
5912 { |
|
5913 PRINT( _L("Camera <> Changing mode image => video") ); |
|
5914 switch( iModeChangePhase ) |
|
5915 { |
|
5916 // First two phases only usable if CAE v1 in use. |
|
5917 // Must start from phase2 otherwise. |
|
5918 // ------------------------------- |
|
5919 case ECamModeChangePhase0: |
|
5920 { |
|
5921 PRINT( _L("Camera <> Phase0: Release camera..") ); |
|
5922 TInt cameraIndex = iInfo.iCurrentCamera; |
|
5923 ReleaseCurrentCamera(); |
|
5924 SwitchCameraL( cameraIndex ); |
|
5925 CompleteSwitchCameraL(); |
|
5926 callback = EFalse; |
|
5927 // iModeChangePhase is incremented when iActive->RunL calls |
|
5928 // ProcessNextRequestL for the next time. |
|
5929 break; |
|
5930 } |
|
5931 // ------------------------------- |
|
5932 case ECamModeChangePhase1: |
|
5933 { |
|
5934 PRINT( _L("Camera <> Phase1: calling CCaeEngine::InitL..") ); |
|
5935 iCaeEngine->InitL(); |
|
5936 iCaeInUse = ETrue; |
|
5937 // Continue mode change in callback |
|
5938 PRINT( _L("Camera <> ..waiting for to complete") ); |
|
5939 break; |
|
5940 } |
|
5941 // ------------------------------- |
|
5942 case ECamModeChangePhase2: |
|
5943 { |
|
5944 PRINT( _L("Camera <> Phase2: Prepare video..") ); |
|
5945 PRINT( _L("Camera <> Call InitVideoRecorderL..") ); |
|
5946 iCaeEngine->InitVideoRecorderL(); |
|
5947 |
|
5948 PRINT( _L("Camera <> Ask filename..") ); |
|
5949 // HBufC* filename( HBufC::NewLC( KMaxFileName ) ); |
|
5950 // TPtr ptr ( filename->Des() ); |
|
5951 // iSettingProvider.ProvideCameraSettingL( ECameraSettingFileName, &ptr ); |
|
5952 _LIT( KTempFilename, "C:\\video.3gp" ); |
|
5953 TPtrC ptr; |
|
5954 ptr.Set( KTempFilename() ); |
|
5955 #pragma message( "Camera Controller: video filename hardcoded" ) |
|
5956 PRINT1( _L("Camera <> Set filename [%S]"), &ptr ); |
|
5957 iCaeEngine->SetVideoRecordingFileNameL( ptr ); |
|
5958 // CleanupStack::PopAndDestroy( filename ); |
|
5959 |
|
5960 |
|
5961 // Set max video clip size |
|
5962 ProcessSettingL( ECameraSettingFileMaxSize ); |
|
5963 |
|
5964 |
|
5965 TPckgBuf<TCamParamsVideoCae> params; |
|
5966 iSettingProvider.ProvideCameraParamL( ECameraParamVideoCae, ¶ms ); |
|
5967 // The audioOn value is defined On==0 and Off==1, but the engine expects |
|
5968 // ETrue if audio recording is On |
|
5969 params().iAudioOn = ( ECamSettOn == params().iAudioOn ) |
|
5970 ? ETrue |
|
5971 : EFalse; |
|
5972 PRINT( _L("Camera <> Call prepare..") ); |
|
5973 // McaeoVideoPrepareComplete will be called when prepare is ready. |
|
5974 // The callback is allowed to come also *during* this call. |
|
5975 iCaeEngine->PrepareVideoRecordingL( params().iFrameSize, |
|
5976 params().iFrameRate, |
|
5977 params().iVideoBitRate, |
|
5978 params().iAudioOn, |
|
5979 params().iAudioBitRate, |
|
5980 params().iMimeType, |
|
5981 params().iSupplier, |
|
5982 params().iVideoType, |
|
5983 params().iAudioType ); |
|
5984 |
|
5985 // iCaeEngine->PrepareVideoRecordingL( 0 ); |
|
5986 |
|
5987 break; |
|
5988 } |
|
5989 // ------------------------------- |
|
5990 case ECamModeChangePhase3: |
|
5991 { |
|
5992 PRINT( _L("Camera <> Phase3: Notifying..") ); |
|
5993 iModeChange = ECamModeChangeInactive; |
|
5994 iModeChangePhase = ECamModeChangePhaseIdle; |
|
5995 callback = EFalse; |
|
5996 |
|
5997 NotifyObservers( iModeChangeStatus, |
|
5998 ECamCameraEventVideoInit, |
|
5999 ECamCameraEventClassVideo ); |
|
6000 break; |
|
6001 } |
|
6002 // ------------------------------- |
|
6003 default: |
|
6004 { |
|
6005 Panic( ECamCameraControllerCorrupt ); |
|
6006 break; |
|
6007 } |
|
6008 // ------------------------------- |
|
6009 } |
|
6010 } |
|
6011 // ------------------------------------------------------- |
|
6012 else if( ECamModeChangeVideo2Image == iModeChange ) |
|
6013 { |
|
6014 PRINT( _L("Camera <> Changing mode video => image") ); |
|
6015 switch( iModeChangePhase ) |
|
6016 { |
|
6017 // ------------------------------- |
|
6018 case ECamModeChangePhase0: |
|
6019 { |
|
6020 PRINT( _L("Camera <> Phase0: Release camera..") ); |
|
6021 TInt cameraIndex = iInfo.iCurrentCamera; |
|
6022 ReleaseCurrentCamera(); |
|
6023 SwitchCameraL( cameraIndex ); |
|
6024 CompleteSwitchCameraL(); |
|
6025 callback = EFalse; |
|
6026 break; |
|
6027 } |
|
6028 // ------------------------------- |
|
6029 case ECamModeChangePhase1: |
|
6030 { |
|
6031 PRINT( _L("Camera <> Phase1: Reserve camera..") ); |
|
6032 iCaeInUse = EFalse; |
|
6033 iCamera->Reserve(); |
|
6034 break; |
|
6035 } |
|
6036 // ------------------------------- |
|
6037 case ECamModeChangePhase2: |
|
6038 { |
|
6039 PRINT( _L("Camera <> Phase2: Power on..") ); |
|
6040 iCamera->PowerOn(); |
|
6041 break; |
|
6042 } |
|
6043 // ------------------------------- |
|
6044 case ECamModeChangePhase3: |
|
6045 { |
|
6046 PRINT( _L("Camera <> Phase3: Prepare image..") ); |
|
6047 TPckgBuf<TCamParamsImage> params; |
|
6048 iSettingProvider.ProvideCameraParamL( ECameraParamImage, ¶ms ); |
|
6049 |
|
6050 // Query the supported resolutions for the selected format. |
|
6051 TInt index = GetResolutionIndexL( params().iFormat, params().iSize ); |
|
6052 User::LeaveIfError( index ); |
|
6053 |
|
6054 PRINT2( _L("Camera <> Image size: (%d, %d)"), |
|
6055 params().iSize.iWidth, |
|
6056 params().iSize.iHeight ); |
|
6057 iCamera->PrepareImageCaptureL( params().iFormat, index ); |
|
6058 iCamera->SetJpegQuality( params().iQualityFactor ); |
|
6059 |
|
6060 SetFlags( iInfo.iState, ECamImageOn ); |
|
6061 |
|
6062 callback = EFalse; |
|
6063 break; |
|
6064 } |
|
6065 // ------------------------------- |
|
6066 case ECamModeChangePhase4: |
|
6067 { |
|
6068 PRINT( _L("Camera <> Phase4: Notifying..") ); |
|
6069 iModeChange = ECamModeChangeInactive; |
|
6070 iModeChangePhase = ECamModeChangePhaseIdle; |
|
6071 callback = EFalse; |
|
6072 |
|
6073 NotifyObservers( iModeChangeStatus, |
|
6074 ECamCameraEventImageInit, |
|
6075 ECamCameraEventClassImage ); |
|
6076 |
|
6077 break; |
|
6078 } |
|
6079 // ------------------------------- |
|
6080 default: |
|
6081 { |
|
6082 Panic( ECamCameraControllerCorrupt ); |
|
6083 break; |
|
6084 } |
|
6085 // ------------------------------- |
|
6086 } |
|
6087 } |
|
6088 // ------------------------------------------------------- |
|
6089 else |
|
6090 { |
|
6091 Panic( ECamCameraControllerCorrupt ); |
|
6092 } |
|
6093 // ------------------------------------------------------- |
|
6094 |
|
6095 PRINT1( _L("Camera <= CCamCameraController::DoProceedModeSwitchL, more calls now:%d"), !callback ); |
|
6096 return !callback; |
|
6097 } |
|
6098 #endif // CAMERAAPP_CAE_FIX |
|
6099 |
|
6100 |
|
6101 /** |
|
6102 * CCamCameraController::RemainingVideoRecordingTime() |
|
6103 * Method to retrieve Remaining Recording time from CCaeEngine |
|
6104 * which is used in AppController and AppUi during Video Rec Operation |
|
6105 */ |
|
6106 TTimeIntervalMicroSeconds |
|
6107 CCamCameraController::RemainingVideoRecordingTime() |
|
6108 { |
|
6109 if( iCaeEngine ) |
|
6110 return iCaeEngine->RemainingVideoRecordingTime(); |
|
6111 else |
|
6112 return 0; |
|
6113 } |
|
6114 |
|
6115 |
|
6116 // =========================================================================== |
|
6117 // Performance measurement related |
|
6118 |
|
6119 #ifdef CAMERAAPP_PERFORMANCE_CONTROLLER |
|
6120 |
|
6121 // --------------------------------------------------------------------------- |
|
6122 // PerformanceLogger() |
|
6123 // |
|
6124 // Return the performance logger instance. |
|
6125 // Used to record performance measurement data. |
|
6126 // --------------------------------------------------------------------------- |
|
6127 // |
|
6128 const CCamPerformanceLogger* |
|
6129 CCamCameraController::PerformanceLogger() const |
|
6130 { |
|
6131 return iPerformanceLogger; |
|
6132 } |
|
6133 |
|
6134 #endif // CAMERAAPP_PERFORMANCE_CONTROLLER |
|
6135 |
|
6136 |
|
6137 |
|
6138 // =========================================================================== |
|
6139 // Debug prints |
|
6140 |
|
6141 #ifdef _DEBUG |
|
6142 // --------------------------------------------------------------------------- |
|
6143 // PrintCameraInfo |
|
6144 // --------------------------------------------------------------------------- |
|
6145 // |
|
6146 void |
|
6147 CCamCameraController::PrintCameraInfo() const |
|
6148 { |
|
6149 PRINT ( _L("Camera <> ==================================================") ); |
|
6150 PRINT ( _L("Camera <> Camera info:") ); |
|
6151 PRINT3( _L("Camera <> Camera hw version[%d.%d.%d]"), |
|
6152 iCameraInfo.iHardwareVersion.iMajor, |
|
6153 iCameraInfo.iHardwareVersion.iMinor, |
|
6154 iCameraInfo.iHardwareVersion.iBuild ); |
|
6155 PRINT3( _L("Camera <> Camera sw version[%d.%d.%d]"), |
|
6156 iCameraInfo.iSoftwareVersion.iMajor, |
|
6157 iCameraInfo.iSoftwareVersion.iMinor, |
|
6158 iCameraInfo.iSoftwareVersion.iBuild ); |
|
6159 PRINT1( _L("Camera <> TCameraInfo.iMinZoom : %d"), iCameraInfo.iMinZoom ); |
|
6160 PRINT1( _L("Camera <> TCameraInfo.iMaxZoom : %d"), iCameraInfo.iMaxZoom ); |
|
6161 PRINT1( _L("Camera <> TCameraInfo.iMaxDigitalZoom : %d"), iCameraInfo.iMaxDigitalZoom ); |
|
6162 PRINT1( _L("Camera <> TCameraInfo.iMinZoomFactor : %f"), iCameraInfo.iMinZoomFactor ); |
|
6163 PRINT1( _L("Camera <> TCameraInfo.iMaxZoomFactor : %f"), iCameraInfo.iMaxZoomFactor ); |
|
6164 PRINT1( _L("Camera <> TCameraInfo.iMaxDigitalZoomFactor: %f"), iCameraInfo.iMaxDigitalZoomFactor ); |
|
6165 PRINT ( _L("Camera <> ==================================================") ); |
|
6166 } |
|
6167 |
|
6168 |
|
6169 // --------------------------------------------------------------------------- |
|
6170 // PrintSnapshotInfo |
|
6171 // --------------------------------------------------------------------------- |
|
6172 // |
|
6173 void |
|
6174 CCamCameraController::PrintSnapshotInfo() const |
|
6175 { |
|
6176 PRINT ( _L("Camera <> ===========================================================") ); |
|
6177 PRINT ( _L("Camera <> Snapshot info" ) ); |
|
6178 PRINT1( _L("Camera <> Formats supported (1st) : %032b" ), iSnapshotProvider->SupportedFormats() ); |
|
6179 PRINT1( _L("Camera <> EFormatFbsBitmapColor4K : %032b" ), CCamera::EFormatFbsBitmapColor4K ); |
|
6180 PRINT1( _L("Camera <> EFormatFbsBitmapColor64K : %032b" ), CCamera::EFormatFbsBitmapColor64K ); |
|
6181 PRINT1( _L("Camera <> EFormatFbsBitmapColor16M : %032b" ), CCamera::EFormatFbsBitmapColor16M ); |
|
6182 PRINT1( _L("Camera <> EFormatFbsBitmapColor16MU: %032b" ), CCamera::EFormatFbsBitmapColor16MU ); |
|
6183 PRINT ( _L("Camera <> ===========================================================") ); |
|
6184 } |
|
6185 |
|
6186 // =========================================================================== |
|
6187 #endif // _DEBUG |
|
6188 |
|
6189 // --------------------------------------------------------------------------- |
|
6190 // CCamCameraController::SettingValueUpToDateL |
|
6191 // --------------------------------------------------------------------------- |
|
6192 // |
|
6193 TBool |
|
6194 CCamCameraController::SettingValueUpToDateL( const NCamCameraController::TCamCameraSettingId& aSettingId ) |
|
6195 { |
|
6196 PRINT( _L("Camera => CCamCameraController::SettingValueUpToDate") ); |
|
6197 TBool upToDate = ETrue; |
|
6198 |
|
6199 switch( aSettingId ) |
|
6200 { |
|
6201 case ECameraSettingFlash: |
|
6202 case ECameraUserSceneSettingFlash: |
|
6203 { |
|
6204 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingFlash") ); |
|
6205 |
|
6206 // Supposed setting value from settings provider |
|
6207 CCamera::TFlash flashSetting( CCamera::EFlashNone ); |
|
6208 iSettingProvider.ProvideCameraSettingL( aSettingId, &flashSetting ); |
|
6209 |
|
6210 // Real settings value from camera |
|
6211 CCamera::TFlash flashValue( CCamera::EFlashNone ); |
|
6212 GetCameraSettingValueL( aSettingId, &flashValue ); |
|
6213 |
|
6214 PRINT2( _L("Camera <> flashValue = %d, flashSetting = %d"), flashValue, flashSetting ); |
|
6215 upToDate = ( flashValue == flashSetting ); |
|
6216 break; |
|
6217 } |
|
6218 case ECameraSettingExposure: |
|
6219 case ECameraUserSceneSettingExposure: |
|
6220 { |
|
6221 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingExposure") ); |
|
6222 TPckgBuf<TCamSettingDataExposure> exposureSetting; |
|
6223 iSettingProvider.ProvideCameraSettingL( aSettingId, &exposureSetting ); |
|
6224 |
|
6225 TPckgBuf<TCamSettingDataExposure> exposureValue; |
|
6226 GetCameraSettingValueL( aSettingId, &exposureValue ); |
|
6227 |
|
6228 if ( exposureSetting().iExposureMode != exposureValue().iExposureMode || |
|
6229 exposureSetting().iExposureStep != exposureValue().iExposureStep ) |
|
6230 { |
|
6231 upToDate = EFalse; |
|
6232 } |
|
6233 |
|
6234 break; |
|
6235 } |
|
6236 case ECameraSettingLightSensitivity: |
|
6237 case ECameraUserSceneSettingLightSensitivity: |
|
6238 { |
|
6239 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingLightSensitivity") ); |
|
6240 |
|
6241 RArray<TInt> ISOarray; |
|
6242 CleanupClosePushL( ISOarray ); |
|
6243 #ifdef CAMERAAPP_CAPI_V2 |
|
6244 iAdvancedSettings->GetSupportedIsoRatesL( ISOarray ); |
|
6245 #endif |
|
6246 iSettingProvider.SetSupportedISORatesL( ISOarray ); |
|
6247 |
|
6248 TInt* isoSetting = 0; |
|
6249 iSettingProvider.ProvideCameraSettingL( aSettingId, &isoSetting ); |
|
6250 CleanupStack::PopAndDestroy( &ISOarray ); |
|
6251 |
|
6252 |
|
6253 TInt* isoValue = 0; |
|
6254 GetCameraSettingValueL( aSettingId, &isoValue ); |
|
6255 |
|
6256 upToDate = ( isoSetting == isoValue ); |
|
6257 break; |
|
6258 } |
|
6259 case ECameraSettingWhiteBalance: |
|
6260 case ECameraUserSceneSettingWhiteBalance: |
|
6261 { |
|
6262 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingWhiteBalance") ); |
|
6263 |
|
6264 TPckgBuf<TCamSettingDataWhiteBalance> wbSetting; |
|
6265 iSettingProvider.ProvideCameraSettingL( aSettingId, &wbSetting ); |
|
6266 |
|
6267 TPckgBuf<TCamSettingDataWhiteBalance> wbValue; |
|
6268 GetCameraSettingValueL( aSettingId, &wbValue ); |
|
6269 |
|
6270 upToDate = ( wbSetting().iWhiteBalanceMode == wbValue().iWhiteBalanceMode ); |
|
6271 break; |
|
6272 } |
|
6273 case ECameraSettingColourEffect: |
|
6274 case ECameraUserSceneSettingColourEffect: |
|
6275 { |
|
6276 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingColourEffect") ); |
|
6277 |
|
6278 CIP::TEffect effectSetting( CIP::EEffectNone ); |
|
6279 iSettingProvider.ProvideCameraSettingL( aSettingId, &effectSetting ); |
|
6280 |
|
6281 CIP::TEffect effectValue( CIP::EEffectNone ); |
|
6282 // Can't leave here or other settings won't be restored |
|
6283 TRAP_IGNORE( GetCameraSettingValueL( aSettingId, &effectValue ) ); |
|
6284 |
|
6285 upToDate = ( effectSetting == effectValue ); |
|
6286 break; |
|
6287 } |
|
6288 case ECameraSettingBrightness: |
|
6289 case ECameraUserSceneSettingBrightness: |
|
6290 { |
|
6291 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingBrightness") ); |
|
6292 CCamera::TBrightness brightnessSetting; |
|
6293 iSettingProvider.ProvideCameraSettingL( aSettingId, &brightnessSetting ); |
|
6294 |
|
6295 CCamera::TBrightness brightnessValue; |
|
6296 GetCameraSettingValueL( aSettingId, &brightnessValue ); |
|
6297 |
|
6298 upToDate = ( brightnessSetting == brightnessValue ); |
|
6299 break; |
|
6300 } |
|
6301 case ECameraSettingContrast: |
|
6302 case ECameraUserSceneSettingContrast: |
|
6303 { |
|
6304 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingContrast") ); |
|
6305 CCamera::TContrast contrastSetting( CCamera::EContrastAuto ); |
|
6306 iSettingProvider.ProvideCameraSettingL( aSettingId, &contrastSetting ); |
|
6307 |
|
6308 CCamera::TContrast contrastValue( CCamera::EContrastAuto ); |
|
6309 GetCameraSettingValueL( aSettingId, &contrastValue ); |
|
6310 |
|
6311 upToDate = ( contrastSetting == contrastValue ); |
|
6312 break; |
|
6313 } |
|
6314 case ECameraSettingSharpness: |
|
6315 case ECameraUserSceneSettingSharpness: |
|
6316 { |
|
6317 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingSharpness") ); |
|
6318 TInt sharpnessSetting( 0 ); |
|
6319 iSettingProvider.ProvideCameraSettingL( aSettingId, &sharpnessSetting ); |
|
6320 |
|
6321 TInt sharpnessValue( 0 ); |
|
6322 // Can't leave here or other settings won't be restored |
|
6323 TRAP_IGNORE( GetCameraSettingValueL( aSettingId, &sharpnessValue ) ); |
|
6324 |
|
6325 upToDate = ( sharpnessSetting == sharpnessValue ); |
|
6326 break; |
|
6327 } |
|
6328 case ECameraSettingDigitalZoom: |
|
6329 { |
|
6330 TInt zoomSetting( 0 ); |
|
6331 iSettingProvider.ProvideCameraSettingL( aSettingId, &zoomSetting ); |
|
6332 |
|
6333 TInt zoomValue( 0 ); |
|
6334 GetCameraSettingValueL( aSettingId, &zoomValue ); |
|
6335 |
|
6336 upToDate = ( zoomSetting == zoomValue ); |
|
6337 break; |
|
6338 } |
|
6339 #ifdef CAMERAAPP_CAPI_V2 |
|
6340 case ECameraSettingStabilization: |
|
6341 { |
|
6342 PRINT( _L("Camera <> CCamCameraController::SettingValueUpToDate ECameraSettingStabilization") ); |
|
6343 |
|
6344 TPckgBuf<TCamSettingDataStabilization> stabilizationSetting; |
|
6345 iSettingProvider.ProvideCameraSettingL( aSettingId, &stabilizationSetting ); |
|
6346 |
|
6347 TPckgBuf<TCamSettingDataStabilization> stabilizationValue; |
|
6348 GetCameraSettingValueL( aSettingId, &stabilizationValue ); |
|
6349 if ( stabilizationSetting().iMode != stabilizationValue().iMode || |
|
6350 stabilizationSetting().iEffect != stabilizationValue().iEffect || |
|
6351 stabilizationSetting().iComplexity != stabilizationValue().iComplexity ) |
|
6352 { |
|
6353 upToDate = EFalse; |
|
6354 } |
|
6355 break; |
|
6356 } |
|
6357 case ECameraSettingContAF: |
|
6358 { |
|
6359 TBool isContAFon( iAdvancedSettings->AutoFocusType() & |
|
6360 CAS::EAutoFocusTypeContinuous ); |
|
6361 if( IsFlagOn( iInfo.iState, ECamVideoOn ) ) |
|
6362 { |
|
6363 TBool contAF( ETrue ); |
|
6364 iSettingProvider.ProvideCameraSettingL( aSettingId, &contAF ); |
|
6365 if( contAF != isContAFon ) |
|
6366 { |
|
6367 upToDate = EFalse; |
|
6368 } |
|
6369 } |
|
6370 else |
|
6371 { |
|
6372 //Do nothing |
|
6373 |
|
6374 } |
|
6375 break; |
|
6376 } |
|
6377 #endif |
|
6378 default: |
|
6379 { |
|
6380 PRINT1( _L("CCamCameraController::SettingValueUpToDate - unknown setting id: %d"), aSettingId ); |
|
6381 } |
|
6382 |
|
6383 } |
|
6384 |
|
6385 PRINT1( _L("Camera <= CCamCameraController::SettingValueUpToDate returning %d"), upToDate ); |
|
6386 return upToDate; |
|
6387 } |
|
6388 |
|
6389 |
|
6390 |
|
6391 // --------------------------------------------------------------------------- |
|
6392 // CCamCameraController::SetViewfinderWindowHandle |
|
6393 // --------------------------------------------------------------------------- |
|
6394 // |
|
6395 void CCamCameraController::SetViewfinderWindowHandle( RWindowBase* aWindow ) |
|
6396 { |
|
6397 PRINT( _L("Camera => CCamCameraController::SetViewfinderWindowHandle") ); |
|
6398 PRINT2( _L("Camera <> aWindow=0x%08x iViewfinderWindow=0x%08x "), aWindow, iViewfinderWindow ); |
|
6399 |
|
6400 if ( aWindow != iViewfinderWindow && |
|
6401 iCamera && |
|
6402 iInfo.iVfState == ECamTriActive && |
|
6403 iInfo.iVfMode == ECamViewfinderDirect ) |
|
6404 { |
|
6405 PRINT( _L("Camera <> viewfinder active and window handle changed, restarting viewfinder...") ); |
|
6406 iCamera->StopViewFinder(); |
|
6407 iInfo.iVfState = ECamTriInactive; |
|
6408 |
|
6409 // restart viewfinder |
|
6410 //TRAP_IGNORE( ProcessVfStartRequestL() ); |
|
6411 iAppController.EnterViewfinderMode(iAppController.CurrentMode()); |
|
6412 } |
|
6413 iViewfinderWindow = aWindow; |
|
6414 |
|
6415 PRINT( _L("Camera <= CCamCameraController::SetViewfinderWindowHandle") ); |
|
6416 } |
|
6417 |
|
6418 // --------------------------------------------------------------------------- |
|
6419 // CCamCameraController::ViewfinderWindowDeleted |
|
6420 // --------------------------------------------------------------------------- |
|
6421 // |
|
6422 void CCamCameraController::ViewfinderWindowDeleted( RWindowBase* aWindow ) |
|
6423 { |
|
6424 PRINT( _L("Camera => CCamCameraController::ViewfinderWindowDeleted") ); |
|
6425 PRINT2( _L("Camera <> aWindow=0x%08x iViewfinderWindow=0x%08x "), aWindow, iViewfinderWindow ); |
|
6426 |
|
6427 if ( aWindow == iViewfinderWindow ) |
|
6428 { |
|
6429 if ( iCamera && |
|
6430 iInfo.iVfState == ECamTriActive && |
|
6431 iInfo.iVfMode == ECamViewfinderDirect ) |
|
6432 { |
|
6433 PRINT( _L("Camera <> viewfinder active and window deleted, stopping viewfinder...") ); |
|
6434 iCamera->StopViewFinder(); |
|
6435 iInfo.iVfState = ECamTriInactive; |
|
6436 } |
|
6437 iViewfinderWindow = NULL; |
|
6438 } |
|
6439 |
|
6440 PRINT( _L("Camera <= CCamCameraController::ViewfinderWindowDeleted") ); |
|
6441 } |
|
6442 |
|
6443 // --------------------------------------------------------------------------- |
|
6444 // CCamCameraController::SetVfWindowOrdinal |
|
6445 // --------------------------------------------------------------------------- |
|
6446 // |
|
6447 TInt CCamCameraController::SetVfWindowOrdinal( TInt aOrdinalPosition ) |
|
6448 { |
|
6449 TInt orgPos( KErrUnknown ); |
|
6450 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
6451 if ( iViewfinderWindow ) |
|
6452 { |
|
6453 TInt cbaPos(0); |
|
6454 TInt toolbarPos(0); |
|
6455 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
6456 orgPos = iViewfinderWindow->OrdinalPosition(); |
|
6457 if ( aOrdinalPosition != KErrUnknown) |
|
6458 { |
|
6459 // Set wanted ordinal position |
|
6460 iViewfinderWindow->SetOrdinalPosition( aOrdinalPosition ); |
|
6461 } |
|
6462 else if ( appUi ) |
|
6463 { |
|
6464 // Find out other windows ordinal positions |
|
6465 if ( cba ) |
|
6466 { |
|
6467 cbaPos = cba->DrawableWindow()->OrdinalPosition(); |
|
6468 } |
|
6469 CAknToolbar* toolbar = appUi->CurrentFixedToolbar(); |
|
6470 if ( toolbar ) |
|
6471 { |
|
6472 RDrawableWindow* toolbarwindow = toolbar->DrawableWindow(); |
|
6473 if ( toolbarwindow ) |
|
6474 { |
|
6475 toolbarPos = toolbarwindow->OrdinalPosition(); |
|
6476 } |
|
6477 } |
|
6478 // Calculate new viewfinder position, |
|
6479 // just under fixed toolbar and CBA buttons |
|
6480 TInt newPos = Max( toolbarPos, cbaPos ) + 1; |
|
6481 // Use new position if viefinder window is not visible already |
|
6482 iViewfinderWindow->SetOrdinalPosition( Min( orgPos, newPos ) ); |
|
6483 } |
|
6484 } |
|
6485 return orgPos; |
|
6486 } |
|
6487 |
|
6488 #ifdef CAMERAAPP_CAE_ERR_SIMULATION |
|
6489 |
|
6490 // --------------------------------------------------------------------------- |
|
6491 // CCamCameraController::DelayedCaeCallback |
|
6492 // Static function called when the timer expires |
|
6493 // --------------------------------------------------------------------------- |
|
6494 // |
|
6495 TInt |
|
6496 CCamCameraController::DelayedCaeCallback( TAny* aController ) |
|
6497 { |
|
6498 CCamCameraController* self = static_cast<CCamCameraController*>( aController ); |
|
6499 self->CallAppropriateCallback(); |
|
6500 |
|
6501 return KErrNone; |
|
6502 } |
|
6503 |
|
6504 // --------------------------------------------------------------------------- |
|
6505 // CCamCameraController::CallAppropriateCallback |
|
6506 // Helper function to call the appropriate callback handler. |
|
6507 // --------------------------------------------------------------------------- |
|
6508 // |
|
6509 void |
|
6510 CCamCameraController::CallAppropriateCallback( const TCamCameraEventId aEventId, |
|
6511 TInt aStatus ) |
|
6512 { |
|
6513 PRINT2( _L("Camera => CCamCameraController::CallAppropriateCallback, event:%d, status:%d"), aEventId, aStatus ) |
|
6514 |
|
6515 switch ( iSimEventId ) |
|
6516 { |
|
6517 case ECamCameraEventVideoInit: |
|
6518 case ECamCameraEventVideoStart: // fallthrough |
|
6519 case ECamCameraEventVideoPause: // fallthrough |
|
6520 case ECamCameraEventVideoStop: |
|
6521 if( aEventId == ECamCameraEventNone ) |
|
6522 { |
|
6523 PRINT( _L("Camera <> CCamCameraController::CallAppropriateCallback - calling handler after delay") ) |
|
6524 HandleVideoEvent( iSimEventId, iSimStatus ); |
|
6525 } |
|
6526 else |
|
6527 { |
|
6528 PRINT( _L("Camera <> CCamCameraController::CallAppropriateCallback - calling handler without delay") ) |
|
6529 HandleVideoEvent( aEventId, aStatus ); |
|
6530 } |
|
6531 break; |
|
6532 default: |
|
6533 break; |
|
6534 } |
|
6535 |
|
6536 // In case of being called by timer, stop and destro the timer |
|
6537 if( aEventId == ECamCameraEventNone && iCallbackTimer ) |
|
6538 { |
|
6539 iCallbackTimer->Cancel(); |
|
6540 delete iCallbackTimer; |
|
6541 iCallbackTimer = NULL; |
|
6542 } |
|
6543 |
|
6544 PRINT( _L("Camera <= CCamCameraController::CallAppropriateCallback") ) |
|
6545 } |
|
6546 |
|
6547 #endif // CAMERAAPP_CAE_ERR_SIMULATION |
|
6548 |
|
6549 // --------------------------------------------------------------------------- |
|
6550 // CCamCameraController::AsyncVideoStopModeSupported |
|
6551 // --------------------------------------------------------------------------- |
|
6552 // |
|
6553 TBool |
|
6554 CCamCameraController::AsyncVideoStopModeSupported() |
|
6555 { |
|
6556 PRINT1( _L("Camera <> CCamCameraController::AsyncVideoStopModeSupported = %d "), iAsyncVideoStopModeSupported ); |
|
6557 return( iAsyncVideoStopModeSupported ); |
|
6558 } |
|
6559 |
|
6560 // --------------------------------------------------------------------------- |
|
6561 // IdleCallback <<static>> |
|
6562 // --------------------------------------------------------------------------- |
|
6563 // |
|
6564 // static |
|
6565 TInt CCamCameraController::IdleCallback( TAny* aSelf ) |
|
6566 { |
|
6567 CCamCameraController* self( static_cast<CCamCameraController*>( aSelf ) ); |
|
6568 self->DoIveRecovery(); |
|
6569 |
|
6570 return EFalse; |
|
6571 } |
|
6572 |
|
6573 // --------------------------------------------------------------------------- |
|
6574 // CCamCameraController::DoIveRecovery |
|
6575 // --------------------------------------------------------------------------- |
|
6576 // |
|
6577 void CCamCameraController::DoIveRecovery() |
|
6578 { |
|
6579 PRINT( _L("Camera => CCamCameraController::DoIveRecovery") ) |
|
6580 if( iAppController.IsAppUiAvailable() |
|
6581 && !( iAppController.IsInShutdownMode() || iAppController.CheckExitStatus() ) ) |
|
6582 { |
|
6583 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
6584 __ASSERT_DEBUG(appUi, CamPanic(ECamPanicNullPointer)); |
|
6585 TVwsViewId activeView; |
|
6586 TInt viewErr = appUi->GetActiveViewId( activeView ); |
|
6587 CCamViewBase* view = NULL; |
|
6588 if( !viewErr ) |
|
6589 { |
|
6590 view = static_cast<CCamViewBase*>( appUi->View( activeView.iViewUid )); |
|
6591 } |
|
6592 else |
|
6593 { |
|
6594 //There was an error when getting active view ID. Propably camera |
|
6595 //application went to background. In that case just return because |
|
6596 //camera resource should be released when going to background. |
|
6597 return; |
|
6598 } |
|
6599 __ASSERT_DEBUG(view, CamPanic(ECamPanicNullPointer)); |
|
6600 if ( appUi->StandbyStatus() && view->IsInStandbyMode() ) |
|
6601 { |
|
6602 PRINT( _L("Camera <> CCamCameraController::DoIveRecovery - Standby mode active, try to exit") ) |
|
6603 TRAP_IGNORE( appUi->HandleControllerEventL( ECamEventCameraChanged, |
|
6604 KErrNone ) ); |
|
6605 } |
|
6606 else |
|
6607 { |
|
6608 PRINT( _L("Camera <> CCamCameraController::DoIveRecovery - Start recovering from beginning") ) |
|
6609 if( IsFlagOn( iInfo.iBusy, ECamBusySequence|ECamBusySetting ) ) |
|
6610 { |
|
6611 if( iActive && |
|
6612 iActive->IsActive() ) |
|
6613 { |
|
6614 iActive->Cancel(); |
|
6615 } |
|
6616 EndSequence( KErrNone ); |
|
6617 } |
|
6618 NotifyObservers( KErrNone, ECamCameraEventIveRecover, |
|
6619 ECamCameraEventClassBasicControl ); |
|
6620 } |
|
6621 iIveRecoveryCount--; |
|
6622 iIveRecoveryOngoing = ETrue; |
|
6623 } |
|
6624 PRINT1( _L("Camera <= CCamCameraController::DoIveRecovery iIveRecoveryCount%d"),iIveRecoveryCount ) |
|
6625 } |
|
6626 |
|
6627 // --------------------------------------------------------------------------- |
|
6628 // CCamCameraController::IsWaitingIveResources |
|
6629 // --------------------------------------------------------------------------- |
|
6630 // |
|
6631 TBool CCamCameraController::IsWaitingIveResources() |
|
6632 { |
|
6633 return iIdle && iIdle->IsActive(); |
|
6634 } |
|
6635 |
|
6636 |
|
6637 // --------------------------------------------------------------------------- |
|
6638 // CCamCameraController::SetFaceTrackingL |
|
6639 // --------------------------------------------------------------------------- |
|
6640 // |
|
6641 void CCamCameraController::SetFaceTrackingL() |
|
6642 { |
|
6643 if( iCustomInterfaceFaceTracking && |
|
6644 KPrimaryCameraIndex == iInfo.iCurrentCamera ) |
|
6645 { |
|
6646 TBool ftOn( EFalse ); |
|
6647 iSettingProvider.ProvideCameraSettingL( ECameraSettingFacetracking, &ftOn ); |
|
6648 PRINT1( _L("Camera <> Set facetracking: %d"), ftOn ) |
|
6649 iCustomInterfaceFaceTracking->SetFaceTrackingL( ftOn ); |
|
6650 iCustomInterfaceFaceTracking->EnableFaceIndicatorsL( ETrue ); |
|
6651 DirectRequestL( ECamRequestSetAfRange ); |
|
6652 } |
|
6653 } |
|
6654 |
|
6655 // End of file |
|