|
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 CAPIVIDEOSOURCE_H |
|
20 #define CAPIVIDEOSOURCE_H |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <e32base.h> |
|
24 #include <ecam.h> |
|
25 #include <mmfutilities.h> |
|
26 #include <mmfdatasource.h> |
|
27 #include <mvtprotocolhandler.h> |
|
28 #include <ecamimageprocessing.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 |
|
32 class MVSControllerObserver; |
|
33 class MVSDataSourceObserver; |
|
34 class MVSDataProviderObserver; |
|
35 class CVSDataSource; |
|
36 class CVSDataProvider; |
|
37 class TVSDataProviderInfo; |
|
38 class CVSDataSourceImp; |
|
39 class CProviderErrorNotifierAO; |
|
40 |
|
41 class MFrameBuffer; |
|
42 class RWsSession; |
|
43 class CWsScreenDevice; |
|
44 class RWindowBase; |
|
45 class CFbsBitmap; |
|
46 class MDataSink; |
|
47 class MDataSource; |
|
48 class MAsyncEventHandler; |
|
49 class TMMFPrioritySettings; |
|
50 class TMMFMessage; |
|
51 class CDesC8Array; |
|
52 class CVSMMFDataBuffer; |
|
53 |
|
54 // Camera lost during VT error |
|
55 const TInt KVsErrCameraNoLongerReserved = 666; |
|
56 // CLASS DECLARATION |
|
57 |
|
58 /** |
|
59 * Initialization settings class for still image provider. |
|
60 * |
|
61 * @lib videosource.lib |
|
62 */ |
|
63 class TVSStillImageDataProviderParams |
|
64 { |
|
65 public: |
|
66 /** |
|
67 * Enumeration that defines different initialization |
|
68 * types. |
|
69 */ |
|
70 enum TInitialize |
|
71 { |
|
72 /** Created as blank image */ |
|
73 EInitializeAsBlankImage, |
|
74 /** Image will be load from General Settings */ |
|
75 EInitializeFromGeneralSettings, |
|
76 /** Image will be from file */ |
|
77 EInitializeFromFile, |
|
78 /** Imge will be load from phone server */ |
|
79 EInitializeAsDefaultStillImage |
|
80 }; |
|
81 |
|
82 public: |
|
83 /** |
|
84 * Constructor, set iInitialize to EInitializeAsBlankImage. iFileName |
|
85 * is initialized as an empty descriptor. |
|
86 */ |
|
87 inline TVSStillImageDataProviderParams(); |
|
88 |
|
89 /** |
|
90 * Constructor. iFileName is initialized as an empty descriptor. |
|
91 * @param aInitialize Defines how provider must be initialized. |
|
92 */ |
|
93 inline TVSStillImageDataProviderParams( const TInitialize aInitialize ); |
|
94 |
|
95 /** |
|
96 * Constructor. iInitialize is set to EInitializeFromFile. |
|
97 * @param aFileName Name of the file from which this instance will |
|
98 * be initialized. |
|
99 */ |
|
100 inline TVSStillImageDataProviderParams( const TFileName& aFileName ); |
|
101 |
|
102 public: |
|
103 // Initialization type |
|
104 TInitialize iInitialize; |
|
105 |
|
106 // Filename for EInitializeFromFile |
|
107 TFileName iFileName; |
|
108 }; |
|
109 |
|
110 typedef TPckgBuf< TVSStillImageDataProviderParams > TVSStillImageDataProviderParamsBuf; |
|
111 |
|
112 /** |
|
113 * An interface to access free MMF buffers. |
|
114 * |
|
115 * @lib videosource.lib |
|
116 */ |
|
117 class MVSBufferPool |
|
118 { |
|
119 public: |
|
120 |
|
121 /** |
|
122 * Pure virtual function to get next free buffer from free buffer pool. |
|
123 * @param "aRemove" Boolean flag. If ETrue buffer will be removed from |
|
124 * the pool. |
|
125 * @exception Can leave with one of the system wide error codes. |
|
126 * @return Returns pointer to next available buffer in free buffers |
|
127 * queue or NULL if no buffers in queue are available. |
|
128 */ |
|
129 virtual CVSMMFDataBuffer* GetBufferL( TBool aRemove ) = 0; |
|
130 |
|
131 /** |
|
132 * Frees buffer that was previously got using GetBufferL(). |
|
133 * @param "aBuffer" Buffer to be freed. |
|
134 * @exception Can leave with one of the system wide error codes. |
|
135 */ |
|
136 virtual void FreeBufferL( CVSMMFDataBuffer* aBuffer ) = 0; |
|
137 }; |
|
138 |
|
139 /** |
|
140 * An interface to a controller callback functions. |
|
141 * |
|
142 * @lib videosource.lib |
|
143 */ |
|
144 class MVSControllerObserver |
|
145 { |
|
146 public: |
|
147 |
|
148 /** |
|
149 * Called when provider count has been changed. |
|
150 * @param "aAttached" ETrue if provider attached, else EFalse. |
|
151 */ |
|
152 virtual void vsProvidersChanged( TBool aAttached ) = 0; |
|
153 }; |
|
154 |
|
155 /** |
|
156 * Controller interface. |
|
157 * |
|
158 * @lib videosource.lib |
|
159 */ |
|
160 class CVSController : public CBase |
|
161 { |
|
162 public: // Constructor and destructor |
|
163 |
|
164 /** |
|
165 * Static factory function to create instance of this class. |
|
166 * @param "aObserver" Pointer to controller observer. |
|
167 * @exception Can leave with one of the system wide error codes. |
|
168 * @return Pointer to new instance. |
|
169 */ |
|
170 IMPORT_C static CVSController* NewL( MVSControllerObserver* aObserver ); |
|
171 |
|
172 /** |
|
173 * Pure virtual function to create data source instance. |
|
174 * @param "aObserver" Pointer to data source observer. |
|
175 * @exception Can leave with one of the system wide error codes. |
|
176 * @return Pointer to new data source instance. |
|
177 */ |
|
178 virtual CVSDataSource* CreateDataSourceL( |
|
179 MVSDataSourceObserver* aObserver ) = 0; |
|
180 |
|
181 public: // New functions |
|
182 |
|
183 /** |
|
184 * Pure virtual function to return provider count and provider index. |
|
185 * @return Number of providers available. Count also acts as zero based |
|
186 * provider index. |
|
187 */ |
|
188 virtual TInt ProvidersAvailable() = 0; |
|
189 |
|
190 /** |
|
191 * Pure virtual function to return provider information. |
|
192 * @param "aProviderIndex" Index of the provider to return information |
|
193 * for. |
|
194 * @param "aInfo" Reference to the variable where the provider |
|
195 * information is copied. |
|
196 * @exception Can leave with one of the system wide error codes. |
|
197 */ |
|
198 virtual void ProviderInfoL( |
|
199 TInt aProviderIndex, |
|
200 TVSDataProviderInfo& aInfo ) = 0; |
|
201 |
|
202 /** |
|
203 * Pure virtual function to create provider instance. |
|
204 * @param "aProviderIndex" Index of the provider to be created. |
|
205 * @param "aObserver" Pointer to provider observer. |
|
206 * @param "aPool" Pointer to data MVSBufferPool that gives buffer to |
|
207 * data provider. |
|
208 * @exception Can leave with one of the system wide error codes. |
|
209 * @return Pointer to new provider instance. |
|
210 */ |
|
211 virtual CVSDataProvider* CreateDataProviderL( |
|
212 TInt aProviderIndex, |
|
213 MVSDataProviderObserver* aObserver, |
|
214 MVSBufferPool* aPool ) = 0; |
|
215 |
|
216 public: // Constructor and destructor |
|
217 |
|
218 public: // Functions from base classes |
|
219 |
|
220 protected: // New functions |
|
221 |
|
222 /** |
|
223 * C++ default constructor. |
|
224 */ |
|
225 CVSController(); |
|
226 |
|
227 /** |
|
228 * Inliner to return reference to the controller observer. |
|
229 * @return Reference to the controller observer. |
|
230 */ |
|
231 inline MVSControllerObserver& Observer() const; |
|
232 |
|
233 protected: // Constructor and destructor |
|
234 |
|
235 /** |
|
236 * 2nd phase constructor. |
|
237 * @param "aObserver" Pointer to controller observer |
|
238 * @exception Can leave with one of the system wide error codes. |
|
239 */ |
|
240 virtual void ConstructL( MVSControllerObserver* aObserver ) = 0; |
|
241 |
|
242 protected: // Functions from base classes |
|
243 |
|
244 public: // Data |
|
245 |
|
246 protected: // Data |
|
247 |
|
248 // Pointer to controller observer |
|
249 MVSControllerObserver* iObserver; |
|
250 |
|
251 private: // Data |
|
252 |
|
253 }; |
|
254 |
|
255 /** |
|
256 * An interface to a provider callback functions. |
|
257 * |
|
258 * @lib videosource.lib |
|
259 */ |
|
260 class MVSDataProviderObserver |
|
261 { |
|
262 public: |
|
263 |
|
264 /** |
|
265 * Called when an error occurred in provider. |
|
266 * @param "aError" of the system wide error codes. |
|
267 */ |
|
268 virtual void vsProviderError( TInt aError ) = 0; |
|
269 |
|
270 /** |
|
271 * Called when provider is initalized. |
|
272 */ |
|
273 virtual void vsProviderReady() = 0; |
|
274 |
|
275 /** |
|
276 * Called when provider has view finder bitmap ready. |
|
277 * @param "aFrame" Reference to the view finder bitmap. |
|
278 */ |
|
279 virtual void vsViewFinderFrameReady( CFbsBitmap& aFrame ) = 0; |
|
280 }; |
|
281 |
|
282 /** |
|
283 * Extension to standard ECam TCameraInfo class. |
|
284 * |
|
285 * @lib videosource.lib |
|
286 */ |
|
287 class TVSDataProviderInfo : public TCameraInfo |
|
288 { |
|
289 public: // Data |
|
290 |
|
291 // ETrue if the Freeze() is supported. |
|
292 TBool iFreezeSupported; |
|
293 |
|
294 // Pointer to extension information. |
|
295 TAny* iExtension; |
|
296 |
|
297 // A bitfield of suported colortones |
|
298 TUint32 iSupportedColorTones; |
|
299 }; |
|
300 |
|
301 /** |
|
302 * Provider interface. |
|
303 * |
|
304 * @lib videosource.lib |
|
305 */ |
|
306 class CVSDataProvider : public CBase |
|
307 { |
|
308 public: // Constructor and destructor |
|
309 |
|
310 /** |
|
311 * Static factory function to create instance of this class. |
|
312 * @param "aProviderIndex" Index of the provider to be created. |
|
313 * @param "aObserver" Pointer to data provider observer. |
|
314 * @param "aPool" Pointer to data MVSBufferPool that gives buffer to |
|
315 * data provider. |
|
316 * @exception Can leave with one of the system wide error codes. |
|
317 * @return Pointer to new instance. |
|
318 */ |
|
319 static CVSDataProvider* NewL( |
|
320 TInt aProviderIndex, |
|
321 MVSDataProviderObserver* aObserver, |
|
322 MVSBufferPool* aPool ); |
|
323 |
|
324 /** |
|
325 * Destructor. |
|
326 */ |
|
327 ~CVSDataProvider(); |
|
328 |
|
329 public: // New functions |
|
330 |
|
331 /** |
|
332 * Static function get provider count and provider index. |
|
333 * @return Number of providers available. Count also acts as zero based |
|
334 * provider index. |
|
335 */ |
|
336 static TInt ProvidersAvailable(); |
|
337 |
|
338 /** |
|
339 * Static function to return provider information. |
|
340 * @param "aProviderIndex" Index of the provider to return information |
|
341 * for. |
|
342 * @param "aInfo" Reference to the variable to where the provider |
|
343 * information is copied. |
|
344 * @exception Can leave with one of the system wide error codes. |
|
345 */ |
|
346 static void ProviderInfoL( |
|
347 TInt aProviderIndex, |
|
348 TVSDataProviderInfo& aInfo ); |
|
349 |
|
350 /** |
|
351 * Pure virtual function to initialize provider. |
|
352 * @param "aInitParams" Reference to the initialization parameters. |
|
353 * @exception Can leave with one of the system wide error codes. |
|
354 */ |
|
355 virtual void InitializeL( const TDesC8& aInitParams ) = 0; |
|
356 |
|
357 /** |
|
358 * Pure virtual function to cancel initialization of provider. |
|
359 */ |
|
360 virtual void CancelInitializing() = 0; |
|
361 |
|
362 /** |
|
363 * Pure virtual function to return digital zoom factor. |
|
364 * @return Digital zoom factor. |
|
365 */ |
|
366 virtual TInt DigitalZoomFactor() const = 0; |
|
367 |
|
368 /** |
|
369 * Pure virtual function to set digital zoom factor. |
|
370 * @param "aDigitalZoomFactor" Digital zoom factor. |
|
371 * @exception Can leave with one of the system wide error codes. |
|
372 */ |
|
373 virtual void SetDigitalZoomFactorL( TInt aDigitalZoomFactor = 0 ) = 0; |
|
374 |
|
375 /** |
|
376 * Pure virtual function to start view finder bitmaps. |
|
377 * @param "aSize" Size of the returned view finder bitmap. |
|
378 * @exception Can leave with one of the system wide error codes. |
|
379 */ |
|
380 virtual void StartViewFinderBitmapsL( TSize& aSize ) = 0; |
|
381 |
|
382 /** |
|
383 * Pure virtual function to start view finder bitmaps. |
|
384 * @param "aSize" Size of the returned view finder bitmap. |
|
385 * @param "aClipRect" Required clip rectangle. |
|
386 * @exception Can leave with one of the system wide error codes. |
|
387 */ |
|
388 virtual void StartViewFinderBitmapsL( |
|
389 TSize& aSize, |
|
390 TRect& aClipRect ) = 0; |
|
391 |
|
392 /** |
|
393 * Pure virtual function to start view finder bitmaps using direct |
|
394 * screen access. |
|
395 * @param "aWs" Window server session. |
|
396 * @param "aScreenDevice" Screen device. |
|
397 * @param "aWindow" Displayable window. |
|
398 * @param "aScreenRect" Portion of the screen to which view finder data |
|
399 * is to be transferred. |
|
400 * @exception Can leave with one of the system wide error codes. |
|
401 */ |
|
402 virtual void StartViewFinderDirectL( |
|
403 RWsSession& aWs, |
|
404 CWsScreenDevice& aScreenDevice, |
|
405 RWindowBase& aWindow, |
|
406 TRect& aScreenRect ) = 0; |
|
407 |
|
408 /** |
|
409 * Pure virtual function to start view finder bitmaps using direct |
|
410 * screen access. |
|
411 * @param "aWs" Window server session. |
|
412 * @param "aScreenDevice" Screen device. |
|
413 * @param "aWindow" Displayable window. |
|
414 * @param "aScreenRect" Portion of the screen to which view finder data |
|
415 * is to be transferred. |
|
416 * @param "aClipRect" The rectangle to which the screen will be clipped. |
|
417 * @exception Can leave with one of the system wide error codes. |
|
418 */ |
|
419 virtual void StartViewFinderDirectL( |
|
420 RWsSession& aWs, |
|
421 CWsScreenDevice& aScreenDevice, |
|
422 RWindowBase& aWindow, |
|
423 TRect& aScreenRect, |
|
424 TRect& aClipRect ) = 0; |
|
425 |
|
426 /** |
|
427 * Pure virtual function to test if view finder is active. |
|
428 * @return ETrue if view finder active. |
|
429 */ |
|
430 virtual TBool ViewFinderActive() const = 0; |
|
431 |
|
432 /** |
|
433 * Pure virtual function to stop view finder bitmaps. |
|
434 */ |
|
435 virtual void StopViewFinder() = 0; |
|
436 |
|
437 /** |
|
438 * Pure virtual function to return provider information. |
|
439 * @param "aInfo" Reference to the variable to where the provider |
|
440 * information is copied. |
|
441 */ |
|
442 virtual void ProviderInfo( TVSDataProviderInfo& aInfo ) = 0; |
|
443 |
|
444 /** |
|
445 * Used to switch between what the camera sees and what you would see |
|
446 * if the device were a mirror. |
|
447 * @param "aMirror" ETrue to set mirroring on, EFalse to set mirroring off. |
|
448 * @exception May leave with KErrNotSupported. |
|
449 */ |
|
450 virtual void SetViewFinderMirrorL( TBool aMirror ) = 0; |
|
451 |
|
452 /** |
|
453 * Gets whether view finder mirroring is active. |
|
454 * @return ETrue if mirroring is set, EFalse if mirroring is not set. |
|
455 */ |
|
456 virtual TBool ViewFinderMirror() const = 0; |
|
457 |
|
458 /** |
|
459 * Freezes video (i.e. starts sending the last frame until provider is |
|
460 * unfrozen). |
|
461 * @exception May leave with KErrNotSupported if freezing is not supported |
|
462 * by the provider. |
|
463 */ |
|
464 virtual void FreezeL() = 0; |
|
465 |
|
466 /** |
|
467 * Unfreezes video (i.e. starts sending actual frames). |
|
468 * @exception May leave with KErrNotSupported if freezing |
|
469 * is not supported |
|
470 * by the provider. |
|
471 */ |
|
472 virtual void UnfreezeL()= 0; |
|
473 |
|
474 /** |
|
475 * Gets whether freeze is active. |
|
476 * @return ETrue if video is frozen, EFalse otherwise. |
|
477 */ |
|
478 virtual TBool IsFrozen() const = 0; |
|
479 |
|
480 /** |
|
481 * Sets the contrast adjustment of the device. |
|
482 * This must be in the range of -100 to +100 or EContrastAuto. |
|
483 * May leave with KErrNotSupported if the specified contrast value |
|
484 * is out of range. |
|
485 * @since S60 v3.2 |
|
486 * @param aContrast |
|
487 */ |
|
488 virtual void SetContrastL( TInt aContrast ) = 0; |
|
489 |
|
490 /** |
|
491 * Gets the currently set contrast value. |
|
492 * @since S60 v3.2 |
|
493 * @param aContrast The currently set contrast value. |
|
494 * @return indication if method succeed or not. |
|
495 */ |
|
496 virtual TInt GetContrast( TInt& aContrast ) const = 0; |
|
497 |
|
498 /** |
|
499 * Sets the brightness adjustment of the device. |
|
500 * This must be in the range of -100 to +100 or EBrightnessAuto. |
|
501 * May leave with KErrNotSupported if the brightness adjustment |
|
502 * is out of range. |
|
503 * @since S60 v3.2 |
|
504 * @param aBrightness The required brightness adjustment. |
|
505 */ |
|
506 virtual void SetBrightnessL( TInt aBrightness ) = 0; |
|
507 |
|
508 /** |
|
509 * Gets the currently set brightness adjustment value. |
|
510 * @since S60 v3.2 |
|
511 * @param aBrightness The currently set brightness adjustment value. |
|
512 * @return indication if method succeed or not. |
|
513 */ |
|
514 virtual TInt GetBrightness( TInt& aBrightness ) const = 0; |
|
515 |
|
516 /** |
|
517 * Sets the white balance adjustment of the device. |
|
518 * No effect if this is not supported, see |
|
519 * TCameraInfo::iWhiteBalanceModesSupported. |
|
520 * @since S60 v3.2 |
|
521 * @param aWhiteBalance The required white balance adjustment. |
|
522 * @leave KErrNotSupported if the specified white balance adjustment |
|
523 * is invalid. |
|
524 */ |
|
525 virtual void SetWhiteBalanceL( |
|
526 CCamera::TWhiteBalance aWhiteBalance = CCamera::EWBAuto) = 0; |
|
527 |
|
528 /** |
|
529 * Gets the currently set white balance adjustment value. |
|
530 * @since S60 v3.2 |
|
531 * @param aWhiteBalance The currently set white balance adjustment value. |
|
532 * @return indication if method succeed or not. |
|
533 */ |
|
534 virtual TInt GetWhiteBalance( |
|
535 CCamera::TWhiteBalance& aWhiteBalance ) const = 0; |
|
536 |
|
537 /** |
|
538 * Gives the current color tone setting value |
|
539 * @since S60 v3.2 |
|
540 * @param aColorTone The currently set color tone adjustment value. |
|
541 * @return indication if method succeed or not. |
|
542 */ |
|
543 virtual TInt GetColorTone( |
|
544 CCamera::CCameraImageProcessing::TEffect& aColorTone ) const = 0; |
|
545 |
|
546 /** |
|
547 * Sets color tone |
|
548 * @since S60 v3.2 |
|
549 * @param aValue new color tone |
|
550 */ |
|
551 virtual void SetColorToneL( |
|
552 CCamera::CCameraImageProcessing::TEffect aValue ) = 0; |
|
553 |
|
554 public: // Functions from base classes |
|
555 |
|
556 protected: // New functions |
|
557 |
|
558 protected: // Functions from base classes |
|
559 |
|
560 private: // New functions |
|
561 |
|
562 /** |
|
563 * See MDataSource for description. |
|
564 */ |
|
565 virtual void FillBufferL( |
|
566 CMMFBuffer* aBuffer, |
|
567 MVTVideoSink* aConsumer, |
|
568 TMediaId aMediaId ) = 0; |
|
569 |
|
570 /** |
|
571 * See MDataSource for description. |
|
572 */ |
|
573 virtual TInt SourceThreadLogon( MAsyncEventHandler& aEventHandler ) = 0; |
|
574 |
|
575 /** |
|
576 * See MDataSource for description. |
|
577 */ |
|
578 virtual void SourceThreadLogoff() = 0; |
|
579 |
|
580 /** |
|
581 * See MDataSource for description. |
|
582 */ |
|
583 virtual void SourcePrimeL() = 0; |
|
584 |
|
585 /** |
|
586 * See MDataSource for description. |
|
587 */ |
|
588 virtual void SourcePlayL() = 0; |
|
589 |
|
590 /** |
|
591 * See MDataSource for description. |
|
592 */ |
|
593 virtual void SourcePauseL() = 0; |
|
594 |
|
595 /** |
|
596 * See MDataSource for description. |
|
597 */ |
|
598 virtual void SourceStopL() = 0; |
|
599 |
|
600 private: // New functions |
|
601 |
|
602 /** |
|
603 * See MVTVideoInput for description. |
|
604 */ |
|
605 virtual void SetFormatL( const TDesC8& aFormat ) = 0; |
|
606 |
|
607 /** |
|
608 * See MVTVideoInput for description. |
|
609 */ |
|
610 virtual void SetFrameRateL( TReal32 aFrameRate ) = 0; |
|
611 |
|
612 /** |
|
613 * See MVTVideoInput for description. |
|
614 */ |
|
615 virtual void SetVideoFrameSizeL( const TSize& aSize ) = 0; |
|
616 |
|
617 /** |
|
618 * See MVTVideoInput for description. |
|
619 */ |
|
620 virtual void GetVideoFrameSizeL( TSize& aSize ) const = 0; |
|
621 |
|
622 private: // Functions from base classes |
|
623 |
|
624 protected: // New functions |
|
625 |
|
626 /** |
|
627 * This version of prime method will be called when a provider |
|
628 * is being switched. |
|
629 * @exception Can leave with one of the system wide error codes. |
|
630 */ |
|
631 virtual void PrimeL() = 0; |
|
632 |
|
633 /** |
|
634 * Inliner to test if FillBufferL call is active. |
|
635 * @return ETrue if FillBufferL call is ongoing, else EFalse. |
|
636 */ |
|
637 inline TBool FillBufferActive() const; |
|
638 |
|
639 /** |
|
640 * Inliner to return the sink that will empty the buffer. |
|
641 * @return Pointer to sink. |
|
642 */ |
|
643 inline MVTVideoSink* Consumer() const; |
|
644 |
|
645 /** |
|
646 * Inliner to return sink media ID that is used. |
|
647 * @return Media ID identifiyng the stream that is used. |
|
648 */ |
|
649 inline TMediaId MediaId() const; |
|
650 |
|
651 /** |
|
652 * Inliner to return reference to the provider observer. |
|
653 * @return Reference to the provider observer. |
|
654 */ |
|
655 inline MVSDataProviderObserver& Observer() const; |
|
656 |
|
657 /** |
|
658 * Saves input parameters given in FillBufferL call. |
|
659 * @param "aConsumer" Pointer to sink that will empty the filled buffer. |
|
660 * @param "aMediaId" Media ID for source/provider stream that is used. |
|
661 */ |
|
662 virtual void SetFillBufferParams( |
|
663 MVTVideoSink* aConsumer, |
|
664 TMediaId aMediaId ); |
|
665 |
|
666 /** |
|
667 * Notify observer about provider error. |
|
668 * @param "aError" Error code |
|
669 */ |
|
670 void NotifyError( TInt aError ); |
|
671 |
|
672 /** |
|
673 * Inliner to return reference to the buffer pool. |
|
674 * @return Reference to the buffer pool. |
|
675 */ |
|
676 inline MVSBufferPool& BufferPool() const; |
|
677 |
|
678 protected: // Constructor and destructor |
|
679 |
|
680 /** |
|
681 * C++ default constructor. |
|
682 */ |
|
683 CVSDataProvider(); |
|
684 |
|
685 /** |
|
686 * Constructor. |
|
687 * @param "aObserver" Pointer to provider observer. |
|
688 */ |
|
689 CVSDataProvider( |
|
690 MVSDataProviderObserver* aObserver, |
|
691 MVSBufferPool* aPool ); |
|
692 |
|
693 /** |
|
694 * 2nd phase constructor. |
|
695 * @exception Can leave with one of the system wide error codes. |
|
696 */ |
|
697 void ConstructL(); |
|
698 |
|
699 /** |
|
700 * Returns microseconds from the first SourcePlayL() call. |
|
701 */ |
|
702 const TTimeIntervalMicroSeconds& TimeToPlay(); |
|
703 |
|
704 /** |
|
705 * Resets start time (the time when SourcePlayL() was called). |
|
706 * iStartTime is set to TTime::HomeTime(). |
|
707 */ |
|
708 void ResetStartTime(); |
|
709 |
|
710 private: // New functions |
|
711 |
|
712 /** |
|
713 * |
|
714 */ |
|
715 static TInt CamerasAvailable(); |
|
716 |
|
717 /** |
|
718 * Sets timestamp for first SourcePlayL() call. This method |
|
719 * is called by the CVSDataSource when data provider is switched. |
|
720 */ |
|
721 void SwitchFrom( const CVSDataProvider& anOldProvider ); |
|
722 |
|
723 /** |
|
724 * Enumerate all providers and create a set of formats that is supported |
|
725 * by all of them. |
|
726 */ |
|
727 static void EnumerateVideoFrameFormatsL( |
|
728 CDesC8Array* aSupportedFormats ); |
|
729 |
|
730 /** |
|
731 * Enumerate all providers and create a set of video frame sizes that |
|
732 * is supported by all of them. |
|
733 */ |
|
734 static void EnumerateVideoFrameSizesL( |
|
735 RArray<TSize>& aSupportedSizes, |
|
736 const TDesC8& aFormat ); |
|
737 |
|
738 /** |
|
739 * Enumerate all providers and create a set of video frame rates that |
|
740 * is supported by all of them. |
|
741 */ |
|
742 static void EnumerateVideoFrameRatesL( |
|
743 RArray<TReal32>& aSupportedRates, |
|
744 const TDesC8& aFormat, |
|
745 const TSize& aSize ); |
|
746 |
|
747 protected: // New functions |
|
748 |
|
749 /** |
|
750 * Get video frame size. Implemented in each provider. |
|
751 */ |
|
752 virtual void GetVideoFrameSize( |
|
753 TSize& aSize, |
|
754 TInt aSizeIndex, |
|
755 const TDesC8& aFormat ) = 0; |
|
756 |
|
757 /** |
|
758 * Get video frame rate. Implemented in each provider. |
|
759 */ |
|
760 virtual void GetVideoFrameRate( |
|
761 TReal32& aRate, |
|
762 TInt aRateIndex, |
|
763 const TDesC8& aFormat, |
|
764 const TSize& aSize ) = 0; |
|
765 |
|
766 public: // Data |
|
767 |
|
768 protected: // Data |
|
769 |
|
770 // Boolean that is ETrue when FillBufferL call is active. |
|
771 TBool iFillBufferActive; |
|
772 |
|
773 // Sink that empties the buffer filled with video frame. Not owned. |
|
774 MVTVideoSink* iConsumer; |
|
775 |
|
776 // Provider's media ID identifying media stream used. |
|
777 TMediaId iMediaId; |
|
778 |
|
779 private: // Data |
|
780 |
|
781 // Pointer to provider observer. |
|
782 MVSDataProviderObserver* iObserver; |
|
783 |
|
784 // Pointer to AO that reports provider errors to provider observer, |
|
785 // used through NotifyError call. |
|
786 CProviderErrorNotifierAO* iErrorNotifier; |
|
787 |
|
788 // Pointer to buffer pool |
|
789 MVSBufferPool* iPool; |
|
790 |
|
791 // Previous TimeToPlay interval |
|
792 TTimeIntervalMicroSeconds iPreviousTimeToPlay; |
|
793 |
|
794 // Start time (time when SourcePlayL() was called) |
|
795 TTime iStartTime; |
|
796 |
|
797 private: // Data |
|
798 |
|
799 // Source is friend because it's MDataSource and MVTVideoInput derived |
|
800 // calls are forwarded to provider. |
|
801 friend class CVSDataSource; |
|
802 |
|
803 // Source is friend because it's MDataSource and MVTVideoInput derived |
|
804 // calls are forwarded to provider. |
|
805 friend class CVSDataSourceImp; |
|
806 }; |
|
807 |
|
808 /** |
|
809 * An interface to a data source callback functions. |
|
810 * |
|
811 * @lib videosource.lib |
|
812 */ |
|
813 class MVSDataSourceObserver |
|
814 { |
|
815 public: |
|
816 |
|
817 /** |
|
818 * Called when provider switch completed. |
|
819 * @param "aOldProvider" Pointer provider that was previously active. |
|
820 */ |
|
821 virtual void vsProviderSwitchDone( CVSDataProvider* aOldProvider ) = 0; |
|
822 }; |
|
823 |
|
824 /** |
|
825 * Data source interface. |
|
826 * |
|
827 * @lib videosource.lib |
|
828 */ |
|
829 class CVSDataSource : |
|
830 public CBase, |
|
831 public MVTVideoSource, |
|
832 public MVSBufferPool |
|
833 { |
|
834 public: // Constructor and destructor |
|
835 |
|
836 /** |
|
837 * Static factory function to create data source instance. |
|
838 * @param "aObserver" Pointer to data source observer. |
|
839 * @exception Can leave with one of the system wide error codes. |
|
840 * @return Pointer to data source instance. |
|
841 */ |
|
842 static CVSDataSource* NewSourceL( MVSDataSourceObserver* aObserver ); |
|
843 |
|
844 public: // New functions |
|
845 |
|
846 /** |
|
847 * Pure virtual function to switch active provider for source. |
|
848 * @param "aNewProvider" Pointer to provider instance. |
|
849 * @exception Can leave with one of the system wide error codes. |
|
850 */ |
|
851 virtual void SwitchDataProviderL( CVSDataProvider* aNewProvider ) = 0; |
|
852 |
|
853 /** |
|
854 * Temporarily pause video sending. Used during initialization. |
|
855 */ |
|
856 virtual void PauseSending() = 0; |
|
857 |
|
858 /** |
|
859 * Resume video sending. Used during initialization. |
|
860 */ |
|
861 virtual void ResumeSending() = 0; |
|
862 |
|
863 public: // Functions from base classes |
|
864 |
|
865 protected: // New functions |
|
866 |
|
867 /** |
|
868 * Inliner to return reference to the data source observer. |
|
869 * @return Reference to the data source observer. |
|
870 */ |
|
871 inline MVSDataSourceObserver& Observer() const; |
|
872 |
|
873 /** |
|
874 * Inliner to return reference to the provider that is active. |
|
875 * @return Reference to the provider. |
|
876 */ |
|
877 inline CVSDataProvider& DataProvider() const; |
|
878 |
|
879 /** |
|
880 * Inliner to update member variable holding pointer to provider with |
|
881 * new provider pointer. |
|
882 * @param "aNewProvider" Pointer to (new) provider. |
|
883 * @return Pointer to (old) provider. |
|
884 */ |
|
885 inline CVSDataProvider* SwitchProvider( CVSDataProvider* aNewProvider ); |
|
886 |
|
887 protected: // Constructor and destructor |
|
888 |
|
889 /** |
|
890 * Constructor. |
|
891 */ |
|
892 CVSDataSource(); |
|
893 |
|
894 private: // Constructor and destructor |
|
895 |
|
896 /** |
|
897 * 2nd phase consturctor. |
|
898 * @param "aObserver" Pointer to data source observer. |
|
899 * @exception Can leave with one of the system wide error codes. |
|
900 */ |
|
901 void ConstructL( MVSDataSourceObserver* aObserver ); |
|
902 |
|
903 private: // New functions |
|
904 |
|
905 private: // Functions from base classes |
|
906 |
|
907 public: // Data |
|
908 |
|
909 protected: // Data |
|
910 |
|
911 private: // Data |
|
912 |
|
913 // Pointer to data source observer. |
|
914 MVSDataSourceObserver* iObserver; |
|
915 |
|
916 // Pointer to active provider. |
|
917 CVSDataProvider* iProvider; |
|
918 }; |
|
919 |
|
920 #include "capivideosource.inl" |
|
921 |
|
922 #endif // CAPIVIDEOSOURCE_H |