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