1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmplugins/cameraplugins/source/testcamera/TestCamera.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,318 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __TESTCAMERA_H__
1.20 +#define __TESTCAMERA_H__
1.21 +
1.22 +
1.23 +#include <ecam/ecamplugin.h>
1.24 +#include <ecam/ecaminfoplugin.h>
1.25 +#include <bitdev.h>
1.26 +#include <ecam.h>
1.27 +#include <w32std.h>
1.28 +#include <ecamadvsettings.h>
1.29 +
1.30 +_LIT(KTestCameraPluginName, "C:\\102070cc.txt");
1.31 +
1.32 +const TInt KMinTestCameraZoom = -3;
1.33 +const TInt KMaxTestCameraZoom = 3;
1.34 +const TReal32 KMaxTestCameraDigitalZoomFactor = 1.0;
1.35 +const TInt KMaxTestCameraDigitalZoom = 0;
1.36 +const TInt KFramePosIncrement = 5;
1.37 +const TInt KFrameFeatureSize = 25;
1.38 +const TInt KFrameFeatureBorderThickness = 5;
1.39 +const enum CCamera::TFormat KInitialViewFinderFormat = CCamera::EFormatFbsBitmapColor16M;
1.40 +const TDisplayMode KViewFinderDisplayMode = EColor4K;
1.41 +
1.42 +class CTestCamAdvSet;
1.43 +class CTestCamPresets;
1.44 +class CTestCamSnapshot;
1.45 +class CTestCamImgProc;
1.46 +
1.47 +class RTestCameraFrameBuffer : public MCameraBuffer
1.48 + {
1.49 +public:
1.50 + RTestCameraFrameBuffer(CFbsBitmap*& aFrame): iAvailable(ETrue), iFrame(aFrame) {}
1.51 + virtual TInt NumFrames() {return 0;}
1.52 + virtual TDesC8* DataL(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return NULL; }
1.53 + virtual CFbsBitmap& BitmapL(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return *iFrame;}
1.54 + virtual RChunk& ChunkL() { return iChunk;}
1.55 + virtual TInt ChunkOffsetL(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return 0;}
1.56 + virtual TInt FrameSize(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return 0; }
1.57 + virtual void Release() {iAvailable = ETrue;}
1.58 +public:
1.59 + volatile TBool iAvailable;
1.60 + CFbsBitmap*& iFrame;
1.61 + RChunk iChunk;
1.62 + };
1.63 +
1.64 +class RTestFrameBuffer : public MFrameBuffer
1.65 + {
1.66 +public:
1.67 + RTestFrameBuffer(CFbsBitmap*& aFrame): iAvailable(ETrue), iFrame(aFrame) {}
1.68 + virtual TDesC8* DataL(TInt /*aIndex*/) { User::Leave(KErrNotSupported); return NULL; }
1.69 + virtual CFbsBitmap* FrameL(TInt aIndex) { if (aIndex != 0) User::Leave(KErrNotSupported); return iFrame; }
1.70 + virtual void Release() { iAvailable = ETrue; }
1.71 +public:
1.72 + TBool iAvailable;
1.73 + CFbsBitmap*& iFrame;
1.74 + };
1.75 +
1.76 +class CDirectScreenAccess;
1.77 +
1.78 +class CTestCamera : public CCameraPlugin, public MDirectScreenAccess
1.79 + {
1.80 + friend class CTestCamAdvSet;
1.81 + friend class CTestCamPresets;
1.82 + friend class CTestCamSnapshot;
1.83 + friend class CTestCamImgProc;
1.84 +
1.85 +public:
1.86 + static CTestCamera* NewL();
1.87 + ~CTestCamera();
1.88 + void ConstructL();
1.89 + // from CCameraPlugin
1.90 + void Construct2L(MCameraObserver& aObserver,TInt aCameraIndex);
1.91 + void Construct2DupL(MCameraObserver& aObserver,TInt aCameraHandle);
1.92 + void Construct2L(MCameraObserver2& aObserver,TInt aCameraIndex,TInt aPriority);
1.93 + void Construct2DupL(MCameraObserver2& aObserver,TInt aCameraHandle);
1.94 +private:
1.95 + // From CCamera
1.96 + virtual void CameraInfo(TCameraInfo& aInfo) const;
1.97 + virtual void Reserve();
1.98 + virtual void Release();
1.99 + virtual void PowerOn();
1.100 + virtual void PowerOff();
1.101 + virtual TInt Handle();
1.102 +
1.103 + virtual void SetZoomFactorL(TInt aZoomFactor = 0);
1.104 + virtual TInt ZoomFactor() const;
1.105 + virtual void SetDigitalZoomFactorL(TInt aDigitalZoomFactor = 0);
1.106 + virtual TInt DigitalZoomFactor() const;
1.107 +
1.108 + virtual void SetContrastL(TInt aContrast);
1.109 + virtual TInt Contrast() const;
1.110 + virtual void SetBrightnessL(TInt aBrightness);
1.111 + virtual TInt Brightness() const;
1.112 + virtual void SetFlashL(TFlash aFlash = EFlashNone);
1.113 + virtual TFlash Flash() const;
1.114 + virtual void SetExposureL(TExposure aExposure = EExposureAuto);
1.115 + virtual TExposure Exposure() const;
1.116 + virtual void SetWhiteBalanceL(TWhiteBalance aWhiteBalance = EWBAuto);
1.117 + virtual TWhiteBalance WhiteBalance() const;
1.118 +
1.119 + virtual void StartViewFinderDirectL(RWsSession& aWs,CWsScreenDevice& aScreenDevice,RWindowBase& aWindow,TRect& aScreenRect);
1.120 + virtual void StartViewFinderDirectL(RWsSession& aWs,CWsScreenDevice& aScreenDevice,RWindowBase& aWindow,TRect& aScreenRect,TRect& aClipRect);
1.121 + virtual void StartViewFinderBitmapsL(TSize& aSize);
1.122 + virtual void StartViewFinderBitmapsL(TSize& aSize,TRect& aClipRect);
1.123 + virtual void StartViewFinderL(TFormat aImageFormat,TSize& aSize);
1.124 + virtual void StartViewFinderL(TFormat aImageFormat,TSize& aSize,TRect& aClipRect);
1.125 + virtual void StopViewFinder();
1.126 + virtual TBool ViewFinderActive() const;
1.127 + virtual void SetViewFinderMirrorL(TBool aMirror);
1.128 + virtual TBool ViewFinderMirror() const;
1.129 +
1.130 + virtual void PrepareImageCaptureL(TFormat aImageFormat,TInt aSizeIndex);
1.131 + virtual void PrepareImageCaptureL(TFormat aImageFormat,TInt aSizeIndex,const TRect& aClipRect);
1.132 + virtual void CaptureImage();
1.133 + virtual void CancelCaptureImage();
1.134 + virtual void EnumerateCaptureSizes(TSize& aSize,TInt aSizeIndex,TFormat aFormat) const;
1.135 +
1.136 + virtual void PrepareVideoCaptureL(TFormat aFormat,TInt aSizeIndex,TInt aRateIndex,TInt aBuffersToUse,TInt aFramesPerBuffer);
1.137 + virtual void PrepareVideoCaptureL(TFormat aFormat,TInt aSizeIndex,TInt aRateIndex,TInt aBuffersToUse,TInt aFramesPerBuffer,const TRect& aClipRect);
1.138 + virtual void StartVideoCapture();
1.139 + virtual void StopVideoCapture();
1.140 +
1.141 + virtual TBool VideoCaptureActive() const;
1.142 + virtual void EnumerateVideoFrameSizes(TSize& aSize,TInt aSizeIndex,TFormat aFormat) const;
1.143 + virtual void EnumerateVideoFrameRates(TReal32& aRate,TInt aRateIndex,TFormat aFormat,TInt aSizeIndex,TExposure aExposure = EExposureAuto) const;
1.144 + virtual void GetFrameSize(TSize& aSize) const;
1.145 + virtual TReal32 FrameRate() const;
1.146 + virtual TInt BuffersInUse() const;
1.147 + virtual TInt FramesPerBuffer() const;
1.148 +
1.149 + virtual void SetJpegQuality(TInt aQuality);
1.150 + virtual TInt JpegQuality() const;
1.151 +
1.152 + virtual TAny* CustomInterface(TUid aInterface);
1.153 +
1.154 + // From MAbortDirectScreenAccess
1.155 + virtual void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
1.156 +
1.157 + // From MDirectScreenAccess
1.158 + virtual void Restart(RDirectScreenAccess::TTerminationReasons aReason);
1.159 +
1.160 + // New functions
1.161 + static TInt TimerCallBack(TAny* aThis);
1.162 + void FrameReady();
1.163 + void GetFrame(CFbsBitGc& aGc, TPoint& aPos) const;
1.164 + void GetImgProcessedFrame(CFbsBitGc& aGc, TPoint& aPos) const;
1.165 + void ServiceVideo(TInt aBuferNum);
1.166 + void ServiceViewFinder(CFbsBitmap* aSourceFrame);
1.167 + void ServiceImageCapture(const CFbsBitGc& aSourceBitmapGc);
1.168 + void ServiceBurstImageCapture(const CFbsBitGc& aSourceBitmapGc);
1.169 + void DoCaptureImageL();
1.170 + void CheckReserveAndPowerL();
1.171 + TInt CheckReserveAndPower() const;
1.172 + void CustomInterfaceL(TAny*& aIface, TUid aInterface);
1.173 + static TInt ReserveCallBack(TAny* aThis);
1.174 + static TInt PowerOnCallBack(TAny* aThis);
1.175 + static TInt ImageCaptureCallBack(TAny* aThis);
1.176 + static TInt VideoCaptureCallBack(TAny* aThis);
1.177 + static TInt HandleEventCallBack(TAny* aThis);
1.178 + static TInt HandleEvent2CallBack(TAny* aThis);
1.179 +
1.180 +private:
1.181 + CTestCamera();
1.182 +private:
1.183 + MCameraObserver* iObserver; // not owned
1.184 + MCameraObserver2* iObserver2; // not owned
1.185 + TBool iReserved;
1.186 + TBool iPowerOn;
1.187 +
1.188 + TCameraInfo iInfo;
1.189 + CPeriodic* iTimer;
1.190 + TTimeIntervalMicroSeconds32 iFrameDelay;
1.191 + TInt iFrameIndex;
1.192 + TTimeIntervalMicroSeconds iElapsedTime;
1.193 + TPoint iStillImagePos;
1.194 + TPoint iVideoFramePos;
1.195 +
1.196 + TReal32 iVideoFrameRate;
1.197 + TInt iBuffersInUse;
1.198 + TSize iVideoFrameSize;
1.199 + TFormat iVideoFrameFormat;
1.200 +
1.201 + CFbsBitmap* iVideoFrame1;
1.202 + CFbsBitmapDevice* iVideoFrameDev1;
1.203 + CFbsBitGc* iVideoFrameGc1;
1.204 + CFbsBitmap* iVideoFrame2;
1.205 + CFbsBitmapDevice* iVideoFrameDev2;
1.206 + CFbsBitGc* iVideoFrameGc2;
1.207 +
1.208 + TInt iStillCaptureErr;
1.209 + TSize iStillImageSize;
1.210 + TFormat iStillImageFormat;
1.211 + CFbsBitmap* iStillImage;
1.212 + CFbsBitmapDevice* iStillImageDev;
1.213 + CFbsBitGc* iStillImageGc;
1.214 +
1.215 + TSize iViewFinderSize;
1.216 + TFormat iViewFinderFormat;
1.217 + CFbsBitmap* iViewFinderBitmap;
1.218 + CFbsBitmapDevice* iViewFinderBitmapDev;
1.219 + CFbsBitGc* iViewFinderBitmapGc;
1.220 +
1.221 + CDirectScreenAccess* iDSA;
1.222 + CFbsScreenDevice* iScreenDev;
1.223 + CFbsBitGc* iScreenGc;
1.224 + TRect iScreenRect;
1.225 + TRect iClipRect;
1.226 +
1.227 + CFbsBitmap* iImage;
1.228 + CFbsBitmapDevice* iDev;
1.229 + CFbsBitGc* iGc;
1.230 +
1.231 + CAsyncCallBack iReserveAsync;
1.232 + CAsyncCallBack iPowerOnAsync;
1.233 + CAsyncCallBack iImageCaptureAsync;
1.234 + CAsyncCallBack iVideoCaptureAsync;
1.235 + CAsyncCallBack iHandleEventAsync;
1.236 + CAsyncCallBack iHandleEvent2Async;
1.237 +
1.238 + RTestFrameBuffer iFrameBuffer1;
1.239 + RTestFrameBuffer iFrameBuffer2;
1.240 +
1.241 + RTestCameraFrameBuffer iFrameCameraBuffer1;
1.242 + RTestCameraFrameBuffer iFrameCameraBuffer2;
1.243 +
1.244 + TInt iVideoCaptureErr;
1.245 + // Members to store the current optical or digital value set with SetZoomFactorL() and SetDigitalZoomFactorL()
1.246 + // Although arguments have trailing Factor in fact they must contain values in the ranges specified by
1.247 + // iInfo.iMinZoom : iInfo.iMaxZoom for optical zoom and
1.248 + // 0 : iInfo.iMaxDigitalZoom for digital zoom
1.249 + // The factor values cannot be modified using Camera API as it is assumed
1.250 + // that they are determined by the camera hardware.
1.251 + TInt iZoom;
1.252 + TInt iDigitalZoom;
1.253 +
1.254 + TInt iContrast;
1.255 + TInt iBrightness;
1.256 +
1.257 + TInt iImgProcBrightness;
1.258 + TInt iImgProcContrast;
1.259 +
1.260 + volatile TBool iViewFinderActive;
1.261 + volatile TBool iVideoCaptureActive;
1.262 + volatile TBool iImageCaptureActive;
1.263 + volatile TBool iVideoPreparedLast;
1.264 + volatile TBool iVideoCapturePrepared;
1.265 + volatile TBool iImageCapturePrepared;
1.266 +
1.267 + RArray<TSize> iImageSizes;
1.268 + RArray<TSize> iVideoFrameSizes;
1.269 + RArray<TReal32> iVideoFrameRates;
1.270 + TInt iCameraIndex;
1.271 + TInt iCameraHandle;
1.272 + TInt iPriority;
1.273 +
1.274 + TECAMEvent iECamEvent;
1.275 + TECAMEvent2 iECamEvent2;
1.276 + TInt iEventError;
1.277 +
1.278 + CTestCamAdvSet* iAdvSettingsImpl;
1.279 + CTestCamSnapshot* iSnapshotImpl;
1.280 + CTestCamImgProc* iImgProcImpl;
1.281 +
1.282 + CCamera::CCameraAdvancedSettings::TDriveMode iDriveMode;
1.283 + TInt iBurstImages;
1.284 + };
1.285 +
1.286 +class CTestCameraInfo : public CCameraInfoPlugin
1.287 + {
1.288 +public:
1.289 + static CTestCameraInfo* NewL();
1.290 + ~CTestCameraInfo();
1.291 + // from CCameraInfoPlugin
1.292 + TInt CamerasAvailable();
1.293 +private:
1.294 + CTestCameraInfo();
1.295 + };
1.296 +
1.297 +enum TStubPanicReasons
1.298 + {
1.299 + EPanicUnimplemented=1
1.300 + };
1.301 +
1.302 +class FileDependencyUtil
1.303 + {
1.304 +public:
1.305 + static void CheckFileDependencyL();
1.306 + };
1.307 +
1.308 +class CDataGlobal : public CBase
1.309 + {
1.310 +public:
1.311 + CTestCamAdvSet* iTestCamAdvSet;
1.312 + CTestCamPresets* iTestCamPresets;
1.313 + CTestCamSnapshot* iTestCamSnapshot;
1.314 + CTestCamImgProc* iTestCamImgProc;
1.315 + TInt iAdvSetReferenceCount;
1.316 + TInt iPresetsReferenceCount;
1.317 + TInt iSnapshotReferenceCount;
1.318 + TInt iImgProcReferenceCount;
1.319 + };
1.320 +
1.321 +#endif