os/mm/imagingandcamerafws/cameraunittest/src/ECamUnitTestPlugin/ECamUnitTestPlugin.cpp
Update contrib.
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include <ecom/ecom.h>
18 #include <ecom/implementationproxy.h>
19 #include <ecamuids.hrh>
21 #include <ecam/ecamadvsettingsintfuids.hrh>
22 #include "ECamUnitTestPlugin.h"
23 #include "ECamUnitTestPluginUids.hrh"
24 #include "AdvancedSettings.h"
25 #include <ecam/ecamcommonuids.hrh>
26 #include "EnhanceFunctionality.h"
27 #include "directviewfinder.h"
28 #include "extended_functionality.h"
30 const TBool KTestCamerasPresent[] = {ETrue, EFalse, EFalse};
31 const CCamera::CCameraAdvancedSettings::TCameraType KTestCamerasTypes[] =
33 CCamera::CCameraAdvancedSettings::ECameraOnBoard,
34 CCamera::CCameraAdvancedSettings::ECameraPluggable,
35 CCamera::CCameraAdvancedSettings::ECameraPluggable
41 static void Panic(TInt aReason)
43 _LIT(KDllName, "ECam Unit Test Plugin");
44 User::Panic(KDllName, aReason);
50 CCamUnitTestPlugin::CCamUnitTestPlugin()
53 iSupportedISORates.Reset();
54 iIsoRate = KDefaultIsoRate;
55 for ( TInt i = 0; i< KECamSetAvailableCameras; i++)
57 iCameras[i] = KTestCamerasPresent[i];
58 iCameraTypes[i] = KTestCamerasTypes[i];
61 iVFHandleGenerater = 0;
64 CCamUnitTestPlugin::~CCamUnitTestPlugin()
66 iSupportedISORates.Close();
69 CCamUnitTestPlugin* CCamUnitTestPlugin::NewL()
71 FileDependencyUtil::CheckFileDependencyL();
72 return new (ELeave) CCamUnitTestPlugin;
76 // 2nd stage ConstructL calls called by framework
79 void CCamUnitTestPlugin::Construct2L(MCameraObserver& aObserver,TInt aCameraIndex)
81 iObserver = &aObserver;
82 iCameraIndex = aCameraIndex;
85 void CCamUnitTestPlugin::Construct2DupL(MCameraObserver& aObserver,TInt aCameraHandle)
87 iObserver = &aObserver;
88 iCameraHandle = aCameraHandle;
92 void CCamUnitTestPlugin::Construct2L(MCameraObserver2& aObserver,TInt aCameraIndex,TInt aPriority)
94 iObserver2 = &aObserver;
95 iCameraIndex = aCameraIndex;
96 iPriority = aPriority;
98 iSupportedISORates.AppendL(KMinIsoRate);
99 iSupportedISORates.AppendL(KDefaultIsoRate);
100 iSupportedISORates.AppendL(KIsoRate1);
101 iSupportedISORates.AppendL(KIsoRate2);
102 iSupportedISORates.AppendL(KIsoRate3);
103 iSupportedISORates.AppendL(KIsoRate4);
104 iSupportedISORates.AppendL(KIsoRate5);
105 iSupportedISORates.AppendL(KMaxIsoRate);
108 void CCamUnitTestPlugin::Construct2DupL(MCameraObserver2& aObserver,TInt aCameraHandle)
110 iObserver2 = &aObserver;
111 iCameraHandle = aCameraHandle;
114 iSupportedISORates.AppendL(KMinIsoRate);
115 iSupportedISORates.AppendL(KDefaultIsoRate);
116 iSupportedISORates.AppendL(KIsoRate1);
117 iSupportedISORates.AppendL(KIsoRate2);
118 iSupportedISORates.AppendL(KIsoRate3);
119 iSupportedISORates.AppendL(KIsoRate4);
120 iSupportedISORates.AppendL(KIsoRate5);
121 iSupportedISORates.AppendL(KMaxIsoRate);
127 // Dummy versions of virtual functions
130 void CCamUnitTestPlugin::CameraInfo(TCameraInfo& /*aInfo*/) const
134 void CCamUnitTestPlugin::Reserve()
139 void CCamUnitTestPlugin::Release()
143 void CCamUnitTestPlugin::PowerOn()
147 void CCamUnitTestPlugin::PowerOff()
151 TInt CCamUnitTestPlugin::Handle()
156 void CCamUnitTestPlugin::SetZoomFactorL(TInt /*aZoomFactor = 0*/)
160 TInt CCamUnitTestPlugin::ZoomFactor() const
165 void CCamUnitTestPlugin::SetDigitalZoomFactorL(TInt /*aDigitalZoomFactor = 0*/)
169 TInt CCamUnitTestPlugin::DigitalZoomFactor() const
174 void CCamUnitTestPlugin::SetContrastL(TInt /*aContrast*/)
178 TInt CCamUnitTestPlugin::Contrast() const
183 void CCamUnitTestPlugin::SetBrightnessL(TInt /*aBrightness*/)
187 TInt CCamUnitTestPlugin::Brightness() const
193 void CCamUnitTestPlugin::SetFlashL(TFlash /*aFlash = EFlashNone*/)
195 Panic(EPanicUnimplemented);
198 CCamera::TFlash CCamUnitTestPlugin::Flash() const
200 Panic(EPanicUnimplemented);
204 void CCamUnitTestPlugin::SetExposureL(TExposure /*aExposure = EExposureAuto*/)
206 Panic(EPanicUnimplemented);
209 CCamera::TExposure CCamUnitTestPlugin::Exposure() const
211 Panic(EPanicUnimplemented);
212 return EExposureAuto;
215 void CCamUnitTestPlugin::SetWhiteBalanceL(TWhiteBalance /*aWhiteBalance = EWBAuto*/)
217 Panic(EPanicUnimplemented);
220 CCamera::TWhiteBalance CCamUnitTestPlugin::WhiteBalance() const
222 Panic(EPanicUnimplemented);
226 void CCamUnitTestPlugin::StartViewFinderDirectL(RWsSession& /*aWs*/,CWsScreenDevice& /*aScreenDevice*/,RWindowBase& /*aWindow*/,TRect& /*aScreenRect*/)
228 Panic(EPanicUnimplemented);
231 void CCamUnitTestPlugin::StartViewFinderDirectL(RWsSession& /*aWs*/,CWsScreenDevice& /*aScreenDevice*/,RWindowBase& /*aWindow*/,TRect& /*aScreenRect*/,TRect& /*aClipRect*/)
233 Panic(EPanicUnimplemented);
236 void CCamUnitTestPlugin::StartViewFinderBitmapsL(TSize& /*aSize*/)
238 Panic(EPanicUnimplemented);
241 void CCamUnitTestPlugin::StartViewFinderBitmapsL(TSize& /*aSize*/,TRect& /*aClipRect*/)
243 Panic(EPanicUnimplemented);
247 void CCamUnitTestPlugin::StartViewFinderL(TFormat /*aImageFormat*/,TSize& /*aSize*/)
249 Panic(EPanicUnimplemented);
252 void CCamUnitTestPlugin::StartViewFinderL(TFormat /*aImageFormat*/,TSize& /*aSize*/,TRect& /*aClipRect*/)
254 Panic(EPanicUnimplemented);
258 void CCamUnitTestPlugin::StopViewFinder()
260 Panic(EPanicUnimplemented);
263 TBool CCamUnitTestPlugin::ViewFinderActive() const
265 Panic(EPanicUnimplemented);
269 void CCamUnitTestPlugin::SetViewFinderMirrorL(TBool /*aMirror*/)
271 Panic(EPanicUnimplemented);
274 TBool CCamUnitTestPlugin::ViewFinderMirror() const
276 Panic(EPanicUnimplemented);
280 void CCamUnitTestPlugin::PrepareImageCaptureL(TFormat /*aImageFormat*/,TInt /*aSizeIndex*/)
282 Panic(EPanicUnimplemented);
285 void CCamUnitTestPlugin::PrepareImageCaptureL(TFormat /*aImageFormat*/,TInt /*aSizeIndex*/,const TRect& /*aClipRect*/)
287 Panic(EPanicUnimplemented);
290 void CCamUnitTestPlugin::CaptureImage()
292 Panic(EPanicUnimplemented);
295 void CCamUnitTestPlugin::CancelCaptureImage()
297 Panic(EPanicUnimplemented);
300 void CCamUnitTestPlugin::EnumerateCaptureSizes(TSize& /*aSize*/,TInt /*aSizeIndex*/,TFormat /*aFormat*/) const
302 Panic(EPanicUnimplemented);
305 void CCamUnitTestPlugin::PrepareVideoCaptureL(TFormat /*aFormat*/,TInt /*aSizeIndex*/,TInt /*aRateIndex*/,TInt /*aBuffersToUse*/,TInt /*aFramesPerBuffer*/)
307 Panic(EPanicUnimplemented);
310 void CCamUnitTestPlugin::PrepareVideoCaptureL(TFormat /*aFormat*/,TInt /*aSizeIndex*/,TInt /*aRateIndex*/,TInt /*aBuffersToUse*/,TInt /*aFramesPerBuffer*/,const TRect& /*aClipRect*/)
312 Panic(EPanicUnimplemented);
315 void CCamUnitTestPlugin::StartVideoCapture()
317 Panic(EPanicUnimplemented);
320 void CCamUnitTestPlugin::StopVideoCapture()
322 Panic(EPanicUnimplemented);
325 TBool CCamUnitTestPlugin::VideoCaptureActive() const
327 Panic(EPanicUnimplemented);
331 void CCamUnitTestPlugin::EnumerateVideoFrameSizes(TSize& /*aSize*/,TInt /*aSizeIndex*/,TFormat /*aFormat*/) const
333 Panic(EPanicUnimplemented);
336 void CCamUnitTestPlugin::EnumerateVideoFrameRates(TReal32& /*aRate*/,TInt /*aRateIndex*/,TFormat /*aFormat*/,TInt /*aSizeIndex*/,TExposure /*aExposure = EExposureAuto*/) const
338 Panic(EPanicUnimplemented);
341 void CCamUnitTestPlugin::GetFrameSize(TSize& /*aSize*/) const
343 Panic(EPanicUnimplemented);
346 TReal32 CCamUnitTestPlugin::FrameRate() const
348 Panic(EPanicUnimplemented);
352 TInt CCamUnitTestPlugin::BuffersInUse() const
354 Panic(EPanicUnimplemented);
358 TInt CCamUnitTestPlugin::FramesPerBuffer() const
360 Panic(EPanicUnimplemented);
364 void CCamUnitTestPlugin::SetJpegQuality(TInt /*aQuality*/)
366 Panic(EPanicUnimplemented);
369 TInt CCamUnitTestPlugin::JpegQuality() const
371 Panic(EPanicUnimplemented);
375 TAny* CCamUnitTestPlugin::CustomInterface(TUid aInterfaceUid)
377 TAny* advSettingObject = NULL;
378 // use the fact that the parent is a friend of the class
380 TRAPD(err, advSettingObject = CCamera::CustomInterface(aInterfaceUid));
384 return advSettingObject;
386 /*else if (err == KErrNoMemory)
388 User::Leave(KErrNoMemory);
394 TAny* CCamera::CustomInterface(TUid aInterfaceUid)
396 switch (aInterfaceUid.iUid)
399 case KECamPresetsUidValue:
401 CCamera::CCameraPresets* presets = new (ELeave)CCamera::CCameraPresets(*this);
402 CleanupStack::PushL(presets);
403 presets->ConstructL();
404 CleanupStack::Pop(presets);
406 return static_cast<TAny*>(presets);
409 case KECamMCameraPresetsUidValue:
411 return static_cast<MCameraPresets*>(CCamPresets::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
414 case KECamMCameraPresets2UidValue:
416 return static_cast<MCameraPresets2*>(CCamPresets::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
420 case KECamImageProcessingUidValue:
422 CCamera::CCameraImageProcessing* processing = new (ELeave)CCamera::CCameraImageProcessing(*this);
423 CleanupStack::PushL(processing);
424 processing->ConstructL();
425 CleanupStack::Pop(processing);
427 return static_cast<TAny*>(processing);
430 case KECamMCameraImageProcessingUidValue:
432 return static_cast<MCameraImageProcessing*>(CCamImgProc::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
435 case KECamMCameraImageProcessing2UidValue:
437 return static_cast<MCameraImageProcessing2*>(CCamImgProc::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
440 case KECamMCameraImageProcessing3UidValue:
442 return static_cast<MCameraImageProcessing3*>(CCamImgProc::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
446 case KECamAdvancedSettingUidValue:
448 CCamera::CCameraAdvancedSettings* settings = new (ELeave)CCamera::CCameraAdvancedSettings(*this);
449 CleanupStack::PushL(settings);
450 settings->ConstructL();
451 CleanupStack::Pop(settings);
453 return static_cast<TAny*>(settings);
456 case KECamMCameraAdvancedSettingsUidValue:
458 return static_cast<MCameraAdvancedSettings*>(CCamAdvSet::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
461 case KECamMCameraAdvancedSettings2UidValue:
463 return static_cast<MCameraAdvancedSettings2*>(CCamAdvSet::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
466 case KECamMCameraAdvancedSettings3UidValue:
468 return static_cast<MCameraAdvancedSettings3*>(CCamAdvSet::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
471 case KECamMCameraAdvancedSettings4UidValue:
473 return static_cast<MCameraAdvancedSettings4*>(CCamAdvSet::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
476 case KUidCameraManagementUidValue:
478 return (CCamManagement::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
482 // enhance camera functionality //
484 case KECamHistogramUidValue:
486 return static_cast<TAny*>(CCamera::CCameraHistogram::NewL(*this));
489 case KECamMCameraHistogramUidValue:
491 return static_cast<MCameraHistogram*>(CCamHistogram::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
494 case KECamOverlayUidValue:
496 return static_cast<TAny*>(CCamera::CCameraOverlay::NewL(*this));
499 case KECamMCameraOverlayUidValue:
501 return static_cast<MCameraOverlay*>(CCamOverlay::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
504 case KECamMCameraOverlay2UidValue:
506 return static_cast<MCameraOverlay2*>(CCamOverlay::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
509 case KECamSnapshotUidValue:
511 return static_cast<TAny*>(CCamera::CCameraSnapshot::NewL(*this));
514 case KECamMCameraSnapshotUidValue:
516 return static_cast<MCameraSnapshot*>(CCamSnapshot::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
520 // direct viewfinder functionality //
522 case KECamDirectViewFinderUidValue:
524 return static_cast<TAny*>(CCamera::CCameraDirectViewFinder::NewL(*this));
527 case KECamMCameraDirectViewFinderUidValue:
529 return static_cast<MCameraDirectViewFinder*>(CCamDirectViewFinder::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
532 case KECamMCameraPreImageCaptureControlUidValue:
534 return static_cast<MCameraPreImageCaptureControl*>(CCamPreImageCaptureControl::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
537 case KECamMCameraImageCaptureUidValue:
539 return static_cast<MCameraImageCapture*>(CCamImageCapture::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
542 case KECamMCameraVideoCaptureControlUidValue:
544 return static_cast<MCameraVideoCaptureControl*>(CCamVideoCaptureControl::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
547 case KECamMCameraClientViewFinderUidValue:
549 return static_cast<MCameraClientViewFinder*>(CCamClientViewFinder::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
552 case KECamMCameraBaseClientViewFinderUidValue:
554 return static_cast<MCameraViewFinder*>(CCamClientViewFinder::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
557 case KECamMCameraV2DirectViewFinderUidValue:
559 return static_cast<MCameraV2DirectViewFinder*>(CCamV2DirectViewFinder::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
562 case KECamMCameraBaseV2DirectViewFinderUidValue:
564 return static_cast<MCameraViewFinder*>(CCamV2DirectViewFinder::NewL(static_cast<CCamUnitTestPlugin&>(*this)));
573 void CCamUnitTestPlugin::GenerateVFHandle(TInt& aVFHandle)
575 iVFHandleGenerater++;
576 aVFHandle = iVFHandleGenerater;
579 void CCamUnitTestPlugin::Notify(TUid aMessageId, TInt aError)
581 if (iObserver2 != NULL)
583 iObserver2->HandleEvent(TECAMEvent(aMessageId, aError));
587 void CCamUnitTestPlugin::Notify2(TUid aMessageId, TInt aError, TInt aParam)
589 if (iObserver2 != NULL)
591 iObserver2->HandleEvent(TECAMEvent2(aMessageId, aError, aParam));
596 // CCamUnitTestPluginInfo
599 CCamUnitTestPluginInfo::CCamUnitTestPluginInfo()
603 CCamUnitTestPluginInfo::~CCamUnitTestPluginInfo()
607 CCamUnitTestPluginInfo* CCamUnitTestPluginInfo::NewL()
609 FileDependencyUtil::CheckFileDependencyL();
610 return new (ELeave) CCamUnitTestPluginInfo;
613 TInt CCamUnitTestPluginInfo::CamerasAvailable()
615 return KECamSetAvailableCameras;
619 // CCamUnitTestPluginSecureId
622 CCamUnitTestPluginSecureId::CCamUnitTestPluginSecureId()
626 CCamUnitTestPluginSecureId::~CCamUnitTestPluginSecureId()
630 CCamUnitTestPluginSecureId* CCamUnitTestPluginSecureId::NewL()
632 CCamUnitTestPluginSecureId* pluginSecureId = new (ELeave) CCamUnitTestPluginSecureId;
633 return pluginSecureId;
636 void CCamUnitTestPluginSecureId::Release()
641 void CCamUnitTestPluginSecureId::GetSecureIdL(TInt& aSecureId) const
643 TSecureId secureId = User::CreatorSecureId();
644 aSecureId = secureId.iId;
647 void FileDependencyUtil::CheckFileDependencyL()
652 User::LeaveIfError(fsSession.Connect());
653 CleanupClosePushL(fsSession);
654 TInt err = file.Open(fsSession, KECamUnitTestPluginName, EFileRead);
659 User::LeaveIfError(KErrNotSupported);
661 CleanupStack::PopAndDestroy(); //fsSession
665 // __________________________________________________________________________
666 // Exported proxy for instantiation method resolution
667 // Define the interface UIDs
668 const TImplementationProxy ImplementationTable[] =
670 IMPLEMENTATION_PROXY_ENTRY(KUidCameraUnitTestPlugin, CCamUnitTestPlugin::NewL),
671 IMPLEMENTATION_PROXY_ENTRY(KUidCameraUnitTestInfo, CCamUnitTestPluginInfo::NewL),
672 IMPLEMENTATION_PROXY_ENTRY(KUidCameraUnitTestSecureId, CCamUnitTestPluginSecureId::NewL)
675 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
677 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
679 return ImplementationTable;