Update contrib.
1 // Copyright (c) 2002-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.
16 #ifndef __TESTCAMERA_H__
17 #define __TESTCAMERA_H__
20 #include <ecam/ecamplugin.h>
21 #include <ecam/ecaminfoplugin.h>
25 #include <ecamadvsettings.h>
27 _LIT(KTestCameraPluginName, "C:\\102070cc.txt");
29 const TInt KMinTestCameraZoom = -3;
30 const TInt KMaxTestCameraZoom = 3;
31 const TReal32 KMaxTestCameraDigitalZoomFactor = 1.0;
32 const TInt KMaxTestCameraDigitalZoom = 0;
33 const TInt KFramePosIncrement = 5;
34 const TInt KFrameFeatureSize = 25;
35 const TInt KFrameFeatureBorderThickness = 5;
36 const enum CCamera::TFormat KInitialViewFinderFormat = CCamera::EFormatFbsBitmapColor16M;
37 const TDisplayMode KViewFinderDisplayMode = EColor4K;
40 class CTestCamPresets;
41 class CTestCamSnapshot;
42 class CTestCamImgProc;
44 class RTestCameraFrameBuffer : public MCameraBuffer
47 RTestCameraFrameBuffer(CFbsBitmap*& aFrame): iAvailable(ETrue), iFrame(aFrame) {}
48 virtual TInt NumFrames() {return 0;}
49 virtual TDesC8* DataL(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return NULL; }
50 virtual CFbsBitmap& BitmapL(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return *iFrame;}
51 virtual RChunk& ChunkL() { return iChunk;}
52 virtual TInt ChunkOffsetL(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return 0;}
53 virtual TInt FrameSize(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return 0; }
54 virtual void Release() {iAvailable = ETrue;}
56 volatile TBool iAvailable;
61 class RTestFrameBuffer : public MFrameBuffer
64 RTestFrameBuffer(CFbsBitmap*& aFrame): iAvailable(ETrue), iFrame(aFrame) {}
65 virtual TDesC8* DataL(TInt /*aIndex*/) { User::Leave(KErrNotSupported); return NULL; }
66 virtual CFbsBitmap* FrameL(TInt aIndex) { if (aIndex != 0) User::Leave(KErrNotSupported); return iFrame; }
67 virtual void Release() { iAvailable = ETrue; }
73 class CDirectScreenAccess;
75 class CTestCamera : public CCameraPlugin, public MDirectScreenAccess
77 friend class CTestCamAdvSet;
78 friend class CTestCamPresets;
79 friend class CTestCamSnapshot;
80 friend class CTestCamImgProc;
83 static CTestCamera* NewL();
87 void Construct2L(MCameraObserver& aObserver,TInt aCameraIndex);
88 void Construct2DupL(MCameraObserver& aObserver,TInt aCameraHandle);
89 void Construct2L(MCameraObserver2& aObserver,TInt aCameraIndex,TInt aPriority);
90 void Construct2DupL(MCameraObserver2& aObserver,TInt aCameraHandle);
93 virtual void CameraInfo(TCameraInfo& aInfo) const;
94 virtual void Reserve();
95 virtual void Release();
96 virtual void PowerOn();
97 virtual void PowerOff();
98 virtual TInt Handle();
100 virtual void SetZoomFactorL(TInt aZoomFactor = 0);
101 virtual TInt ZoomFactor() const;
102 virtual void SetDigitalZoomFactorL(TInt aDigitalZoomFactor = 0);
103 virtual TInt DigitalZoomFactor() const;
105 virtual void SetContrastL(TInt aContrast);
106 virtual TInt Contrast() const;
107 virtual void SetBrightnessL(TInt aBrightness);
108 virtual TInt Brightness() const;
109 virtual void SetFlashL(TFlash aFlash = EFlashNone);
110 virtual TFlash Flash() const;
111 virtual void SetExposureL(TExposure aExposure = EExposureAuto);
112 virtual TExposure Exposure() const;
113 virtual void SetWhiteBalanceL(TWhiteBalance aWhiteBalance = EWBAuto);
114 virtual TWhiteBalance WhiteBalance() const;
116 virtual void StartViewFinderDirectL(RWsSession& aWs,CWsScreenDevice& aScreenDevice,RWindowBase& aWindow,TRect& aScreenRect);
117 virtual void StartViewFinderDirectL(RWsSession& aWs,CWsScreenDevice& aScreenDevice,RWindowBase& aWindow,TRect& aScreenRect,TRect& aClipRect);
118 virtual void StartViewFinderBitmapsL(TSize& aSize);
119 virtual void StartViewFinderBitmapsL(TSize& aSize,TRect& aClipRect);
120 virtual void StartViewFinderL(TFormat aImageFormat,TSize& aSize);
121 virtual void StartViewFinderL(TFormat aImageFormat,TSize& aSize,TRect& aClipRect);
122 virtual void StopViewFinder();
123 virtual TBool ViewFinderActive() const;
124 virtual void SetViewFinderMirrorL(TBool aMirror);
125 virtual TBool ViewFinderMirror() const;
127 virtual void PrepareImageCaptureL(TFormat aImageFormat,TInt aSizeIndex);
128 virtual void PrepareImageCaptureL(TFormat aImageFormat,TInt aSizeIndex,const TRect& aClipRect);
129 virtual void CaptureImage();
130 virtual void CancelCaptureImage();
131 virtual void EnumerateCaptureSizes(TSize& aSize,TInt aSizeIndex,TFormat aFormat) const;
133 virtual void PrepareVideoCaptureL(TFormat aFormat,TInt aSizeIndex,TInt aRateIndex,TInt aBuffersToUse,TInt aFramesPerBuffer);
134 virtual void PrepareVideoCaptureL(TFormat aFormat,TInt aSizeIndex,TInt aRateIndex,TInt aBuffersToUse,TInt aFramesPerBuffer,const TRect& aClipRect);
135 virtual void StartVideoCapture();
136 virtual void StopVideoCapture();
138 virtual TBool VideoCaptureActive() const;
139 virtual void EnumerateVideoFrameSizes(TSize& aSize,TInt aSizeIndex,TFormat aFormat) const;
140 virtual void EnumerateVideoFrameRates(TReal32& aRate,TInt aRateIndex,TFormat aFormat,TInt aSizeIndex,TExposure aExposure = EExposureAuto) const;
141 virtual void GetFrameSize(TSize& aSize) const;
142 virtual TReal32 FrameRate() const;
143 virtual TInt BuffersInUse() const;
144 virtual TInt FramesPerBuffer() const;
146 virtual void SetJpegQuality(TInt aQuality);
147 virtual TInt JpegQuality() const;
149 virtual TAny* CustomInterface(TUid aInterface);
151 // From MAbortDirectScreenAccess
152 virtual void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
154 // From MDirectScreenAccess
155 virtual void Restart(RDirectScreenAccess::TTerminationReasons aReason);
158 static TInt TimerCallBack(TAny* aThis);
160 void GetFrame(CFbsBitGc& aGc, TPoint& aPos) const;
161 void GetImgProcessedFrame(CFbsBitGc& aGc, TPoint& aPos) const;
162 void ServiceVideo(TInt aBuferNum);
163 void ServiceViewFinder(CFbsBitmap* aSourceFrame);
164 void ServiceImageCapture(const CFbsBitGc& aSourceBitmapGc);
165 void ServiceBurstImageCapture(const CFbsBitGc& aSourceBitmapGc);
166 void DoCaptureImageL();
167 void CheckReserveAndPowerL();
168 TInt CheckReserveAndPower() const;
169 void CustomInterfaceL(TAny*& aIface, TUid aInterface);
170 static TInt ReserveCallBack(TAny* aThis);
171 static TInt PowerOnCallBack(TAny* aThis);
172 static TInt ImageCaptureCallBack(TAny* aThis);
173 static TInt VideoCaptureCallBack(TAny* aThis);
174 static TInt HandleEventCallBack(TAny* aThis);
175 static TInt HandleEvent2CallBack(TAny* aThis);
180 MCameraObserver* iObserver; // not owned
181 MCameraObserver2* iObserver2; // not owned
187 TTimeIntervalMicroSeconds32 iFrameDelay;
189 TTimeIntervalMicroSeconds iElapsedTime;
190 TPoint iStillImagePos;
191 TPoint iVideoFramePos;
193 TReal32 iVideoFrameRate;
195 TSize iVideoFrameSize;
196 TFormat iVideoFrameFormat;
198 CFbsBitmap* iVideoFrame1;
199 CFbsBitmapDevice* iVideoFrameDev1;
200 CFbsBitGc* iVideoFrameGc1;
201 CFbsBitmap* iVideoFrame2;
202 CFbsBitmapDevice* iVideoFrameDev2;
203 CFbsBitGc* iVideoFrameGc2;
205 TInt iStillCaptureErr;
206 TSize iStillImageSize;
207 TFormat iStillImageFormat;
208 CFbsBitmap* iStillImage;
209 CFbsBitmapDevice* iStillImageDev;
210 CFbsBitGc* iStillImageGc;
212 TSize iViewFinderSize;
213 TFormat iViewFinderFormat;
214 CFbsBitmap* iViewFinderBitmap;
215 CFbsBitmapDevice* iViewFinderBitmapDev;
216 CFbsBitGc* iViewFinderBitmapGc;
218 CDirectScreenAccess* iDSA;
219 CFbsScreenDevice* iScreenDev;
220 CFbsBitGc* iScreenGc;
225 CFbsBitmapDevice* iDev;
228 CAsyncCallBack iReserveAsync;
229 CAsyncCallBack iPowerOnAsync;
230 CAsyncCallBack iImageCaptureAsync;
231 CAsyncCallBack iVideoCaptureAsync;
232 CAsyncCallBack iHandleEventAsync;
233 CAsyncCallBack iHandleEvent2Async;
235 RTestFrameBuffer iFrameBuffer1;
236 RTestFrameBuffer iFrameBuffer2;
238 RTestCameraFrameBuffer iFrameCameraBuffer1;
239 RTestCameraFrameBuffer iFrameCameraBuffer2;
241 TInt iVideoCaptureErr;
242 // Members to store the current optical or digital value set with SetZoomFactorL() and SetDigitalZoomFactorL()
243 // Although arguments have trailing Factor in fact they must contain values in the ranges specified by
244 // iInfo.iMinZoom : iInfo.iMaxZoom for optical zoom and
245 // 0 : iInfo.iMaxDigitalZoom for digital zoom
246 // The factor values cannot be modified using Camera API as it is assumed
247 // that they are determined by the camera hardware.
254 TInt iImgProcBrightness;
255 TInt iImgProcContrast;
257 volatile TBool iViewFinderActive;
258 volatile TBool iVideoCaptureActive;
259 volatile TBool iImageCaptureActive;
260 volatile TBool iVideoPreparedLast;
261 volatile TBool iVideoCapturePrepared;
262 volatile TBool iImageCapturePrepared;
264 RArray<TSize> iImageSizes;
265 RArray<TSize> iVideoFrameSizes;
266 RArray<TReal32> iVideoFrameRates;
271 TECAMEvent iECamEvent;
272 TECAMEvent2 iECamEvent2;
275 CTestCamAdvSet* iAdvSettingsImpl;
276 CTestCamSnapshot* iSnapshotImpl;
277 CTestCamImgProc* iImgProcImpl;
279 CCamera::CCameraAdvancedSettings::TDriveMode iDriveMode;
283 class CTestCameraInfo : public CCameraInfoPlugin
286 static CTestCameraInfo* NewL();
288 // from CCameraInfoPlugin
289 TInt CamerasAvailable();
294 enum TStubPanicReasons
296 EPanicUnimplemented=1
299 class FileDependencyUtil
302 static void CheckFileDependencyL();
305 class CDataGlobal : public CBase
308 CTestCamAdvSet* iTestCamAdvSet;
309 CTestCamPresets* iTestCamPresets;
310 CTestCamSnapshot* iTestCamSnapshot;
311 CTestCamImgProc* iTestCamImgProc;
312 TInt iAdvSetReferenceCount;
313 TInt iPresetsReferenceCount;
314 TInt iSnapshotReferenceCount;
315 TInt iImgProcReferenceCount;