omxilvideocomps/omxilgraphicsink/tsrc/src/omxilgraphicsinktestbase.cpp
changeset 0 5d29cba61097
equal deleted inserted replaced
-1:000000000000 0:5d29cba61097
       
     1 /*
       
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  * @file
       
    21  * @internalTechnology
       
    22  */
       
    23 
       
    24 #include "omxilgraphicsinktestbase.h"
       
    25 #include <mmf/server/mmfbuffer.h>
       
    26 #include <mmf/server/mmfdatabuffer.h>
       
    27 
       
    28 CCallbackHandler*
       
    29 CCallbackHandler::NewL(COmxGsTestBase& aCameraSourceTest)
       
    30 	{
       
    31 	CCallbackHandler* self = new (ELeave) CCallbackHandler(aCameraSourceTest);
       
    32 	CleanupStack::PushL(self);
       
    33 	self->ConstructL();
       
    34 	CleanupStack::Pop(self);
       
    35 	return self;
       
    36 	}
       
    37 
       
    38 
       
    39 void
       
    40 CCallbackHandler::ConstructL()
       
    41 	{
       
    42 	OMX_CALLBACKTYPE h =
       
    43 			{
       
    44 			CCallbackHandler::EventHandler,
       
    45 			CCallbackHandler::EmptyBufferDone,
       
    46 			CCallbackHandler::FillBufferDone
       
    47 			};
       
    48 
       
    49 	iHandle = h;
       
    50 	CActiveScheduler::Add(this);
       
    51 
       
    52 	User::LeaveIfError(iMsgQueue.CreateLocal(KMaxMsgQueueEntries));
       
    53 	iMsgQueue.NotifyDataAvailable(iStatus);
       
    54 	SetActive();
       
    55 	}
       
    56 
       
    57 CCallbackHandler::CCallbackHandler(COmxGsTestBase& aCameraSourceTest)
       
    58 	: CActive(EPriorityStandard),
       
    59 	  iCameraSourceTest(aCameraSourceTest)
       
    60 	{
       
    61 	}
       
    62 
       
    63 
       
    64 CCallbackHandler::operator OMX_CALLBACKTYPE*()
       
    65 	{
       
    66 	return &iHandle;
       
    67 	}
       
    68 
       
    69 
       
    70 void
       
    71 CCallbackHandler::RunL()
       
    72 	{
       
    73 	TOmxMessage msg;
       
    74 	while (iMsgQueue.Receive(msg)==KErrNone)
       
    75 		{
       
    76 		switch (msg.iType)
       
    77 			{
       
    78 			case EEmptyBufferCallback:
       
    79 				{
       
    80 //				MOmxInputPortCallbacks* callback = msg.iBuffer->InputPortCallbacks();
       
    81 //				const CMMFBuffer* buffer = msg.iBuffer->MmfBuffer();
       
    82 //				callback->EmptyBufferDone(msg.iComponent, buffer);
       
    83 				iCameraSourceTest.DoEmptyBufferDone(msg.iComponent, static_cast<OMX_BUFFERHEADERTYPE*>(msg.iBuffer));
       
    84 				break;
       
    85 				}
       
    86 
       
    87 			case EFillBufferCallback:
       
    88 				{
       
    89 				//iCameraSourceTest.DoFillBufferDone(msg.iComponent,static_cast<CCameraBuffer*>(msg.iBuffer));
       
    90 				iCameraSourceTest.DoFillBufferDone(msg.iComponent, static_cast<OMX_BUFFERHEADERTYPE*>(msg.iBuffer));
       
    91 				break;
       
    92 				}
       
    93 			case EEventCallback:
       
    94 				{
       
    95 				iCameraSourceTest.DoEventHandler(msg.iComponent,
       
    96 											msg.iEventParams.iEvent,
       
    97 											msg.iEventParams.iData1,
       
    98 											msg.iEventParams.iData2,
       
    99 											msg.iEventParams.iExtra);
       
   100 				break;
       
   101 				}
       
   102 			default:
       
   103 				{
       
   104 				// This is an invalid state
       
   105 				ASSERT(EFalse);
       
   106 				}
       
   107 			}
       
   108 		}
       
   109 
       
   110 	// setup for next callbacks
       
   111 	iStatus = KRequestPending;
       
   112 	iMsgQueue.NotifyDataAvailable(iStatus);
       
   113 	SetActive();
       
   114 
       
   115 	}
       
   116 
       
   117 CCallbackHandler::~CCallbackHandler()
       
   118 	{
       
   119 	Cancel();
       
   120 	iMsgQueue.Close();
       
   121 	}
       
   122 
       
   123 
       
   124 void
       
   125 CCallbackHandler::DoCancel()
       
   126 	{
       
   127 	if (iMsgQueue.Handle())
       
   128 		{
       
   129 		iMsgQueue.CancelDataAvailable();
       
   130 		}
       
   131 	}
       
   132 
       
   133 OMX_ERRORTYPE
       
   134 CCallbackHandler::FillBufferDone(OMX_HANDLETYPE aComponent,
       
   135 									TAny* aAppData,
       
   136 									OMX_BUFFERHEADERTYPE* aBuffer)
       
   137 	{
       
   138 	ASSERT(aAppData);
       
   139 	//CCameraBuffer* pBuffer = static_cast<CCameraBuffer*>(aBuffer->pAppPrivate);
       
   140 	return static_cast<CCallbackHandler*>(aAppData)->DoFillBufferDone(aComponent, aBuffer);
       
   141 	}
       
   142 
       
   143 OMX_ERRORTYPE
       
   144 CCallbackHandler::EmptyBufferDone(OMX_HANDLETYPE aComponent,
       
   145 									 TAny* aAppData,
       
   146 									 OMX_BUFFERHEADERTYPE* aBuffer)
       
   147 	{
       
   148 	ASSERT(aAppData);
       
   149 	//CCameraBuffer* pBuffer = static_cast<CCameraBuffer*>(aBuffer->pAppPrivate);
       
   150 	return static_cast<CCallbackHandler*>(aAppData)->DoEmptyBufferDone(aComponent, aBuffer);
       
   151 
       
   152 	}
       
   153 
       
   154 OMX_ERRORTYPE
       
   155 CCallbackHandler::EventHandler(OMX_HANDLETYPE aComponent,
       
   156 								  TAny* aAppData,
       
   157 								  OMX_EVENTTYPE aEvent,
       
   158 								  TUint32 aData1,
       
   159 								  TUint32 aData2,
       
   160 								  TAny* aExtra)
       
   161 	{
       
   162 	ASSERT(aAppData);
       
   163 	CCallbackHandler::TEventParams eventParams;
       
   164 	eventParams.iEvent = aEvent;
       
   165 	eventParams.iData1 = aData1;
       
   166 	eventParams.iData2 = aData2;
       
   167 	eventParams.iExtra = aExtra;	
       
   168 	return static_cast<CCallbackHandler*>(aAppData)->DoEventHandler(aComponent, eventParams);
       
   169 	}
       
   170 
       
   171 OMX_ERRORTYPE CCallbackHandler::DoFillBufferDone(OMX_HANDLETYPE aComponent,
       
   172 								  OMX_BUFFERHEADERTYPE* aBufferHeader)
       
   173 	{
       
   174 	TOmxMessage message;
       
   175 	message.iType = EFillBufferCallback;
       
   176 	message.iComponent = aComponent;
       
   177 	message.iBuffer = static_cast <OMX_BUFFERHEADERTYPE*>(aBufferHeader);
       
   178 	TInt error = iMsgQueue.Send(message);
       
   179 	//RDebug::Printf("CCallbackHandler:: Error: %d",error);
       
   180 
       
   181 	return (error == KErrNone ? OMX_ErrorNone : OMX_ErrorUndefined);
       
   182 	}
       
   183 
       
   184 OMX_ERRORTYPE CCallbackHandler::DoEmptyBufferDone(OMX_HANDLETYPE aComponent,
       
   185 								   OMX_BUFFERHEADERTYPE* aBufferHeader)
       
   186 	{
       
   187 	TOmxMessage message;
       
   188 	message.iType = EEmptyBufferCallback;
       
   189 	message.iComponent = aComponent;
       
   190 	message.iBuffer = static_cast <OMX_BUFFERHEADERTYPE*> (aBufferHeader);
       
   191 	TInt error = iMsgQueue.Send(message);
       
   192 	//RDebug::Printf("CCallbackHandler:: Error: %d",error);
       
   193 
       
   194 	return (error == KErrNone ? OMX_ErrorNone : OMX_ErrorUndefined);
       
   195 	}
       
   196 
       
   197 
       
   198 OMX_ERRORTYPE CCallbackHandler::DoEventHandler(OMX_HANDLETYPE aComponent, TEventParams aEventParams)
       
   199 	{
       
   200 	TOmxMessage message;
       
   201 	message.iType = EEventCallback;
       
   202 	message.iComponent = aComponent;
       
   203 	message.iEventParams = aEventParams;
       
   204 
       
   205 	/*
       
   206 	OMX_EventCmdComplete,
       
   207     OMX_EventError,
       
   208     OMX_EventMark,
       
   209     OMX_EventPortSettingsChanged,
       
   210     OMX_EventBufferFlag,
       
   211     OMX_EventResourcesAcquired,
       
   212     OMX_EventComponentResumed,
       
   213     OMX_EventDynamicResourcesAvailable,
       
   214     OMX_EventPortFormatDetected,
       
   215     OMX_EventMax = 0x7FFFFFFF
       
   216 	*/
       
   217 
       
   218 	// TO DO - Put in switch on OMX_EVENTTYPE iEvent and print out the event type and relevant error code in test logs
       
   219 	TInt error = iMsgQueue.Send(message);
       
   220 	//RDebug::Printf("CCallbackHandler:: Error: %d",error);
       
   221 
       
   222 	return (error == KErrNone ? OMX_ErrorNone : OMX_ErrorUndefined);
       
   223 	}
       
   224 
       
   225 //
       
   226 // COmxGsTestBase
       
   227 //
       
   228 
       
   229 // Device driver constants
       
   230 
       
   231 TVerdict COmxGsTestBase::doTestStepPreambleL()
       
   232 /**
       
   233  * @return - TVerdict
       
   234  * Implementation of CTestStep base class virtual
       
   235  * It is used for doing all initialisation common to derived classes in here.
       
   236  * Make it being able to leave if there are any errors here as there's no point in
       
   237  * trying to run a test step if anything fails.
       
   238  * The leave will be picked up by the framework.
       
   239  */
       
   240 	{
       
   241 	// Here we check to see if there is already an active scheduler
       
   242 	// installed, as this function will receive multiple calls during
       
   243 	// Alloc testing of CS and GS components
       
   244 	__UHEAP_MARK;
       
   245 	if (!CActiveScheduler::Current())
       
   246 		{
       
   247 		iScheduler = new (ELeave) CActiveScheduler;
       
   248 		CActiveScheduler::Install(iScheduler);
       
   249 		}
       
   250 
       
   251 	// Make sure we are not running the Alloc tests, if we are
       
   252 	// then we will create these elsewhere.
       
   253 	if (TestStepName() != (_L("MMVIDEO-OMX-CS-004-HP")) &&
       
   254 		TestStepName() != (_L("MMVIDEO-OMX-GS-001-00-HP")) &&
       
   255 		TestStepName() != (_L("MMVIDEO-OMX-JP-001-00-HP")) &&
       
   256 		TestStepName() != (_L("MMVIDEO-OMX-FS-001-00-HP")) &&
       
   257 		TestStepName() != (_L("MMVIDEO-OMX-IW-001-00-HP")))
       
   258 		{
       
   259 		InitialiseOmxComponents();
       
   260 		if (TestStepResult() != EPass)
       
   261 			{
       
   262 			INFO_PRINTF1(_L("*** InitialiseOmxComponents() failed. No point running test case. ***"));
       
   263 
       
   264 			// If the preamble leaves then the postamble isn't called by TEF.
       
   265 			// We have to do it ourselves to ensure stuff is cleaned up.
       
   266 			TRAP_IGNORE(doTestStepPostambleL());
       
   267 			User::Leave(KErrGeneral);
       
   268 			}
       
   269 		}
       
   270 
       
   271 	return TestStepResult();
       
   272 	}
       
   273 
       
   274 TVerdict COmxGsTestBase::doTestStepPostambleL()
       
   275 /**
       
   276  * @return - TVerdict
       
   277  * Implementation of CTestStep base class virtual
       
   278  * It is used for doing all after test treatment common to derived classes in here.
       
   279  * Make it being able to leave
       
   280  * The leave will be picked up by the framework.
       
   281  */
       
   282 	{
       
   283 	CloseTestStep();
       
   284 
       
   285 	delete iScheduler;
       
   286 	__UHEAP_MARKEND;
       
   287 	return TestStepResult();
       
   288 	}
       
   289 
       
   290 COmxGsTestBase::~COmxGsTestBase()
       
   291 	{
       
   292 	}
       
   293 
       
   294 
       
   295 
       
   296 
       
   297 COmxGsTestBase::COmxGsTestBase() : iCamPrevState(OMX_StateInvalid),
       
   298 										iGphxPrevState(OMX_StateInvalid)
       
   299 	{
       
   300 	}
       
   301 
       
   302 
       
   303 void
       
   304 COmxGsTestBase::PrintOmxState(OMX_STATETYPE aOmxState)
       
   305 	{
       
   306 	switch(aOmxState)
       
   307 		{
       
   308 	    case OMX_StateInvalid:
       
   309 			{
       
   310 			INFO_PRINTF1(_L("OMX STATE : OMX_StateInvalid"));
       
   311 			}
       
   312 			break;
       
   313 	    case OMX_StateLoaded:
       
   314 			{
       
   315 			INFO_PRINTF1(_L("OMX STATE : OMX_StateLoaded"));
       
   316 			}
       
   317 			break;
       
   318 	    case OMX_StateIdle:
       
   319 			{
       
   320 			INFO_PRINTF1(_L("OMX STATE : OMX_StateIdle"));
       
   321 			}
       
   322 			break;
       
   323 	    case OMX_StateExecuting:
       
   324 			{
       
   325 			INFO_PRINTF1(_L("OMX STATE : OMX_StateExecuting"));
       
   326 			}
       
   327 			break;
       
   328 	    case OMX_StatePause:
       
   329 			{
       
   330 			INFO_PRINTF1(_L("OMX STATE : OMX_StatePause"));
       
   331 			}
       
   332 			break;
       
   333 	    case OMX_StateWaitForResources:
       
   334 			{
       
   335 			//INFO_PRINTF1(_L("OMX STATE : OMX_StateWaitForResources"));
       
   336 			}
       
   337 			break;
       
   338 		default:
       
   339 			{
       
   340 			//INFO_PRINTF1(_L("OMX STATE : Wrong state found"));
       
   341 			}
       
   342 		}
       
   343 	}
       
   344 
       
   345 TInt COmxGsTestBase::PrintOmxError(OMX_ERRORTYPE aOmxError)
       
   346 	{
       
   347     switch(aOmxError)
       
   348 		{
       
   349 		case OMX_ErrorNone:
       
   350 			{
       
   351 			INFO_PRINTF1(_L("OMX ERROR : OMX_ErrorNone"));
       
   352 			return KErrNone;
       
   353 			}
       
   354 
       
   355 		case OMX_ErrorInsufficientResources:
       
   356 			{
       
   357 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorInsufficientResources"));
       
   358 			return KErrNoMemory; //KErrNotReady;
       
   359 			}
       
   360 
       
   361 		case OMX_ErrorUndefined:
       
   362 			{
       
   363 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorUndefined"));
       
   364 			return KErrGeneral;
       
   365 			}
       
   366 
       
   367 		case OMX_ErrorInvalidComponentName:
       
   368 			{
       
   369 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorInvalidComponentName"));
       
   370 			return KErrBadName;
       
   371 			}
       
   372 
       
   373 		case OMX_ErrorComponentNotFound:
       
   374 			{
       
   375 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorComponentNotFound"));
       
   376 			return KErrNotFound;
       
   377 			}
       
   378 
       
   379 		case OMX_ErrorInvalidComponent:
       
   380 			{
       
   381 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorInvalidComponent"));
       
   382 			return KErrBadHandle;
       
   383 			}
       
   384 
       
   385 		case OMX_ErrorBadParameter:
       
   386 			{
       
   387 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorBadParameter"));
       
   388 			return KErrArgument;
       
   389 			}
       
   390 
       
   391 		case OMX_ErrorNotImplemented:
       
   392 			{
       
   393 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorNotImplemented"));
       
   394 			return KErrNotSupported;
       
   395 			}
       
   396 
       
   397 		case OMX_ErrorUnderflow:
       
   398 			{
       
   399 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorUnderflow"));
       
   400 			return KErrUnderflow;
       
   401 			}
       
   402 
       
   403 		case OMX_ErrorOverflow:
       
   404 			{
       
   405 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorOverflow"));
       
   406 			return KErrOverflow;
       
   407 			}
       
   408 
       
   409 		case OMX_ErrorHardware:
       
   410 			{
       
   411 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorHardware"));
       
   412 			return KErrUnknown;
       
   413 			}
       
   414 
       
   415 		case OMX_ErrorInvalidState:
       
   416 			{
       
   417 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorInvalidState"));
       
   418 			return KErrGeneral;
       
   419 			}
       
   420 
       
   421 		case OMX_ErrorStreamCorrupt:
       
   422 			{
       
   423 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorStreamCorrupt"));
       
   424 			return KErrCorrupt;
       
   425 			}
       
   426 
       
   427 		case OMX_ErrorPortsNotCompatible:
       
   428 			{
       
   429 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorPortsNotCompatible"));
       
   430 			//ERR_PRINTF1(_L("Ports being connected are not compatible"));
       
   431 			return KErrUnknown;
       
   432 			}
       
   433 
       
   434 		case OMX_ErrorResourcesLost:
       
   435 			{
       
   436 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorResourcesLost"));
       
   437 			//ERR_PRINTF1(_L("Resources allocated to an idle component have been lost resulting in the component returning to the loaded state"));
       
   438 			return KErrNotReady;
       
   439 			}
       
   440 
       
   441 		case OMX_ErrorNoMore:
       
   442 			{
       
   443 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorNoMore"));
       
   444 			//ERR_PRINTF1(_L("No more indicies can be enumerated"));
       
   445 			return KErrGeneral;
       
   446 			}
       
   447 
       
   448 		case OMX_ErrorVersionMismatch:
       
   449 			{
       
   450 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorVersionMismatch"));
       
   451 			//ERR_PRINTF1(_L("The component detected a version mismatch"));
       
   452 			return KErrArgument;
       
   453 			}
       
   454 
       
   455 		case OMX_ErrorNotReady:
       
   456 			{
       
   457 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorNotReady"));
       
   458 			//ERR_PRINTF1(_L("The component is not ready to return data at this time"));
       
   459 			return KErrNotReady;
       
   460 			}
       
   461 
       
   462 		case OMX_ErrorTimeout:
       
   463 			{
       
   464 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorTimeout"));
       
   465 			//ERR_PRINTF1(_L("There was a timeout that occurred"));
       
   466 			return KErrTimedOut;
       
   467 			}
       
   468 
       
   469 		case OMX_ErrorSameState:
       
   470 			{
       
   471 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorSameState"));
       
   472 			//ERR_PRINTF1(_L("This error occurs when trying to transition into the state you are already in"));
       
   473 			return KErrGeneral;
       
   474 			}
       
   475 
       
   476 		case OMX_ErrorResourcesPreempted:
       
   477 			{
       
   478 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorResourcesPreempted"));
       
   479 			//ERR_PRINTF1(_L("Resources allocated to an executing or paused component have been preempted, causing the component to return to the idle state"));
       
   480 			return KErrGeneral;
       
   481 			}
       
   482 
       
   483 		case OMX_ErrorPortUnresponsiveDuringAllocation:
       
   484 			{
       
   485 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorPortUnresponsiveDuringAllocation"));
       
   486 			//ERR_PRINTF1(_L("A non-supplier port sends this error to the IL client (via the EventHandler callback) during the allocation of buffers (on a transition from the LOADED to the IDLE state or on a port restart) when it deems that it has waited an unusually long time for the supplier to send it an allocated buffer via a UseBuffer call."));
       
   487 			return KErrGeneral; //KErrTimedOut
       
   488 			}
       
   489 
       
   490 		case OMX_ErrorPortUnresponsiveDuringDeallocation:
       
   491 			{
       
   492 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorPortUnresponsiveDuringDeallocation"));
       
   493 			//ERR_PRINTF1(_L("A non-supplier port sends this error to the IL client (via the EventHandler callback) during the deallocation of buffers (on a transition from the IDLE to LOADED state or on a port stop) when it deems that it has waited an unsually long time for the supplier to request the deallocation of a buffer header via a FreeBuffer call."));
       
   494 			return KErrGeneral; //KErrTimedOut
       
   495 			}
       
   496 
       
   497 		case OMX_ErrorPortUnresponsiveDuringStop:
       
   498 			{
       
   499 		ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorPortUnresponsiveDuringStop"));
       
   500 			//ERR_PRINTF1(_L("A supplier port sends this error to the IL client (via the EventHandler callback) during the stopping of a port (either on a transition from the IDLE to LOADED state or a port stop) when it deems that it has waited an unusually long time for the non-supplier to return a buffer via an EmptyThisBuffer or FillThisBuffer call."));
       
   501 			return KErrGeneral; //KErrTimedOut
       
   502 			}
       
   503 
       
   504 		case OMX_ErrorIncorrectStateTransition:
       
   505 			{
       
   506 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorIncorrectStateTransition"));
       
   507 			//ERR_PRINTF1(_L("Attempting a state transtion that is not allowed"));
       
   508 			return KErrGeneral;
       
   509 			}
       
   510 
       
   511 		case OMX_ErrorIncorrectStateOperation:
       
   512 			{
       
   513 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorIncorrectStateOperation"));
       
   514 			//ERR_PRINTF1(_L("Attempting a command that is not allowed during the present state."));
       
   515 			return KErrGeneral; //KErrNotSupported
       
   516 			}
       
   517 
       
   518 		case OMX_ErrorUnsupportedSetting:
       
   519 			{
       
   520 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorUnsupportedSetting"));
       
   521 			//ERR_PRINTF1(_L("The values encapsulated in the parameter or config structure are not supported."));
       
   522 			return KErrGeneral; //KErrNotSupported
       
   523 			}
       
   524 
       
   525 		case OMX_ErrorUnsupportedIndex:
       
   526 			{
       
   527 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorUnsupportedIndex"));
       
   528 			//ERR_PRINTF1(_L("The parameter or config indicated by the given index is not supported."));
       
   529 			return KErrNotSupported; //KErrTooBig or KErrGeneral
       
   530 			}
       
   531 
       
   532 		case OMX_ErrorBadPortIndex:
       
   533 			{
       
   534 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorBadPortIndex"));
       
   535 			//ERR_PRINTF1(_L("The port index supplied is incorrect."));
       
   536 			return KErrArgument; //KErrTooBig
       
   537 			}
       
   538 
       
   539 		case OMX_ErrorPortUnpopulated:
       
   540 			{
       
   541 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorPortUnpopulated"));
       
   542 			//ERR_PRINTF1(_L("The port has lost one or more of its buffers and it thus unpopulated."));
       
   543 			return KErrGeneral;
       
   544 			}
       
   545 
       
   546 		case OMX_ErrorComponentSuspended:
       
   547 			{
       
   548 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorComponentSuspended"));
       
   549 			//ERR_PRINTF1(_L("Component suspended due to temporary loss of resources"));
       
   550 			return KErrAbort;
       
   551 			}
       
   552 
       
   553 		case OMX_ErrorDynamicResourcesUnavailable:
       
   554 			{
       
   555 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorDynamicResourcesUnavailable"));
       
   556 			//ERR_PRINTF1(_L("Component suspended due to an inability to acquire dynamic resources"));
       
   557 			return KErrAbort; //KErrGeneral
       
   558 			}
       
   559 
       
   560 		case OMX_ErrorMbErrorsInFrame:
       
   561 			{
       
   562 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorMbErrorsInFrame"));
       
   563 			//ERR_PRINTF1(_L("When the macroblock error reporting is enabled the component returns new error for every frame that has errors"));
       
   564 			return KErrGeneral;
       
   565 			}
       
   566 
       
   567 		case OMX_ErrorFormatNotDetected:
       
   568 			{
       
   569 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorFormatNotDetected"));
       
   570 			//ERR_PRINTF1(_L("A component reports this error when it cannot parse or determine the format of an input stream."));
       
   571 			return KErrCorrupt; //KErrGeneral
       
   572 			}
       
   573 
       
   574 		case OMX_ErrorContentPipeOpenFailed:
       
   575 			{
       
   576 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorContentPipeOpenFailed"));
       
   577 			//R//ERR_PRINTF1(_L("The content open operation failed."));
       
   578 			return KErrGeneral;
       
   579 			//break;
       
   580 			}
       
   581 
       
   582 		case OMX_ErrorContentPipeCreationFailed:
       
   583 			{
       
   584 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorContentPipeCreationFailed"));
       
   585 			//ERR_PRINTF1(_L("The content creation operation failed."));
       
   586 			return KErrGeneral;
       
   587 			}
       
   588 
       
   589 		case OMX_ErrorSeperateTablesUsed:
       
   590 			{
       
   591 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorSeperateTablesUsed"));
       
   592 			//ERR_PRINTF1(_L("Separate table information is being used"));
       
   593 			return KErrGeneral;
       
   594 			}
       
   595 
       
   596 		case OMX_ErrorTunnelingUnsupported:
       
   597 			{
       
   598 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorTunnelingUnsupported"));
       
   599 			//ERR_PRINTF1(_L("Tunneling is unsupported by the component"));
       
   600 			return KErrNotSupported;
       
   601 			}
       
   602 
       
   603 		case OMX_ErrorMax:
       
   604 			{
       
   605 			ERR_PRINTF1(_L("OMX ERROR : OMX_ErrorMax"));
       
   606 			//ERR_PRINTF1(_L("OMX_ErrorMax"));
       
   607 			return KErrTooBig; // KErrGeneral
       
   608 			}
       
   609 
       
   610 		default:
       
   611 			{
       
   612 			ERR_PRINTF1(_L("OMX ERROR : Wrong error code found"));
       
   613 			return KErrGeneral;
       
   614 			}
       
   615 		}
       
   616 	}
       
   617 
       
   618 void COmxGsTestBase::InfoPrint1(const TDesC& aPrint)
       
   619 	{
       
   620 	INFO_PRINTF1(aPrint);
       
   621 	}
       
   622 
       
   623 OMX_ERRORTYPE COmxGsTestBase::ConvertSymbianErrorType(TInt aError)
       
   624 	{
       
   625 	OMX_ERRORTYPE err = OMX_ErrorNone;
       
   626 	switch (aError)
       
   627 		{
       
   628 	case KErrNone:
       
   629 		err = OMX_ErrorNone;
       
   630 		break;
       
   631 	case KErrNoMemory:
       
   632 		err = OMX_ErrorInsufficientResources;
       
   633 		break;
       
   634 	case KErrGeneral:
       
   635 		break;
       
   636 	default:
       
   637 		err = OMX_ErrorUndefined;
       
   638 		}
       
   639 	return err;
       
   640 	}
       
   641 
       
   642 
       
   643 void COmxGsTestBase::InitialiseOmxComponents()
       
   644 	{
       
   645 	iError = OMX_Init();
       
   646 
       
   647 	if (OMX_ErrorNone != iError)
       
   648 		{
       
   649 		SetTestStepError(PrintOmxError(iError));
       
   650 		return SetTestStepResult(EFail);
       
   651 		}
       
   652 
       
   653 	ASSERT(!iCallbackHandler);
       
   654 	TRAPD(error, iCallbackHandler = CCallbackHandler::NewL(*this));
       
   655 	OMX_CALLBACKTYPE* omxCallbacks = *iCallbackHandler;
       
   656 
       
   657 	if (error)
       
   658 		{
       
   659 		SetTestStepError(error);
       
   660 		return SetTestStepResult(EFail);
       
   661 		}
       
   662 
       
   663 	OMX_PTR appData = iCallbackHandler;
       
   664 
       
   665 	OMX_HANDLETYPE graphicsSinkHandle = NULL;
       
   666 	OMX_STRING graphicsSinkComponentName = "OMX.SYMBIAN.VIDEO.GRAPHICSINK";
       
   667 
       
   668 	iError = OMX_GetHandle(
       
   669 	    &graphicsSinkHandle,
       
   670 	    graphicsSinkComponentName,
       
   671 	    appData,
       
   672 	    omxCallbacks);
       
   673 
       
   674 	if (OMX_ErrorNone != iError)
       
   675 		{
       
   676 		INFO_PRINTF2(_L("Error %08X loading graphics sink"), iError);
       
   677 		SetTestStepError(PrintOmxError(iError));
       
   678 		return SetTestStepResult(EFail);
       
   679 		}
       
   680 
       
   681 	iGraphicSinkCompHandle = (OMX_COMPONENTTYPE*) graphicsSinkHandle;
       
   682 	INFO_PRINTF2(_L("OMX.SYMBIAN.VIDEO.GRAPHICSINK: Handle: %X"), iGraphicSinkCompHandle);
       
   683 /*
       
   684 	OMX_HANDLETYPE cameraSourceHandle = NULL;
       
   685 	OMX_STRING cameraSourceComponentName = "OMX.SYMBIAN.VIDEO.CAMERASOURCE";
       
   686 
       
   687 	iError = OMX_GetHandle(
       
   688 	    &cameraSourceHandle,
       
   689 	    cameraSourceComponentName,
       
   690 	    appData,
       
   691 	    omxCallbacks);
       
   692 
       
   693 	if (OMX_ErrorNone != iError)
       
   694 		{
       
   695 		INFO_PRINTF2(_L("Error %08X loading camera source"), iError);
       
   696 		OMX_FreeHandle(iGraphicSinkCompHandle);
       
   697 		SetTestStepError(PrintOmxError(iError));
       
   698 		return SetTestStepResult(EFail);
       
   699 		}
       
   700 	iCameraSourceCompHandle = (OMX_COMPONENTTYPE*)cameraSourceHandle;
       
   701 	INFO_PRINTF2(_L("OMX.SYMBIAN.VIDEO.CAMERASOURCE: Handle: %X"), iCameraSourceCompHandle);
       
   702 	
       
   703  	OMX_HANDLETYPE fileSinkHandle = NULL;
       
   704 	OMX_STRING fileSinkComponentName = "OMX.SYMBIAN.OTHER.FILESINK";
       
   705 
       
   706 	iError = OMX_GetHandle(
       
   707 	    &fileSinkHandle,
       
   708 	    fileSinkComponentName,
       
   709 	    appData,
       
   710 	    omxCallbacks);
       
   711 
       
   712 	if (OMX_ErrorNone != iError)
       
   713 		{
       
   714 		INFO_PRINTF2(_L("Error %08X loading file sink"), iError);
       
   715 		OMX_FreeHandle(iGraphicSinkCompHandle);
       
   716 		OMX_FreeHandle(iCameraSourceCompHandle);
       
   717 		SetTestStepError(PrintOmxError(iError));
       
   718 		return SetTestStepResult(EFail);
       
   719 		}
       
   720 
       
   721 	iFileSinkCompHandle = (OMX_COMPONENTTYPE*)fileSinkHandle;
       
   722 	INFO_PRINTF2(_L("OMX.SYMBIAN.OTHER.FILESINK: Handle: %X"), iFileSinkCompHandle);
       
   723 
       
   724 
       
   725 	OMX_HANDLETYPE jpegEncoderHandle = NULL;
       
   726 	OMX_STRING jpegEncoderComponentName = "OMX.SYMBIAN.IMAGE.ENCODER.JPEG";
       
   727 
       
   728 	iError = OMX_GetHandle(&jpegEncoderHandle,
       
   729 							jpegEncoderComponentName,
       
   730 							appData,
       
   731 							omxCallbacks);
       
   732 
       
   733 	if (OMX_ErrorNone != iError)
       
   734 		{
       
   735 		INFO_PRINTF2(_L("Error %08X loading jpeg encoder"), iError);
       
   736 		OMX_FreeHandle(iGraphicSinkCompHandle);
       
   737 		OMX_FreeHandle(iCameraSourceCompHandle);
       
   738 		OMX_FreeHandle(iFileSinkCompHandle);
       
   739 		SetTestStepError(PrintOmxError(iError));
       
   740 		return SetTestStepResult(EFail);
       
   741 		}
       
   742 
       
   743 	iJpegEncoderCompHandle = (OMX_COMPONENTTYPE*) jpegEncoderHandle;
       
   744 	INFO_PRINTF2(_L("OMX.SYMBIAN.IMAGE.ENCODER.JPEG: Handle: %X"), iJpegEncoderCompHandle);
       
   745 	
       
   746 	
       
   747     OMX_HANDLETYPE imageWriterHandle = NULL;
       
   748     OMX_STRING imageWriterComponentName = "OMX.SYMBIAN.IMAGE.IMAGEWRITER";
       
   749 
       
   750     iError = OMX_GetHandle(&imageWriterHandle,
       
   751                             imageWriterComponentName,
       
   752                             appData,
       
   753                             omxCallbacks);
       
   754 
       
   755     if (OMX_ErrorNone != iError)
       
   756         {
       
   757         INFO_PRINTF2(_L("Error %08X loading image writer"), iError);
       
   758         OMX_FreeHandle(iGraphicSinkCompHandle);
       
   759         OMX_FreeHandle(iCameraSourceCompHandle);
       
   760         OMX_FreeHandle(iFileSinkCompHandle);
       
   761         OMX_FreeHandle(iJpegEncoderCompHandle);
       
   762         SetTestStepError(PrintOmxError(iError));
       
   763         return SetTestStepResult(EFail);
       
   764         }
       
   765 
       
   766     iImageWriterCompHandle = (OMX_COMPONENTTYPE*) imageWriterHandle;
       
   767     INFO_PRINTF2(_L("OMX.SYMBIAN.IMAGE.IMAGEWRITER: Handle: %X"), iImageWriterCompHandle);
       
   768 */
       
   769 	InitialiseTestSpecificOmxComponents();
       
   770 	
       
   771 	SetTestStepResult(EPass);
       
   772 	}
       
   773 
       
   774 void COmxGsTestBase::InitialiseTestSpecificOmxComponents()
       
   775     {
       
   776     // Disable clock port in Camera Source
       
   777 //    INFO_PRINTF1(_L("send port 3 to disable"));
       
   778 //    SendCommand(iCameraSourceCompHandle, OMX_CommandPortDisable, KCameraClockPortIndex, 0);
       
   779     
       
   780     // Disable port VC in Camera Source
       
   781 //    INFO_PRINTF1(_L("send port 1 to disable"));
       
   782 //    SendCommand(iCameraSourceCompHandle, OMX_CommandPortDisable, KCameraVCPortIndex, 0);
       
   783     }
       
   784 
       
   785 void COmxGsTestBase::CreateWindowL()
       
   786 	{
       
   787 	iSurfaceUpdateSession.Close();
       
   788 		iSurfaceManager.Close();iWindowHandle = 0;
       
   789 	// Connect to a WS Session.
       
   790     User::LeaveIfError(iWsSession.Connect());
       
   791 
       
   792     // Create a Window Group.
       
   793     iWindowGroup = RWindowGroup(iWsSession);
       
   794 	User::LeaveIfError(iWindowGroup.Construct(iWindowHandle++));
       
   795 
       
   796     // Create the Screen device for the WServ session.
       
   797     iWsSd = new (ELeave) CWsScreenDevice(iWsSession);
       
   798     User::LeaveIfError(iWsSd->Construct());
       
   799 
       
   800     //Done in different class
       
   801     iWindow = new (ELeave) RWindow(iWsSession);
       
   802     User::LeaveIfError(iWindow->Construct(iWindowGroup, iWindowHandle++));
       
   803 
       
   804     iWindow2 = new (ELeave) RWindow(iWsSession);
       
   805     User::LeaveIfError(iWindow2->Construct(iWindowGroup, iWindowHandle));
       
   806 
       
   807     //done in different class
       
   808 	iGc = new (ELeave) CWindowGc(iWsSd);
       
   809     User::LeaveIfError(iGc->Construct());
       
   810 
       
   811 	iGc2 = new (ELeave) CWindowGc(iWsSd);
       
   812     User::LeaveIfError(iGc2->Construct());
       
   813 
       
   814     // Reset the screen mode.
       
   815     if(iWsSd->CurrentScreenMode() != 0)
       
   816 	    {
       
   817 	    iWsSd->SetAppScreenMode(0);
       
   818 	    iWsSd->SetScreenMode(0);
       
   819 	    }
       
   820 
       
   821 	iWindow->Activate();
       
   822 	iGc->Activate(*iWindow);
       
   823 	iGc->Clear();
       
   824 	iWindow->SetVisible(ETrue);
       
   825 	iWsSession.Flush();
       
   826 	}
       
   827 
       
   828 void COmxGsTestBase::CloseTest()
       
   829 	{
       
   830 	delete iCallbackHandler;
       
   831 	iCallbackHandler = NULL;
       
   832 	if(iTestChunk.Handle())
       
   833 		{
       
   834 		iTestChunk.Close();
       
   835 		}
       
   836 
       
   837 	if (iGc)
       
   838 	    {
       
   839 	    delete iGc;
       
   840 	    iGc = NULL;
       
   841 	    }
       
   842 	if (iGc2)
       
   843 	    {
       
   844 	    delete iGc2;
       
   845 	    iGc2 = NULL;
       
   846 	    }
       
   847 	
       
   848 	if (iWsSd)
       
   849 	    {
       
   850 	    delete iWsSd;
       
   851 	    iWsSd = NULL;
       
   852 	    }
       
   853 	
       
   854 	iWsSession.Close();
       
   855 	
       
   856 	if (iWindow)
       
   857 	    {
       
   858 	    delete iWindow;
       
   859 	    iWindow = NULL;
       
   860 	    }
       
   861 	
       
   862 	if (iWindow2)
       
   863 	    {
       
   864 	    delete iWindow2;
       
   865 	    iWindow2 = NULL;
       
   866 	    }
       
   867 
       
   868 	if (iTestShutdown)
       
   869 	    {
       
   870 	    delete iTestShutdown;
       
   871 	    iTestShutdown = NULL;
       
   872 	    }
       
   873 	
       
   874 	if (iTestPause)
       
   875 	    {
       
   876 	    delete iTestPause;
       
   877 	    iTestPause = NULL;
       
   878 	    }
       
   879 	
       
   880 	if (iTestStateTransition)
       
   881 	    {
       
   882 	    delete iTestStateTransition;
       
   883 	    iTestStateTransition = NULL;	    
       
   884 	    }
       
   885 
       
   886 	iSurfaceUpdateSession.Close();
       
   887 	iSurfaceManager.Close();
       
   888 	// Make sure we are not running the Alloc tests, if we are
       
   889 	// then we have already cleaned up the OMX components and core.
       
   890 	if(TestStepName() != (_L("MMVIDEO-OMX-CS-004-HP")) && TestStepName() != (_L("MMVIDEO-OMX-GS-001-00-HP"))
       
   891 			&& TestStepName() != (_L("MMVIDEO-OMX-JP-001-00-HP")) && TestStepName() != (_L("MMVIDEO-OMX-FS-001-00-HP"))
       
   892 			&& TestStepName() != (_L("MMVIDEO-OMX-IW-001-00-HP")))
       
   893 		{
       
   894 		FreeHandles();
       
   895 		iError = OMX_Deinit();
       
   896 		}
       
   897 
       
   898 	REComSession::FinalClose();
       
   899 	}
       
   900 
       
   901 TInt COmxGsTestBase::InitialiseSurfaceManager()
       
   902 	{
       
   903 	TInt err = iSurfaceManager.Open();
       
   904 	if (err == KErrNone)
       
   905 		{
       
   906 		err = iSurfaceUpdateSession.Connect(3);
       
   907 		}
       
   908 
       
   909 	if (err == KErrNotFound)
       
   910 		{
       
   911 		INFO_PRINTF1(_L("Failed to find surfacemanger or surfaceupdatesession"));
       
   912 		INFO_PRINTF1(_L("Make sure 'SYMBIAN_GRAPHICS_USE_GCE ON' is specified in epoc.ini"));
       
   913 		}
       
   914 
       
   915 	return err;
       
   916 	}
       
   917 
       
   918 TInt COmxGsTestBase::CreateAndMapSurface(const RSurfaceManager::TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId)
       
   919 	{
       
   920 	TInt err = iSurfaceManager.CreateSurface(aReqs, aSurfaceId);
       
   921 	if (err)
       
   922 		{
       
   923 		ERR_PRINTF2(_L("RSurfaceManager::CreateSurface() failed with %d"), err);
       
   924 		return err;
       
   925 		}
       
   926 
       
   927 	err = iSurfaceManager.MapSurface(aSurfaceId, iTestChunk);
       
   928 	if (err)
       
   929 		{
       
   930 		ERR_PRINTF2(_L("RSurfaceManager::MapSurface() failed with %d"), err);
       
   931 		return err;
       
   932 		}
       
   933 
       
   934 	iSurfaceId = aSurfaceId;
       
   935 	return KErrNone;
       
   936 	}
       
   937 
       
   938 void COmxGsTestBase::SendCommand(
       
   939 			            OMX_HANDLETYPE aComponent,
       
   940 			            OMX_COMMANDTYPE aCmd,
       
   941 			            OMX_U32 aParam1,
       
   942 			            OMX_PTR aCmdData,
       
   943 			            OMX_ERRORTYPE aExpError)
       
   944 	{
       
   945 	iError = OMX_SendCommand(aComponent,aCmd,aParam1,aCmdData);
       
   946 
       
   947 	if (aExpError != iError)
       
   948 		{
       
   949 		ERR_PRINTF1(_L("SendCommandErr"));
       
   950 		SetTestStepError(PrintOmxError(iError));
       
   951 		return SetTestStepResult(EFail);
       
   952 		}
       
   953 	}
       
   954 
       
   955 void COmxGsTestBase::GetState(OMX_HANDLETYPE aComponent,OMX_STATETYPE* aState,OMX_STATETYPE aExpectedState)
       
   956 	{
       
   957 	iError = OMX_GetState(aComponent,aState);
       
   958 	if (OMX_ErrorNone != iError)
       
   959 		{
       
   960 		SetTestStepError(PrintOmxError(iError));
       
   961 		return SetTestStepResult(EFail);
       
   962 		}
       
   963 
       
   964 	// PrintOmxState(*aState);
       
   965 	if (aExpectedState != OMX_StateMax)
       
   966 		{
       
   967 		if (aExpectedState != *aState)
       
   968 			{
       
   969 			ERR_PRINTF1(_L("Did not return expected state"));
       
   970 			PrintOmxState(*aState);
       
   971 			SetTestStepError(KErrGeneral);
       
   972 			return SetTestStepResult(EFail);
       
   973 			}
       
   974 		}
       
   975 
       
   976 	}
       
   977 
       
   978 void COmxGsTestBase::SetParameter(
       
   979 						OMX_HANDLETYPE aComponent,
       
   980             			OMX_INDEXTYPE aIndex,
       
   981             			OMX_PTR aComponentParameterStructure,
       
   982             			OMX_ERRORTYPE aExpError)
       
   983 	{
       
   984 	iError = OMX_SetParameter(aComponent,
       
   985 										aIndex,
       
   986 										aComponentParameterStructure);
       
   987 	if (aExpError != iError)
       
   988 		{
       
   989 		INFO_PRINTF3(_L("SetParameter() returned %08X instead of %08X"), iError, aExpError);
       
   990 		SetTestStepError(PrintOmxError(iError));
       
   991 		return SetTestStepResult(EFail);
       
   992 		}
       
   993 	}
       
   994 
       
   995 void COmxGsTestBase::GetParameter(
       
   996 					OMX_HANDLETYPE aComponent,
       
   997             		OMX_INDEXTYPE aIndex,
       
   998             		OMX_PTR aComponentParameterStructure,
       
   999             		OMX_ERRORTYPE aExpError)
       
  1000 	{
       
  1001 	iError = OMX_GetParameter(aComponent,
       
  1002 										aIndex,
       
  1003 										aComponentParameterStructure);
       
  1004 	if (aExpError != iError)
       
  1005 		{
       
  1006 		ERR_PRINTF3(_L("COmxGsTestBase::GetParameter - expected: %08X got: %08X"), aExpError, iError);
       
  1007 		SetTestStepError(PrintOmxError(iError));
       
  1008 		return SetTestStepResult(EFail);
       
  1009 		}
       
  1010 	}
       
  1011 
       
  1012 void COmxGsTestBase::SetConfig(
       
  1013 						OMX_HANDLETYPE aComponent,
       
  1014             			OMX_INDEXTYPE aIndex,
       
  1015             			OMX_PTR aComponentParameterStructure,
       
  1016             			OMX_ERRORTYPE aExpError)
       
  1017 	{
       
  1018 	iError = OMX_SetConfig(aComponent,
       
  1019 										aIndex,
       
  1020 										aComponentParameterStructure);
       
  1021 	if (aExpError != iError)
       
  1022 		{
       
  1023 		INFO_PRINTF1(_L("COmxGsTestBase::SetConfig fail"));
       
  1024 		SetTestStepError(PrintOmxError(iError));
       
  1025 		return SetTestStepResult(EFail);
       
  1026 		}
       
  1027 	}
       
  1028 
       
  1029 void COmxGsTestBase::GetConfig(
       
  1030 					OMX_HANDLETYPE aComponent,
       
  1031             		OMX_INDEXTYPE aIndex,
       
  1032             		OMX_PTR aComponentParameterStructure,
       
  1033             		OMX_ERRORTYPE aExpError)
       
  1034 	{
       
  1035 	iError = OMX_GetConfig(aComponent,
       
  1036 										aIndex,
       
  1037 										aComponentParameterStructure);
       
  1038 	if (aExpError != iError)
       
  1039 		{
       
  1040 		INFO_PRINTF1(_L("COmxGsTestBase::GetConfig fail"));
       
  1041 		SetTestStepError(PrintOmxError(iError));
       
  1042 		return SetTestStepResult(EFail);
       
  1043 		}
       
  1044 	}
       
  1045 
       
  1046 void COmxGsTestBase::FreeBuffer(
       
  1047 		OMX_HANDLETYPE aComponent,
       
  1048         OMX_U32 aPortIndex,
       
  1049         RPointerArray<OMX_BUFFERHEADERTYPE> aArrayBufferHeaderType,
       
  1050         OMX_ERRORTYPE aExpError)
       
  1051 	{
       
  1052 	TInt bufferCount = aArrayBufferHeaderType.Count();
       
  1053 
       
  1054 	for (TInt i =0; i < bufferCount ; ++i)
       
  1055 		{
       
  1056 		iError = OMX_FreeBuffer(aComponent,aPortIndex,aArrayBufferHeaderType[i]);
       
  1057 		if (aExpError != iError)
       
  1058 			{
       
  1059 			SetTestStepError(PrintOmxError(iError));
       
  1060 			return SetTestStepResult(EFail);
       
  1061 			}
       
  1062 		}
       
  1063 	}
       
  1064 
       
  1065 void COmxGsTestBase::AllocateBuffer(
       
  1066 		OMX_HANDLETYPE aComponent,
       
  1067 		OMX_BUFFERHEADERTYPE** aBufferHeaderType,
       
  1068         OMX_U32 aPortIndex,
       
  1069         OMX_PTR aAppPrivate,
       
  1070         OMX_U32 aSizeBytes,
       
  1071         RPointerArray<OMX_BUFFERHEADERTYPE>* aArrayBufferHeaderType,
       
  1072         OMX_U32 aCount,
       
  1073         OMX_ERRORTYPE aExpError)
       
  1074 	{
       
  1075 	for(TInt i = 0 ; i < aCount; i++ )
       
  1076 		{
       
  1077 		iError = OMX_AllocateBuffer(aComponent,*&aBufferHeaderType,aPortIndex,aAppPrivate,aSizeBytes);
       
  1078 		if (aExpError != iError)
       
  1079 			{
       
  1080 			SetTestStepError(PrintOmxError(iError));
       
  1081 			return SetTestStepResult(EFail);
       
  1082 			}
       
  1083 
       
  1084 		// Used for tracking
       
  1085 		TInt err = aArrayBufferHeaderType->Append(*aBufferHeaderType);
       
  1086 		if (err != KErrNone)
       
  1087 			{
       
  1088 			INFO_PRINTF2(_L("Append Buffer Failed %d"), err);
       
  1089 			SetTestStepError(err);
       
  1090 			return SetTestStepResult(EFail);
       
  1091 			}
       
  1092 		}
       
  1093 	}
       
  1094 
       
  1095 void COmxGsTestBase::FreeHandles()
       
  1096 	{
       
  1097 	// Don't call this function after OMX_DeInit call
       
  1098 	if (iGraphicSinkCompHandle)
       
  1099 		{
       
  1100 		INFO_PRINTF1(_L("FreeHandle for GFX ++"));
       
  1101 		OMX_FreeHandle(iGraphicSinkCompHandle);
       
  1102 		iGraphicSinkCompHandle = NULL;
       
  1103 		}
       
  1104 /*
       
  1105 	if(iCameraSourceCompHandle)
       
  1106 		{
       
  1107 		INFO_PRINTF1(_L("FreeHandle for CAM ++"));
       
  1108 		OMX_FreeHandle(iCameraSourceCompHandle);
       
  1109 		iCameraSourceCompHandle = NULL;
       
  1110 		}
       
  1111 
       
  1112 	if (iFileSinkCompHandle)
       
  1113 		{
       
  1114 		INFO_PRINTF1(_L("FreeHandle for FSK ++"));
       
  1115 		OMX_FreeHandle(iFileSinkCompHandle);
       
  1116 		iFileSinkCompHandle = NULL;
       
  1117 		}
       
  1118 
       
  1119 	if(iJpegEncoderCompHandle)
       
  1120 		{
       
  1121 		INFO_PRINTF1(_L("FreeHandle for JPEG Encoder ++"));
       
  1122 		OMX_FreeHandle(iJpegEncoderCompHandle);
       
  1123 		iJpegEncoderCompHandle = NULL;
       
  1124 		}
       
  1125 	
       
  1126     if(iImageWriterCompHandle)
       
  1127         {
       
  1128         INFO_PRINTF1(_L("FreeHandle for Image Writer ++"));
       
  1129         OMX_FreeHandle(iImageWriterCompHandle);
       
  1130         iImageWriterCompHandle = NULL;
       
  1131         }
       
  1132 	
       
  1133 	if(iXvidEncoderCompHandle)
       
  1134         {
       
  1135         INFO_PRINTF1(_L("FreeHandle for Xvid Encoder ++"));
       
  1136         OMX_FreeHandle(iXvidEncoderCompHandle);
       
  1137         iXvidEncoderCompHandle = NULL;
       
  1138         }
       
  1139     
       
  1140     if(i3gpMuxerCompHandle)
       
  1141         {
       
  1142         INFO_PRINTF1(_L("FreeHandle for 3gp Muxer ++"));
       
  1143         OMX_FreeHandle(i3gpMuxerCompHandle);
       
  1144         i3gpMuxerCompHandle = NULL;
       
  1145         }
       
  1146     
       
  1147     if(iClockCompHandle)
       
  1148         {
       
  1149         INFO_PRINTF1(_L("FreeHandle for Clock ++"));
       
  1150         OMX_FreeHandle(iClockCompHandle);
       
  1151         iClockCompHandle = NULL;
       
  1152         }
       
  1153 */
       
  1154 	}
       
  1155 
       
  1156 
       
  1157 
       
  1158 TInt COmxGsTestBase::StateTransition(const TDesC& /*aStateTransitionName*/)
       
  1159 	{
       
  1160 	return KErrNone;
       
  1161 	}
       
  1162 
       
  1163 void COmxGsTestBase::StartTimer()
       
  1164 	{
       
  1165 	TRAPD(err, iTestShutdown = COmxGsTestShutdown::NewL(this,1));
       
  1166 	if(err)
       
  1167 		{
       
  1168 		ERR_PRINTF1(_L("OOM ERROR"));
       
  1169 		return SetTestStepError(err);
       
  1170 		}
       
  1171 	iInterval = KTSU_OMX_GS_Interval;
       
  1172 	iTestShutdown->Start(iInterval,KErrNone, EPass);
       
  1173 	CActiveScheduler::Start();
       
  1174 	}
       
  1175 
       
  1176 void COmxGsTestBase::WaitForCallbacks()
       
  1177 	{
       
  1178 	TRAPD(error, iTestShutdown = COmxGsTestShutdown::NewL(this,2));
       
  1179 	if(error)
       
  1180 		{
       
  1181 		ERR_PRINTF1(_L("OOM ERROR"));
       
  1182 		return SetTestStepError(error);
       
  1183 		}
       
  1184 
       
  1185 	iInterval = KTSU_OMX_GS_CALLBACK;
       
  1186 	iTestShutdown->Start(iInterval,KErrGeneral, EPass);
       
  1187 	CActiveScheduler::Start();
       
  1188 	}
       
  1189 
       
  1190 void COmxGsTestBase::PauseTimer()
       
  1191 	{
       
  1192 	TRAPD(error, iTestPause = COmxGsTestShutdown::NewL(this,3));
       
  1193 	if(error)
       
  1194 		{
       
  1195 		ERR_PRINTF1(_L("OOM ERROR"));
       
  1196 		return SetTestStepError(error);
       
  1197 		}
       
  1198 
       
  1199 	iInterval = KTSU_OMX_GS_Pause_Interval/2;
       
  1200 	iTestPause->Start(iInterval,KErrGeneral, EPass);
       
  1201 	}
       
  1202 
       
  1203 // ShutDown Class
       
  1204 COmxGsTestShutdown* COmxGsTestShutdown::NewL(COmxGsTestBase* aOmxGsTest,TInt aTimerId)
       
  1205 	{
       
  1206 	COmxGsTestShutdown* self = new(ELeave) COmxGsTestShutdown(aOmxGsTest,aTimerId);
       
  1207 	CleanupStack::PushL(self);
       
  1208 	self->ConstructL();
       
  1209 	CleanupStack::Pop();
       
  1210 	return self;
       
  1211 	}
       
  1212 
       
  1213 COmxGsTestShutdown::COmxGsTestShutdown(COmxGsTestBase* aOmxGsTest,TInt aTimerId)
       
  1214 : CTimer(EPriorityUserInput), iOmxGsTest(aOmxGsTest), iTimerId(aTimerId)
       
  1215 	{
       
  1216 	CActiveScheduler::Add(this);
       
  1217 	}
       
  1218 
       
  1219 COmxGsTestShutdown::~COmxGsTestShutdown()
       
  1220 	{
       
  1221 	Cancel();
       
  1222 	}
       
  1223 
       
  1224 void COmxGsTestShutdown::ConstructL()
       
  1225 	{
       
  1226 	CTimer::ConstructL();
       
  1227 	}
       
  1228 
       
  1229 void COmxGsTestShutdown::Start(TTimeIntervalMicroSeconds32 aInterval, TInt aReason, TVerdict aResult)
       
  1230 	{
       
  1231 	iReason = aReason;
       
  1232 	iResult = aResult;
       
  1233 	After(aInterval);
       
  1234 	}
       
  1235 
       
  1236 void COmxGsTestShutdown::RunL()
       
  1237 	{
       
  1238 	iOmxGsTest->PostKickOffTestL(iTimerId);
       
  1239 	}
       
  1240 
       
  1241 COmxGsTestStateTransition* COmxGsTestStateTransition::NewL(COmxGsTestBase* aOmxGsTest,TInt aPriority)
       
  1242 	{
       
  1243 	COmxGsTestStateTransition* self = new(ELeave) COmxGsTestStateTransition(aOmxGsTest,aPriority);
       
  1244 	CleanupStack::PushL(self);
       
  1245 	self->ConstructL();
       
  1246 	CleanupStack::Pop();
       
  1247 	return self;
       
  1248 
       
  1249 	}
       
  1250 
       
  1251 COmxGsTestStateTransition::COmxGsTestStateTransition(COmxGsTestBase* aOmxGsTest,TInt aPriority)
       
  1252 : CTimer(aPriority), iOmxGsTest(aOmxGsTest)
       
  1253 	{
       
  1254 	CActiveScheduler::Add(this);
       
  1255 	}
       
  1256 
       
  1257 COmxGsTestStateTransition::~COmxGsTestStateTransition()
       
  1258 	{
       
  1259 	Cancel();
       
  1260 	}
       
  1261 
       
  1262 void COmxGsTestStateTransition::ConstructL()
       
  1263 	{
       
  1264 	CTimer::ConstructL();
       
  1265 	}
       
  1266 
       
  1267 void COmxGsTestStateTransition::Start(TTimeIntervalMicroSeconds32 aInterval,const TDesC& aStateTransitionName)
       
  1268 	{
       
  1269 	iStateTransitionName = aStateTransitionName;
       
  1270 	After(aInterval);
       
  1271 	}
       
  1272 
       
  1273 void COmxGsTestStateTransition::RunL()
       
  1274 	{
       
  1275 	iOmxGsTest->StateTransition(iStateTransitionName);
       
  1276 	}