h264_dec/arih264dechwdevice/src/arih264dechwdevice.cpp
changeset 0 bb31fbe78861
equal deleted inserted replaced
-1:000000000000 0:bb31fbe78861
       
     1 /*
       
     2 * Copyright (c) 2009 Aricent and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "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 * Aricent - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * This is a source file, required for arih264dechwdevice
       
    16 *
       
    17 */
       
    18 
       
    19 //User includes
       
    20 #include "arih264dechwdevice.h"
       
    21 #include "arih264decwrapper.h"
       
    22 #include "aristatemachine.h"
       
    23 #include "ariprint.h"
       
    24 
       
    25 //
       
    26 //CAriH264decHwDevice
       
    27 //
       
    28 
       
    29 _LIT( KManufacturer, "Aricent" );
       
    30 
       
    31 _LIT( KIdentifier, "H264 Video Decoder" );
       
    32 
       
    33 //supported h264 mime types
       
    34 _LIT8( KH264SupportedMimeType, "video/H264" );
       
    35 
       
    36 
       
    37 //---------------------------------------------------------------------------
       
    38 //1st phase constructor of CAriH264decHwDevice
       
    39 //---------------------------------------------------------------------------
       
    40 //
       
    41 CMMFVideoDecodeHwDevice* CAriH264decHwDevice::NewL()
       
    42 	{
       
    43 	PRINT_ENTRY;
       
    44 	CAriH264decHwDevice* self = new ( ELeave ) CAriH264decHwDevice;
       
    45 	CleanupStack::PushL( self );
       
    46 	self->ConstructL();
       
    47 	CleanupStack::Pop();
       
    48 	PRINT_EXIT;
       
    49 	return self;
       
    50 	}
       
    51 
       
    52 //---------------------------------------------------------------------------
       
    53 //Destructor
       
    54 //---------------------------------------------------------------------------
       
    55 //
       
    56 CAriH264decHwDevice::~CAriH264decHwDevice()
       
    57 	{
       
    58 	PRINT_ENTRY;
       
    59 	delete iInputFormat;
       
    60 	delete iEngine;
       
    61 	delete iCodec;
       
    62 	delete iState;
       
    63 
       
    64     delete iVideoPictureHeader;
       
    65 
       
    66 	// This is required becoz user may say exit before start at that point
       
    67 	// OutputFreeBuffer is not created
       
    68 	if ( iOutputFreeBuffer )
       
    69 		{
       
    70 		for( TInt i = 0 ; i < KMaxOutputBuffers; i++ )
       
    71 			{
       
    72             if ( ( iOutputFreeBuffer + i )->iHeader )
       
    73                 {
       
    74 			    delete ( iOutputFreeBuffer + i )->iHeader;
       
    75                 }
       
    76 			if ( ( iOutputFreeBuffer + i )->iData.iRawData )
       
    77 				{
       
    78 				delete
       
    79 				( TUint8* )( iOutputFreeBuffer + i )->iData.iRawData->Ptr();
       
    80 				}
       
    81             if ( ( iOutputFreeBuffer + i )->iData.iRawData )
       
    82                 {
       
    83 			    delete ( iOutputFreeBuffer + i )->iData.iRawData;
       
    84                 }
       
    85 			}
       
    86 		delete [] iOutputFreeBuffer;
       
    87 		}
       
    88 
       
    89 	if ( iInputFreeBuffers )
       
    90 		{
       
    91 		for ( TInt i = 0 ; i < iBufferOptions.iMinNumInputBuffers; i++ )
       
    92 			{
       
    93 			delete [] ( TUint8* )iInputFreeBuffers[i].iData.Ptr();
       
    94 			delete iInputFreeBuffers[i].iUser;
       
    95 			}
       
    96 		delete [] iInputFreeBuffers;
       
    97 		}
       
    98 
       
    99 	if ( iCustomBufferOptions )
       
   100 		{
       
   101 		delete iCustomBufferOptions;
       
   102 		}
       
   103 
       
   104     iOutputFreeBufferQueue.Close();
       
   105 	iInputFreeBufferQueue.Close();
       
   106 
       
   107 	iMaxPictureRates.Reset();
       
   108 	iMaxPictureRates.Close();
       
   109 	iSupportedFormats.Reset();
       
   110 	iSupportedFormats.Close();
       
   111 
       
   112     iOutputDevice = NULL;
       
   113     iMMFDevVideoPlayProxy = NULL;
       
   114     iCustomBufferHandle = NULL;
       
   115 
       
   116 	PRINT_EXIT;
       
   117     }
       
   118 //---------------------------------------------------------------------------
       
   119 //Retrieves a custom interface to the device.
       
   120 //---------------------------------------------------------------------------
       
   121 //
       
   122 TAny* CAriH264decHwDevice::CustomInterface( TUid /*aInterface*/ )
       
   123 	{
       
   124 	PRINT_ENTRY;
       
   125 	PRINT_EXIT;
       
   126 	return NULL;
       
   127 	}
       
   128 
       
   129 //---------------------------------------------------------------------------
       
   130 //Retrieves decoder information about this hardware device. The device
       
   131 //creates a CVideoDecoderInfo structure, fills it with correct data,
       
   132 //pushes it to the cleanup stack and returns it. The client will delete the
       
   133 //object when it is no longer needed.
       
   134 //---------------------------------------------------------------------------
       
   135 //
       
   136 CVideoDecoderInfo* CAriH264decHwDevice::VideoDecoderInfoLC()
       
   137 	{
       
   138     PRINT_ENTRY;
       
   139 
       
   140     // construct the video types for iVidTypes
       
   141 	CCompressedVideoFormat* format = NULL;
       
   142 	format = CCompressedVideoFormat::NewL( KH264SupportedMimeType );
       
   143 	CleanupStack::PushL(format);
       
   144 	TInt status = iSupportedFormats.Append( format );
       
   145 	if ( status != KErrNone )
       
   146 		{
       
   147 		PRINT_MSG( LEVEL_LOW, ( " Format support is not done, retval of "
       
   148 				"append = %d \n", status ) );
       
   149 		}
       
   150 	CleanupStack::Pop( format );
       
   151 
       
   152     for ( TUint i = 0; i < KDecoderInfoCount; i++ )
       
   153 		{
       
   154 		// max picture rates
       
   155 		TPictureRateAndSize pictureRateAndSize;
       
   156 		pictureRateAndSize.iPictureSize = TSize( KMaxFrameWidth,
       
   157 				                                KMaxFrameHeight );
       
   158 		pictureRateAndSize.iPictureRate = KPicRate;
       
   159 		status = iMaxPictureRates.Append(pictureRateAndSize);
       
   160 		if ( status != KErrNone )
       
   161 			{
       
   162 			PRINT_MSG( LEVEL_LOW, ( " error in appendng picturerates = %d \n",
       
   163 					status ) );
       
   164 			}
       
   165 		}
       
   166     TUint maxBitRate = KMaxBitRate;
       
   167 	CVideoDecoderInfo* videoDecoderInfo = CVideoDecoderInfo::NewL(
       
   168             KUidH264DecoderHwDevice,
       
   169             KManufacturer,
       
   170             KIdentifier,
       
   171             TVersion( 1, 0, 0 ),
       
   172             iSupportedFormats.Array(),
       
   173             // Non-Accelerated
       
   174             EFalse,
       
   175             // Doesnt support Direct Display
       
   176             EFalse,
       
   177             TSize( KMaxFrameWidth, KMaxFrameHeight ),
       
   178             maxBitRate,
       
   179             iMaxPictureRates.Array(),
       
   180             //decoder supports picture loss indications
       
   181             ETrue,
       
   182             //decoder supports slice loss indications
       
   183             ETrue );
       
   184 
       
   185     CleanupStack::PushL( videoDecoderInfo );
       
   186 
       
   187     PRINT_MSG( LEVEL_LOW, ( "Closing maxPictureRates&supportedFormats\n" ) );
       
   188 
       
   189     PRINT_EXIT;
       
   190 
       
   191     return videoDecoderInfo;
       
   192 	}
       
   193 
       
   194 //---------------------------------------------------------------------------
       
   195 //Reads header information from a coded data unit.
       
   196 //---------------------------------------------------------------------------
       
   197 //
       
   198 TVideoPictureHeader* CAriH264decHwDevice::GetHeaderInformationL(
       
   199 								TVideoDataUnitType /*aDataUnitType*/,
       
   200 								TVideoDataUnitEncapsulation aEncapsulation,
       
   201 								TVideoInputBuffer* aDataUnit )
       
   202 	{
       
   203 	PRINT_ENTRY;
       
   204     if (!aDataUnit )
       
   205 	    {
       
   206 	    PRINT_ERR( "Input argument is not proper, aDataUnit is null \n" );
       
   207 		User::Leave( KErrArgument );
       
   208 		}
       
   209 
       
   210     if ( aEncapsulation != EDuElementaryStream )
       
   211     	{
       
   212     	PRINT_ERR( "aEncapsulation is not supported type \n" );
       
   213         User::Leave( KErrNotSupported );
       
   214     	}
       
   215 
       
   216     iVideoPictureHeader = new ( ELeave ) TVideoPictureHeader;
       
   217 
       
   218 	TRAPD( err, CAriH264decWrapper::GetHeaderInfoL( *aDataUnit,
       
   219 													*iVideoPictureHeader ) );
       
   220 
       
   221     if ( err == KErrNone )
       
   222     	{
       
   223     	PRINT_EXIT;
       
   224         return ( iVideoPictureHeader );
       
   225     	}
       
   226 
       
   227     // An error has occured
       
   228     delete iVideoPictureHeader;
       
   229     iVideoPictureHeader = NULL;
       
   230 
       
   231     switch ( err )
       
   232         {
       
   233         case KErrCorrupt:
       
   234         case KErrNoMemory:
       
   235         case KErrArgument:
       
   236         case KErrNotSupported:
       
   237             {
       
   238             PRINT_ERR( "GetHeaderInfoL is returned with error \n" );
       
   239             User::Leave( err );
       
   240             break;
       
   241             }
       
   242         case KErrUnderflow:
       
   243             {
       
   244             PRINT_ERR( "GetHeaderInfoL returnd with error KErrUnderflow\n" );
       
   245             break;
       
   246             }
       
   247         default:
       
   248             {
       
   249             PRINT_ERR( "GetHeaderInfoL is returned with error \n" );
       
   250             User::Leave( KErrGeneral );
       
   251             }
       
   252         };
       
   253 
       
   254     PRINT_EXIT;
       
   255 	return NULL;
       
   256 	}
       
   257 
       
   258 //---------------------------------------------------------------------------
       
   259 //Returns a header from GetHeaderInformationL() back to the decoder so that
       
   260 //the memory can be freed.
       
   261 //---------------------------------------------------------------------------
       
   262 //
       
   263 void CAriH264decHwDevice::ReturnHeader( TVideoPictureHeader* aHeader )
       
   264 	{
       
   265 	PRINT_ENTRY;
       
   266 	if ( !iState->IsInitialized() )
       
   267 		{
       
   268 		if ( iVideoPictureHeader == aHeader )
       
   269 			{
       
   270 			delete iVideoPictureHeader;
       
   271             iVideoPictureHeader = NULL;
       
   272 			}
       
   273 		else
       
   274 			{
       
   275 			iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrArgument );
       
   276 			}
       
   277 		}
       
   278 	else
       
   279 		{
       
   280 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
   281 		}
       
   282 	PRINT_EXIT;
       
   283 	}
       
   284 
       
   285 //---------------------------------------------------------------------------
       
   286 //Sets the device input format to a compressed video format.
       
   287 //---------------------------------------------------------------------------
       
   288 //
       
   289 void CAriH264decHwDevice::SetInputFormatL(
       
   290 								const CCompressedVideoFormat& aFormat,
       
   291 								TVideoDataUnitType aDataUnitType,
       
   292 								TVideoDataUnitEncapsulation aEncapsulation,
       
   293 								TBool aDataInOrder )
       
   294 	{
       
   295 	PRINT_ENTRY;
       
   296 	if ( !iState->IsInitialized() )
       
   297 		{
       
   298 		if ( ( !aDataInOrder ) ||
       
   299              ( aEncapsulation == EDuGenericPayload ) ||
       
   300              ( aEncapsulation == EDuRtpPayload ) )
       
   301              User::Leave( KErrNotSupported );
       
   302 
       
   303 		if ( ( aFormat.MimeType().FindF( KH264SupportedMimeType ) !=
       
   304 															 KErrNotFound ) )
       
   305 
       
   306 			{
       
   307 			iInputFormat = CCompressedVideoFormat::NewL( aFormat );
       
   308 			iDataUnitType  = aDataUnitType;
       
   309 			iEncapsulation = aEncapsulation;
       
   310 			}
       
   311 		else
       
   312 			{
       
   313 			PRINT_ERR( "aFormat is not supported \n" );
       
   314 			User::Leave( KErrNotSupported );
       
   315 			}
       
   316 		}
       
   317 	else
       
   318 		{
       
   319 		PRINT_ERR( "istate is not initialized yet\n" );
       
   320 		User::Leave( KErrNotReady );
       
   321 		}
       
   322 	PRINT_EXIT;
       
   323 	}
       
   324 
       
   325 //---------------------------------------------------------------------------
       
   326 //Sets whether decoding should be synchronized to the current clock source,
       
   327 //if any, or if pictures should instead be decoded as soon as possible.
       
   328 //If decoding is synchronized, decoding timestamps are used if available,
       
   329 //presentation timestamps are used if not. When decoding is not synchronized,
       
   330 //pictures are decoded as soon as source data is available for them, and the
       
   331 //decoder has a free output buffer. If a clock source is not available,
       
   332 //decoding will not be synchronized.
       
   333 //---------------------------------------------------------------------------
       
   334 //
       
   335 void CAriH264decHwDevice::SynchronizeDecoding( TBool /*aSynchronize*/ )
       
   336 	{
       
   337 	PRINT_ENTRY;
       
   338 	PRINT_EXIT;
       
   339 	return;
       
   340 	}
       
   341 
       
   342 
       
   343 //---------------------------------------------------------------------------
       
   344 //Sets the Buffer Options as specified by the client.
       
   345 //---------------------------------------------------------------------------
       
   346 //
       
   347 void CAriH264decHwDevice::SetBufferOptionsL(
       
   348 						const CMMFDevVideoPlay::TBufferOptions& aOptions )
       
   349 	{
       
   350 	PRINT_ENTRY;
       
   351 	if ( !iState->IsInitialized() )
       
   352 		{
       
   353 		TTimeIntervalMicroSeconds zerotime( 0 );
       
   354         if ( ( aOptions.iMinNumInputBuffers < KMinInputBuffers ) ||
       
   355              ( aOptions.iPreDecodeBufferSize != 0 ) ||
       
   356              ( aOptions.iMaxPostDecodeBufferSize != 0 ) ||
       
   357              ( aOptions.iPreDecoderBufferPeriod != zerotime ) ||
       
   358              ( aOptions.iPostDecoderBufferPeriod != zerotime ) )
       
   359         	{
       
   360             User::Leave( KErrArgument );
       
   361         	}
       
   362 
       
   363 		if ( ( aOptions.iMinNumInputBuffers > KMaxInputBuffers ) ||
       
   364                ( aOptions.iMaxInputBufferSize > KMaxInputBufferSize ) )
       
   365 			{
       
   366 		    User::Leave( KErrNotSupported );
       
   367 			}
       
   368 
       
   369 		iBufferOptions = aOptions;
       
   370 		}
       
   371 	else
       
   372 		{
       
   373 		PRINT_ERR( "istate is not initialized yet\n" );
       
   374 		User::Leave( KErrNotReady );
       
   375 		}
       
   376 	PRINT_EXIT;
       
   377 	}
       
   378 
       
   379 //---------------------------------------------------------------------------
       
   380 //Gets the video decoder buffer options actually in use.
       
   381 //---------------------------------------------------------------------------
       
   382 //
       
   383 void CAriH264decHwDevice::GetBufferOptions(
       
   384 								 CMMFDevVideoPlay::TBufferOptions& aOptions )
       
   385 	{
       
   386 	PRINT_ENTRY;
       
   387 	if ( !iState->IsInitialized() )
       
   388 		{
       
   389 		aOptions = iBufferOptions;
       
   390 		}
       
   391 	else
       
   392 		{
       
   393 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
   394 		}
       
   395 	PRINT_EXIT;
       
   396 	}
       
   397 
       
   398 //---------------------------------------------------------------------------
       
   399 //Indicates which HRD/VBV specification is fulfilled in the input stream and
       
   400 //any related parameters.
       
   401 //---------------------------------------------------------------------------
       
   402 //
       
   403 void CAriH264decHwDevice::SetHrdVbvSpec(
       
   404 										THrdVbvSpecification /*aHrdVbvSpec*/,
       
   405 										const TDesC8& /*aHrdVbvParams*/ )
       
   406 	{
       
   407 	PRINT_ENTRY;
       
   408 	PRINT_EXIT;
       
   409 	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
   410 	}
       
   411 
       
   412 //---------------------------------------------------------------------------
       
   413 //Sets the output post-processor device to use.
       
   414 //---------------------------------------------------------------------------
       
   415 //
       
   416 void CAriH264decHwDevice::SetOutputDevice(
       
   417 										 CMMFVideoPostProcHwDevice* aDevice )
       
   418 	{
       
   419 	PRINT_ENTRY;
       
   420 	if ( !iState->IsInitialized() )
       
   421 		{
       
   422 		if ( !aDevice )
       
   423 			{
       
   424 			iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrArgument );
       
   425 			}
       
   426 		else
       
   427 			{
       
   428 			iOutputDevice = aDevice;
       
   429 
       
   430 			// checks whether customBuffer supported by o/p device
       
   431 			iCustomBufferHandle = ( MMmfVideoBufferManagement* )
       
   432 	      ( iOutputDevice->CustomInterface( KMmfVideoBuffermanagementUid ) );
       
   433 			}
       
   434 		}
       
   435 	else
       
   436 		{
       
   437 		PRINT_ERR( "istate is not initialized yet, "
       
   438 						"calling MdvppFatalError on iMMFDevVideoPlayProxy\n" );
       
   439 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
   440 		}
       
   441 	PRINT_EXIT;
       
   442 	}
       
   443 
       
   444 //---------------------------------------------------------------------------
       
   445 //Returns the current decoding position, i.e.
       
   446 //the timestamp for the most recently decoded picture.
       
   447 //---------------------------------------------------------------------------
       
   448 //
       
   449 TTimeIntervalMicroSeconds CAriH264decHwDevice::DecodingPosition()
       
   450 	{
       
   451 	PRINT_ENTRY;
       
   452 	if ( iState->IsInitialized() )
       
   453 		{
       
   454 		PRINT_EXIT;
       
   455 		return iDecodingPosition;
       
   456 		}
       
   457 	else
       
   458 		{
       
   459 		PRINT_ERR( "iState is not initialised, calling  MdvppFatalError\n" );
       
   460 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
   461 		return ( TTimeIntervalMicroSeconds( 0 ) );
       
   462 		}
       
   463 	}
       
   464 
       
   465 //---------------------------------------------------------------------------
       
   466 //Returns the current pre-decoder buffer size.
       
   467 //---------------------------------------------------------------------------
       
   468 //
       
   469 TUint CAriH264decHwDevice::PreDecoderBufferBytes()
       
   470 	{
       
   471 	PRINT_ENTRY;
       
   472     if ( !( iState->IsInitialized() ) )
       
   473         {
       
   474         iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
   475 		return ( 0 );
       
   476         }
       
   477 
       
   478     PRINT_EXIT;
       
   479     return 0;
       
   480 	}
       
   481 
       
   482 //---------------------------------------------------------------------------
       
   483 //Reads various counters related to the received input bitstream
       
   484 //and coded data units.
       
   485 //---------------------------------------------------------------------------
       
   486 //
       
   487 void CAriH264decHwDevice::GetBitstreamCounters(
       
   488 							CMMFDevVideoPlay::TBitstreamCounters& aCounters )
       
   489 	{
       
   490 	PRINT_ENTRY;
       
   491 	if ( iState->IsInitialized() )
       
   492 		{
       
   493 		aCounters = iBitstreamCounters;
       
   494 		//Reset the counters to Zero
       
   495 		iBitstreamCounters.iLostPackets = 0;
       
   496 		iBitstreamCounters.iTotalPackets = 0;
       
   497 		}
       
   498 	else
       
   499 		{
       
   500 		PRINT_ERR( "iState is not initialised, calling  MdvppFatalError\n" );
       
   501 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
   502 		}
       
   503 	PRINT_EXIT;
       
   504 	}
       
   505 
       
   506 //---------------------------------------------------------------------------
       
   507 //Retrieves the number of free input buffers the decoder has available
       
   508 //---------------------------------------------------------------------------
       
   509 //
       
   510 TUint CAriH264decHwDevice::NumFreeBuffers()
       
   511 	{
       
   512 	PRINT_ENTRY;
       
   513 	if ( iState->IsInitialized() )
       
   514 		{
       
   515 		if ( iNumberOfInputBuffersAllocated == 0 )
       
   516 		    {
       
   517 		    PRINT_EXIT;
       
   518 		    return ( iBufferOptions.iMinNumInputBuffers );
       
   519 		    }
       
   520 		else
       
   521 		    {
       
   522 		    PRINT_EXIT;
       
   523 		    return  ( iInputFreeBufferQueue.Count() );
       
   524 		    }
       
   525 		}
       
   526 	else
       
   527 		{
       
   528 		PRINT_ERR( "iState is not initialised, calling  MdvppFatalError\n" );
       
   529 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
   530 		return( 0 );
       
   531 		}
       
   532 	}
       
   533 
       
   534 //---------------------------------------------------------------------------
       
   535 //Returns an input buffer of size aBufferSize. If no buffer is available
       
   536 //then NULL is returned.
       
   537 //---------------------------------------------------------------------------
       
   538 //
       
   539 TVideoInputBuffer* CAriH264decHwDevice::GetBufferL( TUint aBufferSize )
       
   540 	{
       
   541 	PRINT_ENTRY;
       
   542 	if ( !( iState->IsInitialized() ) )
       
   543         {
       
   544         PRINT_ERR( "istate is not initialized yet\n" );
       
   545         User::Leave( KErrNotReady );
       
   546 		return NULL;
       
   547         }
       
   548 
       
   549     if ( iState->IsInputEndPending() )
       
   550 	    {
       
   551 	    PRINT_ERR( "input is pending\n" );
       
   552 		User::Leave( KErrNotReady );
       
   553 		return NULL;
       
   554 	    }
       
   555 
       
   556     if ( aBufferSize > iBufferOptions.iMaxInputBufferSize )
       
   557         {
       
   558         PRINT_ERR( "aBufferSize is more than the allowed size\n" );
       
   559         User::Leave( KErrArgument );
       
   560         return NULL;
       
   561         }
       
   562 
       
   563 
       
   564 	TVideoInputBuffer *inBuffer;
       
   565 
       
   566     if ( iNumberOfInputBuffersAllocated ==
       
   567 									     iBufferOptions.iMinNumInputBuffers )
       
   568         {
       
   569         if ( iInputFreeBufferQueue.Count() )
       
   570             {
       
   571             PRINT_ERR( "CreateInputBufferL returned ETRUE\n" );
       
   572             // Reallocate the input buffer if needed
       
   573 			CreateInputBufferL( aBufferSize, ETrue );
       
   574 			inBuffer = iInputFreeBufferQueue[0];
       
   575 			iInputFreeBufferQueue.Remove( 0 );
       
   576 
       
   577             }
       
   578         else
       
   579             {
       
   580             PRINT_ERR( "No input free buffers available \n" );
       
   581             return NULL;
       
   582             }
       
   583         }
       
   584     else if ( iNumberOfInputBuffersAllocated <
       
   585 										 iBufferOptions.iMinNumInputBuffers )
       
   586         {
       
   587         PRINT_ERR( "CreateInputBufferL returned EFALSE\n" );
       
   588         // Allocate new buffer of the requested size
       
   589         CreateInputBufferL( aBufferSize, EFalse );
       
   590 
       
   591         // remove the last created buffer
       
   592         inBuffer = iInputFreeBufferQueue[ iInputFreeBufferQueue.Count() - 1];
       
   593 
       
   594         iInputFreeBufferQueue.Remove( iInputFreeBufferQueue.Count() - 1 );
       
   595         }
       
   596     else
       
   597         {
       
   598         PRINT_ERR( "iNumberOfInputBuffersAllocated is less "
       
   599                 		"			iBufferOptions.iMinNumInputBuffers\n" );
       
   600         User::Leave( KErrGeneral ); // unwanted state;
       
   601         return NULL;
       
   602         }
       
   603 
       
   604     PRINT_EXIT;
       
   605 	return inBuffer;
       
   606 	}
       
   607 
       
   608 
       
   609 //---------------------------------------------------------------------------
       
   610 //Called by DevVideoPlay to write the coded data.
       
   611 //Writes a piece of coded video data to the decoder. The data buffer must
       
   612 //be retrieved from the decoder with GetBufferL()..
       
   613 //---------------------------------------------------------------------------
       
   614 //
       
   615 void CAriH264decHwDevice::WriteCodedDataL( TVideoInputBuffer* aBuffer )
       
   616 	{
       
   617 	PRINT_ENTRY;
       
   618 	if ( !iState->IsInitialized() )
       
   619 		{
       
   620 		PRINT_ERR( "istate is not initialized yet \n" );
       
   621 		User::Leave( KErrNotReady );
       
   622 		}
       
   623 
       
   624     if ( !aBuffer )
       
   625 		{
       
   626 		PRINT_ERR( "aBuffer is null \n" );
       
   627 		User::Leave( KErrArgument );
       
   628 		}
       
   629 
       
   630     if ( aBuffer->iData.Length() == 0 )
       
   631 	    {
       
   632 	    PRINT_ERR( "length of aBuffer is zero \n" );
       
   633 		User::Leave( KErrArgument );
       
   634 	    }
       
   635 
       
   636 	if ( iState->IsInputEndPending() )
       
   637 		{
       
   638 		PRINT_ERR( "IsInputEndPending is true \n" );
       
   639 		User::Leave( KErrEof );
       
   640 		}
       
   641 
       
   642 	if ( !iCodec )
       
   643 		{
       
   644 		iCodec = CAriH264decWrapper::NewL( iDataUnitType,
       
   645 				                           iOutputFormat,
       
   646 				                           &aBuffer->iData,
       
   647 				                           iStreamType );
       
   648 
       
   649 		iDecoderConfigured = ETrue;
       
   650 		}
       
   651 
       
   652 	if ( ( iDataUnitType == EDuSeveralSegments ) ||
       
   653 		 ( iDataUnitType == EDuVideoSegment ) )
       
   654 		{
       
   655 		iBitstreamCounters.iTotalPackets++;
       
   656 		}
       
   657 
       
   658 	// if custom interface is supported by o/p device get all the buffers
       
   659 	//and add it to Engine
       
   660 	if ( !iOutputBuffersCreated )
       
   661 		{
       
   662 		// Set Stream information
       
   663 		if ( !iDecoderConfigured )
       
   664 			{
       
   665 			User::Leave( KErrNotReady );
       
   666 			}
       
   667 
       
   668     	if ( !iCustomBufferHandle )
       
   669     		{
       
   670 			// Get o/p buffer length for creation
       
   671 			iCodec->GetParam( CONTROL_CMD_GET_OUTPUTBUFFERLENGTH,
       
   672 							  ( TAny* )&iOutputBufferSize );
       
   673 			CreateOutputBuffersL();
       
   674     		}
       
   675 		iOutputBuffersCreated = ETrue;
       
   676 		}
       
   677 
       
   678 	// add all the o/p buffers to engine
       
   679 	if ( !iBufferAdded )
       
   680 		{
       
   681 		if ( iCustomBufferHandle )
       
   682 			{
       
   683 			TVideoPicture* videoPicture = NULL;
       
   684 			for ( TInt i = 0;
       
   685 				  i < iCustomBufferOptions->iNumInputBuffers;
       
   686 				  i++ )
       
   687 				{
       
   688 				videoPicture =
       
   689 				iCustomBufferHandle->MmvbmGetBufferL(
       
   690 									     iCustomBufferOptions->iBufferSize );
       
   691 				if ( videoPicture )
       
   692 					{
       
   693 					TRAPD( lErr, videoPicture->iHeader =
       
   694 									new ( ELeave ) TVideoPictureHeader ) ;
       
   695 					if ( lErr != KErrNone )
       
   696                     	{
       
   697                     	iCustomBufferHandle->MmvbmReleaseBuffer(
       
   698 															  videoPicture );
       
   699                     	iMMFDevVideoPlayProxy->MdvppFatalError( this,
       
   700 															  KErrArgument );
       
   701                     	}
       
   702                     else
       
   703                     	{
       
   704 					    iEngine->AddOutput( videoPicture );
       
   705                     	}
       
   706 					}
       
   707 				else
       
   708 					{
       
   709 					break;
       
   710 					}
       
   711 				}
       
   712 			}
       
   713 		else
       
   714 			{
       
   715 			for( TInt i = 0; i < iOutputFreeBufferQueue.Count(); i++ )
       
   716 				{
       
   717 				iEngine->AddOutput( iOutputFreeBufferQueue[0] );
       
   718 				iOutputFreeBufferQueue.Remove( 0 );
       
   719 				}
       
   720 			}
       
   721 		iBufferAdded = ETrue;
       
   722 		}
       
   723 
       
   724 	iPictureCounters.iTotalPictures++;
       
   725 	iFilledBufferCounter++;
       
   726 	TInt err = iEngine->AddInput( aBuffer );
       
   727 	PRINT_MSG( LEVEL_LOW, ( "WriteCodedDataL, addinput err=%d", err ) );
       
   728 	PRINT_EXIT;
       
   729 	}
       
   730 
       
   731 //---------------------------------------------------------------------------
       
   732 //Configures the H264 decoder by passing the required header
       
   733 //information for the stream that is getting decoded. The header
       
   734 //structurespecific  to the Decoder is passed as iOptional member.
       
   735 //---------------------------------------------------------------------------
       
   736 //
       
   737 #ifdef SYMBIAN_MDF_API_V2
       
   738 void CAriH264decHwDevice::ConfigureDecoderL(
       
   739 							 const TVideoPictureHeader& aVideoPictureHeader )
       
   740 	{
       
   741 	PRINT_ENTRY;
       
   742 	if ( iState->IsInitialized() )
       
   743 		{
       
   744 		PRINT_ERR( "iState is already initialised \n" );
       
   745 		User::Leave( KErrNotReady );
       
   746 		}
       
   747 	if ( !iCodec )
       
   748 		{
       
   749 		iCodec = CAriH264decWrapper::NewL( iDataUnitType,
       
   750 				                       iOutputFormat,
       
   751 				                       aVideoPictureHeader.iOptional,
       
   752 				                       iStreamType );
       
   753 
       
   754 		if ( !iCodec )
       
   755 			{
       
   756 			PRINT_ERR( "codec wrapper returned error \n" );
       
   757 			User::Leave( KErrNotReady );
       
   758 			}
       
   759 		iDecoderConfigured = ETrue;
       
   760 	    iConfigureDecoderCalled = ETrue;
       
   761 		}
       
   762 
       
   763 	iWidthSource = aVideoPictureHeader.iSizeInMemory.iWidth;
       
   764 	iHeightSource = aVideoPictureHeader.iSizeInMemory.iHeight;
       
   765 	PRINT_EXIT;
       
   766 	}
       
   767 #endif
       
   768 
       
   769 
       
   770 
       
   771 //---------------------------------------------------------------------------
       
   772 //Retrieves post-processing information about this hardware device.
       
   773 //The device creates a CPostProcessorInfo structure, fills it with correct
       
   774 //data, pushes it to the cleanup stack and returns it. The client will
       
   775 //delete the object when it is no longer needed.
       
   776 //---------------------------------------------------------------------------
       
   777 //
       
   778 CPostProcessorInfo* CAriH264decHwDevice::PostProcessorInfoLC()
       
   779 	{
       
   780 	PRINT_ENTRY;
       
   781 	//Aricent decoder does not support any post processing functionality
       
   782 	RArray<TUncompressedVideoFormat> supportedFormats;
       
   783 	CleanupClosePushL( supportedFormats );
       
   784 
       
   785 	RArray<TUint32> supportedCombinations;
       
   786 	CleanupClosePushL( supportedCombinations );
       
   787 
       
   788 	TYuvToRgbCapabilities yuvToRgbCapabilities;
       
   789 	RArray<TScaleFactor> supportedScaleFactors;
       
   790 	CleanupClosePushL( supportedScaleFactors );
       
   791 
       
   792 	CPostProcessorInfo* info = CPostProcessorInfo::NewL(
       
   793 		KUidH264DecoderHwDevice,
       
   794 		KManufacturer,
       
   795 		KIdentifier,
       
   796 		TVersion( 1, 0, 0 ),
       
   797 		supportedFormats.Array(),
       
   798 		supportedCombinations.Array(),
       
   799 		EFalse, //Accelerated or not
       
   800 		EFalse, //supports DSA
       
   801 		yuvToRgbCapabilities,
       
   802 		ERotateNone, //supported rotations
       
   803 		EFalse, //supports Arbitrary scaling
       
   804 		supportedScaleFactors.Array(),
       
   805 		EFalse ) //supports antialiased scaling
       
   806         ;
       
   807 
       
   808 	CleanupStack::PushL( info );
       
   809 
       
   810 	CleanupStack::Pop( &supportedScaleFactors );
       
   811 	supportedScaleFactors.Close();
       
   812 	CleanupStack::Pop( &supportedCombinations );
       
   813 	supportedCombinations.Close();
       
   814 	CleanupStack::Pop( &supportedFormats );
       
   815 	supportedFormats.Close();
       
   816 
       
   817 	PRINT_EXIT;
       
   818 	return info;
       
   819 	}
       
   820 
       
   821 //---------------------------------------------------------------------------
       
   822 //Retrieves the list of the output formats that the device supports.
       
   823 //The list can depend on the device source format, and therefore
       
   824 //SetSourceFormatL() must be called before calling this method.
       
   825 //---------------------------------------------------------------------------
       
   826 //
       
   827 void CAriH264decHwDevice::GetOutputFormatListL(
       
   828 								 RArray<TUncompressedVideoFormat>& aFormats )
       
   829 	{
       
   830 	PRINT_ENTRY;
       
   831     if ( iState->IsInitialized() )
       
   832     	{
       
   833     	PRINT_ERR( "iState is already initialised \n" );
       
   834         User::Leave( KErrNotReady );
       
   835     	}
       
   836 
       
   837     if ( !iInputFormat )
       
   838 	    {
       
   839 		//Input format should be set before calling this function, as output
       
   840         // format is decided based on input format
       
   841 	    PRINT_ERR( "iInputFormat is not set yet \n" );
       
   842 		User::Leave( KErrNotReady );
       
   843 	    }
       
   844 
       
   845 	TUncompressedVideoFormat format;
       
   846 	format.iDataFormat = EYuvRawData;
       
   847 	format.iYuvFormat.iYuv2RgbMatrix = NULL;
       
   848 	format.iYuvFormat.iRgb2YuvMatrix = NULL;
       
   849 	format.iYuvFormat.iAspectRatioNum = 1;
       
   850 	format.iYuvFormat.iAspectRatioDenom = 1;
       
   851 
       
   852 	aFormats.Reset();
       
   853 
       
   854     //The following formats are supported by both H.263 and Mpeg-4
       
   855 
       
   856 	//YUV 420 Chroma0 Planar
       
   857 	format.iYuvFormat.iCoefficients = EYuvBt601Range0;
       
   858 	format.iYuvFormat.iPattern      = EYuv420Chroma1;
       
   859 	format.iYuvFormat.iDataLayout   = EYuvDataPlanar;
       
   860 	aFormats.Append( format );
       
   861 
       
   862     //YUV 422 Chroma LE Interleaved
       
   863     format.iYuvFormat.iPattern      = EYuv422Chroma1;
       
   864 	format.iYuvFormat.iDataLayout   = EYuvDataInterleavedLE;
       
   865     aFormats.Append( format );
       
   866 
       
   867     //YUV 422 Chroma BE Interleaved
       
   868     format.iYuvFormat.iDataLayout   = EYuvDataInterleavedBE;
       
   869     aFormats.Append( format );
       
   870 
       
   871     //The following formats are only supported by Mpeg-4
       
   872     if ( iInputFormat->MimeType().FindF( KH264SupportedMimeType ) !=
       
   873 															    KErrNotFound )
       
   874         {
       
   875         //BT 601.5 Full Range
       
   876         // YUV 420 Chroma0 Planar
       
   877         format.iYuvFormat.iCoefficients = EYuvBt601Range1;
       
   878 	    format.iYuvFormat.iPattern      = EYuv420Chroma1;
       
   879 	    format.iYuvFormat.iDataLayout   = EYuvDataPlanar;
       
   880         aFormats.Append( format );
       
   881 
       
   882         //YUV 422 Chroma LE Interleaved
       
   883         format.iYuvFormat.iPattern      = EYuv422Chroma1;
       
   884 	    format.iYuvFormat.iDataLayout   = EYuvDataInterleavedLE;
       
   885         aFormats.Append( format );
       
   886 
       
   887         //YUV 422 Chroma BE Interleaved
       
   888         format.iYuvFormat.iDataLayout   = EYuvDataInterleavedBE;
       
   889         aFormats.Append( format );
       
   890 
       
   891         //BT 709 Reduced Range
       
   892 	    // YUV 420 Chroma0 Planar
       
   893 	    format.iYuvFormat.iCoefficients = EYuvBt709Range0;
       
   894 	    format.iYuvFormat.iPattern      = EYuv420Chroma1;
       
   895 	    format.iYuvFormat.iDataLayout   = EYuvDataPlanar;
       
   896 	    aFormats.Append( format );
       
   897 
       
   898         //YUV 422 Chroma LE Interleaved
       
   899         format.iYuvFormat.iPattern      = EYuv422Chroma1;
       
   900 	    format.iYuvFormat.iDataLayout   = EYuvDataInterleavedLE;
       
   901         aFormats.Append( format );
       
   902 
       
   903         //YUV 422 Chroma BE Interleaved
       
   904         format.iYuvFormat.iDataLayout   = EYuvDataInterleavedBE;
       
   905         aFormats.Append( format );
       
   906 
       
   907         //BT 709 Full Range
       
   908         // YUV 420 Chroma0 Planar
       
   909 	    format.iYuvFormat.iCoefficients = EYuvBt709Range1;
       
   910 	    format.iYuvFormat.iPattern      = EYuv420Chroma1;
       
   911 	    format.iYuvFormat.iDataLayout   = EYuvDataPlanar;
       
   912 	    aFormats.Append( format );
       
   913 
       
   914         //YUV 422 Chroma LE Interleaved
       
   915         format.iYuvFormat.iPattern      = EYuv422Chroma1;
       
   916 	    format.iYuvFormat.iDataLayout   = EYuvDataInterleavedLE;
       
   917         aFormats.Append( format );
       
   918 
       
   919         //YUV 422 Chroma BE Interleaved
       
   920         format.iYuvFormat.iDataLayout   = EYuvDataInterleavedBE;
       
   921         aFormats.Append( format );
       
   922 	    }
       
   923     PRINT_EXIT;
       
   924     }
       
   925 
       
   926 //---------------------------------------------------------------------------
       
   927 // Sets the device output format.
       
   928 //---------------------------------------------------------------------------
       
   929 //
       
   930 void CAriH264decHwDevice::SetOutputFormatL(
       
   931 									const TUncompressedVideoFormat &aFormat )
       
   932 	{
       
   933 	PRINT_ENTRY;
       
   934     if ( iState->IsInitialized() )
       
   935     	{
       
   936     	PRINT_ERR( "istate is already initialised \n" );
       
   937         User::Leave( KErrNotReady );
       
   938     	}
       
   939 
       
   940     if ( !iInputFormat )
       
   941 	    {
       
   942 		//Input format should be set before calling this function, as output
       
   943         // format is decided based on input format
       
   944 	    PRINT_ERR( "iInputFormat is not set yet \n" );
       
   945 		User::Leave( KErrNotReady );
       
   946 	    }
       
   947 
       
   948 	// check whether the output format is supported or not. if not
       
   949     //supported leave
       
   950 	RArray<TUncompressedVideoFormat> formats;
       
   951 	CleanupClosePushL( formats );
       
   952 
       
   953 	GetOutputFormatListL( formats );
       
   954 
       
   955 	TBool flag = EFalse;
       
   956 
       
   957 	for ( TInt i = 0; i < formats.Count(); i++ )
       
   958 		{
       
   959 		if ( aFormat == formats[i] )
       
   960 			{
       
   961 			flag = ETrue;
       
   962 			break;
       
   963 			}
       
   964 		}
       
   965 	CleanupStack::Pop ( &formats );
       
   966     formats.Close();
       
   967 
       
   968 	if ( !flag )
       
   969 		{
       
   970 		PRINT_ERR( "outputformat is not supported \n" );
       
   971         User::Leave( KErrNotSupported );
       
   972 		}
       
   973 
       
   974     iOutputFormat = aFormat;
       
   975     PRINT_EXIT;
       
   976 	}
       
   977 
       
   978 //---------------------------------------------------------------------------
       
   979 // Sets the clock source to use for video timing.
       
   980 //---------------------------------------------------------------------------
       
   981 //
       
   982 void CAriH264decHwDevice::SetClockSource( MMMFClockSource* /*aClock*/ )
       
   983 	{
       
   984 	PRINT_ENTRY;
       
   985     if ( iState->IsInitialized() )
       
   986     	{
       
   987     	PRINT_ERR( "iState is initialised,calling MdvppFatalError \n" );
       
   988 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
   989     	}
       
   990 
       
   991     PRINT_EXIT;
       
   992 	return;
       
   993 	}
       
   994 
       
   995 //---------------------------------------------------------------------------
       
   996 // Sets the device video output destination.
       
   997 //---------------------------------------------------------------------------
       
   998 //
       
   999 void CAriH264decHwDevice::SetVideoDestScreenL( TBool aScreen )
       
  1000 	{
       
  1001 	PRINT_ENTRY;
       
  1002 	if ( !iState->IsInitialized() )
       
  1003 		{
       
  1004 		if ( aScreen )
       
  1005 			{
       
  1006 			PRINT_ERR( "KErrNotSupported \n" );
       
  1007 			User::Leave( KErrNotSupported );
       
  1008 			}
       
  1009 		}
       
  1010 	else
       
  1011 		{
       
  1012 		PRINT_ERR( "KErrNotSupported \n" );
       
  1013 		User::Leave( KErrNotReady );
       
  1014 		}
       
  1015 	PRINT_EXIT;
       
  1016 	}
       
  1017 
       
  1018 //---------------------------------------------------------------------------
       
  1019 // Sets the post-processing types to be used.
       
  1020 //---------------------------------------------------------------------------
       
  1021 //
       
  1022 void CAriH264decHwDevice::SetPostProcessTypesL(
       
  1023 										   TUint32 /*aPostProcCombination*/ )
       
  1024 	{
       
  1025 	PRINT_ENTRY;
       
  1026 	PRINT_ERR( "KErrNotSupported API\n" );
       
  1027 	PRINT_EXIT;
       
  1028 	User::Leave( KErrNotSupported );
       
  1029 	}
       
  1030 
       
  1031 //---------------------------------------------------------------------------
       
  1032 // Sets post-processing options for input (pan-scan ) cropping.
       
  1033 //---------------------------------------------------------------------------
       
  1034 //
       
  1035 void CAriH264decHwDevice::SetInputCropOptionsL( const TRect& /*aRect*/ )
       
  1036 	{
       
  1037 	PRINT_ENTRY;
       
  1038 	PRINT_ERR( "KErrNotSupported API\n" );
       
  1039 	PRINT_EXIT;
       
  1040 	User::Leave( KErrNotSupported );
       
  1041 	}
       
  1042 
       
  1043 
       
  1044 //---------------------------------------------------------------------------
       
  1045 // Sets post-processing options for YUV to RGB color space conversion
       
  1046 //---------------------------------------------------------------------------
       
  1047 //
       
  1048 void CAriH264decHwDevice::SetYuvToRgbOptionsL(
       
  1049 										const TYuvToRgbOptions& /*aOptions*/,
       
  1050 										const TYuvFormat& /*aYuvFormat*/,
       
  1051 										TRgbFormat /*aRgbFormat*/ )
       
  1052 	{
       
  1053 	PRINT_ENTRY;
       
  1054 	PRINT_ERR( "KErrNotSupported API\n" );
       
  1055 	PRINT_EXIT;
       
  1056 	User::Leave( KErrNotSupported );
       
  1057 	}
       
  1058 
       
  1059 //---------------------------------------------------------------------------
       
  1060 // Sets post-processing options for YUV to RGB color space conversion. Uses
       
  1061 //the device input and output formats.
       
  1062 //---------------------------------------------------------------------------
       
  1063 //
       
  1064 void CAriH264decHwDevice::SetYuvToRgbOptionsL(
       
  1065 									   const TYuvToRgbOptions& /*aOptions*/ )
       
  1066 	{
       
  1067 	PRINT_ENTRY;
       
  1068 	PRINT_ERR( "KErrNotSupported API\n" );
       
  1069 	PRINT_EXIT;
       
  1070 	User::Leave( KErrNotSupported );
       
  1071 	}
       
  1072 
       
  1073 //---------------------------------------------------------------------------
       
  1074 // Sets post-processing options for rotation. SetPostProcessTypesL() must be
       
  1075 //called before this method is used.
       
  1076 //---------------------------------------------------------------------------
       
  1077 //
       
  1078 void CAriH264decHwDevice::SetRotateOptionsL( TRotationType /*aRotationType*/ )
       
  1079 	{
       
  1080 	PRINT_ENTRY;
       
  1081 	PRINT_ERR( "KErrNotSupported API\n" );
       
  1082 	PRINT_EXIT;
       
  1083 	User::Leave( KErrNotSupported );
       
  1084 	}
       
  1085 
       
  1086 //---------------------------------------------------------------------------
       
  1087 //Sets post-processing options for scaling. SetPostProcessTypesL() must be
       
  1088 //called before this method is used.
       
  1089 //---------------------------------------------------------------------------
       
  1090 //
       
  1091 void CAriH264decHwDevice::SetScaleOptionsL( const TSize& /*aTargetSize*/,
       
  1092 											TBool /*aAntiAliasFiltering*/ )
       
  1093 	{
       
  1094 	PRINT_ENTRY;
       
  1095 	PRINT_ERR( "KErrNotSupported API\n" );
       
  1096 	PRINT_EXIT;
       
  1097 	User::Leave( KErrNotSupported );
       
  1098 	}
       
  1099 
       
  1100 //---------------------------------------------------------------------------
       
  1101 //Sets post-processing options for output cropping.
       
  1102 //---------------------------------------------------------------------------
       
  1103 //
       
  1104 void CAriH264decHwDevice::SetOutputCropOptionsL( const TRect& /*aRect*/ )
       
  1105 	{
       
  1106 	PRINT_ENTRY;
       
  1107 	PRINT_ERR( "KErrNotSupported API\n" );
       
  1108 	PRINT_EXIT;
       
  1109 	User::Leave( KErrNotSupported );
       
  1110 	}
       
  1111 
       
  1112 
       
  1113 //---------------------------------------------------------------------------
       
  1114 //Sets post-processing plug-in specific options.
       
  1115 //---------------------------------------------------------------------------
       
  1116 //
       
  1117 void CAriH264decHwDevice::SetPostProcSpecificOptionsL(
       
  1118 												 const TDesC8& /*aOptions*/ )
       
  1119 	{
       
  1120 	PRINT_ENTRY;
       
  1121 	PRINT_ERR( "KErrNotSupported API\n" );
       
  1122 	PRINT_EXIT;
       
  1123 	User::Leave( KErrNotSupported );
       
  1124 	}
       
  1125 
       
  1126 //---------------------------------------------------------------------------
       
  1127 //Initializes the device. This method is asynchronous, the device calls
       
  1128 //MdvppInitializeComplete() of MMFVideoPlayProxy after initialization has
       
  1129 //completed. After this method has successfully completed, further
       
  1130 //configuration changes are not possible except where separately noted.
       
  1131 //---------------------------------------------------------------------------
       
  1132 //
       
  1133 void CAriH264decHwDevice::Initialize()
       
  1134 	{
       
  1135 	PRINT_ENTRY;
       
  1136     if ( !iState->IsTransitionValid( CStateMachine::EInitializeCommand ) )
       
  1137 		{
       
  1138 		PRINT_ERR( "state is not valid in statemachine \n" );
       
  1139 		iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, KErrNotReady );
       
  1140         return;
       
  1141 		}
       
  1142 
       
  1143     TRAPD( err, iInputFreeBuffers	=
       
  1144       new ( ELeave ) TVideoInputBuffer[iBufferOptions.iMinNumInputBuffers] );
       
  1145     if ( err )
       
  1146         {
       
  1147         iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err );
       
  1148         PRINT_ERR( "creation of iInputFreeBuffers returned error\n" );
       
  1149 		return;
       
  1150 		}
       
  1151 
       
  1152 	iPictureCounters.iPicturesDisplayed = 0;
       
  1153 	iPictureCounters.iPicturesSkipped = 0;
       
  1154 	iPictureCounters.iTotalPictures = 0;
       
  1155 	iPictureCounters.iPicturesDecoded = 0;
       
  1156 
       
  1157 	iBitstreamCounters.iLostPackets = 0;
       
  1158 	iBitstreamCounters.iTotalPackets = 0;
       
  1159 
       
  1160 	// if custom interface is supported then enable the interface
       
  1161 	if ( iCustomBufferHandle )
       
  1162 		{
       
  1163 
       
  1164 		TRAP( err, iCustomBufferOptions =
       
  1165 		          new ( ELeave ) MMmfVideoBufferManagement::TBufferOptions );
       
  1166 
       
  1167 		if ( err != KErrNone )
       
  1168 			{
       
  1169 			iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err );
       
  1170 			PRINT_ERR( "creation of iCustomBuffeOptions returned error \n" );
       
  1171 			return;
       
  1172 			}
       
  1173 
       
  1174 		iCustomBufferOptions->iNumInputBuffers = KMaxOutputBuffers + 1;
       
  1175 		iCustomBufferOptions->iBufferSize	= TSize( KMaxFrameWidth,
       
  1176 				KMaxFrameHeight );
       
  1177 
       
  1178 		PRINT_MSG( LEVEL_HIGH, ( "w = %d, h = %d \n", KMaxFrameWidth,
       
  1179 				KMaxFrameHeight) );
       
  1180 
       
  1181 		iCustomBufferHandle->MmvbmSetObserver(
       
  1182 							   ( MMmfVideoBufferManagementObserver * )this );
       
  1183 
       
  1184 		iCustomBufferHandle->MmvbmEnable( ETrue );
       
  1185 
       
  1186 		TRAP ( err, iCustomBufferHandle->MmvbmSetBufferOptionsL(
       
  1187 												*iCustomBufferOptions ) );
       
  1188 
       
  1189 		if ( err != KErrNone )
       
  1190 			{
       
  1191 			iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err );
       
  1192 			PRINT_ERR( "iCustomBufferHandle->MmvbmSetBufferOptionsL \n" );
       
  1193 			return;
       
  1194 			}
       
  1195 		}
       
  1196 	// Engine Creation
       
  1197 	TRAP( err, iEngine = CBaseEngine::NewL( this,
       
  1198 											 ( MBaseCodec* )iCodec,
       
  1199 											 EFalse ) );
       
  1200 	if ( err != KErrNone )
       
  1201 		{
       
  1202 		iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err );
       
  1203 		PRINT_ERR( "Baseengine::NewL returned error \n" );
       
  1204 		return;
       
  1205 		}
       
  1206 
       
  1207 	// set input & output formats to Codec
       
  1208 
       
  1209 	err = iState->Transit( CStateMachine::EInitializeCommand );
       
  1210 	if ( err )
       
  1211 		{
       
  1212 		iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err );
       
  1213 		return;
       
  1214 		}
       
  1215 
       
  1216 	iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, KErrNone );
       
  1217 	PRINT_EXIT;
       
  1218 	}
       
  1219 
       
  1220 //---------------------------------------------------------------------------
       
  1221 //Commit all changes since the last CommitL(), Revert() or Initialize()
       
  1222 //to the hardware device. This only applies to methods which can be called
       
  1223 //both before AND after DevVideoPlay has been initialized.
       
  1224 //---------------------------------------------------------------------------
       
  1225 //
       
  1226 void CAriH264decHwDevice::CommitL()
       
  1227 	{
       
  1228 	PRINT_ENTRY;
       
  1229     if ( !( iState->IsInitialized() ) )
       
  1230 	    {
       
  1231 	    PRINT_ERR( "istate is not initialised yet \n" );
       
  1232 		User::Leave( KErrNotReady );
       
  1233 	    }
       
  1234     PRINT_EXIT;
       
  1235     return;
       
  1236 	}
       
  1237 
       
  1238 //---------------------------------------------------------------------------
       
  1239 //Revert all changes since the last CommitL(), Revert() or Initialize() back
       
  1240 //to their previous settings. This only applies to methods which can be
       
  1241 //called both before AND after DevVideoPlay has been initialized..
       
  1242 //---------------------------------------------------------------------------
       
  1243 //
       
  1244 void CAriH264decHwDevice::Revert()
       
  1245 	{
       
  1246 	PRINT_ENTRY;
       
  1247     if ( !( iState->IsInitialized() ) )
       
  1248 	    {
       
  1249 	    PRINT_ERR( "istate is not initialised yet \n" );
       
  1250 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
  1251 	    }
       
  1252     PRINT_EXIT;
       
  1253     return;
       
  1254 	}
       
  1255 
       
  1256 //---------------------------------------------------------------------------
       
  1257 //Not Supported.
       
  1258 //---------------------------------------------------------------------------
       
  1259 //
       
  1260 void CAriH264decHwDevice::StartDirectScreenAccessL(
       
  1261 										 const TRect& /*aVideoRect*/,
       
  1262 									     CFbsScreenDevice& /*aScreenDevice*/,
       
  1263 										 const TRegion& /*aClipRegion*/ )
       
  1264 	{
       
  1265 	PRINT_ENTRY;
       
  1266 	PRINT_ERR( "Not supported API \n" );
       
  1267 	PRINT_EXIT;
       
  1268 	User::Leave( KErrNotSupported );
       
  1269 	}
       
  1270 
       
  1271 //---------------------------------------------------------------------------
       
  1272 //Not Supported.
       
  1273 //---------------------------------------------------------------------------
       
  1274 //
       
  1275 void CAriH264decHwDevice::SetScreenClipRegion( const TRegion& /*aRegion*/ )
       
  1276 	{
       
  1277 	PRINT_ENTRY;
       
  1278 	PRINT_ERR( "Not supported API \n" );
       
  1279 	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
  1280 	PRINT_EXIT;
       
  1281 	return;
       
  1282 	}
       
  1283 
       
  1284 //---------------------------------------------------------------------------
       
  1285 //Not Supported.
       
  1286 //---------------------------------------------------------------------------
       
  1287 //
       
  1288 void CAriH264decHwDevice::SetPauseOnClipFail( TBool /*aPause*/ )
       
  1289 	{
       
  1290 	PRINT_ENTRY;
       
  1291 	PRINT_ERR( "Not supported API \n" );
       
  1292 	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
  1293 	PRINT_EXIT;
       
  1294 	return;
       
  1295 	}
       
  1296 
       
  1297 //---------------------------------------------------------------------------
       
  1298 //Not Supported.
       
  1299 //---------------------------------------------------------------------------
       
  1300 //
       
  1301 void CAriH264decHwDevice::AbortDirectScreenAccess()
       
  1302 	{
       
  1303 	PRINT_ENTRY;
       
  1304 	PRINT_ERR( "Not supported API \n" );
       
  1305 	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
  1306 	PRINT_EXIT;
       
  1307 	return;
       
  1308 	}
       
  1309 
       
  1310 //---------------------------------------------------------------------------
       
  1311 //Indicates whether playback is proceeding. This method can be used to check
       
  1312 //whether playback was paused or not in response to a new clipping region
       
  1313 //or DSA abort
       
  1314 //---------------------------------------------------------------------------
       
  1315 //
       
  1316 TBool CAriH264decHwDevice::IsPlaying()
       
  1317 	{
       
  1318 	PRINT_ENTRY;
       
  1319 	if ( !( iState->IsInitialized() ) )
       
  1320 		{
       
  1321 		PRINT_ERR( "istate is not initialised yet \n" );
       
  1322 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1323 		}
       
  1324 	PRINT_EXIT;
       
  1325 	return ( iState->IsStarted() );
       
  1326 	}
       
  1327 
       
  1328 //---------------------------------------------------------------------------
       
  1329 //Not Supported.
       
  1330 //---------------------------------------------------------------------------
       
  1331 //
       
  1332 void CAriH264decHwDevice::Redraw()
       
  1333 	{
       
  1334 	PRINT_ENTRY;
       
  1335 	PRINT_ERR( "Not supported API \n" );
       
  1336 	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
  1337 	PRINT_EXIT;
       
  1338 	return;
       
  1339 	}
       
  1340 
       
  1341 //---------------------------------------------------------------------------
       
  1342 //Starts video playback, including decoding, post-processing, and rendering.
       
  1343 //Playback will proceed until it has been stopped or paused, or the end of
       
  1344 //the bitstream is reached.
       
  1345 //---------------------------------------------------------------------------
       
  1346 //
       
  1347 void CAriH264decHwDevice::Start()
       
  1348 	{
       
  1349 	PRINT_ENTRY;
       
  1350     if ( iState->IsPlaying() )
       
  1351     	{
       
  1352 		PRINT_EXIT;
       
  1353 		PRINT_ERR( "already in playing state \n" );
       
  1354         return;
       
  1355     	}
       
  1356 
       
  1357 	if ( !iState->IsTransitionValid( CStateMachine::EStartCommand ) )
       
  1358 		{
       
  1359 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1360 		}
       
  1361 
       
  1362 	iDecodingPosition = TTimeIntervalMicroSeconds( 0 );
       
  1363 	iEngine->Start();
       
  1364 
       
  1365 	TInt error = iState->Transit( CStateMachine::EStartCommand );
       
  1366 	if ( error != KErrNone )
       
  1367 		{
       
  1368 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1369 		}
       
  1370 	PRINT_EXIT;
       
  1371 	}
       
  1372 
       
  1373 //---------------------------------------------------------------------------
       
  1374 //Stops video playback. No new pictures will be decoded, post-processed,
       
  1375 //or rendered.
       
  1376 //---------------------------------------------------------------------------
       
  1377 //
       
  1378 void CAriH264decHwDevice::Stop()
       
  1379 	{
       
  1380 	PRINT_ENTRY;
       
  1381     if ( iState->IsStopped() )
       
  1382     	{
       
  1383 		PRINT_EXIT;
       
  1384 		PRINT_ERR( "already in stopped state \n" );
       
  1385         return;
       
  1386     	}
       
  1387 
       
  1388 	if ( !iState->IsTransitionValid( CStateMachine::EStopCommand ) )
       
  1389 		{
       
  1390 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1391 		}
       
  1392 
       
  1393 	iPictureNumber = 0;
       
  1394 	// Stop & Reset the Engine
       
  1395 	iEngine->Stop();
       
  1396 	iEngine->Reset();
       
  1397 	iBufferAdded			= EFalse;
       
  1398 	iFilledBufferCounter	= 0;
       
  1399 	iInputEndCalled			= EFalse;
       
  1400 	TInt error = iState->Transit( CStateMachine::EStopCommand );
       
  1401 	if ( error != KErrNone )
       
  1402 		{
       
  1403 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1404 		}
       
  1405 	PRINT_EXIT;
       
  1406 	}
       
  1407 
       
  1408 //---------------------------------------------------------------------------
       
  1409 //Pauses video playback, including decoding, post-processing, and rendering.
       
  1410 //No pictures will be decoded, post-processed, or rendered until playback has
       
  1411 //been resumed.
       
  1412 //---------------------------------------------------------------------------
       
  1413 //
       
  1414 void CAriH264decHwDevice::Pause()
       
  1415 	{
       
  1416 	PRINT_ENTRY;
       
  1417     if ( iState->IsPaused() )
       
  1418     	{
       
  1419 		PRINT_EXIT;
       
  1420 		PRINT_ERR( "already in paused state \n" );
       
  1421         return;
       
  1422     	}
       
  1423 
       
  1424 	if ( !iState->IsTransitionValid( CStateMachine::EPauseCommand ) )
       
  1425 		{
       
  1426 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1427 		}
       
  1428 
       
  1429 	//Stop the Engine
       
  1430 	iEngine->Stop();
       
  1431 
       
  1432 	TInt error = iState->Transit( CStateMachine::EPauseCommand );
       
  1433 	if ( error != KErrNone )
       
  1434 		{
       
  1435 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1436 		}
       
  1437 	PRINT_EXIT;
       
  1438 	}
       
  1439 
       
  1440 //---------------------------------------------------------------------------
       
  1441 //Resumes video playback after a pause.
       
  1442 //---------------------------------------------------------------------------
       
  1443 //
       
  1444 void CAriH264decHwDevice::Resume()
       
  1445 	{
       
  1446 	PRINT_ENTRY;
       
  1447     if ( iState->IsPlaying() )
       
  1448     	{
       
  1449 		PRINT_EXIT;
       
  1450 		PRINT_ERR( "already in playing state \n" );
       
  1451         return;
       
  1452     	}
       
  1453 
       
  1454 	if ( !iState->IsTransitionValid( CStateMachine::EResumeCommand ) )
       
  1455 		{
       
  1456 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1457 		}
       
  1458 
       
  1459 	// Start The Engine
       
  1460 	iEngine->Start();
       
  1461 
       
  1462 	TInt error = iState->Transit( CStateMachine::EResumeCommand );
       
  1463 	if ( error != KErrNone )
       
  1464 		{
       
  1465 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1466 		}
       
  1467 	PRINT_EXIT;
       
  1468 	}
       
  1469 
       
  1470 
       
  1471 
       
  1472 //---------------------------------------------------------------------------
       
  1473 //Changes to a new decoding and playback position,used for randomly accessing
       
  1474 //(seeking)the input stream. The position change flushes all input and output
       
  1475 //buffers. Pre-decoder and post-decoder buffering are handled as if a new
       
  1476 //bitstream was being decoded. If the device still has buffered pictures that
       
  1477 //precede the new playback position, they will be discarded. If playback is
       
  1478 //synchronized to a clock source, the client is responsible for setting the
       
  1479 //clock source to the new position..
       
  1480 //---------------------------------------------------------------------------
       
  1481 //
       
  1482 void CAriH264decHwDevice::SetPosition(
       
  1483 						const TTimeIntervalMicroSeconds& aPlaybackPosition )
       
  1484 	{
       
  1485 	PRINT_ENTRY;
       
  1486 	//Start Decoding from new position
       
  1487 	if ( iState->IsInitialized() )
       
  1488 		{
       
  1489 		iEngine->Stop();
       
  1490 		iEngine->Reset();
       
  1491         iDecodingPosition = aPlaybackPosition;
       
  1492 		iBufferAdded = EFalse;
       
  1493 		iEngine->Start();
       
  1494 		}
       
  1495 	else
       
  1496 		{
       
  1497 		PRINT_ERR( "istate is not initialised yet\n" );
       
  1498 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1499 		}
       
  1500 	PRINT_EXIT;
       
  1501 	}
       
  1502 
       
  1503 
       
  1504 //---------------------------------------------------------------------------
       
  1505 //Not Supported.
       
  1506 //---------------------------------------------------------------------------
       
  1507 //
       
  1508 void CAriH264decHwDevice::FreezePicture(
       
  1509 							const TTimeIntervalMicroSeconds& /*aTimestamp*/ )
       
  1510 	{
       
  1511 	PRINT_ENTRY;
       
  1512 	PRINT_ERR( "not supported API \n" );
       
  1513 	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
  1514 	PRINT_EXIT;
       
  1515 	return;
       
  1516 	}
       
  1517 
       
  1518 //---------------------------------------------------------------------------
       
  1519 //Not Supported.
       
  1520 //---------------------------------------------------------------------------
       
  1521 //
       
  1522 void CAriH264decHwDevice::ReleaseFreeze(
       
  1523 							const TTimeIntervalMicroSeconds& /*aTimestamp*/ )
       
  1524 	{
       
  1525 	PRINT_ENTRY;
       
  1526 	PRINT_ERR( "not supported API \n" );
       
  1527 	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
  1528 	PRINT_EXIT;
       
  1529 	return;
       
  1530 	}
       
  1531 
       
  1532 //---------------------------------------------------------------------------
       
  1533 //Returns the current playback position, i.e. the timestamp for the most
       
  1534 //recently displayed or virtually displayed picture. If the device output
       
  1535 //is written to another device, the most recent output picture is used
       
  1536 //---------------------------------------------------------------------------
       
  1537 //
       
  1538 TTimeIntervalMicroSeconds CAriH264decHwDevice::PlaybackPosition()
       
  1539 	{
       
  1540 	PRINT_ENTRY;
       
  1541 	// In Decoder case decoding position is same as playback position
       
  1542 	if ( !( iState->IsInitialized() ) )
       
  1543 		{
       
  1544 		PRINT_ERR( "iState is not initialised \n" );
       
  1545 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1546 		}
       
  1547 
       
  1548 	PRINT_EXIT;
       
  1549 	return iDecodingPosition;
       
  1550 	}
       
  1551 
       
  1552 //---------------------------------------------------------------------------
       
  1553 //Returns the total amount of memory allocated for uncompressed pictures.
       
  1554 //---------------------------------------------------------------------------
       
  1555 //
       
  1556 TUint CAriH264decHwDevice::PictureBufferBytes()
       
  1557 	{
       
  1558 	PRINT_ENTRY;
       
  1559 	if ( !( iState->IsInitialized() ) )
       
  1560 		{
       
  1561 		PRINT_ERR( "iState is not initialised \n" );
       
  1562 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1563 		}
       
  1564 
       
  1565 	PRINT_EXIT;
       
  1566 	return( KMaxOutputBuffers * iOutputBufferSize );
       
  1567 	}
       
  1568 
       
  1569 //---------------------------------------------------------------------------
       
  1570 //Reads various counters related to decoded pictures.
       
  1571 //---------------------------------------------------------------------------
       
  1572 //
       
  1573 void CAriH264decHwDevice::GetPictureCounters(
       
  1574 							CMMFDevVideoPlay::TPictureCounters& aCounters )
       
  1575 	{
       
  1576 	PRINT_ENTRY;
       
  1577     if ( !( iState->IsInitialized() ) )
       
  1578     	{
       
  1579     	PRINT_ERR( "iState is not initialised yet \n" );
       
  1580 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1581     	}
       
  1582 
       
  1583 	aCounters = iPictureCounters;
       
  1584 
       
  1585 	//Reset the counters to Zero
       
  1586 	iPictureCounters.iPicturesDisplayed = 0;
       
  1587 	iPictureCounters.iPicturesSkipped = 0;
       
  1588 	iPictureCounters.iTotalPictures = 0;
       
  1589 	iPictureCounters.iPicturesDecoded = 0;
       
  1590 	PRINT_EXIT;
       
  1591 	}
       
  1592 
       
  1593 //---------------------------------------------------------------------------
       
  1594 //Not supported API.
       
  1595 //---------------------------------------------------------------------------
       
  1596 //
       
  1597 void CAriH264decHwDevice::SetComplexityLevel( TUint /*aLevel*/ )
       
  1598 	{
       
  1599 	PRINT_ENTRY;
       
  1600 	PRINT_ERR( "not supported API\n" );
       
  1601 	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
  1602 	PRINT_EXIT;
       
  1603 	}
       
  1604 
       
  1605 //---------------------------------------------------------------------------
       
  1606 //Not supported API.
       
  1607 //---------------------------------------------------------------------------
       
  1608 //
       
  1609 TUint CAriH264decHwDevice::NumComplexityLevels()
       
  1610 	{
       
  1611 	PRINT_ENTRY;
       
  1612 	PRINT_ERR( "not supported API\n" );
       
  1613 	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
  1614 	PRINT_EXIT;
       
  1615 	return 0;
       
  1616 	}
       
  1617 
       
  1618 //---------------------------------------------------------------------------
       
  1619 //Not supported API.
       
  1620 //---------------------------------------------------------------------------
       
  1621 //
       
  1622 void CAriH264decHwDevice::GetComplexityLevelInfo( TUint /*aLevel*/,
       
  1623 						CMMFDevVideoPlay::TComplexityLevelInfo& /*aInfo*/ )
       
  1624 	{
       
  1625 	PRINT_ENTRY;
       
  1626 	PRINT_ERR( "not supported API\n" );
       
  1627 	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
  1628 	PRINT_EXIT;
       
  1629 	}
       
  1630 
       
  1631 //---------------------------------------------------------------------------
       
  1632 //Called by the Post Proc hwdevice when a picture is displayed on the screen.
       
  1633 //Returns a picture back to the device.
       
  1634 //---------------------------------------------------------------------------
       
  1635 //
       
  1636 void CAriH264decHwDevice::ReturnPicture( TVideoPicture* aPicture )
       
  1637 	{
       
  1638 	PRINT_ENTRY;
       
  1639     if ( !( iState->IsInitialized() ) )
       
  1640     	{
       
  1641     	PRINT_ERR( "iState is not initialised yet \n" );
       
  1642 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1643     	}
       
  1644 
       
  1645     if ( iCustomBufferHandle )
       
  1646 		{
       
  1647 	    delete aPicture->iHeader ;
       
  1648 	    aPicture->iHeader = NULL ;
       
  1649 		}
       
  1650 	else
       
  1651 		{
       
  1652 		// add to engine if state is not stopped
       
  1653 		if ( iState->IsStopped() )
       
  1654 			{
       
  1655 			iOutputFreeBufferQueue.Append( aPicture );
       
  1656 			}
       
  1657 		else
       
  1658 			{
       
  1659 			iEngine->AddOutput( aPicture );
       
  1660 			}
       
  1661 		}
       
  1662 
       
  1663 	PRINT_EXIT;
       
  1664 	}
       
  1665 
       
  1666 //---------------------------------------------------------------------------
       
  1667 //Not supported API.
       
  1668 //---------------------------------------------------------------------------
       
  1669 //
       
  1670 TBool CAriH264decHwDevice::GetSnapshotL( TPictureData& /*aPictureData*/,
       
  1671 								const TUncompressedVideoFormat& /*aFormat*/ )
       
  1672 	{
       
  1673 	PRINT_ENTRY;
       
  1674 	PRINT_ERR( "not supported API\n" );
       
  1675 	PRINT_EXIT;
       
  1676 	User::Leave( KErrNotSupported );
       
  1677 	return( 0 );
       
  1678 	}
       
  1679 
       
  1680 //---------------------------------------------------------------------------
       
  1681 //Not supported API.
       
  1682 //---------------------------------------------------------------------------
       
  1683 //
       
  1684 void CAriH264decHwDevice::GetTimedSnapshotL(
       
  1685 				TPictureData* /*aPictureData*/,
       
  1686 				const TUncompressedVideoFormat& /*aFormat*/,
       
  1687 				const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/ )
       
  1688 	{
       
  1689 	PRINT_ENTRY;
       
  1690 	PRINT_ERR( "not supported API\n" );
       
  1691 	//Should take it from Post Proc HwDevice
       
  1692 	PRINT_EXIT;
       
  1693 	User::Leave( KErrNotSupported );
       
  1694 	}
       
  1695 
       
  1696 //---------------------------------------------------------------------------
       
  1697 //Not supported API.
       
  1698 //---------------------------------------------------------------------------
       
  1699 //
       
  1700 void CAriH264decHwDevice::GetTimedSnapshotL(
       
  1701 								TPictureData* /*aPictureData*/,
       
  1702 								const TUncompressedVideoFormat& /*aFormat*/,
       
  1703 								const TPictureId& /*aPictureId*/ )
       
  1704 	{
       
  1705 	PRINT_ENTRY;
       
  1706 	PRINT_ERR( "not supported API\n" );
       
  1707 	 //Should take it from Post Proc HwDevice
       
  1708 	PRINT_EXIT;
       
  1709 	User::Leave( KErrNotSupported );
       
  1710 	}
       
  1711 
       
  1712 //---------------------------------------------------------------------------
       
  1713 //Not supported API.
       
  1714 //---------------------------------------------------------------------------
       
  1715 //
       
  1716 void CAriH264decHwDevice::CancelTimedSnapshot()
       
  1717 	{
       
  1718 	PRINT_ENTRY;
       
  1719 	PRINT_ERR( "not supported API\n" );
       
  1720 	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported );
       
  1721 	PRINT_EXIT;
       
  1722 	return;
       
  1723 	}
       
  1724 
       
  1725 
       
  1726 //---------------------------------------------------------------------------
       
  1727 //Not supported API.
       
  1728 //---------------------------------------------------------------------------
       
  1729 //
       
  1730 void CAriH264decHwDevice::GetSupportedSnapshotFormatsL(
       
  1731 							 RArray<TUncompressedVideoFormat>& /*aFormats*/ )
       
  1732 	{
       
  1733 	PRINT_ENTRY;
       
  1734 	PRINT_ERR( "not supported API\n" );
       
  1735 	PRINT_EXIT;
       
  1736 	User::Leave( KErrNotSupported );
       
  1737 	}
       
  1738 
       
  1739 //---------------------------------------------------------------------------
       
  1740 //sets the Flag iInputEndCalled to ETrue
       
  1741 //Notifies the hardware device that the end of input data has been reached
       
  1742 //and no more input data will be written
       
  1743 //---------------------------------------------------------------------------
       
  1744 //
       
  1745 void CAriH264decHwDevice::InputEnd()
       
  1746 	{
       
  1747 	PRINT_ENTRY;
       
  1748 	if ( !( iState->IsTransitionValid( CStateMachine::EInputEndCommand ) ) )
       
  1749 		{
       
  1750 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1751 		}
       
  1752 
       
  1753 	iInputEndCalled = ETrue;
       
  1754 
       
  1755 	if ( iFilledBufferCounter == 0 )
       
  1756 		{
       
  1757 		Stop();
       
  1758 		PRINT_EXIT;
       
  1759 		iMMFDevVideoPlayProxy->MdvppStreamEnd();
       
  1760         return;
       
  1761 		}
       
  1762 
       
  1763 	TInt error = iState->Transit( CStateMachine::EInputEndCommand );
       
  1764 
       
  1765 	if ( error != KErrNone )
       
  1766 		{
       
  1767 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  1768 		}
       
  1769 	PRINT_EXIT;
       
  1770 	}
       
  1771 
       
  1772 //---------------------------------------------------------------------------
       
  1773 //Notifies the Hw Device that input buffer is free
       
  1774 //---------------------------------------------------------------------------
       
  1775 //
       
  1776 TInt CAriH264decHwDevice::InputBufferConsumed ( TAny* aInp, TInt aError  )
       
  1777 	{
       
  1778 	PRINT_ENTRY;
       
  1779 	if ( aInp )
       
  1780 		{
       
  1781 		 iInputFreeBufferQueue.Append( ( TVideoInputBuffer* )aInp );
       
  1782 
       
  1783 		 //call back to clinet
       
  1784 		 if ( ( aError != KErrCancel ) && ( !iInputEndCalled ) )
       
  1785 			iMMFDevVideoPlayProxy->MdvppNewBuffers();
       
  1786 		}
       
  1787 	PRINT_EXIT;
       
  1788 	return ( KErrNone );
       
  1789 	}
       
  1790 
       
  1791 
       
  1792 //---------------------------------------------------------------------------
       
  1793 //Notifies the Hw Device that out buffer has decoded data
       
  1794 //---------------------------------------------------------------------------
       
  1795 //
       
  1796 TInt CAriH264decHwDevice::OutputBufferReady ( TAny* aOut, TInt aError )
       
  1797 	{
       
  1798 	PRINT_ENTRY;
       
  1799     if ( aError == KErrNone )
       
  1800         {
       
  1801         iPictureNumber++;
       
  1802         // call back information regarding slice and picture loss
       
  1803 
       
  1804         SliceAndPictureLoss();
       
  1805 
       
  1806         //Decoded Buffer is available
       
  1807         TVideoPicture* videoPicture = ( TVideoPicture* )aOut;
       
  1808         videoPicture->iHeader->iPictureNumber = iPictureNumber;
       
  1809 
       
  1810         iFilledBufferCounter--;
       
  1811 
       
  1812         iPictureCounters.iPicturesDecoded++;
       
  1813         iPictureCounters.iPicturesDisplayed++;
       
  1814 
       
  1815         iDecodingPosition = videoPicture->iTimestamp;
       
  1816 		if ( !iOutputDevice )
       
  1817 			{
       
  1818 			iMMFDevVideoPlayProxy->MdvppNewPicture( videoPicture );
       
  1819 
       
  1820 			if ( iInputEndCalled && ( iFilledBufferCounter == 0 ) )
       
  1821 				{
       
  1822 				Stop();
       
  1823 				PRINT_ERR( "calling streamend\n" );
       
  1824 				iMMFDevVideoPlayProxy->MdvppStreamEnd();
       
  1825 				}
       
  1826 
       
  1827 			return( KErrNone );
       
  1828 			}
       
  1829 		else
       
  1830 			{
       
  1831 			TRAPD( error, iOutputDevice->WritePictureL( videoPicture ) );
       
  1832 
       
  1833 			if ( error == KErrNone )
       
  1834 				{
       
  1835 				if ( iInputEndCalled && ( iFilledBufferCounter == 0 ) )
       
  1836 					{
       
  1837 					HandleInputEndInStopping();
       
  1838 					PRINT_ERR( "calling streamend\n" );
       
  1839 					iMMFDevVideoPlayProxy->MdvppStreamEnd();
       
  1840 					}
       
  1841 				}
       
  1842 			else if ( error ) // KErrArgument, KErrNotReady
       
  1843 			   {
       
  1844 				iPictureCounters.iPicturesDisplayed--;
       
  1845 				// Currently not handled
       
  1846 			   }
       
  1847             }
       
  1848         }
       
  1849 
       
  1850     else if ( aError == KErrCancel )
       
  1851 		{
       
  1852 
       
  1853 		 // Add buffers to output free buffer queue if cutombuffer is not set
       
  1854 		if ( !iCustomBufferHandle )
       
  1855 			{
       
  1856 			iOutputFreeBufferQueue.Append( ( TVideoPicture* )aOut );
       
  1857 			}
       
  1858 		else
       
  1859 			{
       
  1860 			delete ( ( TVideoPicture* )aOut )->iHeader;
       
  1861 			( ( TVideoPicture* )aOut )->iHeader = NULL;
       
  1862 
       
  1863 			// release the buffer
       
  1864 			iCustomBufferHandle->MmvbmReleaseBuffer( ( TVideoPicture* )aOut );
       
  1865 			}
       
  1866 
       
  1867 		}
       
  1868 
       
  1869     else // other errors
       
  1870         {
       
  1871         // currently not handled
       
  1872         }
       
  1873 
       
  1874     PRINT_EXIT;
       
  1875 	return ( KErrNone );
       
  1876 	}
       
  1877 
       
  1878 //---------------------------------------------------------------------------
       
  1879 //Notifies the hw devcie that Error has occured in PE
       
  1880 //---------------------------------------------------------------------------
       
  1881 //
       
  1882 void CAriH264decHwDevice::FatalErrorFromProcessEngine ( TInt aError )
       
  1883 	{
       
  1884 	PRINT_ENTRY;
       
  1885 	iMMFDevVideoPlayProxy->MdvppFatalError( this, aError );
       
  1886 	PRINT_EXIT;
       
  1887 	}
       
  1888 
       
  1889 /*
       
  1890 ******************************************************************************
       
  1891 Name            : CommandProcessed
       
  1892 Description     : Callback to indicate the command has been processed
       
  1893 Parameter       :
       
  1894 Return Value    :
       
  1895 Assumptions     : None
       
  1896 Known Issues    : None
       
  1897 ******************************************************************************
       
  1898 */
       
  1899 void CAriH264decHwDevice::CommandProcessed ( TInt aCmd, TAny* aCmdData,
       
  1900 												TInt aError )
       
  1901 	{
       
  1902 	PRINT_ENTRY;
       
  1903 	PRINT_EXIT;
       
  1904 	}
       
  1905 
       
  1906 
       
  1907 
       
  1908 //---------------------------------------------------------------------------
       
  1909 //Call back from output device, indicates buffers availability
       
  1910 //---------------------------------------------------------------------------
       
  1911 //
       
  1912 void CAriH264decHwDevice::MmvbmoNewBuffers()
       
  1913 	{
       
  1914 	PRINT_ENTRY;
       
  1915 	TVideoPicture* videoPicture = NULL;
       
  1916 
       
  1917 	TRAPD( err, videoPicture = iCustomBufferHandle->MmvbmGetBufferL(
       
  1918 									iCustomBufferOptions->iBufferSize ) );
       
  1919 
       
  1920 	if ( err != KErrNone )
       
  1921 		{
       
  1922 		PRINT_ERR( "iCustomBufferHandle->MmvbmGetBufferL returned error\n" );
       
  1923 		iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrArgument );
       
  1924 		}
       
  1925 	if ( videoPicture )
       
  1926 		{
       
  1927 		if ( videoPicture->iHeader )
       
  1928 			{
       
  1929 			delete videoPicture->iHeader;
       
  1930 			videoPicture->iHeader = NULL;
       
  1931 			}
       
  1932 
       
  1933         TRAPD(  err1, videoPicture->iHeader =
       
  1934 									   new ( ELeave ) TVideoPictureHeader ) ;
       
  1935 
       
  1936         if ( err1 != KErrNone )
       
  1937         	{
       
  1938         	iCustomBufferHandle->MmvbmReleaseBuffer( videoPicture ) ;
       
  1939         	iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrArgument );
       
  1940         	}
       
  1941         else
       
  1942         	{
       
  1943 		    iEngine->AddOutput( videoPicture );
       
  1944         	}
       
  1945 		}
       
  1946 	PRINT_EXIT;
       
  1947 	}
       
  1948 
       
  1949 //---------------------------------------------------------------------------
       
  1950 //Callback from output device.
       
  1951 //---------------------------------------------------------------------------
       
  1952 //
       
  1953 void CAriH264decHwDevice::MmvbmoReleaseBuffers()
       
  1954 	{
       
  1955 	PRINT_ENTRY;
       
  1956 	iEngine->Stop();
       
  1957 	iEngine->Reset();
       
  1958 	PRINT_EXIT;
       
  1959 	}
       
  1960 
       
  1961 
       
  1962 
       
  1963 //---------------------------------------------------------------------------
       
  1964 //Set the proxy implementation to be used. Called just
       
  1965 //after the object is constructed
       
  1966 //---------------------------------------------------------------------------
       
  1967 //
       
  1968 void CAriH264decHwDevice::SetProxy( MMMFDevVideoPlayProxy& aProxy )
       
  1969 	{
       
  1970 	PRINT_ENTRY;
       
  1971 	iMMFDevVideoPlayProxy = &aProxy;
       
  1972 	PRINT_EXIT;
       
  1973 	}
       
  1974 
       
  1975 //---------------------------------------------------------------------------
       
  1976 //Default constructor of CAriH264decHwDevice
       
  1977 //---------------------------------------------------------------------------
       
  1978 //
       
  1979 CAriH264decHwDevice::CAriH264decHwDevice()
       
  1980     :iInputFreeBuffers( NULL ),
       
  1981      iOutputDevice( NULL ),
       
  1982      iMMFDevVideoPlayProxy( NULL ),
       
  1983 	 iState( NULL ),
       
  1984      iVideoPictureHeader( NULL ),
       
  1985 	 iDecodingPosition( TTimeIntervalMicroSeconds( 0 ) ),
       
  1986      iInputFormat( NULL ),
       
  1987      iCodec( NULL ),
       
  1988      iEngine( NULL ),
       
  1989      iInputEndCalled( EFalse ),
       
  1990      iOutputFreeBuffer( NULL ),
       
  1991      iFilledBufferCounter( 0 ),
       
  1992      iDataUnitType( EDuCodedPicture ),
       
  1993      iEncapsulation( EDuElementaryStream ),
       
  1994      iOutputBufferSize( 0 ),
       
  1995      iOutputBuffersCreated( EFalse ),
       
  1996      iPictureNumber( 0 ),
       
  1997      iNumberOfInputBuffersAllocated( 0 ),
       
  1998 	 iCustomBufferHandle( NULL ),
       
  1999 	 iCustomBufferOptions( NULL ),
       
  2000 	 iBufferAdded( EFalse ),
       
  2001      iConfigureDecoderCalled( EFalse ),
       
  2002 	 iDecoderConfigured( EFalse )
       
  2003     {
       
  2004     PRINT_ENTRY;
       
  2005 	iBufferOptions.iPreDecodeBufferSize 		= 0;
       
  2006 	iBufferOptions.iMaxPostDecodeBufferSize   	= 0;
       
  2007 	iBufferOptions.iPreDecoderBufferPeriod 		= 0;
       
  2008 	iBufferOptions.iPostDecoderBufferPeriod 	= 0;
       
  2009 	iBufferOptions.iMinNumInputBuffers 			= KMaxInputBuffers;
       
  2010 	iBufferOptions.iMaxInputBufferSize 			= KMaxInputBufferSize;
       
  2011 
       
  2012 
       
  2013     // Initializing iOutputFormat with one of the combination supported by
       
  2014 	iOutputFormat.iDataFormat					= EYuvRawData;
       
  2015 	iOutputFormat.iYuvFormat.iCoefficients		= EYuvBt601Range0;
       
  2016 	iOutputFormat.iYuvFormat.iPattern			= EYuv420Chroma1;
       
  2017 	iOutputFormat.iYuvFormat.iDataLayout		= EYuvDataPlanar;
       
  2018 	iOutputFormat.iYuvFormat.iYuv2RgbMatrix		= NULL;
       
  2019 	iOutputFormat.iYuvFormat.iRgb2YuvMatrix		= NULL;
       
  2020 	iOutputFormat.iYuvFormat.iAspectRatioNum	= 1;
       
  2021 	iOutputFormat.iYuvFormat.iAspectRatioDenom	= 1;
       
  2022 	PRINT_EXIT;
       
  2023     }
       
  2024 //---------------------------------------------------------------------------
       
  2025 //This is the 2nd phase constructor
       
  2026 //---------------------------------------------------------------------------
       
  2027 //
       
  2028 void CAriH264decHwDevice::ConstructL()
       
  2029 	{
       
  2030 	PRINT_ENTRY;
       
  2031 	iState = CStateMachine::NewL();
       
  2032 	PRINT_EXIT;
       
  2033     }
       
  2034 
       
  2035 //---------------------------------------------------------------------------
       
  2036 //Module to create output data
       
  2037 //---------------------------------------------------------------------------
       
  2038 //
       
  2039 void CAriH264decHwDevice::CreateOutputBuffersL()
       
  2040 	{
       
  2041 	PRINT_ENTRY;
       
  2042 	if ( iOutputFreeBuffer )
       
  2043 		{
       
  2044 		for ( TInt i = 0 ; i < KMaxOutputBuffers; i++ )
       
  2045 			{
       
  2046 			if ( ( iOutputFreeBuffer + i )->iHeader )
       
  2047 				{
       
  2048 				delete ( iOutputFreeBuffer + i )->iHeader;
       
  2049 				}
       
  2050 			if ( ( iOutputFreeBuffer + i )->iData.iRawData )
       
  2051 				{
       
  2052 				delete
       
  2053 				( TUint8* )( iOutputFreeBuffer + i )->iData.iRawData->Ptr();
       
  2054 				}
       
  2055 			if ( ( iOutputFreeBuffer + i )->iData.iRawData )
       
  2056 				{
       
  2057 				delete ( iOutputFreeBuffer + i )->iData.iRawData;
       
  2058 				}
       
  2059 			}
       
  2060 		delete [] iOutputFreeBuffer;
       
  2061 		}
       
  2062 	for ( TInt i = 0; i < iOutputFreeBufferQueue.Count(); i++ )
       
  2063 		{
       
  2064 		iOutputFreeBufferQueue.Remove( 0 );
       
  2065 		}
       
  2066 
       
  2067 	// Create the output Buffer( s ) and buffers to engine
       
  2068 	iOutputFreeBuffer = new ( ELeave ) TVideoPicture[KMaxOutputBuffers];
       
  2069 	TInt i;
       
  2070     for ( i = 0 ; i < KMaxOutputBuffers; i++ )
       
  2071 		{
       
  2072         ( iOutputFreeBuffer + i )->iData.iRawData = NULL;
       
  2073 		( iOutputFreeBuffer + i )->iHeader = NULL;
       
  2074         }
       
  2075 
       
  2076 	for ( i = 0 ; i < KMaxOutputBuffers; i++ )
       
  2077 		{
       
  2078 		TUint8* ptr;
       
  2079 		TPtr8*  temp;
       
  2080 
       
  2081 		ptr = new ( ELeave ) TUint8[iOutputBufferSize];
       
  2082 		CleanupStack::PushL( ptr );
       
  2083 		temp = new ( ELeave ) TPtr8( ptr, 0, iOutputBufferSize );
       
  2084 		CleanupStack::Pop( ptr );
       
  2085 
       
  2086 		( iOutputFreeBuffer + i )->iData.iRawData = temp;
       
  2087 		( iOutputFreeBuffer + i )->iHeader =
       
  2088 										  new ( ELeave ) TVideoPictureHeader;
       
  2089 
       
  2090 		// kunal
       
  2091 		// set the frame widht and height
       
  2092 
       
  2093 		( iOutputFreeBuffer + i )->iData.iDataSize =
       
  2094 										TSize( iWidthSource,iHeightSource );
       
  2095 		//Add o/p buffer( s ) to the Queue
       
  2096 		iEngine->AddOutput( ( iOutputFreeBuffer + i ) );
       
  2097 		}
       
  2098 	PRINT_EXIT;
       
  2099 	}
       
  2100 
       
  2101 
       
  2102 //---------------------------------------------------------------------------
       
  2103 //Gives callbacks to client regarding slice and picture loss
       
  2104 //---------------------------------------------------------------------------
       
  2105 //
       
  2106 void CAriH264decHwDevice::SliceAndPictureLoss()
       
  2107 	{
       
  2108 	PRINT_ENTRY;
       
  2109 	TUint firstMacroblock = 0;
       
  2110 	TUint numMacroblocks = 0;
       
  2111 	TPictureId pictureId;
       
  2112 	TUint picLoss = 0;
       
  2113 	pictureId.iIdType = TPictureId::EPictureNumber;
       
  2114 
       
  2115 	 // call back to client regading picture loss
       
  2116 	if ( ( iCodec->GetParam( CONTROL_CMD_GET_PICTURELOSSINFO,
       
  2117 							 ( TAny* )&picLoss ) ) >= KMaxAllowPicLoss )
       
  2118 		iMMFDevVideoPlayProxy->MdvppPictureLoss();
       
  2119 
       
  2120 	PRINT_MSG( LEVEL_LOW, ( "CAriH264decHwDevice::SliceAndPictureLoss, "
       
  2121 	   			"				calling callback regarding slice loss" ) );
       
  2122 
       
  2123 	 // call back to clinet regarding slice loss
       
  2124 	firstMacroblock = iCodec->GetParam( CONTROL_CMD_GET_SLICELOSSINFO,
       
  2125 									    ( TAny* )&numMacroblocks );
       
  2126 
       
  2127 	if ( ( firstMacroblock != 0 ) || ( numMacroblocks != 0 ) )
       
  2128 	 	iMMFDevVideoPlayProxy->MdvppSliceLoss( firstMacroblock,
       
  2129 											   numMacroblocks,
       
  2130 											   pictureId );
       
  2131 
       
  2132 	PRINT_EXIT;
       
  2133 	}
       
  2134 
       
  2135 //---------------------------------------------------------------------------
       
  2136 //Creates one input Buffer
       
  2137 //---------------------------------------------------------------------------
       
  2138 //
       
  2139 void CAriH264decHwDevice::CreateInputBufferL( TUint aBufferSize,
       
  2140 											  TBool aReallocate )
       
  2141 	{
       
  2142 	PRINT_ENTRY;
       
  2143 	if ( !aReallocate )
       
  2144 		{
       
  2145 		// Create the Buffer and add it to Queue
       
  2146 		TUint8* ptr = new ( ELeave ) TUint8[aBufferSize];
       
  2147 		TInt* lastBufferFlag  = new ( ELeave ) TInt[sizeof( TInt )];
       
  2148 		iInputFreeBuffers[iNumberOfInputBuffersAllocated].iData.Set(
       
  2149 															ptr,
       
  2150 															0,
       
  2151 															aBufferSize );
       
  2152 		iInputFreeBuffers[iNumberOfInputBuffersAllocated].iUser =
       
  2153 													( TAny* )lastBufferFlag;
       
  2154 		iInputFreeBufferQueue.Append(
       
  2155 						iInputFreeBuffers + iNumberOfInputBuffersAllocated );
       
  2156 		iNumberOfInputBuffersAllocated++;
       
  2157 		}
       
  2158 
       
  2159 	else // input buffers are already created and do reallocation here
       
  2160 		{
       
  2161 		TVideoInputBuffer* inBuffer = iInputFreeBufferQueue[0];
       
  2162 		// check the size of the current with the size of the buffer
       
  2163 		//present in i/p Q
       
  2164 		if ( aBufferSize > inBuffer->iData.MaxLength() )
       
  2165 			{
       
  2166 			// delete the previous buffer
       
  2167 			delete [] ( TUint8* )inBuffer->iData.Ptr();
       
  2168 			delete inBuffer->iUser;
       
  2169 
       
  2170 			// reallocate the buffer
       
  2171 			TUint8* ptr = new ( ELeave ) TUint8[aBufferSize];
       
  2172 			TInt* lastBufferFlag  = new ( ELeave ) TInt[sizeof( TInt )];
       
  2173 			inBuffer->iData.Set( ptr, 0, aBufferSize );
       
  2174 			inBuffer->iUser = ( TAny* )lastBufferFlag;
       
  2175 			}
       
  2176 		}
       
  2177 	PRINT_EXIT;
       
  2178 	}
       
  2179 //---------------------------------------------------------------------------
       
  2180 //When InputEnd is called while the hw device in Stopping State.
       
  2181 //---------------------------------------------------------------------------
       
  2182 //
       
  2183 void CAriH264decHwDevice::HandleInputEndInStopping()
       
  2184 	{
       
  2185 	PRINT_ENTRY;
       
  2186 	if ( iState->IsInputEndPending() )
       
  2187 		{
       
  2188 		iPictureNumber = 0;
       
  2189 		// Stop & Reset the Engine
       
  2190 		iEngine->Stop();
       
  2191 		iBufferAdded			= EFalse;
       
  2192 		iFilledBufferCounter	= 0;
       
  2193 		iInputEndCalled			= EFalse;
       
  2194 		TInt error = iState->Transit( CStateMachine::EStopCommand );
       
  2195 		if ( error != KErrNone )
       
  2196 			{
       
  2197 			iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady );
       
  2198 			}
       
  2199 		}
       
  2200 	PRINT_EXIT;
       
  2201 	}
       
  2202 
       
  2203 
       
  2204 const TImplementationProxy ImplementationTable[] =
       
  2205 	{
       
  2206 	//IMPLEMENTATION_PROXY_ENTRY( 0x20029903, CAriH264decHwDevice::NewL )
       
  2207     IMPLEMENTATION_PROXY_ENTRY( KUidH264DecoderHwDeviceImplUid,
       
  2208 										CAriH264decHwDevice::NewL )
       
  2209 	};
       
  2210 
       
  2211 
       
  2212 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
       
  2213 													      TInt& aTableCount )
       
  2214 	{
       
  2215 	PRINT_ENTRY;
       
  2216 	aTableCount =
       
  2217 		      sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
       
  2218 	PRINT_EXIT;
       
  2219 	return ImplementationTable;
       
  2220 	}
       
  2221 
       
  2222 
       
  2223 #ifndef EKA2
       
  2224 GLDEF_C TInt E32Dll( TDllReason )
       
  2225     {
       
  2226     return KErrNone;
       
  2227     }
       
  2228 
       
  2229 #endif
       
  2230