os/mm/mmplugins/cameraplugins/source/testcamera/TestCamera.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef __TESTCAMERA_H__
sl@0
    17
#define __TESTCAMERA_H__
sl@0
    18
sl@0
    19
sl@0
    20
#include <ecam/ecamplugin.h>
sl@0
    21
#include <ecam/ecaminfoplugin.h>
sl@0
    22
#include <bitdev.h>
sl@0
    23
#include <ecam.h>
sl@0
    24
#include <w32std.h>
sl@0
    25
#include <ecamadvsettings.h>
sl@0
    26
sl@0
    27
_LIT(KTestCameraPluginName, "C:\\102070cc.txt");
sl@0
    28
sl@0
    29
const TInt KMinTestCameraZoom = -3;
sl@0
    30
const TInt KMaxTestCameraZoom = 3;
sl@0
    31
const TReal32 KMaxTestCameraDigitalZoomFactor = 1.0;
sl@0
    32
const TInt KMaxTestCameraDigitalZoom = 0;
sl@0
    33
const TInt KFramePosIncrement = 5;
sl@0
    34
const TInt KFrameFeatureSize = 25;
sl@0
    35
const TInt KFrameFeatureBorderThickness = 5;
sl@0
    36
const enum CCamera::TFormat KInitialViewFinderFormat = CCamera::EFormatFbsBitmapColor16M;
sl@0
    37
const TDisplayMode KViewFinderDisplayMode = EColor4K;
sl@0
    38
sl@0
    39
class CTestCamAdvSet;
sl@0
    40
class CTestCamPresets;
sl@0
    41
class CTestCamSnapshot;
sl@0
    42
class CTestCamImgProc;
sl@0
    43
sl@0
    44
class RTestCameraFrameBuffer : public MCameraBuffer
sl@0
    45
	{
sl@0
    46
public:
sl@0
    47
	RTestCameraFrameBuffer(CFbsBitmap*& aFrame): iAvailable(ETrue), iFrame(aFrame) {}
sl@0
    48
	virtual TInt NumFrames() {return 0;}
sl@0
    49
	virtual TDesC8* DataL(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return NULL; }
sl@0
    50
	virtual CFbsBitmap& BitmapL(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return *iFrame;}
sl@0
    51
 	virtual	RChunk& ChunkL() { return iChunk;}
sl@0
    52
	virtual TInt ChunkOffsetL(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return 0;}
sl@0
    53
	virtual TInt FrameSize(TInt aFrameIndex) {if (aFrameIndex != 0) { User::Leave(KErrArgument); } return 0; }
sl@0
    54
	virtual void Release() {iAvailable = ETrue;}
sl@0
    55
public:	
sl@0
    56
	volatile TBool iAvailable;
sl@0
    57
	CFbsBitmap*& iFrame;
sl@0
    58
	RChunk iChunk;
sl@0
    59
	};
sl@0
    60
sl@0
    61
class RTestFrameBuffer : public MFrameBuffer
sl@0
    62
	{
sl@0
    63
public:
sl@0
    64
	RTestFrameBuffer(CFbsBitmap*& aFrame): iAvailable(ETrue), iFrame(aFrame) {}
sl@0
    65
	virtual TDesC8* DataL(TInt /*aIndex*/) { User::Leave(KErrNotSupported); return NULL; }
sl@0
    66
	virtual CFbsBitmap* FrameL(TInt aIndex) { if (aIndex != 0) User::Leave(KErrNotSupported); return iFrame; }
sl@0
    67
	virtual void Release() { iAvailable = ETrue; }
sl@0
    68
public:
sl@0
    69
	TBool iAvailable;
sl@0
    70
	CFbsBitmap*& iFrame;
sl@0
    71
	};
sl@0
    72
sl@0
    73
class CDirectScreenAccess;
sl@0
    74
sl@0
    75
class CTestCamera : public CCameraPlugin, public MDirectScreenAccess
sl@0
    76
	{
sl@0
    77
	friend class CTestCamAdvSet;
sl@0
    78
	friend class CTestCamPresets;
sl@0
    79
	friend class CTestCamSnapshot;
sl@0
    80
	friend class CTestCamImgProc;
sl@0
    81
	
sl@0
    82
public:
sl@0
    83
	static CTestCamera* NewL();
sl@0
    84
	~CTestCamera();
sl@0
    85
	void ConstructL();
sl@0
    86
	// from CCameraPlugin
sl@0
    87
	void Construct2L(MCameraObserver& aObserver,TInt aCameraIndex);
sl@0
    88
	void Construct2DupL(MCameraObserver& aObserver,TInt aCameraHandle);
sl@0
    89
	void Construct2L(MCameraObserver2& aObserver,TInt aCameraIndex,TInt aPriority);
sl@0
    90
	void Construct2DupL(MCameraObserver2& aObserver,TInt aCameraHandle);
sl@0
    91
private:
sl@0
    92
	// From CCamera
sl@0
    93
	virtual void CameraInfo(TCameraInfo& aInfo) const;
sl@0
    94
	virtual void Reserve();
sl@0
    95
	virtual void Release();
sl@0
    96
	virtual void PowerOn();
sl@0
    97
	virtual void PowerOff();
sl@0
    98
	virtual TInt Handle();
sl@0
    99
sl@0
   100
	virtual void SetZoomFactorL(TInt aZoomFactor = 0);
sl@0
   101
	virtual TInt ZoomFactor() const;
sl@0
   102
	virtual void SetDigitalZoomFactorL(TInt aDigitalZoomFactor = 0);
sl@0
   103
	virtual TInt DigitalZoomFactor() const;
sl@0
   104
sl@0
   105
	virtual void SetContrastL(TInt aContrast);
sl@0
   106
	virtual TInt Contrast() const;
sl@0
   107
	virtual void SetBrightnessL(TInt aBrightness);
sl@0
   108
	virtual TInt Brightness() const;
sl@0
   109
	virtual void SetFlashL(TFlash aFlash = EFlashNone);
sl@0
   110
	virtual TFlash Flash() const;
sl@0
   111
	virtual void SetExposureL(TExposure aExposure = EExposureAuto);
sl@0
   112
	virtual TExposure Exposure() const;
sl@0
   113
	virtual void SetWhiteBalanceL(TWhiteBalance aWhiteBalance = EWBAuto);
sl@0
   114
	virtual TWhiteBalance WhiteBalance() const;
sl@0
   115
sl@0
   116
	virtual void StartViewFinderDirectL(RWsSession& aWs,CWsScreenDevice& aScreenDevice,RWindowBase& aWindow,TRect& aScreenRect);
sl@0
   117
	virtual void StartViewFinderDirectL(RWsSession& aWs,CWsScreenDevice& aScreenDevice,RWindowBase& aWindow,TRect& aScreenRect,TRect& aClipRect);
sl@0
   118
	virtual void StartViewFinderBitmapsL(TSize& aSize);
sl@0
   119
	virtual void StartViewFinderBitmapsL(TSize& aSize,TRect& aClipRect);
sl@0
   120
	virtual void StartViewFinderL(TFormat aImageFormat,TSize& aSize);
sl@0
   121
	virtual void StartViewFinderL(TFormat aImageFormat,TSize& aSize,TRect& aClipRect);
sl@0
   122
	virtual void StopViewFinder();
sl@0
   123
	virtual TBool ViewFinderActive() const;
sl@0
   124
	virtual void SetViewFinderMirrorL(TBool aMirror);
sl@0
   125
	virtual TBool ViewFinderMirror() const;
sl@0
   126
sl@0
   127
	virtual void PrepareImageCaptureL(TFormat aImageFormat,TInt aSizeIndex);
sl@0
   128
	virtual void PrepareImageCaptureL(TFormat aImageFormat,TInt aSizeIndex,const TRect& aClipRect);
sl@0
   129
	virtual void CaptureImage();
sl@0
   130
	virtual void CancelCaptureImage();
sl@0
   131
	virtual void EnumerateCaptureSizes(TSize& aSize,TInt aSizeIndex,TFormat aFormat) const;
sl@0
   132
sl@0
   133
	virtual void PrepareVideoCaptureL(TFormat aFormat,TInt aSizeIndex,TInt aRateIndex,TInt aBuffersToUse,TInt aFramesPerBuffer);
sl@0
   134
	virtual void PrepareVideoCaptureL(TFormat aFormat,TInt aSizeIndex,TInt aRateIndex,TInt aBuffersToUse,TInt aFramesPerBuffer,const TRect& aClipRect);
sl@0
   135
	virtual void StartVideoCapture();
sl@0
   136
	virtual void StopVideoCapture();
sl@0
   137
sl@0
   138
	virtual TBool VideoCaptureActive() const;
sl@0
   139
	virtual void EnumerateVideoFrameSizes(TSize& aSize,TInt aSizeIndex,TFormat aFormat) const;
sl@0
   140
	virtual void EnumerateVideoFrameRates(TReal32& aRate,TInt aRateIndex,TFormat aFormat,TInt aSizeIndex,TExposure aExposure = EExposureAuto) const;
sl@0
   141
	virtual void GetFrameSize(TSize& aSize) const;
sl@0
   142
	virtual TReal32 FrameRate() const;
sl@0
   143
	virtual TInt BuffersInUse() const;
sl@0
   144
	virtual TInt FramesPerBuffer() const;
sl@0
   145
sl@0
   146
	virtual void SetJpegQuality(TInt aQuality);
sl@0
   147
	virtual TInt JpegQuality() const;
sl@0
   148
sl@0
   149
	virtual TAny* CustomInterface(TUid aInterface);
sl@0
   150
sl@0
   151
	// From MAbortDirectScreenAccess
sl@0
   152
	virtual void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
sl@0
   153
sl@0
   154
	// From MDirectScreenAccess
sl@0
   155
	virtual void Restart(RDirectScreenAccess::TTerminationReasons aReason);
sl@0
   156
sl@0
   157
	// New functions
sl@0
   158
	static TInt TimerCallBack(TAny* aThis);
sl@0
   159
	void FrameReady();
sl@0
   160
	void GetFrame(CFbsBitGc& aGc, TPoint& aPos) const;
sl@0
   161
	void GetImgProcessedFrame(CFbsBitGc& aGc, TPoint& aPos) const;
sl@0
   162
	void ServiceVideo(TInt aBuferNum);
sl@0
   163
	void ServiceViewFinder(CFbsBitmap* aSourceFrame);
sl@0
   164
	void ServiceImageCapture(const CFbsBitGc& aSourceBitmapGc);
sl@0
   165
	void ServiceBurstImageCapture(const CFbsBitGc& aSourceBitmapGc);
sl@0
   166
	void DoCaptureImageL();
sl@0
   167
	void CheckReserveAndPowerL();
sl@0
   168
	TInt CheckReserveAndPower() const;
sl@0
   169
	void CustomInterfaceL(TAny*& aIface, TUid aInterface);
sl@0
   170
	static TInt ReserveCallBack(TAny* aThis);
sl@0
   171
	static TInt PowerOnCallBack(TAny* aThis);
sl@0
   172
	static TInt ImageCaptureCallBack(TAny* aThis);
sl@0
   173
	static TInt VideoCaptureCallBack(TAny* aThis);
sl@0
   174
	static TInt HandleEventCallBack(TAny* aThis);
sl@0
   175
	static TInt HandleEvent2CallBack(TAny* aThis);
sl@0
   176
	
sl@0
   177
private:
sl@0
   178
	 CTestCamera();	
sl@0
   179
private:
sl@0
   180
	MCameraObserver* iObserver; // not owned
sl@0
   181
	MCameraObserver2* iObserver2; // not owned
sl@0
   182
	TBool iReserved;
sl@0
   183
	TBool iPowerOn;
sl@0
   184
sl@0
   185
	TCameraInfo iInfo;
sl@0
   186
	CPeriodic* iTimer;
sl@0
   187
	TTimeIntervalMicroSeconds32 iFrameDelay;
sl@0
   188
	TInt iFrameIndex;
sl@0
   189
	TTimeIntervalMicroSeconds iElapsedTime;
sl@0
   190
	TPoint iStillImagePos;
sl@0
   191
	TPoint iVideoFramePos;
sl@0
   192
sl@0
   193
	TReal32 iVideoFrameRate;
sl@0
   194
	TInt iBuffersInUse;
sl@0
   195
	TSize iVideoFrameSize;
sl@0
   196
	TFormat iVideoFrameFormat;
sl@0
   197
sl@0
   198
	CFbsBitmap* iVideoFrame1;
sl@0
   199
	CFbsBitmapDevice* iVideoFrameDev1;
sl@0
   200
	CFbsBitGc* iVideoFrameGc1;
sl@0
   201
	CFbsBitmap* iVideoFrame2;
sl@0
   202
	CFbsBitmapDevice* iVideoFrameDev2;
sl@0
   203
	CFbsBitGc* iVideoFrameGc2;
sl@0
   204
sl@0
   205
	TInt iStillCaptureErr;
sl@0
   206
	TSize iStillImageSize;
sl@0
   207
	TFormat iStillImageFormat;
sl@0
   208
	CFbsBitmap* iStillImage;
sl@0
   209
	CFbsBitmapDevice* iStillImageDev;
sl@0
   210
	CFbsBitGc* iStillImageGc;
sl@0
   211
sl@0
   212
	TSize iViewFinderSize;
sl@0
   213
	TFormat iViewFinderFormat;
sl@0
   214
	CFbsBitmap* iViewFinderBitmap;
sl@0
   215
	CFbsBitmapDevice* iViewFinderBitmapDev;
sl@0
   216
	CFbsBitGc* iViewFinderBitmapGc;
sl@0
   217
sl@0
   218
	CDirectScreenAccess* iDSA;
sl@0
   219
	CFbsScreenDevice* iScreenDev;
sl@0
   220
	CFbsBitGc* iScreenGc;
sl@0
   221
	TRect iScreenRect;
sl@0
   222
	TRect iClipRect;
sl@0
   223
sl@0
   224
	CFbsBitmap* iImage;
sl@0
   225
	CFbsBitmapDevice* iDev;
sl@0
   226
	CFbsBitGc* iGc;
sl@0
   227
sl@0
   228
	CAsyncCallBack iReserveAsync;
sl@0
   229
	CAsyncCallBack iPowerOnAsync;
sl@0
   230
	CAsyncCallBack iImageCaptureAsync;
sl@0
   231
	CAsyncCallBack iVideoCaptureAsync;
sl@0
   232
	CAsyncCallBack iHandleEventAsync;
sl@0
   233
	CAsyncCallBack iHandleEvent2Async;
sl@0
   234
sl@0
   235
	RTestFrameBuffer iFrameBuffer1;
sl@0
   236
	RTestFrameBuffer iFrameBuffer2;
sl@0
   237
	
sl@0
   238
	RTestCameraFrameBuffer iFrameCameraBuffer1;
sl@0
   239
	RTestCameraFrameBuffer iFrameCameraBuffer2;
sl@0
   240
sl@0
   241
	TInt iVideoCaptureErr;
sl@0
   242
	// Members to store the current optical or digital value set with SetZoomFactorL() and SetDigitalZoomFactorL()
sl@0
   243
	// Although arguments have trailing Factor in fact they must contain values in the ranges specified by
sl@0
   244
	//  	iInfo.iMinZoom : iInfo.iMaxZoom for optical zoom and 
sl@0
   245
	//		0 : iInfo.iMaxDigitalZoom for digital zoom 
sl@0
   246
	// The factor values cannot be modified using Camera API as it is assumed 
sl@0
   247
	// that they are determined by the camera hardware.  
sl@0
   248
	TInt iZoom;
sl@0
   249
	TInt iDigitalZoom;
sl@0
   250
	
sl@0
   251
	TInt iContrast;
sl@0
   252
	TInt iBrightness;
sl@0
   253
	
sl@0
   254
	TInt iImgProcBrightness;
sl@0
   255
	TInt iImgProcContrast;
sl@0
   256
	
sl@0
   257
	volatile TBool iViewFinderActive;
sl@0
   258
	volatile TBool iVideoCaptureActive;
sl@0
   259
	volatile TBool iImageCaptureActive;
sl@0
   260
	volatile TBool iVideoPreparedLast;
sl@0
   261
	volatile TBool iVideoCapturePrepared;
sl@0
   262
	volatile TBool iImageCapturePrepared;
sl@0
   263
sl@0
   264
	RArray<TSize> iImageSizes;
sl@0
   265
	RArray<TSize> iVideoFrameSizes;
sl@0
   266
	RArray<TReal32> iVideoFrameRates;
sl@0
   267
	TInt iCameraIndex;
sl@0
   268
	TInt iCameraHandle;
sl@0
   269
	TInt iPriority;	
sl@0
   270
	
sl@0
   271
	TECAMEvent iECamEvent;
sl@0
   272
	TECAMEvent2 iECamEvent2;
sl@0
   273
	TInt iEventError;
sl@0
   274
	
sl@0
   275
	CTestCamAdvSet* iAdvSettingsImpl;
sl@0
   276
	CTestCamSnapshot* iSnapshotImpl;
sl@0
   277
	CTestCamImgProc* iImgProcImpl;
sl@0
   278
	
sl@0
   279
	CCamera::CCameraAdvancedSettings::TDriveMode iDriveMode;
sl@0
   280
	TInt iBurstImages;
sl@0
   281
	};
sl@0
   282
	
sl@0
   283
class CTestCameraInfo : public CCameraInfoPlugin
sl@0
   284
	{
sl@0
   285
public:
sl@0
   286
	static CTestCameraInfo* NewL();
sl@0
   287
	~CTestCameraInfo();
sl@0
   288
	// from CCameraInfoPlugin
sl@0
   289
	TInt CamerasAvailable();
sl@0
   290
private:
sl@0
   291
	CTestCameraInfo();	
sl@0
   292
	};
sl@0
   293
	
sl@0
   294
enum TStubPanicReasons
sl@0
   295
	{
sl@0
   296
	EPanicUnimplemented=1
sl@0
   297
	};	
sl@0
   298
sl@0
   299
class FileDependencyUtil
sl@0
   300
	{
sl@0
   301
public:
sl@0
   302
	static void CheckFileDependencyL();
sl@0
   303
	};
sl@0
   304
sl@0
   305
class CDataGlobal : public CBase
sl@0
   306
	{
sl@0
   307
public:
sl@0
   308
	CTestCamAdvSet* iTestCamAdvSet;
sl@0
   309
	CTestCamPresets* iTestCamPresets;
sl@0
   310
	CTestCamSnapshot* iTestCamSnapshot;
sl@0
   311
	CTestCamImgProc* iTestCamImgProc;
sl@0
   312
	TInt 		iAdvSetReferenceCount;	
sl@0
   313
	TInt 		iPresetsReferenceCount;
sl@0
   314
	TInt 		iSnapshotReferenceCount;	
sl@0
   315
	TInt 		iImgProcReferenceCount;
sl@0
   316
	};
sl@0
   317
	
sl@0
   318
#endif