|
1 /* |
|
2 * Copyright (c) 2006 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: Video Source subsystem. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CVSONBOARDCAMERADATAPROVIDER_H |
|
20 #define CVSONBOARDCAMERADATAPROVIDER_H |
|
21 |
|
22 // INCLUDE FILES |
|
23 |
|
24 #include "CVSCameraDataProvider.h" |
|
25 |
|
26 // CLASS DECLARATION |
|
27 |
|
28 /** |
|
29 * Handles provider error notification using interface to provider callback |
|
30 * functions. Provider errors can occur in two threads and this class provides |
|
31 * error notification in the same thread context that the provider was created. |
|
32 * |
|
33 * @lib videosource.lib |
|
34 */ |
|
35 class CProviderErrorNotifierAO : public CActive |
|
36 { |
|
37 public: // New functions |
|
38 |
|
39 public: // Functions from base classes |
|
40 |
|
41 protected: // New functions |
|
42 |
|
43 protected: // Functions from base classes |
|
44 |
|
45 private: // Constructors and destructor |
|
46 |
|
47 /** |
|
48 * Static factory function to create instance of this class. |
|
49 * @exception Can leave with one of the system wide error codes. |
|
50 * @return Pointer to new instance. |
|
51 */ |
|
52 static CProviderErrorNotifierAO* NewL(); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 ~CProviderErrorNotifierAO(); |
|
58 |
|
59 private: // New functions |
|
60 |
|
61 /** |
|
62 * Notify provider observer about error. |
|
63 * @param "aObserver" Pointer to provider observer to notify. |
|
64 * @param "aError" Error code. |
|
65 */ |
|
66 void NotifyError( MVSDataProviderObserver* aObserver, TInt aError ); |
|
67 |
|
68 private: // Constructors and destructor |
|
69 |
|
70 /** |
|
71 * Constructor. |
|
72 */ |
|
73 CProviderErrorNotifierAO(); |
|
74 |
|
75 /** |
|
76 * 2nd phase constructor. |
|
77 * @exception Can leave with one of the system wide error codes. |
|
78 */ |
|
79 void ConstructL(); |
|
80 |
|
81 private: // Functions from base classes |
|
82 |
|
83 /** |
|
84 * From CActive. See CActive for description. |
|
85 */ |
|
86 void DoCancel(); |
|
87 |
|
88 /** |
|
89 * From CActive. See CActive for description. |
|
90 */ |
|
91 void RunL(); |
|
92 |
|
93 public: // Data |
|
94 |
|
95 protected: // Data |
|
96 |
|
97 private: // Data |
|
98 |
|
99 // Pointer to provider observer that will receive the error |
|
100 // notification. |
|
101 MVSDataProviderObserver* iObserver; |
|
102 |
|
103 // Error code. |
|
104 TInt iError; |
|
105 |
|
106 // Critical section to synchronize access to this object. |
|
107 RCriticalSection iCS; |
|
108 |
|
109 // Thread id of the thread in which this object was created. |
|
110 TThreadId iThreadId; |
|
111 |
|
112 private: // Data |
|
113 |
|
114 // This class is private to CVSDataProvider. |
|
115 friend class CVSDataProvider; |
|
116 }; |
|
117 |
|
118 /** |
|
119 * Makes onboard camera Reserve and PowerOn function calls synchronous. |
|
120 * |
|
121 * @lib videosource.lib |
|
122 */ |
|
123 class CSyncCameraReserve : public CActive |
|
124 { |
|
125 public: // Constructors and destructor |
|
126 |
|
127 /** |
|
128 * Static factory function to create instance of this class. |
|
129 * @exception Can leave with one of the system wide error codes. |
|
130 * @return Pointer to new instance. |
|
131 */ |
|
132 static CSyncCameraReserve* NewL(); |
|
133 |
|
134 public: // New functions |
|
135 |
|
136 /** |
|
137 * Starts waiting and returns when RunL is called. |
|
138 * @exception Can leave with one of the system wide error codes. |
|
139 */ |
|
140 void StartL(); |
|
141 |
|
142 private: // Constructors and destructor |
|
143 |
|
144 /** |
|
145 * Constructor. |
|
146 */ |
|
147 CSyncCameraReserve(); |
|
148 |
|
149 private: // Functions from base classes |
|
150 |
|
151 /** |
|
152 * From CActive. See CActive for description. |
|
153 */ |
|
154 void DoCancel(); |
|
155 |
|
156 /** |
|
157 * From CActive. See CActive for description. |
|
158 */ |
|
159 void RunL(); |
|
160 |
|
161 private: // Data |
|
162 |
|
163 // Active scheduler loop owner. See CActiveSchedulerWait for |
|
164 // description. |
|
165 CActiveSchedulerWait iWait; |
|
166 }; |
|
167 |
|
168 /** |
|
169 * Internal implementation of onboard camera data provider. This |
|
170 * class is inherited from onboard camera data provider base class. |
|
171 * |
|
172 * @lib videosource.lib |
|
173 */ |
|
174 class CVSOnboardCameraDataProvider : public CVSCameraDataProvider |
|
175 { |
|
176 public: // Constructors and destructor |
|
177 |
|
178 /** |
|
179 * Constructor. |
|
180 * @param "aObserver" Pointer to provider observer. |
|
181 * @param "aPool" Pointer to data MVSBufferPool that gives buffer to |
|
182 * data provider. |
|
183 */ |
|
184 CVSOnboardCameraDataProvider( |
|
185 MVSDataProviderObserver* aObserver, |
|
186 MVSBufferPool* aPool ); |
|
187 |
|
188 /** |
|
189 * Destructor. |
|
190 */ |
|
191 ~CVSOnboardCameraDataProvider(); |
|
192 |
|
193 public: // New functions |
|
194 |
|
195 public: // Functions from base classes |
|
196 |
|
197 protected: // New functions |
|
198 |
|
199 protected: // Functions from base classes |
|
200 |
|
201 private: // New functions |
|
202 |
|
203 /** |
|
204 * See CVSDataProvider for description. |
|
205 */ |
|
206 void PrimeL(); |
|
207 |
|
208 private: // Functions from base classes |
|
209 |
|
210 /** |
|
211 * See MDataSource for description. |
|
212 */ |
|
213 virtual void FillBufferL( |
|
214 CMMFBuffer* aBuffer, |
|
215 MVTVideoSink* aConsumer, |
|
216 TMediaId aMediaId ); |
|
217 |
|
218 /** |
|
219 * See MDataSource for description. |
|
220 */ |
|
221 virtual void BufferEmptiedL( CMMFBuffer* aBuffer ); |
|
222 |
|
223 /** |
|
224 * See MDataSource for description. |
|
225 */ |
|
226 virtual TInt SourceThreadLogon( MAsyncEventHandler& aEventHandler ); |
|
227 |
|
228 /** |
|
229 * See MDataSource for description. |
|
230 */ |
|
231 virtual void SourceThreadLogoff(); |
|
232 |
|
233 /** |
|
234 * See MDataSource for description. |
|
235 */ |
|
236 virtual void SourcePrimeL(); |
|
237 |
|
238 /** |
|
239 * See MDataSource for description. |
|
240 */ |
|
241 virtual void SourcePlayL(); |
|
242 |
|
243 /** |
|
244 * See MDataSource for description. |
|
245 */ |
|
246 virtual void SourcePauseL(); |
|
247 |
|
248 /** |
|
249 * See MDataSource for description. |
|
250 */ |
|
251 virtual void SourceStopL(); |
|
252 |
|
253 private: // Functions from base classes |
|
254 |
|
255 /** |
|
256 * See MVTVideoInput for description. |
|
257 */ |
|
258 virtual void SetFormatL( const TDesC8& aFormat ); |
|
259 |
|
260 /** |
|
261 * See MVTVideoInput for description. |
|
262 */ |
|
263 virtual void SetFrameRateL( TReal32 aFrameRate ); |
|
264 |
|
265 /** |
|
266 * See MVTVideoInput for description. |
|
267 */ |
|
268 virtual void SetVideoFrameSizeL( const TSize& aSize ); |
|
269 |
|
270 /** |
|
271 * See MVTVideoInput for description. |
|
272 */ |
|
273 virtual void GetVideoFrameSizeL( TSize& aSize ) const; |
|
274 |
|
275 private: // from MCameraObserver |
|
276 |
|
277 /** |
|
278 * @see MCameraObserver::ReserveComplete |
|
279 */ |
|
280 virtual void ReserveComplete( TInt aError ); |
|
281 |
|
282 /** |
|
283 * @see MCameraObserver::FrameBufferReady |
|
284 */ |
|
285 virtual void FrameBufferReady( MFrameBuffer* aFrameBuffer, |
|
286 TInt aError ); |
|
287 |
|
288 private: // from MCameraObserver2 |
|
289 |
|
290 /** |
|
291 * @see MCameraObserver2::HandleEvent |
|
292 */ |
|
293 virtual void HandleEvent(const TECAMEvent& aEvent); |
|
294 |
|
295 /** |
|
296 * @see MCameraObserver2::ViewFinderReady |
|
297 */ |
|
298 virtual void ViewFinderReady(MCameraBuffer& aCameraBuffer,TInt aError); |
|
299 |
|
300 /** |
|
301 * @see MCameraObserver2::VideoBufferReady |
|
302 */ |
|
303 virtual void VideoBufferReady(MCameraBuffer& aCameraBuffer,TInt aError); |
|
304 |
|
305 private: // Functions from base classes |
|
306 |
|
307 /** |
|
308 * Get video frame size. |
|
309 */ |
|
310 virtual void GetVideoFrameSize( |
|
311 TSize& aSize, |
|
312 TInt aSizeIndex, |
|
313 const TDesC8& aFormat ); |
|
314 |
|
315 /** |
|
316 * Get video frame rate. |
|
317 */ |
|
318 virtual void GetVideoFrameRate( |
|
319 TReal32& aRate, |
|
320 TInt aRateIndex, |
|
321 const TDesC8& aFormat, |
|
322 const TSize& aSize ); |
|
323 |
|
324 void FreezeFrame( MFrameBuffer* aFrameBuffer ); |
|
325 |
|
326 void FreezeFrame( MCameraBuffer* aCameraBuffer ); |
|
327 |
|
328 public: // Data |
|
329 |
|
330 protected: // Data |
|
331 |
|
332 private: // Data |
|
333 |
|
334 // Onboard camera dublicate for the second thread. Owned. |
|
335 CCamera* iCameraDuplicate; |
|
336 |
|
337 // MMF controller framwork mixin for event handling |
|
338 MAsyncEventHandler* iEventHandler; |
|
339 |
|
340 // Enumerated values for possible states this class can have. |
|
341 enum TState |
|
342 { |
|
343 EStopped, |
|
344 EPrimed, |
|
345 EPlaying |
|
346 }; |
|
347 |
|
348 // One of the enumerated states. |
|
349 TState iState; |
|
350 |
|
351 // ECAM frame rate index. |
|
352 TInt iFrameRateIndex; |
|
353 |
|
354 // ECAM frame size index. |
|
355 TInt iFrameSizeIndex; |
|
356 |
|
357 // Frame size. |
|
358 TSize iFrameSize; |
|
359 |
|
360 // ECAM Video frame format. |
|
361 CCamera::TFormat iFormat; |
|
362 |
|
363 // Pointer to AO that makes iCameraDuplicate.Reserve() and PowerOn() |
|
364 // synchronous. Owned. These are called in SourcePrimeL and because |
|
365 // it is synchronous, reserve & poweron must be too. |
|
366 CSyncCameraReserve* iSyncReserve; |
|
367 |
|
368 // |
|
369 TBool iAsynchronousReserveIssued; |
|
370 |
|
371 // Pointer to dublicated camera bitmap |
|
372 CFbsBitmap* iDublicatedBitmap; |
|
373 |
|
374 // Camera lost by force indicator |
|
375 TBool iCameraLost; |
|
376 |
|
377 private: // friends |
|
378 |
|
379 // Stif test module must be set as friend to be able to call protected |
|
380 // and private methods |
|
381 friend class CstiffVideoSourceAPICases; |
|
382 |
|
383 }; |
|
384 |
|
385 #endif // CVSONBOARDCAMERADATAPROVIDER_H |
|
386 |
|
387 // End of File |