|
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 CVSCAMERADATAPROVIDER_H |
|
20 #define CVSCAMERADATAPROVIDER_H |
|
21 |
|
22 // INCLUDE FILES |
|
23 |
|
24 #include "CApiVideoSource.h" |
|
25 |
|
26 #include <cvtimagescaler.h> |
|
27 #include <cvtimagebitmap.h> |
|
28 // CLASS FORWARDS |
|
29 |
|
30 class CVsFrameBuffer; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * Internal MFrameBuffer API. |
|
36 * |
|
37 * @lib videosource.lib |
|
38 * @since 5.0 |
|
39 */ |
|
40 class MVsFrameBuffer |
|
41 { |
|
42 |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Copies properties from the given frame buffer. |
|
47 * @param "aSource" Source frame buffer from which propreties will |
|
48 * be copied. |
|
49 */ |
|
50 virtual void CopyProperties( MFrameBuffer* aSource ) = 0; |
|
51 |
|
52 /** |
|
53 * Copies properties from the given camera buffer. |
|
54 * @param "aSource" Source camera buffer from which propreties will |
|
55 * be copied. |
|
56 */ |
|
57 virtual void CopyProperties( MCameraBuffer* aSource ) = 0; |
|
58 |
|
59 /** |
|
60 * Copies frame data and properties from the given frame buffer. |
|
61 * @param "aSource" Source frame buffer from which propreties and |
|
62 * frame data will be copied. |
|
63 */ |
|
64 virtual void CopyFrameL( MFrameBuffer* aSource ) = 0; |
|
65 |
|
66 /** |
|
67 * Copies frame data and properties from the given camera buffer. |
|
68 * @param "aSource" Source camera buffer from which propreties and |
|
69 * frame data will be copied. |
|
70 */ |
|
71 virtual void CopyFrameL( MCameraBuffer* aSource ) = 0; |
|
72 |
|
73 }; |
|
74 |
|
75 /** |
|
76 * Internal MFrameBuffer implementation. |
|
77 * |
|
78 * @lib videosource.lib |
|
79 */ |
|
80 class CVsFrameBuffer : public CBase, public MVsFrameBuffer, |
|
81 public MFrameBuffer, public MCameraBuffer |
|
82 { |
|
83 public: |
|
84 |
|
85 /** |
|
86 * Constructor. |
|
87 * @param "sSize" Size of stored frame in bytes. |
|
88 * @exception Can leave with one of the system wide error codes. |
|
89 */ |
|
90 IMPORT_C static CVsFrameBuffer* NewL( TInt aSize ); |
|
91 |
|
92 /** |
|
93 * Destructor. |
|
94 */ |
|
95 IMPORT_C ~CVsFrameBuffer(); |
|
96 |
|
97 public: // from MVsFrameBuffer |
|
98 |
|
99 /** |
|
100 * @see MVsFrameBuffer::CopyProperties |
|
101 */ |
|
102 virtual void CopyProperties( MFrameBuffer* aSource ); |
|
103 |
|
104 /** |
|
105 * @see MVsFrameBuffer::CopyProperties |
|
106 */ |
|
107 virtual void CopyProperties( MCameraBuffer* aSource ); |
|
108 |
|
109 /** |
|
110 * @see MVsFrameBuffer::CopyFrameL |
|
111 */ |
|
112 virtual void CopyFrameL( MFrameBuffer* aSource ); |
|
113 |
|
114 /** |
|
115 * @see MVsFrameBuffer::CopyFrameL |
|
116 */ |
|
117 virtual void CopyFrameL( MCameraBuffer* aSource ); |
|
118 |
|
119 public: // from MFrameBuffer |
|
120 |
|
121 /** |
|
122 * @see MFrameBuffer::DataL or MCameraBuffer::DataL |
|
123 */ |
|
124 TDesC8* DataL( TInt aIndex ); |
|
125 |
|
126 /** |
|
127 * @see MFrameBuffer::FrameL or MCameraBuffer::FrameL |
|
128 */ |
|
129 CFbsBitmap* FrameL( TInt aIndex ); |
|
130 |
|
131 /** |
|
132 * @see MFrameBuffer::Release or MCameraBuffer::Release |
|
133 */ |
|
134 void Release(); |
|
135 |
|
136 /** |
|
137 * @see MCameraBuffer::FrameSize |
|
138 */ |
|
139 TInt FrameSize(TInt aFrameIndex); |
|
140 |
|
141 /** |
|
142 * @see MCameraBuffer::ChunkOffsetL |
|
143 */ |
|
144 TInt ChunkOffsetL(TInt aFrameIndex); |
|
145 |
|
146 /** |
|
147 * @see MCameraBuffer::ChunkL |
|
148 */ |
|
149 RChunk& ChunkL(); |
|
150 |
|
151 /** |
|
152 * @see MCameraBuffer::BitmapL |
|
153 */ |
|
154 CFbsBitmap& BitmapL(TInt aFrameIndex); |
|
155 |
|
156 /** |
|
157 * @see MCameraBuffer::NumFrames |
|
158 */ |
|
159 TInt NumFrames(); |
|
160 |
|
161 private: |
|
162 |
|
163 /** |
|
164 * Constructor. |
|
165 */ |
|
166 CVsFrameBuffer(); |
|
167 |
|
168 /** |
|
169 * Second phase constructor. |
|
170 * @param "aSize" Size of the frame in bytes. |
|
171 */ |
|
172 void ConstructL( TInt aSize ); |
|
173 |
|
174 private: |
|
175 |
|
176 HBufC8* iBuffer; |
|
177 |
|
178 TPtr8 iPtr; |
|
179 |
|
180 }; |
|
181 |
|
182 /** |
|
183 * Internal implementation of onboard camera data provider base class. This |
|
184 * class is inherited from public provider interface. |
|
185 * |
|
186 * @lib videosource.lib |
|
187 */ |
|
188 class CVSCameraDataProvider : public CVSDataProvider, public MCameraObserver, public MVtImageScalerObserver, public MCameraObserver2 |
|
189 { |
|
190 public: // Constructor and destructor |
|
191 |
|
192 /** |
|
193 * Factory function to create instance of onboard camera data provider. |
|
194 * @param "aObserver" Pointer to provider observer. |
|
195 * @param "aProviderIndex" Index of the provider to be created. |
|
196 * @param "aPool" Pointer to data MVSBufferPool that gives buffer to |
|
197 * data provider. |
|
198 * @exception Can leave with one of the system wide error codes. |
|
199 * @return Pointer to new provider instance. |
|
200 */ |
|
201 static CVSCameraDataProvider* NewL( |
|
202 MVSDataProviderObserver* aObserver, |
|
203 TInt aProviderIndex, |
|
204 MVSBufferPool* aPool ); |
|
205 |
|
206 /** |
|
207 * Destructor. |
|
208 */ |
|
209 ~CVSCameraDataProvider(); |
|
210 |
|
211 public: // New functions |
|
212 |
|
213 public: // Functions from base classes |
|
214 |
|
215 /** |
|
216 * Initialize provider. |
|
217 * @param "aInitParams" Initialization parameters. |
|
218 * @exception Can leave with one of the system wide error codes. |
|
219 */ |
|
220 void InitializeL( const TDesC8& aInitParams ); |
|
221 |
|
222 /** |
|
223 * Cancel initialization of camera provider. |
|
224 */ |
|
225 void CancelInitializing(); |
|
226 |
|
227 /** |
|
228 * Return digital zoom factor. |
|
229 * @return Digital zoom factor. |
|
230 */ |
|
231 virtual TInt DigitalZoomFactor() const; |
|
232 |
|
233 /** |
|
234 * Set digital zoom factor. |
|
235 * @param "aDigitalZoomFactor" Digital zoom factor. |
|
236 * @exception Can leave with one of the system wide error codes. |
|
237 */ |
|
238 virtual void SetDigitalZoomFactorL( TInt aDigitalZoomFactor = 0 ); |
|
239 |
|
240 /** |
|
241 * Start view finder bitmaps. |
|
242 * @param "aSize" Size of the returned view finder bitmap. |
|
243 * @exception Can leave with one of the system wide error codes. |
|
244 */ |
|
245 virtual void StartViewFinderBitmapsL( TSize& aSize ); |
|
246 |
|
247 /** |
|
248 * Start view finder bitmaps. |
|
249 * @param "aSize" Size of the returned view finder bitmap. |
|
250 * @param "aClipRect" Required clip rectangle. |
|
251 * @exception Can leave with one of the system wide error codes. |
|
252 */ |
|
253 virtual void StartViewFinderBitmapsL( TSize& aSize,TRect& aClipRect ); |
|
254 |
|
255 /** |
|
256 * Stop view finder bitmaps. |
|
257 */ |
|
258 virtual void StopViewFinder(); |
|
259 |
|
260 /** |
|
261 * Test if view finder is active. |
|
262 * @return ETrue if view finder active. |
|
263 */ |
|
264 virtual TBool ViewFinderActive() const; |
|
265 |
|
266 /** |
|
267 * Start view finder bitmaps using direct screen access. |
|
268 * @param "aWs" Window server session. |
|
269 * @param "aScreenDevice" Screen device. |
|
270 * @param "aWindow" Displayable window. |
|
271 * @param "aScreenRect" Portion of the screen to which view finder data |
|
272 * is to be transferred. |
|
273 * @exception Can leave with one of the system wide error codes. |
|
274 */ |
|
275 virtual void StartViewFinderDirectL( |
|
276 RWsSession& aWs, |
|
277 CWsScreenDevice& aScreenDevice, |
|
278 RWindowBase& aWindow, |
|
279 TRect& aScreenRect ); |
|
280 |
|
281 /** |
|
282 * Start view finder bitmaps using direct screen access. |
|
283 * @param "aWs" Window server session. |
|
284 * @param "aScreenDevice" Screen device. |
|
285 * @param "aWindow" Displayable window. |
|
286 * @param "aScreenRect" Portion of the screen to which view finder data |
|
287 * is to be transferred. |
|
288 * @param "aClipRect" The rectangle to which the screen will be clipped. |
|
289 * @exception Can leave with one of the system wide error codes. |
|
290 */ |
|
291 virtual void StartViewFinderDirectL( |
|
292 RWsSession& aWs, |
|
293 CWsScreenDevice& aScreenDevice, |
|
294 RWindowBase& aWindow, |
|
295 TRect& aScreenRect, |
|
296 TRect& aClipRect ); |
|
297 |
|
298 /** |
|
299 * Return provider information. |
|
300 * @param @param "aInfo" Reference to variable to where the provider |
|
301 * information is copied. |
|
302 */ |
|
303 virtual void ProviderInfo( TVSDataProviderInfo& aInfo ); |
|
304 |
|
305 /** |
|
306 * See CVSDataProvider for description. |
|
307 */ |
|
308 virtual void SetViewFinderMirrorL( TBool aMirror ); |
|
309 |
|
310 /** |
|
311 * See CVSDataProvider for description. |
|
312 */ |
|
313 virtual TBool ViewFinderMirror() const; |
|
314 |
|
315 /** |
|
316 * See CVSDataProvider for description. |
|
317 */ |
|
318 virtual void FreezeL(); |
|
319 |
|
320 /** |
|
321 * See CVSDataProvider for description. |
|
322 */ |
|
323 virtual void UnfreezeL(); |
|
324 |
|
325 /** |
|
326 * See CVSDataProvider for description. |
|
327 */ |
|
328 virtual TBool IsFrozen() const; |
|
329 |
|
330 /** |
|
331 * @see CVSDataProvider::SetContrastL for description. |
|
332 */ |
|
333 virtual void SetContrastL( TInt aContrast ); |
|
334 |
|
335 /** |
|
336 * @see CVSDataProvider::GetContrast |
|
337 */ |
|
338 virtual TInt GetContrast( TInt& aContrast ) const; |
|
339 |
|
340 /** |
|
341 * @see CVSDataProvider::SetBrightnessL for description. |
|
342 */ |
|
343 virtual void SetBrightnessL( TInt aBrightness ); |
|
344 |
|
345 /** |
|
346 * @see CVSDataProvider::GetBrightness for description. |
|
347 */ |
|
348 virtual TInt GetBrightness( TInt& aBrightness ) const; |
|
349 |
|
350 /** |
|
351 * @see CVSDataProvider::SetWhiteBalanceL for description. |
|
352 */ |
|
353 virtual void SetWhiteBalanceL( |
|
354 CCamera::TWhiteBalance aWhiteBalance = CCamera::EWBAuto ); |
|
355 |
|
356 /** |
|
357 * @see CVSDataProvider::GetWhiteBalance for description. |
|
358 */ |
|
359 virtual TInt GetWhiteBalance( |
|
360 CCamera::TWhiteBalance& aWhiteBalance ) const; |
|
361 |
|
362 /** |
|
363 * @see CVSDataProvider::GetColorTone for description. |
|
364 */ |
|
365 virtual TInt GetColorTone( |
|
366 CCamera::CCameraImageProcessing::TEffect& aColorTone ) const; |
|
367 |
|
368 /** |
|
369 * @see CVSDataProvider::SetColorToneL for description. |
|
370 */ |
|
371 virtual void SetColorToneL( |
|
372 CCamera::CCameraImageProcessing::TEffect aValue ); |
|
373 |
|
374 protected: // from MCameraObserver |
|
375 |
|
376 /** |
|
377 * @see MCameraObserver::ImageReady |
|
378 */ |
|
379 virtual void ImageReady( CFbsBitmap* aBitmap, HBufC8* aData, |
|
380 TInt aError ); |
|
381 |
|
382 /** |
|
383 * @see MCameraObserver::PowerOnComplete |
|
384 */ |
|
385 virtual void PowerOnComplete( TInt aError ); |
|
386 |
|
387 /** |
|
388 * @see MCameraObserver::ViewFinderFrameReady |
|
389 */ |
|
390 virtual void ViewFinderFrameReady( CFbsBitmap& aFrame ); |
|
391 |
|
392 protected: // from MVtImageScalerObserver |
|
393 |
|
394 /** |
|
395 * @see MVtImageScalerObserver::ScalingFinished( TInt aError ) |
|
396 */ |
|
397 virtual void ScalingFinished( TInt aError ); |
|
398 |
|
399 protected: // from MCameraObserver2 |
|
400 |
|
401 /** |
|
402 * @see MCameraObserver2::ImageBufferReady |
|
403 */ |
|
404 virtual void ImageBufferReady( MCameraBuffer& aCameraBuffer, |
|
405 TInt aError ); |
|
406 |
|
407 protected: // New functions |
|
408 |
|
409 /** |
|
410 * Inliner to return reference to the onboard camera handle. |
|
411 * @return Reference to the onboard camera handle. |
|
412 */ |
|
413 inline CCamera& Camera() const; |
|
414 |
|
415 protected: // Constructors and destructor |
|
416 |
|
417 /** |
|
418 * Constructor. |
|
419 * @param "aObserver" Pointer to provider observer. |
|
420 */ |
|
421 CVSCameraDataProvider( |
|
422 MVSDataProviderObserver* aObserver, |
|
423 MVSBufferPool* aPool ); |
|
424 |
|
425 private: // Constructors and destructors |
|
426 |
|
427 /** |
|
428 * 2nd phase constructor. |
|
429 * @param "aProviderIndex" Index of the provider to be created. |
|
430 * @exception Can leave with one of the system wide error codes. |
|
431 */ |
|
432 void ConstructL( TInt aProviderIndex ); |
|
433 |
|
434 void FreezeViewFinderFrame( CFbsBitmap& aFrame ); |
|
435 |
|
436 void ScaleFrozenBitmapL( TSize& aSize ); |
|
437 |
|
438 private: // New functions |
|
439 |
|
440 /** |
|
441 * Return provider information. |
|
442 */ |
|
443 void ProviderInfoExL( TVSDataProviderInfo& aInfo ); |
|
444 |
|
445 private: // Functions from base classes |
|
446 |
|
447 public: // Data |
|
448 |
|
449 protected: // Data |
|
450 |
|
451 enum TFreezePendingFlags |
|
452 { |
|
453 EViewFinderFreezePending = ( 1 << 0 ), |
|
454 EVideoFrameFreezePending = ( 1 << 1 ) |
|
455 }; |
|
456 |
|
457 // Camera handle number. |
|
458 TInt iCameraHandle; |
|
459 |
|
460 // ETrue after ReserveComplete for iCamera |
|
461 TBool iReserverComplete; |
|
462 |
|
463 // ETrue after PowerOnComplete for iCamera |
|
464 TBool iPowerOnComplete; |
|
465 |
|
466 // ETrue after Freeze |
|
467 TBool iFrozen; |
|
468 |
|
469 // Contains pending freeze flags after Freeze |
|
470 TUint iFreezePendingFlags; |
|
471 |
|
472 // has frozen viewfinder frame copy |
|
473 TBool iHasFrozenVFFrameCopyCreated; |
|
474 |
|
475 CVsFrameBuffer* iFrozenFrame; |
|
476 |
|
477 RCriticalSection iFreezeCS; |
|
478 |
|
479 private: // Data |
|
480 |
|
481 // Camera handle. |
|
482 CCamera* iCamera; |
|
483 |
|
484 // owned: Copy of frozen VF frame |
|
485 CFbsBitmap* iFrozenVFFrameCopy; |
|
486 |
|
487 // |
|
488 CVtImageBitmap* iSource; |
|
489 |
|
490 // owned: Scaled version of frozen VF frame (this is sent) |
|
491 CFbsBitmap* iFrozenVFFrameToBeSent; |
|
492 |
|
493 // |
|
494 CVtImageBitmap* iTarget; |
|
495 |
|
496 // owned: Scaler instance |
|
497 CVtImageScaler* iScaler; |
|
498 |
|
499 // ETrue when frozen VF frame is ready to be sent EFalse otherwise |
|
500 TBool iFrozenVfFrameReady; |
|
501 |
|
502 // Camera image processing |
|
503 CCamera::CCameraImageProcessing* iCamImgProc; |
|
504 |
|
505 private: // friends |
|
506 |
|
507 // Stif test module must be set as friend to be able to call protected |
|
508 // and private methods |
|
509 friend class CstiffVideoSourceAPICases; |
|
510 |
|
511 }; |
|
512 |
|
513 #include "CVSCameraDataProvider.inl" |
|
514 |
|
515 #endif // CVSCAMERADATAPROVIDER_H |
|
516 |
|
517 // End of File |