amrwb_dec/ariamrwbdecmmfcodec/src/ariamrwbdecmmfcodec.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 * Implementation of member functions of Plugin class (CAriAmrWbDecMmfCodec).
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // System includes
       
    21 #include <ecom.h>
       
    22 #include <implementationproxy.h>
       
    23 // User includes
       
    24 #include "ariamrwbdecwrapper.h"
       
    25 #include "ariamrwbdecmmfcodec.h"
       
    26 #include "ariamrwbdecmmfcodec_uid.hrh"
       
    27 #include "ariprint.h"
       
    28 
       
    29 // Maximum input and output buffer length
       
    30 const TUint KAMRWBMINOutBufLength = 640;
       
    31 
       
    32 
       
    33 //---------------------------------------------------------------------------
       
    34 //  Two-phased constructor.
       
    35 //  Creates an instance of CAriAmrWbDecMmfCodec.
       
    36 //  Instance is not left on cleanup stack.
       
    37 //---------------------------------------------------------------------------
       
    38 //
       
    39 CMMFCodec* CAriAmrWbDecMmfCodec::NewL()
       
    40 	{
       
    41 	PRINT_ENTRY;
       
    42 	CAriAmrWbDecMmfCodec* self = new ( ELeave ) CAriAmrWbDecMmfCodec();
       
    43 	CleanupStack::PushL( self );
       
    44 	self->ConstructL();
       
    45 	CleanupStack::Pop( self );
       
    46 	PRINT_EXIT;
       
    47 	return ( CMMFCodec* )self;
       
    48 	}
       
    49 
       
    50 //---------------------------------------------------------------------------
       
    51 //  Destructor;Destroys the decoder instance and any internal buffers
       
    52 //---------------------------------------------------------------------------
       
    53 //
       
    54 CAriAmrWbDecMmfCodec::~CAriAmrWbDecMmfCodec()
       
    55 	{
       
    56 	PRINT_ENTRY;
       
    57 	if ( iInternalInputBuffer )
       
    58 		{
       
    59 		delete iInternalInputBuffer;
       
    60 		iInternalInputBuffer = NULL;
       
    61 		}
       
    62 	if ( iInternalOutputBuffer )
       
    63 		{
       
    64 		delete iInternalOutputBuffer;
       
    65 		iInternalOutputBuffer = NULL;
       
    66 		}
       
    67 
       
    68 	if ( iCodec )
       
    69 		{
       
    70 		delete iCodec;
       
    71 		iCodec = NULL;
       
    72 		}
       
    73 
       
    74 	PRINT_EXIT;
       
    75 	}
       
    76 
       
    77 //---------------------------------------------------------------------------
       
    78 //  From class CMMFCodec.
       
    79 //  The function Sets codec configuration.
       
    80 //  The value used for aConfigType must be KUidMmfCodecAudioSettings
       
    81 //  (defined in include\mmf\plugins\mmfCodecImplementationUIDs.hrh)
       
    82 //---------------------------------------------------------------------------
       
    83 //
       
    84 void CAriAmrWbDecMmfCodec::ConfigureL( TUid /* aConfigType */,
       
    85 									const TDesC8& /*aParam*/ )
       
    86 	{
       
    87 	PRINT_ENTRY;
       
    88 	PRINT_EXIT;
       
    89 	}
       
    90 //---------------------------------------------------------------------------
       
    91 //  From class CMMFCodec.
       
    92 //  This function is used to flush out status information when a
       
    93 //  reposition occurs.
       
    94 //  This is used if the codec requires resetting prior to use.
       
    95 //---------------------------------------------------------------------------
       
    96 //
       
    97 void CAriAmrWbDecMmfCodec::ResetL()
       
    98 	{
       
    99 	PRINT_ENTRY;
       
   100 	iInternalInputBufferResidueLen = 0;
       
   101 	iInternalOutputBufferPos = 0;
       
   102 	iInternalOutputBufferResidueLen = 0;
       
   103 	PRINT_EXIT;
       
   104 	}
       
   105 
       
   106 
       
   107 //---------------------------------------------------------------------------
       
   108 // From class CMMFCodec.
       
   109 // This function is used to decode the given source and fill the destination
       
   110 // buffer with the decode data.
       
   111 // The buffers can be of any size.  Since the buffers can be of any size there
       
   112 // is no guarantee that all the source buffer can be processed to fill the
       
   113 // destination buffer or that the all the source buffer may be processed
       
   114 // before the destination is full.  Therefore the ProcessL needs to return a
       
   115 // TCodecProcessResult returing the number of source bytes processed and the
       
   116 // number of destination bytes processed along with a process result code
       
   117 // defined thus:
       
   118 // - EProcessComplete: the codec processed all the source data into the sink
       
   119 //	 buffer
       
   120 // - EProcessIncomplete: the codec filled sink buffer before all the source
       
   121 //   buffer was processed
       
   122 // - EDstNotFilled: the codec processed the source buffer but the sink buffer
       
   123 //   was not filled
       
   124 // - EEndOfData: the codec detected the end data - all source data in
       
   125 //   processed but sink may not be full
       
   126 // - EProcessError: the codec process error condition
       
   127 //
       
   128 // The ProcessL should start processing the source buffer from the iPosition
       
   129 // data member of the source data and start filling the destination buffer
       
   130 // from its iPosition.
       
   131 //---------------------------------------------------------------------------
       
   132 //
       
   133 TCodecProcessResult CAriAmrWbDecMmfCodec::ProcessL( const CMMFBuffer& aSrc,
       
   134 													CMMFBuffer& aDst )
       
   135 	{
       
   136 	PRINT_ENTRY;
       
   137 
       
   138 	// total decoded bytes added to the dst buffer
       
   139 	TInt totalDstBytesAdded = 0;
       
   140 	// total src bytes added to the internal src buffer
       
   141 	TInt totalSrcBytesCopied = 0;
       
   142 	// temporary variable to use for copying the sorce or destination data
       
   143 	TInt numberOfBytesCopied;
       
   144 	// Flag for finding valid sync
       
   145 	TBool syncFound = EFalse;
       
   146 
       
   147 	/**
       
   148 	* Process the dst buffer, update the dstBufferPos and check
       
   149 	* whether dst buffer is NULL or not.
       
   150 	*/
       
   151 	CMMFDataBuffer* dst = static_cast<CMMFDataBuffer*>( &aDst );
       
   152 
       
   153 	const TInt dstMaxLen = dst->Data().MaxLength();
       
   154 	TUint8* dstPtr = const_cast<TUint8*>( dst->Data().Ptr() );
       
   155 	TInt dstBufferPos = dst->Position();
       
   156 
       
   157 	/**
       
   158 	* Process the src buffer, update srcbuffer length, position and
       
   159 	* flag for last frame. check whether src buffer is NULL or not
       
   160 	* and check src buffer contains any data
       
   161 	*/
       
   162 	const CMMFDataBuffer* src = static_cast<const CMMFDataBuffer*>( &aSrc );
       
   163 
       
   164 	TUint8* srcPtr = const_cast <TUint8*>( src->Data().Ptr() );
       
   165 	TInt srcBufferLen = src->Data().Length();
       
   166 	TInt srcBufferPos = src->Position();
       
   167 	TBool lastFrame = src->LastBuffer();
       
   168 
       
   169 	if ( srcBufferLen == 0 && iInternalInputBufferResidueLen == 0 )
       
   170 		{
       
   171 		PRINT_ERR( "source buffer length is zero" );
       
   172 		User::Leave( KErrArgument );
       
   173 		}
       
   174 
       
   175 	/**
       
   176 	* if any destination bytes from internal destination buffer is not
       
   177 	* given to the dst buffer from the previous call, give it to the
       
   178 	* dst buffer. After this block, it ensures that no bytes are remaining
       
   179 	* in the internal destination buffer.
       
   180 	*/
       
   181 	if ( iInternalOutputBufferResidueLen - iInternalOutputBufferPos > 0 )
       
   182 		{
       
   183 		numberOfBytesCopied = CopyToDstBuffer( dst, totalDstBytesAdded );
       
   184 
       
   185 		if ( iInternalOutputBufferResidueLen - iInternalOutputBufferPos > 0 )
       
   186 			{
       
   187 			PRINT_EXIT;
       
   188 			return Result( TCodecProcessResult::EProcessIncomplete,
       
   189 							totalSrcBytesCopied, totalDstBytesAdded );
       
   190 			}
       
   191 		else
       
   192 			{
       
   193 			if ( ( lastFrame ) && ( srcBufferLen - srcBufferPos == 0 )&&
       
   194 								( iInternalInputBufferResidueLen == 0 ) )
       
   195 				{
       
   196 				iInternalOutputBufferResidueLen = 0;
       
   197 				iInternalInputBufferResidueLen = 0;
       
   198 				iInternalOutputBufferPos = 0;
       
   199 				PRINT_EXIT;
       
   200 				return Result( TCodecProcessResult::EEndOfData,
       
   201 								totalSrcBytesCopied, totalDstBytesAdded );
       
   202 				}
       
   203 			iInternalOutputBufferPos = 0;
       
   204 			iInternalOutputBufferResidueLen = 0;
       
   205 			}
       
   206 		}
       
   207 
       
   208 	/**
       
   209 	* copy the src buffer data into the internal buffer till internal buffer
       
   210 	* holds minimum bytes to process i.e KMinBytesInput. After this block, it
       
   211 	* ensures that internal source buffer holds KMinBytesInput.
       
   212 	* if it is a last frame, treat remaining residual buffer as internal
       
   213 	* buffer.
       
   214 	*/
       
   215 	if ( ( KAMRWBMINOutBufLength - iInternalInputBufferResidueLen > 0 )
       
   216 							&& ( srcBufferLen - srcBufferPos > 0 ) )
       
   217 		{
       
   218 		numberOfBytesCopied = CopyFromSrcBuffer( src, totalSrcBytesCopied );
       
   219 		}
       
   220 
       
   221 	if ( ( KAMRWBMINOutBufLength > iInternalInputBufferResidueLen )
       
   222 														&& ( !lastFrame ) )
       
   223 		{
       
   224 		PRINT_EXIT;
       
   225 		return Result( TCodecProcessResult::EDstNotFilled,
       
   226 						srcBufferLen - srcBufferPos, totalDstBytesAdded );
       
   227 		}
       
   228 
       
   229 	/**
       
   230 	* process the src buffer till destination buffer or source buffer
       
   231 	* or both buffers are exhausted.
       
   232 	*/
       
   233 	do
       
   234 	{
       
   235 		TInt srcBufferRemainingBytes = srcBufferLen
       
   236 									  - srcBufferPos
       
   237 									  - totalSrcBytesCopied;
       
   238 		TInt dstBufferRemainingBytes = dstMaxLen
       
   239 									   - dstBufferPos
       
   240 									   - totalDstBytesAdded;
       
   241 		TInt internalInputBufferPos = 0;
       
   242 
       
   243 
       
   244 		/**
       
   245 		* initialize the variables like srcUsed and dstLen accordingly.
       
   246 		* call Decode.
       
   247 		*/
       
   248 
       
   249 		TInt32 srcUsed = iInternalInputBufferResidueLen
       
   250 						- internalInputBufferPos;
       
   251 		TInt32 dstLen  = KAMRWBMINOutBufLength;
       
   252 
       
   253 		TInt error =
       
   254 		iCodec->Decode( &iInternalInputBuffer[internalInputBufferPos],
       
   255 						srcUsed,( TInt32* )iInternalOutputBuffer, dstLen );
       
   256 
       
   257 		if ( KErrNone != error )
       
   258 			{
       
   259 			iInternalInputBufferResidueLen = 0;
       
   260 			PRINT_ERR( "Amr Wb Decoder decoding is failed" );
       
   261 			return Result(
       
   262 					TCodecProcessResult::EProcessError,
       
   263 					totalSrcBytesCopied, totalDstBytesAdded );
       
   264 			}
       
   265 
       
   266 		/**
       
   267 		* Fill Destination Buffer
       
   268 		*/
       
   269 
       
   270 		iInternalOutputBufferResidueLen = dstLen;
       
   271 		numberOfBytesCopied = CopyToDstBuffer( dst, totalDstBytesAdded );
       
   272 		dstBufferRemainingBytes -= numberOfBytesCopied;
       
   273 
       
   274 		/***
       
   275 		* Fill Sorce Buffer
       
   276 		*/
       
   277 
       
   278 		internalInputBufferPos += srcUsed ;
       
   279 		ShiftData( internalInputBufferPos, 0 );
       
   280 		numberOfBytesCopied = CopyFromSrcBuffer( src, totalSrcBytesCopied );
       
   281 		srcBufferRemainingBytes -= numberOfBytesCopied;
       
   282 		internalInputBufferPos = 0;
       
   283 
       
   284 		/***
       
   285 		* check four conditions if else for src and if else for dst
       
   286 		*/
       
   287 
       
   288 		// src buffer has available bytes to decode
       
   289 		if ( srcBufferRemainingBytes > 0 )
       
   290 			{
       
   291 			if ( dstBufferRemainingBytes == 0 )
       
   292 				{
       
   293 				PRINT_EXIT;
       
   294 				return Result( TCodecProcessResult::EProcessIncomplete,
       
   295 						totalSrcBytesCopied, totalDstBytesAdded );
       
   296 				}
       
   297 			}
       
   298 
       
   299 		else
       
   300 			{
       
   301 			// dst buffer has availabe space for decoded bytes
       
   302 			if ( dstBufferRemainingBytes > 0 )
       
   303 				{
       
   304 				// last frame of the input stream
       
   305 				if ( lastFrame )
       
   306 					{
       
   307 					if ( iInternalInputBufferResidueLen == 0 )
       
   308 						{
       
   309 						PRINT_EXIT;
       
   310 						return Result( TCodecProcessResult::EEndOfData,
       
   311 								totalSrcBytesCopied, totalDstBytesAdded );
       
   312 						}
       
   313 					}
       
   314 				else
       
   315 					{
       
   316 					PRINT_EXIT;
       
   317 					return Result( TCodecProcessResult::EDstNotFilled,
       
   318 							totalSrcBytesCopied, totalDstBytesAdded );
       
   319 					}
       
   320 				}
       
   321 			else
       
   322 				{
       
   323 				/**
       
   324 				 *internal output buffer has decoded bytes which is not
       
   325 				 *given to dst buffer.
       
   326 				 */
       
   327 				if ( iInternalOutputBufferResidueLen
       
   328 									- iInternalOutputBufferPos > 0 )
       
   329 					{
       
   330 					PRINT_EXIT;
       
   331 					return Result( TCodecProcessResult::EProcessIncomplete,
       
   332 									totalSrcBytesCopied, totalDstBytesAdded );
       
   333 					}
       
   334 				// last frame of the input stream
       
   335 				else if ( lastFrame )
       
   336 					{
       
   337 					// if internal buffer has available bytes to decode
       
   338 					if ( iInternalInputBufferResidueLen > 0 )
       
   339 						{
       
   340 						PRINT_EXIT;
       
   341 						return Result(
       
   342 								TCodecProcessResult::EProcessIncomplete,
       
   343 								totalSrcBytesCopied, totalDstBytesAdded );
       
   344 						}
       
   345 					else
       
   346 						{
       
   347 						iInternalInputBufferResidueLen = 0;
       
   348 						PRINT_EXIT;
       
   349 						return Result( TCodecProcessResult::EEndOfData,
       
   350 									totalSrcBytesCopied, totalDstBytesAdded );
       
   351 						}
       
   352 					}
       
   353 				else
       
   354 					{
       
   355 					PRINT_EXIT;
       
   356 					return Result( TCodecProcessResult::EProcessComplete,
       
   357 									totalSrcBytesCopied, totalDstBytesAdded );
       
   358 					}
       
   359 				}
       
   360 			}
       
   361 	}while ( 1 );
       
   362 	}
       
   363 
       
   364 
       
   365 
       
   366 //---------------------------------------------------------------------------
       
   367 //  Default constructor for performing 1st stage construction.
       
   368 //  Should not contain any code that could leave.
       
   369 //---------------------------------------------------------------------------
       
   370 //
       
   371 CAriAmrWbDecMmfCodec::CAriAmrWbDecMmfCodec():
       
   372 iCodec( NULL ),	iInternalInputBuffer( NULL ),
       
   373 iInternalOutputBuffer( NULL ), iInternalInputBufferResidueLen( 0 ),
       
   374 iInternalOutputBufferResidueLen( 0 ), iInternalOutputBufferPos( 0 )
       
   375 	{
       
   376 	PRINT_ENTRY;
       
   377 	PRINT_EXIT;
       
   378 	}
       
   379 
       
   380 //---------------------------------------------------------------------------
       
   381 //  Destructor;Destroys the decoder instance and any internal buffers
       
   382 //---------------------------------------------------------------------------
       
   383 //
       
   384 void CAriAmrWbDecMmfCodec::ConstructL()
       
   385 	{
       
   386 	PRINT_ENTRY;
       
   387 
       
   388 	iCodec = CAriAmrWbDecWrapper::NewL();
       
   389 
       
   390 	if ( !iCodec )
       
   391 		{
       
   392 		PRINT_ERR( "Amr Nb Decoder creation is failed" );
       
   393 		User::Leave( KErrGeneral );
       
   394 		}
       
   395 
       
   396 	User::LeaveIfError( iCodec->Reset() ) ;
       
   397 
       
   398 	iInternalInputBuffer = new( ELeave ) TUint8[KAMRWBMINOutBufLength];
       
   399 	if ( !iInternalInputBuffer )
       
   400 		{
       
   401 		PRINT_ERR( "internal input buffer creation is failed" );
       
   402 		User::Leave( KErrNoMemory );
       
   403 		}
       
   404 
       
   405 	iInternalOutputBuffer = new( ELeave ) TUint8[KAMRWBMINOutBufLength];
       
   406 	if ( !iInternalOutputBuffer )
       
   407 		{
       
   408 		PRINT_ERR( "internal output buffer creation is failed" );
       
   409 		User::Leave( KErrNoMemory );
       
   410 		}
       
   411 
       
   412 	PRINT_EXIT;
       
   413 	}
       
   414 
       
   415 //----------------------------------------------------------------------------
       
   416 //	Updates the result of the processing
       
   417 //----------------------------------------------------------------------------
       
   418 //
       
   419 TCodecProcessResult CAriAmrWbDecMmfCodec::Result(
       
   420 					TCodecProcessResult::TCodecProcessResultStatus aStatus,
       
   421  					TInt aSrcBytesConsumed, TInt aDstBytesAdded )
       
   422 
       
   423 	 {
       
   424 	 PRINT_ENTRY;
       
   425 	 TCodecProcessResult result;
       
   426 	 // update destination bytes
       
   427 	 result.iDstBytesAdded = aDstBytesAdded;
       
   428 	 // update source bytes
       
   429 	 result.iSrcBytesProcessed = aSrcBytesConsumed;
       
   430 
       
   431 	 // update status
       
   432 	 switch ( aStatus )
       
   433 		 {
       
   434 		 case TCodecProcessResult::EProcessComplete:
       
   435 			result.iStatus = TCodecProcessResult::EProcessComplete;
       
   436 			break;
       
   437 		 case TCodecProcessResult::EProcessIncomplete:
       
   438 		 	result.iStatus = TCodecProcessResult::EProcessIncomplete;
       
   439 		 	break;
       
   440 		 case TCodecProcessResult::EEndOfData:
       
   441 		 	result.iStatus = TCodecProcessResult::EEndOfData;
       
   442 		 	break;
       
   443 		 case TCodecProcessResult::EDstNotFilled:
       
   444 		 	result.iStatus = TCodecProcessResult::EDstNotFilled;
       
   445 		 	break;
       
   446 		 case TCodecProcessResult::EProcessError:
       
   447 		 	result.iStatus = TCodecProcessResult::EProcessError;
       
   448 		 	break;
       
   449 		 default:
       
   450 			result.iStatus = TCodecProcessResult::EProcessError;
       
   451 			break;
       
   452 		 }
       
   453 	 PRINT_MSG( LEVEL_HIGH, ( "result.iSrcBytesProcessed = %d",
       
   454 								result.iSrcBytesProcessed ) );
       
   455 	 PRINT_MSG( LEVEL_HIGH, ( "result.iDstBytesAdded = %d",
       
   456 								result.iDstBytesAdded ) );
       
   457 	 PRINT_MSG( LEVEL_HIGH, ( "result.iStatus = %d",
       
   458 								result.iStatus ) );
       
   459 	 PRINT_EXIT;
       
   460 	 return result;
       
   461 	 }
       
   462 
       
   463 //----------------------------------------------------------------------------
       
   464 // Copy the bytes to destination buffer from the internal buffer
       
   465 // first checks whether the number of bytes to be copied is lesser of the
       
   466 // destination buffer reamining bytes and internal input internal remaining
       
   467 // remaining bytes and then copies that many bytes.
       
   468 //----------------------------------------------------------------------------
       
   469 //
       
   470  TInt CAriAmrWbDecMmfCodec::CopyToDstBuffer( CMMFDataBuffer* aDst,
       
   471 											 TInt &aDstBytesConsumed )
       
   472 	{
       
   473 	PRINT_ENTRY;
       
   474 	TInt numberOfBytesToBeCopied;
       
   475 	const TInt dstMaxLen = aDst->Data().MaxLength();
       
   476 	TUint8* dstPtr = const_cast<TUint8*>( aDst->Data().Ptr() );
       
   477 	TInt dstBufferPos = aDst->Position();
       
   478 
       
   479 	// destination buffer remaining bytes
       
   480 	TInt dstBufferRemainingBytes = dstMaxLen
       
   481 								   - dstBufferPos
       
   482 								   - aDstBytesConsumed;
       
   483 	// internal output buffer remaining bytes
       
   484 	TInt internalOutputBufferRemainingBytes =
       
   485 										 iInternalOutputBufferResidueLen
       
   486 										 - iInternalOutputBufferPos;
       
   487 
       
   488 	if ( internalOutputBufferRemainingBytes > dstBufferRemainingBytes )
       
   489 		{
       
   490 		numberOfBytesToBeCopied = dstBufferRemainingBytes;
       
   491 		}
       
   492 	else
       
   493 		{
       
   494 		numberOfBytesToBeCopied = internalOutputBufferRemainingBytes;
       
   495 		iInternalOutputBufferResidueLen = 0;
       
   496 		}
       
   497 
       
   498 	// copy data to destination buffer from internal ouput buffer
       
   499 	Mem::Copy( dstPtr + dstBufferPos + aDstBytesConsumed,
       
   500 		iInternalOutputBuffer + iInternalOutputBufferPos,
       
   501 		numberOfBytesToBeCopied );
       
   502 
       
   503 	// update internal output buffer position
       
   504 	if( iInternalOutputBufferResidueLen )
       
   505 		{
       
   506 		iInternalOutputBufferPos += dstBufferRemainingBytes;
       
   507 		}
       
   508 	else
       
   509 		{
       
   510 		iInternalOutputBufferPos = 0;
       
   511 		}
       
   512 
       
   513 	aDstBytesConsumed += numberOfBytesToBeCopied;
       
   514 	aDst->Data().SetLength( dstBufferPos +  aDstBytesConsumed );
       
   515 	PRINT_EXIT;
       
   516 	return numberOfBytesToBeCopied;
       
   517 	}
       
   518 
       
   519 //---------------------------------------------------------------------------
       
   520 // Copy the bytes from the source buffer to the internal input buffer.
       
   521 // first it checks number of bytes to be copied is lesser of the source buffer
       
   522 // remaining bytes or internal input buffer remaining bytes and then copies
       
   523 // that many bytes.
       
   524 //---------------------------------------------------------------------------
       
   525 //
       
   526  TInt CAriAmrWbDecMmfCodec::CopyFromSrcBuffer( const CMMFDataBuffer* aSrc,
       
   527 												 TInt &aSrcBytesConsumed )
       
   528 	{
       
   529 	PRINT_ENTRY;
       
   530 	TInt numberOfBytesToBeCopied;
       
   531 	TUint8* srcPtr = const_cast <TUint8*>( aSrc->Data().Ptr() );
       
   532 	TInt srcBufferLen = aSrc->Data().Length();
       
   533 	TInt srcBufferPos = aSrc->Position();
       
   534 
       
   535 	// calculate the source buffer remaining bytes
       
   536 	TInt srcBufferRemainingBytes = srcBufferLen - srcBufferPos
       
   537 								   - aSrcBytesConsumed;
       
   538 
       
   539 	// calculate internal input buffer remaining bytes
       
   540 	TInt internalInputBufferRemaingBytes = KAMRWBMINOutBufLength
       
   541 										   - iInternalInputBufferResidueLen;
       
   542 
       
   543 	if ( internalInputBufferRemaingBytes > srcBufferRemainingBytes )
       
   544 		{
       
   545 		numberOfBytesToBeCopied = srcBufferRemainingBytes;
       
   546 		}
       
   547 	else
       
   548 		{
       
   549 		numberOfBytesToBeCopied = internalInputBufferRemaingBytes;
       
   550 		}
       
   551 
       
   552 	// copy data from source buffer to internal input buffer
       
   553 	Mem::Copy( iInternalInputBuffer + iInternalInputBufferResidueLen,
       
   554 				srcPtr + srcBufferPos + aSrcBytesConsumed,
       
   555 				numberOfBytesToBeCopied );
       
   556 
       
   557 	// update internal input buffer residue length
       
   558 	iInternalInputBufferResidueLen += numberOfBytesToBeCopied;
       
   559 	aSrcBytesConsumed += numberOfBytesToBeCopied;
       
   560 	PRINT_EXIT;
       
   561 	return numberOfBytesToBeCopied;
       
   562 	}
       
   563 //---------------------------------------------------------------------------
       
   564 // Moves the data of the internal input buffer to the start position
       
   565 //---------------------------------------------------------------------------
       
   566 //
       
   567 void CAriAmrWbDecMmfCodec::ShiftData( TInt aFromPos, TInt aToPos )
       
   568 	{
       
   569 	PRINT_ENTRY;
       
   570 	for ( TInt i = aToPos; i < ( iInternalInputBufferResidueLen - aFromPos );
       
   571 																	i++ )
       
   572 		{
       
   573 		iInternalInputBuffer[i] = iInternalInputBuffer[i + aFromPos];
       
   574 		}
       
   575 	iInternalInputBufferResidueLen -= aFromPos;
       
   576 	PRINT_EXIT;
       
   577 	}
       
   578 
       
   579 // __________________________________________________________________________
       
   580 //    *********************   ECOM Instantiation *********************
       
   581 // __________________________________________________________________________
       
   582 
       
   583 const TImplementationProxy ImplementationTable[] =
       
   584 	{
       
   585 	IMPLEMENTATION_PROXY_ENTRY(KUidARIAMRWBDecImplUid,
       
   586 												CAriAmrWbDecMmfCodec::NewL)
       
   587 	};
       
   588 
       
   589 EXPORT_C const TImplementationProxy*
       
   590 								ImplementationGroupProxy( TInt& aTableCount )
       
   591 	{
       
   592 	PRINT_ENTRY;
       
   593 	aTableCount = sizeof( ImplementationTable) /
       
   594 											sizeof(TImplementationProxy );
       
   595 	PRINT_EXIT;
       
   596 	return ImplementationTable;
       
   597 	}