vtprotocolplugins/DisplaySink/src/CDisplaySinkDSA.cpp
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:  Display Sink subsystem for Direct Screen Access.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 
       
    21 #include <cvtimageconverter.h>
       
    22 #include <cvtimageiyuv.h>
       
    23 #include "CDisplaySinkDSA.h"
       
    24 #include "TDisplaySinkParamsDSA.h"
       
    25 
       
    26 // MACROS
       
    27 
       
    28 #ifdef _DEBUG
       
    29     #include <e32debug.h>
       
    30     #define PRINT RDebug::Print
       
    31     #define _IFDBG(a) a
       
    32 #else
       
    33     #define PRINT
       
    34     #define _IFDBG(a)
       
    35 #endif
       
    36 
       
    37 // ======================== CDisplaySinkDSA ==============================
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CDisplaySinkDSA::NewL
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CDisplaySinkDSA* CDisplaySinkDSA::NewL( TDisplaySinkParams& aParams,
       
    44         const TDesC8& aInitData )
       
    45     {
       
    46 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::NewL()<"), RThread().Id().operator TUint()));
       
    47     CDisplaySinkDSA* self = new ( ELeave ) CDisplaySinkDSA();
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL( aParams, aInitData );
       
    50     CleanupStack::Pop(); // self
       
    51 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::NewL()>"), RThread().Id().operator TUint()));
       
    52     return self;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CDisplaySinkDSA::CDisplaySinkDSA
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CDisplaySinkDSA::CDisplaySinkDSA()
       
    60     {
       
    61 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::Ctor<"), RThread().Id().operator TUint()));
       
    62 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::Ctor>"), RThread().Id().operator TUint()));
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CDisplaySinkDSA::~CDisplaySinkDSA
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 CDisplaySinkDSA::~CDisplaySinkDSA()
       
    70     {
       
    71 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::~<"), RThread().Id().operator TUint()));
       
    72     delete iRotator;
       
    73     delete iYUVBitmapConverterVT;
       
    74 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::~>"), RThread().Id().operator TUint()));
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CDisplaySinkDSA::BaseConstructL
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 void CDisplaySinkDSA::BaseConstructL( TDisplaySinkParams& aParams,
       
    82     const TDesC8& )
       
    83     {
       
    84 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseConstructL()<"), RThread().Id().operator TUint()));
       
    85 	iNewParams = static_cast< TDisplaySinkParamsDSA& > ( aParams );
       
    86 	if ( !iNewParams.iBitmap1Handle || !iNewParams.iBitmap2Handle )
       
    87 	    {
       
    88         _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseConstructL() bitmap handle NULL!") ));
       
    89 	    User::Leave( KErrArgument );
       
    90 	    }
       
    91     iBitmapTable[EFirstBitmap].iHandle = iNewParams.iBitmap1Handle;
       
    92 	iBitmapTable[ESecondBitmap].iHandle = iNewParams.iBitmap2Handle;
       
    93     iRotator = CVtImageRotator::NewL( *this );
       
    94     iRotationAngle = iNewParams.iRotationAngle;
       
    95     iYUVBitmapConverterVT = CVTIYUVFbsBitmapConverter::NewL(
       
    96         QCIF, iBitmapTable[EFirstBitmap].iHandle );
       
    97     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseConstructL()>"), RThread().Id().operator TUint()));
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CDisplaySinkDSA::BaseConvert
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 TBool CDisplaySinkDSA::BaseConvert( const TVtMMFDataBuffer& aBuffer )
       
   105     {
       
   106     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseConvert()<"), RThread().Id().operator TUint()));
       
   107     TBool converted( EFalse );
       
   108     TRAPD( err, ConvertL( aBuffer.Data(), converted ) );
       
   109     if ( err != KErrNone )
       
   110         {
       
   111         _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseConvert() err=%d"), RThread().Id().operator TUint(), err));
       
   112         converted = EFalse;
       
   113         }
       
   114     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseConvert() %d>"), RThread().Id().operator TUint(), converted));
       
   115     return converted;
       
   116     }
       
   117 // -----------------------------------------------------------------------------
       
   118 // CDisplaySinkDSA::BaseSinkThreadLogonL
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 void CDisplaySinkDSA::BaseSinkThreadLogonL()
       
   122     {
       
   123     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSinkThreadLogonL()<"), RThread().Id().operator TUint()));
       
   124     CVTYUVFbsBitmapConverter* converter1 =
       
   125 	    CVTIYUVFbsBitmapConverter::NewL(
       
   126 	        QCIF,
       
   127 	        iBitmapTable[EFirstBitmap].iHandle );
       
   128     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSinkThreadLogonL() 1"), RThread().Id().operator TUint()));
       
   129 	CleanupStack::PushL( converter1 );
       
   130     CVTYUVFbsBitmapConverter* converter2 =
       
   131 	    CVTIYUVFbsBitmapConverter::NewL(
       
   132 	        QCIF,
       
   133 	        iBitmapTable[ESecondBitmap].iHandle );
       
   134     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSinkThreadLogonL() 2"), RThread().Id().operator TUint()));
       
   135 	CleanupStack::PushL( converter2 );
       
   136     CleanupStack::Pop( 2 ); // converter1, converter2
       
   137     iYUVBitmapConverter1 = converter1;
       
   138 	iYUVBitmapConverter2 = converter2;
       
   139     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSinkThreadLogonL()>"), RThread().Id().operator TUint()));
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CDisplaySinkDSA::BaseSinkThreadLogoff
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 void CDisplaySinkDSA::BaseSinkThreadLogoff()
       
   147     {
       
   148     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSinkThreadLogoff()<"), RThread().Id().operator TUint()));
       
   149 	delete iYUVBitmapConverter1;
       
   150 	delete iYUVBitmapConverter2;
       
   151     delete iSourceImg; iSourceImg = 0;
       
   152     delete iTargetImg; iTargetImg = 0;
       
   153     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSinkThreadLogoff()>"), RThread().Id().operator TUint()));
       
   154     }
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 // CDisplaySinkDSA::BaseUpdateSinkParamsL
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 void CDisplaySinkDSA::BaseUpdateSinkParamsL( const TDisplaySinkParams& aParams )
       
   161     {
       
   162     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseUpdateSinkParamsL()<"), RThread().Id().operator TUint()));
       
   163     iNewParams = static_cast< const TDisplaySinkParamsDSA& >( aParams );
       
   164     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseUpdateSinkParamsL()>"), RThread().Id().operator TUint()));
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // CDisplaySinkDSA::BaseDoUpdateParamsL
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void CDisplaySinkDSA::BaseDoUpdateParamsL()
       
   172     {
       
   173     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseDoUpdateParamsL()<"), RThread().Id().operator TUint()));
       
   174     iRotationAngle = iNewParams.iRotationAngle;
       
   175     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseDoUpdateParamsL() handle1=%d"), RThread().Id().operator TUint(), iNewParams.iBitmap1Handle));
       
   176     iBitmapTable[ EFirstBitmap ].iHandle = iNewParams.iBitmap1Handle;
       
   177     iBitmapTable[ EFirstBitmap ].iIsFree = ETrue;
       
   178     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseDoUpdateParamsL() handle2=%d"), RThread().Id().operator TUint(), iNewParams.iBitmap2Handle));
       
   179     iBitmapTable[ ESecondBitmap ].iHandle = iNewParams.iBitmap2Handle;
       
   180     iBitmapTable[ ESecondBitmap ].iIsFree = EFalse;
       
   181     UpdateExpectedFrameSizeL();
       
   182     iYUVBitmapConverter1->SetSourceSizeL( iExpectedFrameSize );
       
   183     iYUVBitmapConverter1->SetDestinationL( iNewParams.iBitmap1Handle );
       
   184     iYUVBitmapConverter2->SetSourceSizeL( iExpectedFrameSize );
       
   185     iYUVBitmapConverter2->SetDestinationL( iNewParams.iBitmap2Handle );
       
   186     if( iNewParams.iFrameRateLimit != iFrameRateInterval )
       
   187         {
       
   188         SetFrameRateLimit( iNewParams.iFrameRateLimit );
       
   189         ResetFrameRateLimitter();
       
   190         }
       
   191     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseDoUpdateParamsL()>"), RThread().Id().operator TUint()));
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // CDisplaySinkDSA::BaseSetVideoFrameSizeL
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 void CDisplaySinkDSA::BaseSetVideoFrameSizeL( const TSize& aSize )
       
   199     {
       
   200     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSetVideoFrameSizeL()<"), RThread().Id().operator TUint()));
       
   201     TSize size( aSize );
       
   202     if( ( iRotationAngle == CVtImageRotator::E90DegreesClockwise ) ||
       
   203         ( iRotationAngle == CVtImageRotator::E270DegreesClockwise ) )
       
   204         {
       
   205         size = TSize( aSize.iHeight, aSize.iWidth );
       
   206         }
       
   207     iYUVBitmapConverter1->SetSourceSizeL( size );
       
   208     iYUVBitmapConverter2->SetSourceSizeL( size );
       
   209     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSetVideoFrameSizeL()>"), RThread().Id().operator TUint()));
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CDisplaySinkDSA::BaseSizesMatch
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 TBool CDisplaySinkDSA::BaseSizesMatch( const TSize& aSize )
       
   217     {
       
   218     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSizesMatch()<"), RThread().Id().operator TUint()));
       
   219     TBool sizesMatch( iExpectedFrameSize == aSize );
       
   220     TBool rotateChangesDimension(
       
   221         ( iRotationAngle == CVtImageRotator::E90DegreesClockwise ) ||
       
   222         ( iRotationAngle == CVtImageRotator::E270DegreesClockwise ) );
       
   223     if( rotateChangesDimension )
       
   224         {
       
   225         sizesMatch =
       
   226             ( iExpectedFrameSize.iWidth == aSize.iHeight ) &&
       
   227             ( iExpectedFrameSize.iHeight == aSize.iWidth );
       
   228         }
       
   229     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSizesMatch() %d>"), RThread().Id().operator TUint(), sizesMatch));
       
   230     return sizesMatch;
       
   231     }
       
   232 
       
   233 // -----------------------------------------------------------------------------
       
   234 // CDisplaySinkDSA::BitmapEntry
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 CDisplaySink::TBitmapEntry& CDisplaySinkDSA::BitmapEntry( TInt aIndex )
       
   238     {
       
   239     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BitmapEntry(%d)<"), RThread().Id().operator TUint(), aIndex));
       
   240     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BitmapEntry()>"), RThread().Id().operator TUint()));
       
   241     return iBitmapTable[ aIndex ];
       
   242     }
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // CDisplaySinkDSA::BaseEmptyBufferL
       
   246 // -----------------------------------------------------------------------------
       
   247 //
       
   248 void CDisplaySinkDSA::BaseEmptyBufferL( TVtMMFDataBuffer& aVTMMFBuffer )
       
   249     {
       
   250     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseEmptyBufferL()<"), RThread().Id().operator TUint()));
       
   251     if( iRotationAngle != CVtImageRotator::ERotationNone )
       
   252         {
       
   253         TSize size( aVTMMFBuffer.GetFrameSize() );
       
   254         TInt length( ( size.iWidth * size.iHeight * 12 ) / 8 );
       
   255         // Modifiable pointer descriptor needed, we don't want a copy of image!
       
   256         TPtr8 ptrData( const_cast< TUint8* >(
       
   257             aVTMMFBuffer.Data().Ptr() ), length, length );
       
   258 
       
   259         if( iSourceImg == 0 )
       
   260             {
       
   261             // If source image is not created -> create it
       
   262             iSourceImg = CVtImageIYUV::NewL( size, ptrData );
       
   263             }
       
   264         else
       
   265             {
       
   266             // otherwise just update the data
       
   267             if( iSourceImg->Size() == size )
       
   268                 {
       
   269                 iSourceImg->SetImageL( ptrData );
       
   270                 }
       
   271             else
       
   272                 {
       
   273                 delete iSourceImg; iSourceImg = 0;
       
   274                 iSourceImg = CVtImageIYUV::NewL( size, ptrData );
       
   275                 }
       
   276             }
       
   277         iRotator->RotateL( *iSourceImg, *iTargetImg, iRotationAngle );
       
   278         CleanupStack::PopAndDestroy(); // iBitmapCS.Signal();
       
   279         }
       
   280     else
       
   281         {
       
   282         if ( BaseConvert( aVTMMFBuffer ) )
       
   283             {
       
   284             CleanupStack::PopAndDestroy(); // iBitmapCS.Signal();
       
   285             iSupplier->BufferEmptiedL( iBuffer );
       
   286             }
       
   287         else
       
   288             {
       
   289             if ( iVideoFrameQueue->IsStored() || !IsOkToSendFrame() )
       
   290                 {
       
   291                 CleanupStack::PopAndDestroy(); // iBitmapCS.Signal();
       
   292                 iSupplier->BufferEmptiedL( iBuffer );
       
   293                 }
       
   294             else
       
   295                 {
       
   296                 iVideoFrameQueue->Store( *iSupplier, static_cast<CMMFDataBuffer*>(aVTMMFBuffer.GetMMFBuffer()),  aVTMMFBuffer.GetFrameSize(), aVTMMFBuffer.Data());
       
   297                 CleanupStack::PopAndDestroy();
       
   298                 }
       
   299             }
       
   300         }
       
   301     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseEmptyBufferL()>"), RThread().Id().operator TUint()));
       
   302     }
       
   303 
       
   304 // -----------------------------------------------------------------------------
       
   305 // CDisplaySinkDSA::BaseSetBitmapAvailable( TBitmapNo aBitmapNo )
       
   306 // -----------------------------------------------------------------------------
       
   307 //
       
   308 void CDisplaySinkDSA::BaseSetBitmapAvailable( TBitmapNo aBitmapNo )
       
   309 	{
       
   310 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSetBitmapAvailable()<"), RThread().Id().operator TUint()));
       
   311     if ( iVideoFrameQueue->IsStored() )
       
   312         {
       
   313         _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSetBitmapAvailable() buffer pending"), RThread().Id().operator TUint()));
       
   314         if ( !iReleased && ( *iRequestStatusPtr == KRequestPending ) && IsOkToSendFrame() )
       
   315     		{
       
   316             TRAPD( result, {
       
   317                 iYUVBitmapConverterVT->SetDestinationL(
       
   318                     iBitmapTable[ aBitmapNo ].iHandle );
       
   319                 iYUVBitmapConverterVT->SetSourceL(
       
   320 	                iVideoFrameQueue->Buffer().Data() );
       
   321                 iYUVBitmapConverterVT->ProcessL();
       
   322                 } );
       
   323             if ( result == KErrNone )
       
   324                 {
       
   325                 _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSetBitmapAvailable() conversion succeeded!"), RThread().Id().operator TUint()));
       
   326         		iBitmapTable[ aBitmapNo ].iIsFree = EFalse;
       
   327         		TRequestStatus* statusP = iRequestStatusPtr;
       
   328         		iThread.RequestComplete( statusP, aBitmapNo );
       
   329         	    }
       
   330         	else
       
   331         	    {
       
   332                 _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSetBitmapAvailable() conversion failed!"), RThread().Id().operator TUint()));
       
   333         	    // Drop frame
       
   334         	    }
       
   335     		}
       
   336         else
       
   337             {
       
   338             _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSetBitmapAvailable() dropping frame"), RThread().Id().operator TUint()));
       
   339             // Drop frame
       
   340             }
       
   341         iVideoFrameQueue->Release();
       
   342         }
       
   343 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseSetBitmapAvailable()>"), RThread().Id().operator TUint()));
       
   344 	}
       
   345 
       
   346 // -----------------------------------------------------------------------------
       
   347 // CDisplaySinkDSA::BaseVideoFrameSizeChangedL( const TSize& aNewSize )
       
   348 // -----------------------------------------------------------------------------
       
   349 //
       
   350 void CDisplaySinkDSA::BaseVideoFrameSizeChangedL( const TSize& aNewSize )
       
   351 	{
       
   352 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseVideoFrameSizeChangedL()<"), RThread().Id().operator TUint()));
       
   353 	iYUVBitmapConverterVT->SetSourceSizeL( aNewSize );
       
   354 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::BaseVideoFrameSizeChangedL()>"), RThread().Id().operator TUint()));
       
   355 	}
       
   356 
       
   357 // -----------------------------------------------------------------------------
       
   358 // CDisplaySinkDSA::UpdateExpectedFrameSizeL()
       
   359 // -----------------------------------------------------------------------------
       
   360 //
       
   361 void CDisplaySinkDSA::UpdateExpectedFrameSizeL()
       
   362     {
       
   363 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::UpdateExpectedFrameSizeL()<"), RThread().Id().operator TUint()));
       
   364     CFbsBitmap* bm = new ( ELeave ) CFbsBitmap();
       
   365     CleanupStack::PushL( bm );
       
   366     User::LeaveIfError( bm->Duplicate( iBitmapTable[ EFirstBitmap ].iHandle ) );
       
   367     iExpectedFrameSize = bm->SizeInPixels();
       
   368     User::LeaveIfError( bm->Duplicate( iBitmapTable[ ESecondBitmap ].iHandle ) );
       
   369     if( iExpectedFrameSize != bm->SizeInPixels() )
       
   370         {
       
   371     	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::UpdateExpectedFrameSizeL(): EFirstBitmap size is different from ESecondBitmap size -> Leave()"), RThread().Id().operator TUint()));
       
   372         User::Leave( KErrNotSupported );
       
   373         }
       
   374     CleanupStack::PopAndDestroy(); // bm
       
   375     delete iTargetImg; iTargetImg = 0;
       
   376     iTargetImg = CVtImageIYUV::NewL( iExpectedFrameSize );
       
   377     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::UpdateExpectedFrameSizeL()>"), RThread().Id().operator TUint()));
       
   378     }
       
   379 
       
   380 // -----------------------------------------------------------------------------
       
   381 // CDisplaySinkDSA::RotationFinished( TInt aError )
       
   382 // -----------------------------------------------------------------------------
       
   383 //
       
   384 void CDisplaySinkDSA::RotationFinished( TInt aError )
       
   385     {
       
   386 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::RotationFinished()<"), RThread().Id().operator TUint()));
       
   387     // Rotation finished .. do something
       
   388     if( aError == KErrNone )
       
   389         {
       
   390         iBitmapCS.Wait();
       
   391         TBool converted( EFalse );
       
   392         TRAP( aError, ConvertL( iTargetImg->Image(), converted ) );
       
   393         iBitmapCS.Signal();
       
   394         TRAPD( aError2, iSupplier->BufferEmptiedL( iBuffer ) );
       
   395         if( ( aError != KErrNone ) || ( aError2 != KErrNone  ) )
       
   396             {
       
   397             *iRequestStatusPtr = KRequestPending;
       
   398 		    TRequestStatus* statusP = iRequestStatusPtr;
       
   399 		    iThread.RequestComplete( statusP, aError );
       
   400             }
       
   401         }
       
   402     else
       
   403         {
       
   404         *iRequestStatusPtr = KRequestPending;
       
   405 		TRequestStatus* statusP = iRequestStatusPtr;
       
   406 		iThread.RequestComplete( statusP, aError );
       
   407         }
       
   408 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::RotationFinished()>"), RThread().Id().operator TUint()));
       
   409     }
       
   410 
       
   411 
       
   412 // -----------------------------------------------------------------------------
       
   413 // CDisplaySinkDSA::ConvertL
       
   414 // -----------------------------------------------------------------------------
       
   415 //
       
   416 void CDisplaySinkDSA::ConvertL( const TPtrC8& aBuffer, TBool& aConverted )
       
   417     {
       
   418     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::ConvertL()<"), RThread().Id().operator TUint()));
       
   419     TBitmapNo bitmapNo( iBitmapTable[ EFirstBitmap ].iIsFree ? EFirstBitmap : ESecondBitmap );
       
   420     if ( iBitmapTable[ bitmapNo ].iIsFree &&
       
   421          !iReleased &&
       
   422          ( *iRequestStatusPtr == KRequestPending ) )
       
   423 		{
       
   424 		DoConvertL( aBuffer, bitmapNo );
       
   425     	aConverted = ETrue;
       
   426 		iBitmapTable[ bitmapNo ].iIsFree = EFalse;
       
   427 		TRequestStatus* statusP = iRequestStatusPtr;
       
   428 		iThread.RequestComplete( statusP, bitmapNo );
       
   429 		}
       
   430     else
       
   431         {
       
   432     	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::ConvertL(): could not find free bitmap"), RThread().Id().operator TUint()));
       
   433     	aConverted = EFalse;
       
   434         }
       
   435     _IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::ConvertL()>"), RThread().Id().operator TUint()));
       
   436     }
       
   437 
       
   438 // -----------------------------------------------------------------------------
       
   439 // CDisplaySinkDSA::DoConvert
       
   440 // -----------------------------------------------------------------------------
       
   441 //
       
   442 void CDisplaySinkDSA::DoConvertL( const TPtrC8& aBuffer, TBitmapNo aBitmapNo )
       
   443 	{
       
   444 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::DoConvertL()<"), RThread().Id().operator TUint()));
       
   445 	CVTYUVFbsBitmapConverter* c = 0;
       
   446 	switch( aBitmapNo )
       
   447 		{
       
   448 		case EFirstBitmap:
       
   449 			c = iYUVBitmapConverter1;
       
   450 			break;
       
   451 
       
   452 		case ESecondBitmap:
       
   453 			c = iYUVBitmapConverter2;
       
   454 			break;
       
   455 
       
   456         default:
       
   457             User::Leave( KErrArgument );
       
   458 		};
       
   459 	c->SetSourceL( aBuffer );
       
   460 	c->ProcessL();
       
   461 	_IFDBG(PRINT(_L("VideoSource[%d]: CDisplaySinkDSA::DoConvertL()>"), RThread().Id().operator TUint()));
       
   462 	}
       
   463 
       
   464 // End of File