tsrc/xmltestharness/xmlclient/src/portbufferhandler.cpp
changeset 0 0e4a32b9112d
equal deleted inserted replaced
-1:000000000000 0:0e4a32b9112d
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 #include "portbufferhandler.h"
       
    18 #include "log.h"  // currently needed for INFO_PRINTF etc macros
       
    19 
       
    20 /**
       
    21  * Overflow handler to generate a warning message if a log line will not fit
       
    22  * in the descriptor.
       
    23  */
       
    24 class TOverflowHandler : public TDes16Overflow
       
    25     {
       
    26 public:
       
    27     void Overflow(TDes& aDes)
       
    28         {
       
    29         _LIT(KWarning, "[truncated]");
       
    30         if(aDes.Length() + KWarning().Length() > aDes.MaxLength())
       
    31             {
       
    32             aDes.SetLength(aDes.Length() - KWarning().Length());
       
    33             }
       
    34         aDes.Append(KWarning);
       
    35         }
       
    36     };
       
    37 
       
    38 CPortBufferHandler::CPortBufferHandler()
       
    39 	{
       
    40 	}
       
    41 
       
    42 CPortBufferHandler::~CPortBufferHandler()
       
    43 	{
       
    44 	}
       
    45 
       
    46 void CPortBufferHandler::AddPortL(OMX_COMPONENTTYPE* aComp,
       
    47 								TInt aPortNum,
       
    48 								const TDesC& aFileName,
       
    49 								OMX_BUFFERSUPPLIERTYPE aSupplier,
       
    50 								OMX_DIRTYPE aPortDir,
       
    51 								MOmxScriptTestLogger& aLogger,
       
    52 								TInt aHeaderLength)
       
    53 	{
       
    54 		
       
    55 	CComponentInfo* compInfo = NULL;
       
    56 	TInt pos = iComponents.Find(*aComp, CComponentInfo::CompareComp);
       
    57 	if (pos >= 0)
       
    58 		{
       
    59 		compInfo = iComponents[pos];
       
    60 		}
       
    61 	else
       
    62 		{
       
    63 		compInfo = new (ELeave) CComponentInfo(aComp);
       
    64 		CleanupStack::PushL(compInfo);
       
    65 		iComponents.AppendL(compInfo);
       
    66 		CleanupStack::Pop(compInfo);
       
    67 		}
       
    68 		
       
    69 			
       
    70 	CPortInfo* portInfo = compInfo->AddPortL(aPortNum,aFileName,aSupplier,aPortDir,aLogger,aHeaderLength);
       
    71 	}
       
    72 
       
    73 void CPortBufferHandler::AllocateBuffersL(OMX_COMPONENTTYPE* aComp)
       
    74 	{
       
    75 	TInt pos = iComponents.Find(*aComp, CComponentInfo::CompareComp);
       
    76 	if (pos >= 0)
       
    77 		{
       
    78 		iComponents[pos]->AllocateBuffersL();
       
    79 		}
       
    80 	}
       
    81 	
       
    82 void CPortBufferHandler::Start(OMX_COMPONENTTYPE* aComp, TInt aPortNum)
       
    83 	{
       
    84 	TInt pos = iComponents.Find(*aComp, CComponentInfo::CompareComp);
       
    85 	if (pos >= 0)
       
    86 		{
       
    87 		iComponents[pos]->Start(aPortNum);
       
    88 		}
       
    89 	}
       
    90 	
       
    91 void CPortBufferHandler::Resume(OMX_COMPONENTTYPE* aComp, TInt aPortNum)
       
    92 	{
       
    93 	TInt pos = iComponents.Find(*aComp, CComponentInfo::CompareComp);
       
    94 	if (pos >= 0)
       
    95 		{
       
    96 		iComponents[pos]->Resume(aPortNum);
       
    97 		}
       
    98 	}	
       
    99 
       
   100 void CPortBufferHandler::BufferDone(OMX_COMPONENTTYPE* aComp, OMX_BUFFERHEADERTYPE* aBufHdr, TBool aSource)
       
   101 	{
       
   102 	TInt pos = iComponents.Find(*aComp, CComponentInfo::CompareComp);
       
   103 	if (pos >= 0)
       
   104 		{
       
   105 		iComponents[pos]->BufferDone(aBufHdr, aSource);
       
   106 		}
       
   107 	}
       
   108 
       
   109 void CPortBufferHandler::Stop(OMX_COMPONENTTYPE* aComp, TInt aPortNum)
       
   110 	{
       
   111 	TInt pos = iComponents.Find(*aComp, CComponentInfo::CompareComp);
       
   112 	if (pos >= 0)
       
   113 		{
       
   114 		iComponents[pos]->Stop(aPortNum);
       
   115 		}
       
   116 	}
       
   117 	
       
   118 
       
   119 void CPortBufferHandler::Pause(OMX_COMPONENTTYPE* aComp, TInt aPortNum)
       
   120 	{
       
   121 	TInt pos = iComponents.Find(*aComp, CComponentInfo::CompareComp);
       
   122 	if (pos >= 0)
       
   123 		{
       
   124 		iComponents[pos]->Pause(aPortNum);
       
   125 		}
       
   126 	}	
       
   127 
       
   128 void CPortBufferHandler::FreeBuffers(OMX_COMPONENTTYPE* aComp)
       
   129 	{
       
   130 	TInt pos = iComponents.Find(*aComp, CComponentInfo::CompareComp);
       
   131 	if (pos >= 0)
       
   132 		{
       
   133 		iComponents[pos]->FreeBuffers();
       
   134 		}
       
   135 	}
       
   136 
       
   137 CPortBufferHandler::CComponentInfo::CComponentInfo(OMX_COMPONENTTYPE* aComp) :
       
   138  iComp(aComp),iState(OMX_StateLoaded)
       
   139 	{
       
   140 	}
       
   141 
       
   142 CPortBufferHandler::CComponentInfo::~CComponentInfo()
       
   143 	{
       
   144 	iPorts.ResetAndDestroy();
       
   145 	}
       
   146 
       
   147 CPortBufferHandler::CPortInfo* CPortBufferHandler::CComponentInfo::AddPortL(TInt aPortNum, const TDesC& aFileName,OMX_BUFFERSUPPLIERTYPE aSupplier, OMX_DIRTYPE aPortDir, MOmxScriptTestLogger& aLogger, TInt aHeaderLength)
       
   148 	{
       
   149 	__ASSERT_ALWAYS(iPorts.Find(aPortNum, CPortInfo::ComparePortNum) == KErrNotFound, User::Invariant());
       
   150 
       
   151 	CPortInfo* portInfo = CPortInfo::NewL(iComp, aPortNum, aFileName, aSupplier, aPortDir, aLogger, aHeaderLength);
       
   152 	CleanupStack::PushL(portInfo);
       
   153 	iPorts.AppendL(portInfo);
       
   154 	CleanupStack::Pop(portInfo);
       
   155 
       
   156 	return portInfo;
       
   157 	}
       
   158 
       
   159 void CPortBufferHandler::CComponentInfo::AllocateBuffersL()
       
   160 	{
       
   161 	TInt numPorts = iPorts.Count();
       
   162 	
       
   163 	for (TInt port = 0; port < numPorts; ++port)
       
   164 		{
       
   165 		iPorts[port]->AllocateBuffersL();
       
   166 		}
       
   167 	iState = OMX_StateIdle;	
       
   168 	}
       
   169 
       
   170 void CPortBufferHandler::CComponentInfo::Start(TInt aPortNum)
       
   171 	{
       
   172 	TInt numPorts = iPorts.Count();
       
   173 	
       
   174 	if(aPortNum == -1)
       
   175 		{
       
   176 		for (TInt port = 0; port < numPorts; ++port)
       
   177 			{
       
   178 			iPorts[port]->Start();
       
   179 			}
       
   180 		}
       
   181 	else
       
   182 		{
       
   183 		TInt pos = iPorts.Find(aPortNum, CPortInfo::ComparePortNum);
       
   184 		iPorts[pos]->Start();
       
   185 		}		
       
   186 	iState = OMX_StateExecuting;
       
   187 	}
       
   188 
       
   189 void CPortBufferHandler::CComponentInfo::Resume(TInt aPortNum)
       
   190 	{
       
   191 	if(aPortNum == -1)
       
   192 		{ 
       
   193 		TInt numPorts = iPorts.Count();
       
   194 		
       
   195 		for (TInt port = 0; port < numPorts; ++port)
       
   196 			{
       
   197 			iPorts[port]->Resume();
       
   198 			}
       
   199 		}
       
   200 	else
       
   201 		{
       
   202 		TInt pos = iPorts.Find(aPortNum, CPortInfo::ComparePortNum);
       
   203 		iPorts[pos]->Resume();
       
   204 		}	
       
   205 	iState = OMX_StateExecuting;
       
   206 	}
       
   207 
       
   208 void CPortBufferHandler::CComponentInfo::BufferDone(OMX_BUFFERHEADERTYPE* aBufHdr, TBool aSource)
       
   209 	{
       
   210 	TInt pos = KErrNotFound;
       
   211 
       
   212 	if (aSource)
       
   213 		{
       
   214 		pos = iPorts.Find(static_cast<TInt>(aBufHdr->nOutputPortIndex), CPortInfo::ComparePortNum);
       
   215 		}
       
   216 	else
       
   217 		{
       
   218 		pos = iPorts.Find(static_cast<TInt>(aBufHdr->nInputPortIndex), CPortInfo::ComparePortNum);
       
   219 		}
       
   220 
       
   221 	__ASSERT_ALWAYS(pos != KErrNotFound, User::Invariant());
       
   222 
       
   223 	iPorts[pos]->BufferDone(aBufHdr);
       
   224 	}
       
   225 
       
   226 void CPortBufferHandler::CComponentInfo::Stop(TInt aPortNum)
       
   227 	{
       
   228 	if(aPortNum == -1)
       
   229 		{
       
   230 		for (TInt port = 0; port < iPorts.Count(); ++port)
       
   231 			{
       
   232 			iPorts[port]->Stop();
       
   233 			}
       
   234 		}
       
   235 	else
       
   236 		{
       
   237 		TInt pos = iPorts.Find(aPortNum, CPortInfo::ComparePortNum);
       
   238 		iPorts[pos]->Stop();
       
   239 		}		
       
   240 	iState = OMX_StateIdle;
       
   241 	}
       
   242 
       
   243 void CPortBufferHandler::CComponentInfo::Pause(TInt aPortNum)
       
   244 	{
       
   245 	if(aPortNum == -1)
       
   246 		{	
       
   247 		for (TInt port = 0; port < iPorts.Count(); ++port)
       
   248 			{
       
   249 			iPorts[port]->Pause();
       
   250 			}
       
   251 		}
       
   252 	else
       
   253 		{
       
   254 		TInt pos = iPorts.Find(aPortNum, CPortInfo::ComparePortNum);
       
   255 		iPorts[pos]->Pause();	
       
   256 		}
       
   257 	iState = OMX_StatePause;
       
   258 	}
       
   259 
       
   260 void CPortBufferHandler::CComponentInfo::FreeBuffers()
       
   261 	{
       
   262 	for (TInt port = 0; port < iPorts.Count(); ++port)
       
   263 		{
       
   264 		iPorts[port]->FreeBuffers();
       
   265 		}
       
   266 	iState = OMX_StateLoaded;	
       
   267 	}
       
   268 
       
   269 TBool CPortBufferHandler::CComponentInfo::CompareComp(const OMX_COMPONENTTYPE* aComp, const CComponentInfo& aComponentInfo)
       
   270 	{
       
   271 	return (aComp == aComponentInfo.iComp);
       
   272 	}
       
   273 
       
   274 
       
   275 CPortBufferHandler::CPortInfo::CPortInfo( OMX_COMPONENTTYPE* aComp,
       
   276 		   TInt aPortNum,
       
   277 		   OMX_BUFFERSUPPLIERTYPE aSupplier,
       
   278 		   OMX_DIRTYPE aPortDir,
       
   279 		   MOmxScriptTestLogger& aLogger,
       
   280 		   TInt aHeaderLength):
       
   281 	 iComp(aComp),
       
   282 	 iPortNum(aPortNum),
       
   283 	 iSupplier(aSupplier),
       
   284 	 iPortDir(aPortDir),
       
   285 	 iPosInputData(0),
       
   286 	 iFileHeaderLength(0),
       
   287 	 iFileFillingLength(0),
       
   288 	 iLogger(aLogger),
       
   289 	 iEOSReached(FALSE),
       
   290 	 iTimeStamp(0)
       
   291 	{
       
   292     if(aHeaderLength > -1)
       
   293         {
       
   294         iFileHeaderLength = aHeaderLength;
       
   295         }
       
   296 	}
       
   297 
       
   298 CPortBufferHandler::CPortInfo* CPortBufferHandler::CPortInfo::NewL( OMX_COMPONENTTYPE* aComp,
       
   299 											TInt aPortNum,
       
   300 											const TDesC& aFileName,
       
   301 											OMX_BUFFERSUPPLIERTYPE aSupplier,
       
   302 											OMX_DIRTYPE aPortDir,
       
   303 											MOmxScriptTestLogger& aLogger,
       
   304 											TInt aHeaderLength)
       
   305 	{
       
   306 	CPortInfo* self = new (ELeave) CPortInfo(aComp,aPortNum,aSupplier,aPortDir,aLogger,aHeaderLength);
       
   307 	CleanupStack::PushL(self);
       
   308 	
       
   309 	self->iFileName.Copy(KPortDirectoryPath);
       
   310 	self->iFileName.Append(aFileName);
       
   311 	
       
   312 	User::LeaveIfError(self->iFs.Connect());
       
   313 	if(self->iPortDir == OMX_DirInput)
       
   314 		{
       
   315 		User::LeaveIfError(self->iFileObject.Open(self->iFs, self->iFileName, EFileShareExclusive|EFileRead));
       
   316 		}
       
   317 	else if(self->iPortDir == OMX_DirOutput)
       
   318 		{
       
   319 		User::LeaveIfError(self->iFileObject.Replace(self->iFs, self->iFileName, EFileWrite));
       
   320 		}
       
   321 	else
       
   322 		{
       
   323 		User::LeaveIfError(KErrNotFound);	
       
   324 		}	
       
   325 		
       
   326 	CleanupStack::Pop(self);
       
   327 	return self;
       
   328 	}
       
   329 
       
   330 CPortBufferHandler::CPortInfo::~CPortInfo()
       
   331 	{
       
   332 	DeleteAllBuffers();
       
   333 	iFileObject.Close();
       
   334 	iFs.Close();
       
   335 	}
       
   336 
       
   337 void CPortBufferHandler::CPortInfo::AllocateBuffersL()
       
   338 	{
       
   339 	OMX_BUFFERHEADERTYPE* bufHdr = NULL;
       
   340 
       
   341 	if (iComp)
       
   342 		{
       
   343 		
       
   344 		OMX_PARAM_PORTDEFINITIONTYPE portDef;
       
   345         portDef.nSize = sizeof(portDef);
       
   346         portDef.nVersion = KOmxLILVersion;
       
   347         portDef.nPortIndex = iPortNum;
       
   348         OMX_ERRORTYPE error = iComp->GetParameter(iComp, OMX_IndexParamPortDefinition, &portDef);
       
   349         if(error != OMX_ErrorNone)
       
   350             {
       
   351             User::Leave(error);
       
   352             }
       
   353         
       
   354         iNumBufs = portDef.nBufferCountActual;
       
   355         TInt bufSize = portDef.nBufferSize;
       
   356         
       
   357         if(iFileHeaderLength <=0)
       
   358             {
       
   359             iFileHeaderLength = bufSize;
       
   360             }
       
   361         
       
   362         //fix for video partial tunnelling
       
   363         //mpeg4decoder needs timestamp info in each frame.
       
   364         //Buffer size approximately adjusted to framesize and timestamps added for each buffer
       
   365         //this change is done for all video components(needed only for mpeg4decoder)
       
   366         
       
   367         if(portDef.eDomain == OMX_PortDomainVideo)
       
   368             {
       
   369 			iFileFillingLength = 1600; //bufSize; 
       
   370             }
       
   371         else
       
   372             {
       
   373             iFileFillingLength = bufSize;
       
   374             }
       
   375 		
       
   376 		if (iSupplier == OMX_BufferSupplyInput)
       
   377 			{
       
   378 			for (TInt buf = 0; buf < iNumBufs; ++buf)
       
   379 				{
       
   380 				iComp->AllocateBuffer(iComp, &bufHdr, iPortNum, NULL, bufSize);
       
   381 				bufHdr->pAppPrivate = (OMX_PTR)EBufferFree;
       
   382 				iBufferHeaders.AppendL(bufHdr);
       
   383 				}
       
   384 			}
       
   385 		else
       
   386 			{
       
   387 			OMX_U8* newBuffer = NULL;			
       
   388 			
       
   389 			for (TInt buf = 0; buf < iNumBufs; ++buf)
       
   390 				{
       
   391 				newBuffer = new (ELeave) OMX_U8[bufSize];
       
   392 				CleanupStack::PushL(newBuffer);
       
   393 				iBuffers.AppendL(newBuffer);
       
   394 				CleanupStack::Pop(newBuffer);
       
   395 				
       
   396 				OMX_ERRORTYPE err = iComp->UseBuffer(iComp, &bufHdr, iPortNum, NULL, bufSize, newBuffer);
       
   397 				if(err != OMX_ErrorNone)
       
   398 					{
       
   399 					//error encountered in allocating.
       
   400 					}
       
   401 				bufHdr->pAppPrivate = (OMX_PTR)EBufferFree;				
       
   402 				iBufferHeaders.AppendL(bufHdr);
       
   403 				}
       
   404 			}
       
   405 		}
       
   406 	}
       
   407 
       
   408 void CPortBufferHandler::CPortInfo::BufferDone(OMX_BUFFERHEADERTYPE* aBufHdr)
       
   409 	{
       
   410 	for (TInt buf = 0; buf < iNumBufs; ++buf)
       
   411 		{
       
   412 		if (iBufferHeaders[buf] == aBufHdr)
       
   413 			{
       
   414 			aBufHdr->pAppPrivate = (OMX_PTR)EBufferFree;
       
   415 			if(iPortDir == OMX_DirInput)
       
   416 				{
       
   417 				TPtr8 data(aBufHdr->pBuffer,aBufHdr->nAllocLen);
       
   418 				Mem::FillZ(aBufHdr->pBuffer,aBufHdr->nAllocLen);
       
   419 				// Read data to this buffer.
       
   420 				TInt err = iFileObject.Read(iPosInputData,data,iFileFillingLength);
       
   421 				iPosInputData += iFileFillingLength;
       
   422 				if(err != KErrNone)
       
   423 					{
       
   424 					return; //error return.
       
   425 					}
       
   426                 
       
   427 				aBufHdr->nTimeStamp = iTimeStamp* 1000;
       
   428                 iTimeStamp += 100;
       
   429                 if(!iEOSReached)
       
   430 					{
       
   431 					aBufHdr->nFilledLen = data.Size();
       
   432 					aBufHdr->nOffset = 0;
       
   433 					aBufHdr->nInputPortIndex = iPortNum;
       
   434 					aBufHdr->nOutputPortIndex = OMX_ErrorMax;
       
   435 					
       
   436 					//Send buffer to port and mark that it is under use.
       
   437 					aBufHdr->pAppPrivate = (OMX_PTR)EBufferUnderUse;
       
   438 					if((data.Size() < aBufHdr->nAllocLen)&&(data.Size() < iFileFillingLength))
       
   439 						{
       
   440 						//INFO_PRINTF1(_L("EOS detected on Input Port"));
       
   441 						aBufHdr->nFlags |= OMX_BUFFERFLAG_EOS;
       
   442 						iEOSReached = ETrue;
       
   443 						}
       
   444 					iComp->EmptyThisBuffer(iComp, aBufHdr);
       
   445 					}
       
   446 				}
       
   447 			else
       
   448 				{
       
   449 				//create a pointer into buffer
       
   450 				// using ptr , write buffer data to File.
       
   451 				TPtr8 data( aBufHdr->pBuffer+aBufHdr->nOffset, aBufHdr->nFilledLen, aBufHdr->nAllocLen );
       
   452 				TInt err = iFileObject.Write(data);
       
   453 				if(err != KErrNone)
       
   454 					{
       
   455 					return; //error return.
       
   456 					}
       
   457 				err = iFileObject.Flush();	
       
   458 				if(err != KErrNone)
       
   459 					{
       
   460 					return; //error return.
       
   461 					}
       
   462 				aBufHdr->pAppPrivate = (OMX_PTR)EBufferFree;
       
   463 				aBufHdr->nFilledLen = 0;
       
   464 				aBufHdr->nOffset = 0;
       
   465 				aBufHdr->nOutputPortIndex = iPortNum;
       
   466 				aBufHdr->nInputPortIndex = OMX_ErrorMax;
       
   467 				if(aBufHdr->nFlags & OMX_BUFFERFLAG_EOS)
       
   468 					{
       
   469 					// TODO Logic for EOS
       
   470 					return;
       
   471 					}
       
   472 				else
       
   473 					{
       
   474 					iComp->FillThisBuffer(iComp, aBufHdr);		
       
   475 					}
       
   476 				
       
   477 				}
       
   478 			}
       
   479 		}
       
   480 	}
       
   481 void CPortBufferHandler::CPortInfo::Start()
       
   482 	{
       
   483 	for (TInt buf = 0; buf < iNumBufs; ++buf)
       
   484 		{
       
   485 		OMX_BUFFERHEADERTYPE *bufferHdr = iBufferHeaders[buf];
       
   486 		
       
   487 		if (bufferHdr->pAppPrivate == (OMX_PTR)EBufferFree)
       
   488 			{
       
   489 			if(iPortDir == OMX_DirInput)
       
   490 				{
       
   491 				TPtr8 data(bufferHdr->pBuffer,bufferHdr->nAllocLen);
       
   492 				// Read data to this buffer.
       
   493 				TInt err =0;
       
   494 				if(buf == 0)
       
   495 					{
       
   496 					err = iFileObject.Read(iPosInputData,data,iFileHeaderLength);
       
   497 					iPosInputData += iFileHeaderLength;
       
   498 					bufferHdr->nFlags |= OMX_BUFFERFLAG_STARTTIME;
       
   499 					}
       
   500 				else
       
   501 					{
       
   502 					err = iFileObject.Read(iPosInputData,data,iFileFillingLength);
       
   503 					iPosInputData += iFileFillingLength;	
       
   504 					}				
       
   505 				if(err != KErrNone)
       
   506 					{
       
   507 					return; //error return.
       
   508 					}
       
   509               
       
   510 				bufferHdr->nTimeStamp = iTimeStamp * 1000;
       
   511                 iTimeStamp += 100;
       
   512 				if(data.Size())
       
   513 					{
       
   514 					bufferHdr->nFilledLen = data.Size();
       
   515 					bufferHdr->nOffset = 0;
       
   516 					
       
   517 					//Send buffer to port and mark that it is under use.
       
   518 					bufferHdr->pAppPrivate = (OMX_PTR)EBufferUnderUse;
       
   519 					//CHeck for EOF
       
   520 					if(buf > 0)
       
   521 						{
       
   522 						if(data.Size() < iFileFillingLength)
       
   523 							{
       
   524 							bufferHdr->nFlags |= OMX_BUFFERFLAG_EOS;
       
   525 							}	
       
   526 						}
       
   527 						
       
   528 					if(buf == 0)
       
   529 						{
       
   530 						if(data.Size() < iFileHeaderLength)
       
   531 							{
       
   532 							ASSERT(0);
       
   533 							return;
       
   534 							}	
       
   535 						}	
       
   536 					
       
   537 					iComp->EmptyThisBuffer(iComp, bufferHdr);
       
   538 					}
       
   539 				}
       
   540 			else
       
   541 				{
       
   542 				bufferHdr->pAppPrivate = (OMX_PTR)EBufferUnderUse;
       
   543 				bufferHdr->nFilledLen = 0;
       
   544 				bufferHdr->nOffset = 0;
       
   545 				iComp->FillThisBuffer(iComp, bufferHdr);	
       
   546 				}
       
   547 			}
       
   548 			
       
   549 		}
       
   550 	}
       
   551 
       
   552 void CPortBufferHandler::CPortInfo::Stop()
       
   553 	{
       
   554 //Todo: implement any stop functionality required.
       
   555 	}
       
   556 
       
   557 void CPortBufferHandler::CPortInfo::Resume()
       
   558 	{
       
   559 //Todo: implement any resume functionality required.
       
   560 	}
       
   561 	
       
   562 
       
   563 void CPortBufferHandler::CPortInfo::Pause()
       
   564 	{
       
   565 //Todo: implement any resume functionality required.
       
   566 	}	
       
   567 
       
   568 void CPortBufferHandler::CPortInfo::FreeBuffers()
       
   569 	{
       
   570 	for (TInt buf = 0; buf < iNumBufs; ++buf)
       
   571 		{
       
   572 		iComp->FreeBuffer(iComp, iPortNum, iBufferHeaders[buf]);
       
   573 		}
       
   574 
       
   575 	DeleteAllBuffers();
       
   576 	}
       
   577 
       
   578 void CPortBufferHandler::CPortInfo::DeleteAllBuffers()
       
   579 	{
       
   580 	iBufferHeaders.Reset();
       
   581 
       
   582 	if (iComp && iSupplier != OMX_BufferSupplyInput)
       
   583 		{
       
   584 		iBuffers.ResetAndDestroy();
       
   585 		}
       
   586 	else
       
   587 		{
       
   588 		iBuffers.Reset();
       
   589 		}
       
   590 	}
       
   591 
       
   592 TBool CPortBufferHandler::CPortInfo::ComparePortNum(const TInt* aPortNum, const CPortInfo& aPortInfo)
       
   593 	{
       
   594 	//return (aComp == aPortInfo.iComp);
       
   595 	return (*aPortNum == aPortInfo.iPortNum);
       
   596 	}
       
   597 	
       
   598 OMX_DIRTYPE& CPortBufferHandler::CPortInfo::PortDir()
       
   599 	{
       
   600 	return iPortDir;
       
   601 	}
       
   602 	
       
   603 void CPortBufferHandler::CPortInfo::LogExtra(const TText8* aFile, TInt aLine, TOmxScriptSeverity aSeverity,
       
   604             TRefByValue<const TDesC16> aFmt,...)
       
   605     {
       
   606     VA_LIST aList;
       
   607     VA_START(aList, aFmt);
       
   608 
       
   609     TOverflowHandler overflow;
       
   610     TBuf<255> msg;
       
   611     msg.AppendFormatList(aFmt, aList, &overflow);
       
   612     
       
   613     iLogger.Log(aFile, aLine, aSeverity, msg);
       
   614     
       
   615     VA_END(aList);
       
   616     }