vtengines/videoteleng/Inc/Media/CVtEngDrawDP.h
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2004-2005 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:  Remote video handling class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CVTENGDRAWDP_H
       
    21 #define CVTENGDRAWDP_H
       
    22 
       
    23 //  INCLUDES
       
    24 
       
    25 #include "CVtEngRemoteVideo.h"
       
    26 #include "TVtEngRenderConfigDP.h"
       
    27 
       
    28 #include <cvtimagescaler.h>
       
    29 
       
    30 // FORWARDS
       
    31 
       
    32 class TDisplaySinkParamsDP;
       
    33 class CVtImageBitmap;
       
    34 class CVtImageScaler;
       
    35 
       
    36 // CONSTANTS AND MACROS
       
    37 
       
    38 const TInt KVtEngMaxBuffers = 2;
       
    39 
       
    40 // CLASSES
       
    41 
       
    42 /**
       
    43 *  Buffer waiter observer API
       
    44 *
       
    45 *  @lib videoteleng.lib
       
    46 *  @since Series 60 3.2
       
    47 */
       
    48 NONSHARABLE_CLASS( MVtEngBufferWaiterObserver )
       
    49     {
       
    50     public: // New methods
       
    51 
       
    52         /**
       
    53         * Buffer fetched without errors.
       
    54         * @param aBuffer Pointer to fetched buffer.
       
    55         */
       
    56         virtual void BufferReady(
       
    57             CPostingSurface::TPostingBuff* aBuffer ) = 0;
       
    58 
       
    59         /**
       
    60         * Buffer fetch error.
       
    61         * @param aError Error code.
       
    62         */
       
    63         virtual void FetchError( TInt aError ) = 0;
       
    64     };
       
    65 
       
    66 /**
       
    67 *  Display Posting drawer
       
    68 *
       
    69 *  @lib videoteleng.lib
       
    70 *  @since Series 60 3.2
       
    71 */
       
    72 NONSHARABLE_CLASS( CVtEngDrawDP ) : public CVtEngRemoteVideo::CVtEngDraw,
       
    73     public MVtEngBufferWaiterObserver,
       
    74     public MVtImageScalerObserver
       
    75 
       
    76     {
       
    77     public: // constructor and destructor
       
    78 
       
    79         /**
       
    80         * Two-phased constructor.
       
    81         * @param aObserver call back interface to Display Sink
       
    82         * @return instance of CVtEngDrawDP
       
    83         */
       
    84         static CVtEngDrawDP* NewL( MDisplaySinkObserver* aObserver );
       
    85 
       
    86         // Destructor
       
    87         ~CVtEngDrawDP();
       
    88 
       
    89     private:
       
    90 
       
    91         /**
       
    92         * C++ constructor as private.
       
    93         * @param aObserver callback interface for Display Sink
       
    94         */
       
    95         CVtEngDrawDP( MDisplaySinkObserver* aObserver );
       
    96 
       
    97     private: // from MVtEngDraw
       
    98 
       
    99          /**
       
   100         * @see CVtEngDraw::BaseConstructL
       
   101         */
       
   102         void BaseConstructL();
       
   103 
       
   104         /**
       
   105         * @see CVtEngDraw::CreateSinkL
       
   106         */
       
   107         MDisplaySink* CreateSinkL();
       
   108 
       
   109         /**
       
   110         * @see CVtEngDraw::BaseRefreshL
       
   111         */
       
   112         void BaseRefreshL();
       
   113 
       
   114         /**
       
   115         * @see CVtEngDraw::BaseRefreshBitmapsL
       
   116         */
       
   117         void BaseRefreshBitmapsL();
       
   118 
       
   119         /**
       
   120         * @see CVtEngDraw::BaseDoCancel
       
   121         */
       
   122         void BaseDoCancel();
       
   123 
       
   124         /**
       
   125         * @see CVtEngDraw::BaseVerifyConfigL
       
   126         */
       
   127         void BaseVerifyConfigL();
       
   128 
       
   129         /**
       
   130         * @see CVtEngDraw::BaseRestartL
       
   131         */
       
   132         void BaseRestartL();
       
   133 
       
   134         /**
       
   135         * @see CVtEngDraw::BaseAbortNow
       
   136         */
       
   137         void BaseAbortNow();
       
   138 
       
   139         /**
       
   140         * @see CVtEngDraw::BaseStartDrawL
       
   141         */
       
   142         void BaseStartDrawL();
       
   143 
       
   144         /**
       
   145         * @see CVtEngDraw::BaseStopDraw
       
   146         */
       
   147         void BaseStopDraw();
       
   148 
       
   149         /**
       
   150         * @see CVtEngDraw::BaseSetConfigL
       
   151         */
       
   152         void BaseSetConfigL( const TVtEngRenderConfig& aConfig );
       
   153 
       
   154         /**
       
   155         * @see CVtEngDraw::BaseSetUIForegroundL
       
   156         */
       
   157         void BaseSetUIForegroundL( TBool aForeground );
       
   158 
       
   159         /**
       
   160         * @see CVtEngDraw::BaseVideoFrameSizeChangedL
       
   161         */
       
   162         void BaseVideoFrameSizeChangedL( const TSize& aTo );
       
   163 
       
   164         /**
       
   165         * @see CVtEngDraw::BaseRequestLastFrame
       
   166         */
       
   167         void BaseRequestLastFrame();
       
   168         
       
   169         /**
       
   170         * @see CVtEngDraw::Config
       
   171         */
       
   172         TVtEngRenderConfig& Config();
       
   173 
       
   174     private: // new methods
       
   175 
       
   176         /**
       
   177         * Handles all delayed calls.
       
   178         */
       
   179         void HandleDelayedCallsL();
       
   180 
       
   181         /**
       
   182         * Base construct implementation
       
   183         */
       
   184         void DoBaseConstructL();
       
   185 
       
   186         /**
       
   187         * Base start drawing implementation
       
   188         */
       
   189         void DoBaseStartDrawL();
       
   190 
       
   191         /**
       
   192         * Initialize posting surface implementation
       
   193         */
       
   194         void DoInitializePostingSurfaceL();
       
   195 
       
   196         /**
       
   197         * Update sink params implementation.
       
   198         */
       
   199         void DoUpdateSinkParamsL();
       
   200 
       
   201         /**
       
   202         * Updates sink params.
       
   203         */
       
   204         void UpdateSinkParamsL();
       
   205 
       
   206         /**
       
   207         * Checks if the alpha has been trashed on screen buffer (ETrue if it
       
   208         * has been trashed, EFalse otherwise).
       
   209         */
       
   210         TBool IsAlphaTrashed() const;
       
   211 
       
   212         /**
       
   213         * Sets clipping region (read from DSA).
       
   214         */
       
   215         void SetClipRegionL();
       
   216 
       
   217         /**
       
   218         * Initializes DP.
       
   219         */
       
   220         void InitializePostingSurfaceL();
       
   221 
       
   222         /**
       
   223         * Fills posting source params structure.
       
   224         */
       
   225         void GetPostingSourceParams(
       
   226             CPostingSurface::TPostingSourceParams& aParams ) const;
       
   227 
       
   228         /**
       
   229         * Fills posting params structure.
       
   230         */
       
   231         void GetPostingParams(
       
   232             CPostingSurface::TPostingParams& aParams ) const;
       
   233 
       
   234         /**
       
   235         * Returns ETrue if given format is supported, EFalse otherwise.
       
   236         */
       
   237         TBool SupportsFormat(
       
   238             const CPostingSurface::TPostingFormat& aFormat ) const;
       
   239 
       
   240         /**
       
   241         * Returns ETrue if given size is supported, EFalse otherwise.
       
   242         */
       
   243         TBool SupportsSize( const TSize& aSize ) const;
       
   244 
       
   245         /**
       
   246         * Returns ETrue if given rotation is supported,
       
   247         * EFalse otherwise.
       
   248         */
       
   249         TBool SupportsRotation(
       
   250             CPostingSurface::TRotationType aRotation ) const;
       
   251 
       
   252         /**
       
   253         * Returns ETrue if mirroring is supported, EFalse otherwise.
       
   254         */
       
   255         TBool SupportsMirroring() const;
       
   256 
       
   257         /**
       
   258         * Returns ETrue if scaling is supported, EFalse otherwise.
       
   259         */
       
   260         TBool SupportsScaling() const;
       
   261 
       
   262         /**
       
   263         * Returns ETrue if brightness controlling is supported,
       
   264         * EFalse otherwise.
       
   265         */
       
   266         TBool SupportsBrightness() const;
       
   267 
       
   268         /**
       
   269         * Returns ETrue if contrast controlling is supported,
       
   270         * EFalse otherwise.
       
   271         */
       
   272         TBool SupportsContrast() const;
       
   273 
       
   274         /**
       
   275         * Returns buffer size in bytes for given size and current posting
       
   276         * format.
       
   277         */
       
   278         TInt GetFrameBufferSize( const TSize& aTo ) const;
       
   279 
       
   280         /**
       
   281         * Recreates clipregion. May leave with KErrNoMemory.
       
   282         */
       
   283         void RecalculateClipRegionL();
       
   284 
       
   285         /**
       
   286         * Fixes rect for DP.
       
   287         */
       
   288         void FixRectForDP( TRect& aRect ) const;
       
   289 
       
   290         /**
       
   291         * Fills sink parameters.
       
   292         */
       
   293         void GetSinkParams( TDisplaySinkParamsDP& aSinkParams );
       
   294 
       
   295         /**
       
   296         * Returns reference to sink.
       
   297         */
       
   298         MDisplaySink& DisplaySink();
       
   299 
       
   300         /**
       
   301         * Stores given frame buffer.
       
   302         */
       
   303         void StoreFrameBuffer( CPostingSurface::TPostingBuff* aPostingBuffer );
       
   304 
       
   305         /**
       
   306         * Creates frame buffer.
       
   307         */
       
   308         void CreateFrameBufferL( const TSize& aSize );
       
   309 
       
   310         /**
       
   311         * Async draw callback.
       
   312         */
       
   313         static TInt CallBack( TAny* aPtr );
       
   314 
       
   315         /**
       
   316         * Sets given buffer available to display sink.
       
   317         */
       
   318         void SetAvailableToSink( CPostingSurface::TPostingBuff* aBuffer );
       
   319 
       
   320         /**
       
   321         * Creates instance of posting surface.
       
   322         */
       
   323         CPostingSurface* CreatePostingSurfaceL();
       
   324 
       
   325         /**
       
   326         * Close the DP API library and free the allocated instance.
       
   327         */
       
   328         void CloseDPLibrary();
       
   329 
       
   330         /**
       
   331         * Loads DP API library.
       
   332         */
       
   333         void LoadDPLibraryL();
       
   334 
       
   335         /**
       
   336         * Converts YUV420 image to bitmap.
       
   337         */
       
   338         void Convert420ToVtImg( HBufC8* aSource, CVtImageBitmap& aTarget );
       
   339 
       
   340         /**
       
   341         * Converts YUV422 image to bitmap.
       
   342         */
       
   343         void Convert422ToVtImg( HBufC8* aSource, CVtImageBitmap& aTarget );
       
   344 
       
   345         /**
       
   346         * Updates Vt frame to frame observer.
       
   347         */
       
   348         void UpdateVtFrame();
       
   349 
       
   350     public: // From MVtImageScalerObserver.
       
   351 
       
   352         /**
       
   353         * @ see MVtImageScalerObserver.
       
   354         */
       
   355         virtual void ScalingFinished( TInt aError );
       
   356 
       
   357 
       
   358     private: // from CActive
       
   359 
       
   360         /**
       
   361         * Handles prepared bitmap from display sink.
       
   362         * @see CActive::RunL
       
   363         */
       
   364         void RunL();
       
   365 
       
   366     private: // from MVtEngBufferWaiterObserver
       
   367 
       
   368         /**
       
   369         * @see MVtEngBufferWaiterObserver::BufferReady
       
   370         */
       
   371         void BufferReady( CPostingSurface::TPostingBuff* aBuffer );
       
   372 
       
   373         /**
       
   374         * @see MVtEngBufferWaiterObserver::FetchError
       
   375         */
       
   376         void FetchError( TInt aError );
       
   377 
       
   378     private: // inner classes
       
   379 
       
   380         // Buffer class for storing buffer.
       
   381         NONSHARABLE_CLASS( TVtEngBuffer )
       
   382             {
       
   383             public:
       
   384 
       
   385                 /**
       
   386                 * C++ constructor
       
   387                 */
       
   388                 TVtEngBuffer();
       
   389 
       
   390                 /**
       
   391                 * Sets buffer
       
   392                 */
       
   393                 void Set( CPostingSurface::TPostingBuff* aBuffer );
       
   394 
       
   395                 /**
       
   396                 * Unsets buffer
       
   397                 */
       
   398                 void UnSet();
       
   399 
       
   400                 /**
       
   401                 * Returns ETrue if buffer is set
       
   402                 */
       
   403                 TBool IsSet() const;
       
   404 
       
   405                 /**
       
   406                 * Returns pointer reference to stored buffer.
       
   407                 */
       
   408                 CPostingSurface::TPostingBuff*& Buffer();
       
   409 
       
   410             private:
       
   411 
       
   412                 // Pointer's pointer to buffer
       
   413                 CPostingSurface::TPostingBuff* iBuffer;
       
   414             };
       
   415 
       
   416         // Waiter class for asynchronous events.
       
   417         NONSHARABLE_CLASS( CVtEngBufferWaiter ) : public CActive
       
   418             {
       
   419             public:
       
   420 
       
   421                 /**
       
   422                 * C++ constructor.
       
   423                 */
       
   424                 CVtEngBufferWaiter( CPostingSurface& aPostingSurface,
       
   425                     MVtEngBufferWaiterObserver& aObserver );
       
   426 
       
   427                 /**
       
   428                 * Destructor, frees all resources allocated by this instance.
       
   429                 */
       
   430                 ~CVtEngBufferWaiter();
       
   431 
       
   432                 /**
       
   433                 * Fetch new buffer (also activates listening).
       
   434                 */
       
   435                 TInt FetchBuffer();
       
   436 
       
   437             private: // new methods
       
   438 
       
   439                 /**
       
   440                 * Activate buffer listening (also calls CActive::SetActive()).
       
   441                 */
       
   442                 void Activate();
       
   443 
       
   444             private: // from CActive
       
   445 
       
   446                 /**
       
   447                 * @see CActive::RunL()
       
   448                 */
       
   449                 void RunL();
       
   450 
       
   451                 /**
       
   452                 * @see CActive::DoCancel()
       
   453                 */
       
   454                 void DoCancel();
       
   455 
       
   456             private: // data
       
   457 
       
   458                 // Posting surface instance (not owned)
       
   459                 CPostingSurface* iPostingSurface;
       
   460 
       
   461                 // BufferWaiter observer who gets informed about buffers
       
   462                 MVtEngBufferWaiterObserver* iObserver;
       
   463             };
       
   464 
       
   465     private: // data
       
   466 
       
   467         // Posting surface instance
       
   468         CPostingSurface* iPostingSurface;
       
   469 
       
   470         // Posting capabilities
       
   471         CPostingSurface::TPostingCapab iPostingCaps;
       
   472 
       
   473         // Posting buffers
       
   474         TVtEngBuffer
       
   475             iBuffers[ MDisplaySink::EFirstBitmap + KVtEngMaxBuffers ];
       
   476 
       
   477         // Buffer waiter instance
       
   478         CVtEngBufferWaiter* iBufferWaiter;
       
   479 
       
   480         // Rendering configuration
       
   481         TVtEngRenderConfigDP iConfig;
       
   482 
       
   483         // Clipping region
       
   484         RRegion iClipRegion;
       
   485 
       
   486         // Frame buffer
       
   487         HBufC8* iFrameBuffer;
       
   488 
       
   489         // Selected posting format
       
   490         CPostingSurface::TPostingFormat iPostingFormat;
       
   491 
       
   492         // DP API DLL
       
   493         RLibrary* iDPLib;
       
   494 
       
   495         // Source image contains converted YUV frame
       
   496         CVtImageBitmap* iSource;
       
   497 
       
   498         // Target image contains scaled bitmap
       
   499         CVtImageBitmap* iTarget;
       
   500 
       
   501         // Image scaler instance
       
   502         CVtImageScaler* iImageScaler;
       
   503 
       
   504         // Clip region updated
       
   505         TBool iClipRegionUpdated;
       
   506 
       
   507     };
       
   508 
       
   509 #endif // CVTENGDRAWDP_H