vtprotocolplugins/VideoSource/inc/CVSStillImageDataProvider.h
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     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 CVSSTILLIMTAGEDATAPROVIDER_H
       
    20 #define CVSSTILLIMTAGEDATAPROVIDER_H
       
    21 
       
    22 // INCLUDE FILES
       
    23 
       
    24 #include <gdi.h>
       
    25 #include "CApiVideoSource.h"
       
    26 #include "cvtimagescaler.h"
       
    27 #include <ecamimageprocessing.h>
       
    28 
       
    29 #include "cactivewait.h"
       
    30 #include "mmultiframeprovider.h"
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 
       
    34 class CImageDecoder;
       
    35 class CVSStillImageDataProvider;
       
    36 class CVSFrameRateTimer;
       
    37 class CVtImageBitmap;
       
    38 class CMultiframeProvider;
       
    39 
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 /**
       
    44 *  Internal implementation of still image data provider. This
       
    45 *  class is inherited from from public provider interface.
       
    46 *
       
    47 *  @lib videosource.lib
       
    48 */
       
    49 class CVSStillImageDataProvider : public CVSDataProvider, MMultiframeprovider
       
    50     {
       
    51     public:        // Constructors and destructor
       
    52 
       
    53         /**
       
    54         * Static factory function create instance of this class.
       
    55         * @param "aObserver" Pointer to provider observer.
       
    56         * @param "aPool" Pointer to data MVSBufferPool that gives buffer to
       
    57         * data provider.
       
    58         * @exception Can leave with one of the system wide error codes.
       
    59         * @return Pointer to new instance.
       
    60         */
       
    61         static CVSStillImageDataProvider* NewL(
       
    62             MVSDataProviderObserver* aObserver,
       
    63             MVSBufferPool* aPool );
       
    64 
       
    65         /**
       
    66         * Destructor.
       
    67         */
       
    68         ~CVSStillImageDataProvider();
       
    69 
       
    70     public:        // New functions
       
    71 
       
    72     public:        // Functions from base classes
       
    73 
       
    74         /**
       
    75         * Initialize provider.
       
    76         * @param "aInitParams" Reference to the initialization parameters.
       
    77         * @exception Can leave with one of the system wide error codes.
       
    78         */
       
    79         void InitializeL( const TDesC8& aInitParams );
       
    80 
       
    81         /**
       
    82         * Cancel initialization of still image provider.
       
    83         */
       
    84         void CancelInitializing();
       
    85 
       
    86         /**
       
    87         * Return digital zoom factor.
       
    88         * @return Digital zoom factor.
       
    89         */
       
    90         virtual TInt DigitalZoomFactor() const;
       
    91 
       
    92         /**
       
    93         * Set digital zoom factor.
       
    94         * @param "aDigitalZoomFactor" Digital zoom factor.
       
    95         * @exception Can leave with one of the system wide error codes.
       
    96         */
       
    97         virtual void SetDigitalZoomFactorL( TInt aDigitalZoomFactor = 0 );
       
    98 
       
    99         /**
       
   100         * Start view finder bitmaps.
       
   101         * @param "aSize" Size of the returned view finder bitmap.
       
   102         * @exception Can leave with one of the system wide error codes.
       
   103         */
       
   104         virtual void StartViewFinderBitmapsL( TSize& aSize );
       
   105 
       
   106         /**
       
   107         * Start view finder bitmaps.
       
   108         * @param "aSize" Size of the returned view finder bitmap.
       
   109         * @param "aClipRect" Required clip rectangle.
       
   110         * @exception Can leave with one of the system wide error codes.
       
   111         */
       
   112         virtual void StartViewFinderBitmapsL( TSize& aSize,TRect& aClipRect );
       
   113 
       
   114         /**
       
   115         * Stop view finder bitmaps.
       
   116         */
       
   117         virtual void StopViewFinder();
       
   118 
       
   119         /**
       
   120         * Test if view finder is active.
       
   121         * @return ETrue if view finder active.
       
   122         */
       
   123         virtual TBool ViewFinderActive() const;
       
   124 
       
   125         /**
       
   126         * Start view finder bitmaps using direct screen access.
       
   127         * @param "aWs" Window server session.
       
   128         * @param "aScreenDevice" Screen device.
       
   129         * @param "aWindow" Displayable window.
       
   130         * @param "aScreenRect" Portion of the screen to which view finder data
       
   131         * is to be transferred.
       
   132         * @exception Can leave with one of the system wide error codes.
       
   133         */
       
   134         virtual void StartViewFinderDirectL(
       
   135             RWsSession& aWs,
       
   136             CWsScreenDevice& aScreenDevice,
       
   137             RWindowBase& aWindow,
       
   138             TRect& aScreenRect );
       
   139 
       
   140         /**
       
   141         * Start view finder bitmaps using direct screen access.
       
   142         * @param "aWs" Window server session.
       
   143         * @param "aScreenDevice" Screen device.
       
   144         * @param "aWindow" Displayable window.
       
   145         * @param "aScreenRect" Portion of the screen to which view finder data
       
   146         * is to be transferred.
       
   147         * @param "aClipRect" The rectangle to which the screen will be clipped.
       
   148         * @exception Can leave with one of the system wide error codes.
       
   149         */
       
   150         virtual void StartViewFinderDirectL(
       
   151             RWsSession& aWs,
       
   152             CWsScreenDevice& aScreenDevice,
       
   153             RWindowBase& aWindow,
       
   154             TRect& aScreenRect,
       
   155             TRect& aClipRect );
       
   156 
       
   157         /**
       
   158         * Return provider information.
       
   159         * @param @param "aInfo" Reference to variable to where the provider
       
   160         * information is copied.
       
   161         */
       
   162         virtual void ProviderInfo( TVSDataProviderInfo& aInfo );
       
   163 
       
   164         /**
       
   165         * See CVSDataProvider for description.
       
   166         */
       
   167         virtual void SetViewFinderMirrorL( TBool aMirror );
       
   168 
       
   169         /**
       
   170         * See CVSDataProvider for description.
       
   171         */
       
   172         virtual TBool ViewFinderMirror() const;
       
   173 
       
   174         /**
       
   175         * See CVSDataProvider for description.
       
   176         */
       
   177         virtual void FreezeL();
       
   178 
       
   179         /**
       
   180         * See CVSDataProvider for description.
       
   181         */
       
   182         virtual void UnfreezeL();
       
   183 
       
   184         /**
       
   185         * See CVSDataProvider for description.
       
   186         */
       
   187         virtual TBool IsFrozen() const;
       
   188 
       
   189         /**
       
   190         * @See CVSDataProvider::SetContrastL for description.
       
   191         */
       
   192 		virtual void SetContrastL( TInt aContrast );
       
   193 
       
   194         /**
       
   195         * @See CVSDataProvider::GetContrast for description.
       
   196         */
       
   197 		virtual TInt GetContrast( TInt& aContrast ) const;
       
   198 
       
   199         /**
       
   200         * @See CVSDataProvider::SetBrightnessL for description.
       
   201         */
       
   202 		virtual void SetBrightnessL( TInt aBrightness );
       
   203 
       
   204         /**
       
   205         * @See CVSDataProvider::GetBrightness for description.
       
   206         */
       
   207 		virtual TInt GetBrightness( TInt& aBrightness ) const;
       
   208 
       
   209         /**
       
   210         * @See CVSDataProvider::SetWhiteBalanceL for description.
       
   211         */
       
   212 		virtual void SetWhiteBalanceL(
       
   213 			CCamera::TWhiteBalance aWhiteBalance = CCamera::EWBAuto);
       
   214 
       
   215        	/**
       
   216         * @See CVSDataProvider::GetWhiteBalance for description.
       
   217         */
       
   218 		virtual TInt GetWhiteBalance(
       
   219 			CCamera::TWhiteBalance& aWhiteBalance ) const;
       
   220 
       
   221        	/**
       
   222         * @See CVSDataProvider::GetColorTone for description.
       
   223         */
       
   224         virtual TInt GetColorTone(
       
   225         	CCamera::CCameraImageProcessing::TEffect& aColorTone) const;
       
   226 
       
   227        	/**
       
   228         * @See CVSDataProvider::SetColorToneL for description.
       
   229         */
       
   230         virtual void SetColorToneL(
       
   231         	CCamera::CCameraImageProcessing::TEffect aValue );
       
   232 
       
   233     protected:    // New functions
       
   234 
       
   235     protected:    // Functions from base classes
       
   236 
       
   237     private:    // New functions
       
   238 
       
   239         /**
       
   240         * See CVSDataProvider for description.
       
   241         */
       
   242         void PrimeL();
       
   243 
       
   244     private:
       
   245 
       
   246     private:    // Functions from base classes
       
   247 
       
   248         /**
       
   249         * See MDataSource for description.
       
   250         */
       
   251         virtual void FillBufferL(
       
   252             CMMFBuffer* aBuffer,
       
   253             MVTVideoSink* aConsumer,
       
   254             TMediaId aMediaId );
       
   255 
       
   256     private:
       
   257 
       
   258         /**
       
   259         * See MDataSource for description.
       
   260         */
       
   261         virtual void BufferEmptiedL( CMMFBuffer* aBuffer );
       
   262 
       
   263         /**
       
   264         * See MDataSource for description.
       
   265         */
       
   266         virtual TInt SourceThreadLogon( MAsyncEventHandler& aEventHandler );
       
   267 
       
   268         /**
       
   269         * See MDataSource for description.
       
   270         */
       
   271         virtual void SourceThreadLogoff();
       
   272 
       
   273         /**
       
   274         * See MDataSource for description.
       
   275         */
       
   276         virtual void SourcePrimeL();
       
   277 
       
   278         /**
       
   279         * See MDataSource for description.
       
   280         */
       
   281         virtual void SourcePlayL();
       
   282 
       
   283         /**
       
   284         * See MDataSource for description.
       
   285         */
       
   286         virtual void SourcePauseL();
       
   287 
       
   288         /**
       
   289         * See MDataSource for description.
       
   290         */
       
   291         virtual void SourceStopL();
       
   292 
       
   293     private: // Functions from base classes
       
   294 
       
   295         /**
       
   296         * See MVTVideoInput for description.
       
   297         */
       
   298         virtual void SetFormatL( const TDesC8& aFormat );
       
   299 
       
   300         /**
       
   301         * See MVTVideoInput for description.
       
   302         */
       
   303         virtual void SetFrameRateL( TReal32 aFrameRate );
       
   304 
       
   305         /**
       
   306         * See MVTVideoInput for description.
       
   307         */
       
   308         virtual void SetVideoFrameSizeL( const TSize& aSize );
       
   309 
       
   310         /**
       
   311         * See MVTVideoInput for description.
       
   312         */
       
   313         virtual void GetVideoFrameSizeL( TSize& aSize ) const;
       
   314 
       
   315     private:    // New functions
       
   316 
       
   317         /**
       
   318         * Common initialization of the provider (initializes features
       
   319         * that are always needed by the provider).
       
   320         * @exception Can leave with one of the system wide error codes.
       
   321         */
       
   322         void CommonInitializeL();
       
   323 
       
   324         /**
       
   325         * Undo common initialization of still image data provider.
       
   326         */
       
   327         void UndoCommonInitialized();
       
   328 
       
   329         /**
       
   330         * Loads image that was set in General Settings application.
       
   331         * @param aType Type of of the general settings image.
       
   332         * @exception Can leave with one of the system wide error codes.
       
   333         */
       
   334         void GeneralSettingsInitializeL( const TGeneralSettingsImageType aType );
       
   335 
       
   336         /**
       
   337         * Initializes this instance as blank image instance.
       
   338         * @exception Can leave with one of the system wide error codes.
       
   339         */
       
   340         void BlankImageInitializeL();
       
   341 
       
   342         /**
       
   343         * Initializes this instance from image file.
       
   344         * @param aFileName Name of the file from which this intance will be
       
   345         * initialized.
       
   346         * @exception Can leave with one of the system wide error codes.
       
   347         */
       
   348         void FileImageInitializeL( const TFileName& aFileName );
       
   349 
       
   350         /**
       
   351         * View finder timer callback. This method is called when view finder
       
   352         * needs updating.
       
   353         */
       
   354         void VFTimer();
       
   355 
       
   356         /**
       
   357         * protocol timer callback. This method is called when new frame
       
   358         * will be sent to consumer.
       
   359         */
       
   360         void ProtoTimer();
       
   361 
       
   362         /**
       
   363         * Method for creating timer for protocol. This method is called
       
   364         * in Proto thread context.
       
   365         * @exception Can leave with one of the system wide error codes.
       
   366         */
       
   367         void CreateProtoTimerL();
       
   368 
       
   369         /**
       
   370         * Releases protocol timer. This method is called in Protocol thread
       
   371         * context.
       
   372         */
       
   373         void ReleaseProtoTimer();
       
   374 
       
   375         /**
       
   376         * Creates YUV buffer from still image. This method is called in Protocol
       
   377         * thread context.
       
   378         * @exception Can leave with one of the system wide error codes.
       
   379         */
       
   380         void CreateYUVDataL();
       
   381 
       
   382         /**
       
   383         * Release YUV buffer. This method is called in Protocol thread context.
       
   384         */
       
   385         void ReleaseYUVData();
       
   386 
       
   387     private:    // Constructors and destructor
       
   388 
       
   389         /**
       
   390         * Constructor.
       
   391         * @param "aObserver" Pointer to provider observer.
       
   392         */
       
   393         CVSStillImageDataProvider(
       
   394             MVSDataProviderObserver* aObserver,
       
   395             MVSBufferPool* aPool );
       
   396 
       
   397         /**
       
   398         * 2nd phase constructor.
       
   399         * @exception Can leave with one of the system wide error codes.
       
   400         */
       
   401         void ConstructL();
       
   402 
       
   403     private:    // Functions from base classes
       
   404 
       
   405         /**
       
   406         * Get video frame size.
       
   407         */
       
   408         virtual void GetVideoFrameSize(
       
   409             TSize& aSize,
       
   410             TInt aSizeIndex,
       
   411             const TDesC8& aFormat );
       
   412 
       
   413         /**
       
   414         * Get video frame rate.
       
   415         */
       
   416         virtual void GetVideoFrameRate(
       
   417             TReal32& aRate,
       
   418             TInt aRateIndex,
       
   419             const TDesC8& aFormat,
       
   420             const TSize& aSize );
       
   421 
       
   422         /**
       
   423         * Returns current screen display mode.
       
   424         */
       
   425         TDisplayMode DisplayMode() const;
       
   426 				
       
   427     private:
       
   428         
       
   429         // from MMultiframeprovider
       
   430         /**
       
   431         * @See MMultiframeprovider for description.
       
   432         */
       
   433         virtual void InitializeReady();
       
   434 				
       
   435         /**
       
   436         * @See MMultiframeprovider for description.
       
   437         */
       
   438 				virtual void RefreshYUVData( TImageShareDataBuffer& aYUVBitMap );
       
   439 				
       
   440 				/**
       
   441         * @See MMultiframeprovider for description.
       
   442         */
       
   443 				virtual void RefreshViewFinder( TImageShareDataBuffer& aVFBitMap );
       
   444 				
       
   445 				/**
       
   446         * @See MMultiframeprovider for description.
       
   447         */
       
   448 				virtual void NotifyImageHandlingError( TInt aError );
       
   449 
       
   450     public: // Data
       
   451 
       
   452     protected:  // Data
       
   453 				 RCriticalSection iFreezeCS;
       
   454     private:    // Data
       
   455 
       
   456         // Provider state
       
   457         enum TProviderState
       
   458             {
       
   459             EPSUninitialized,   // Provider is uninitialized
       
   460             EPSStopped,         // Provider is initialized and stopped
       
   461             EPSPrimed,          // Provider is initialized and ready for playing
       
   462             EPSPlaying,         // Provider is playing
       
   463             EPSInitializing,    // Provider is initializing
       
   464             EPSUndoInitializing // Provider is undoinitializing
       
   465             };
       
   466 
       
   467         // Provider state
       
   468         TProviderState iPSState;
       
   469 
       
   470         // View finder state
       
   471         enum TViewFinderState
       
   472             {
       
   473             EVFStopped, // View finder is not started
       
   474             EVFPlaying  // View finder started
       
   475             };
       
   476 
       
   477         // View finder state
       
   478         TViewFinderState iVFState;
       
   479 
       
   480         // Source bitmap's name
       
   481         TFileName iBitmapFileName;
       
   482 
       
   483         // Pointer to view finder timer instance
       
   484         CVSFrameRateTimer* iVFTimer; // owned
       
   485 
       
   486         // Pointer to protocol timer instance
       
   487         CVSFrameRateTimer* iProtoTimer; // owned, created in Proto thread context!
       
   488 
       
   489         // Target image for CVtImageScaler
       
   490         CVtImageBitmap* iScaled;
       
   491         CVtImageBitmap* iYUVBitMap;
       
   492 
       
   493         // Pointer to selected view finder image
       
   494         CVtImageBitmap* iVFCurrent;
       
   495         CVtImageBitmap* iVFBitmap;
       
   496 
       
   497         // Pointer to active waiter instance
       
   498         CVSActiveWait< CVSStillImageDataProvider >* iActiveWait; // owned
       
   499 
       
   500         // Heap descriptor pointer that contains image as YUV
       
   501         HBufC8* iYUVBuffer; // owned, created in Protocol thread context!
       
   502 
       
   503         // Frame counter
       
   504         TUint32 iFrameCount;
       
   505 
       
   506         // protocol timer update rate
       
   507         TInt iProtoUpdateRate;
       
   508 
       
   509         // Rescaling recuirement flag
       
   510         TBool iVFRescalingRequired;
       
   511 
       
   512         // FireServer session instance
       
   513         RFs iFs;
       
   514 
       
   515         // Current display mode
       
   516         TDisplayMode iDisplayMode;
       
   517         
       
   518         // Viewer instance
       
   519         CMultiframeProvider* iViewer; //owned
       
   520         
       
   521         // Traget VF size
       
   522         TSize iTargetSize;
       
   523                 
       
   524         //Record TVSStillImageDataProviderParams::iInitialize in InitializeL(),
       
   525         //used in CancelInitializing call 
       
   526         TVSStillImageDataProviderParams::TInitialize iInitType;
       
   527         
       
   528     };
       
   529 
       
   530 #endif      // CVSSTILLIMTAGEDATAPROVIDER_H
       
   531 
       
   532 // End of File