1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef LOADGEN_PHOTOCAPTURE_H |
|
20 #define LOADGEN_PHOTOCAPTURE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <ecam.h> // CCamera, MCameraObserver |
|
26 |
|
27 #include "loadgen_loadbase.h" |
|
28 #include "loadgen_loadattributes.h" |
|
29 |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CCameraManager; |
|
33 |
|
34 |
|
35 // CLASS DECLARATIONS |
|
36 |
|
37 class CPhotoCapture : public CLoadBase |
|
38 { |
|
39 public: |
|
40 static CPhotoCapture* NewL(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber); |
|
41 virtual ~CPhotoCapture(); |
|
42 |
|
43 private: // Constructors |
|
44 CPhotoCapture(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber); |
|
45 void ConstructL(); |
|
46 |
|
47 public: // New methods |
|
48 virtual void Resume(); |
|
49 virtual void Suspend(); |
|
50 virtual void SetPriority(); |
|
51 virtual void Close(); |
|
52 virtual TPtrC Description(); |
|
53 inline TPhotoCaptureAttributes& Attributes() { return iAttributes; } |
|
54 inline void SetAttributes(const TPhotoCaptureAttributes& aAttributes) { iAttributes = aAttributes; } |
|
55 |
|
56 |
|
57 public: // New static methods |
|
58 static TInt ThreadFunction(TAny* aThreadArg); |
|
59 //static void SetImagesReady(TInt aImages); |
|
60 //static TInt ImagesReady(); |
|
61 |
|
62 private: // New static methods |
|
63 static void GenerateLoad(TPhotoCaptureAttributes& aAttributes); |
|
64 static void DoHeaveStuff(TInt aMode); |
|
65 |
|
66 private: // Data |
|
67 TPhotoCaptureAttributes iAttributes; |
|
68 RThread iThread; |
|
69 //static TInt iImagesReady; |
|
70 }; |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 class CCameraManager : public CActive, public MCameraObserver |
|
76 { |
|
77 public: |
|
78 |
|
79 static CCameraManager* NewL(TPhotoCaptureAttributes& aAttrs); |
|
80 virtual ~CCameraManager(); |
|
81 |
|
82 private: |
|
83 |
|
84 CCameraManager(TPhotoCaptureAttributes& aAttrs); |
|
85 void ConstructL(); |
|
86 |
|
87 private: |
|
88 /** |
|
89 * From MCameraObserver: |
|
90 */ |
|
91 virtual void ReserveComplete(TInt aError); |
|
92 virtual void PowerOnComplete(TInt aError); |
|
93 virtual void ViewFinderFrameReady(CFbsBitmap& aFrame); |
|
94 virtual void ImageReady(CFbsBitmap* aBitmap, |
|
95 HBufC8* aData, TInt aError); |
|
96 virtual void FrameBufferReady(MFrameBuffer* aFrameBuffer, |
|
97 TInt aError); |
|
98 |
|
99 static TInt PeriodicTimerCallBack(TAny* aAny); |
|
100 public: |
|
101 |
|
102 /** |
|
103 * Reserves the camera. |
|
104 */ |
|
105 void ReserveCameraL(); |
|
106 |
|
107 /** |
|
108 * Takes a picture. |
|
109 */ |
|
110 void CapturePhotoL(); |
|
111 |
|
112 TInt NumberOfPictures(); |
|
113 |
|
114 /** |
|
115 * From CActive: |
|
116 */ |
|
117 void RunL(); |
|
118 void DoCancel(); |
|
119 |
|
120 private: |
|
121 |
|
122 enum TState |
|
123 { |
|
124 ENotReady, |
|
125 ECameraReserved, |
|
126 EIdle, |
|
127 ECapture |
|
128 }; |
|
129 |
|
130 CPeriodic* iPeriodicTimer; |
|
131 TPhotoCaptureAttributes& iAttributes; |
|
132 CCamera* iCamera; |
|
133 TState iState; |
|
134 TInt iNumOfPics; |
|
135 TCameraInfo iCameraInfo; |
|
136 TInt iCurrentCamera; |
|
137 }; |
|
138 |
|
139 |
|
140 #endif |
|