omxilvideocomps/omxilgraphicsink/tsrc/src/omxilgraphicsinktestbase.h
changeset 0 5d29cba61097
equal deleted inserted replaced
-1:000000000000 0:5d29cba61097
       
     1 /*
       
     2 * Copyright (c) 2008-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 #ifndef OMXILGRAPHICSINKTESTBASE_H
       
    25 #define OMXILGRAPHICSINKTESTBASE_H
       
    26 
       
    27 #include <test/testexecutestepbase.h>
       
    28 #include <e32msgqueue.h>
       
    29 #include <openmax/il/khronos/v1_x/OMX_Core.h>
       
    30 #include <graphics/surfacemanager.h>
       
    31 #include <graphics/surfaceupdateclient.h>
       
    32 #include <w32std.h>
       
    33 
       
    34 #include "omxilmmbuffer.h"
       
    35 
       
    36 const TInt KTSU_OMX_GS_Interval = 0x0500000;
       
    37 const TInt KTSU_OMX_GS_Pause_Interval = 0x0100000;
       
    38 const TInt KTSU_OMX_GS_Pause_Wait = 2000000;
       
    39 const TInt KTSU_OMX_GS_Pause_Video = 0x0050000;
       
    40 const TInt KTSU_OMX_GS_State_Transition_Interval = 2000000; // 2 Seconds
       
    41 const TInt KTSU_OMX_GS_CALLBACK = 1000000 ;// 2 second timer for test shutdown
       
    42 
       
    43 const TInt KMaxLenStateTransitionName = 126;
       
    44 
       
    45 const TInt KCameraVFPortIndex = 0;
       
    46 const TInt KCameraVCPortIndex = 1;
       
    47 const TInt KCameraICPortIndex = 2;
       
    48 const TInt KCameraClockPortIndex = 3;
       
    49 
       
    50 _LIT(KMMTestCase, "RTestCase");
       
    51 _LIT(KMMTestStep, "RTestStep");
       
    52 
       
    53 // Forward declarations
       
    54 struct OMX_COMPONENTTYPE;
       
    55 class COmxGsTestStateTransition;
       
    56 class COmxGsTestBase;
       
    57 class COmxGsTestShutdown;
       
    58 
       
    59 
       
    60 /**
       
    61  * OpenMAX call back handler used in the test code.
       
    62  */
       
    63 class CCallbackHandler : public CActive
       
    64 	{
       
    65 public:
       
    66 
       
    67 	enum TMessageType
       
    68 		{
       
    69 		EFillBufferCallback,
       
    70 		EEmptyBufferCallback,
       
    71 		EEventCallback
       
    72 		};
       
    73 
       
    74 	class TEventParams
       
    75 		{
       
    76 	public:
       
    77 		OMX_EVENTTYPE iEvent;
       
    78 		TUint iData1;
       
    79 		TUint iData2;
       
    80 		TAny* iExtra;
       
    81 		};
       
    82 
       
    83 	class TOmxMessage
       
    84 		{
       
    85 	public:
       
    86 		TMessageType iType;   
       
    87 		OMX_HANDLETYPE iComponent;
       
    88 		union
       
    89 			{
       
    90 			TAny* iBuffer;
       
    91 			TEventParams iEventParams;
       
    92 			};
       
    93 		};
       
    94 
       
    95 
       
    96 	static const TInt KMaxMsgQueueEntries = 10;
       
    97 
       
    98 public:
       
    99 
       
   100 	static CCallbackHandler* NewL(COmxGsTestBase& aCameraSourceTest);
       
   101 	virtual ~CCallbackHandler();
       
   102 
       
   103 	operator OMX_CALLBACKTYPE*();
       
   104 
       
   105 	void RunL();
       
   106 	void DoCancel();
       
   107 
       
   108 	static OMX_ERRORTYPE FillBufferDone(OMX_HANDLETYPE aComponent,
       
   109 										TAny* aAppData,
       
   110 										OMX_BUFFERHEADERTYPE* aBuffer);
       
   111 
       
   112  	static OMX_ERRORTYPE EmptyBufferDone(OMX_HANDLETYPE aComponent,
       
   113 										 TAny* aAppData,
       
   114 										 OMX_BUFFERHEADERTYPE* aBuffer);
       
   115 
       
   116 	static OMX_ERRORTYPE EventHandler(OMX_HANDLETYPE aComponent,
       
   117 									  TAny* aAppData,
       
   118 									  OMX_EVENTTYPE aEvent,
       
   119 									  TUint32 aData1,
       
   120 									  TUint32 aData2,
       
   121 									  TAny* aExtra);
       
   122 
       
   123 
       
   124 private:
       
   125 
       
   126 	OMX_ERRORTYPE DoEventHandler(OMX_HANDLETYPE aComponent,
       
   127 								 TEventParams aParams);
       
   128 
       
   129 	OMX_ERRORTYPE DoFillBufferDone(OMX_HANDLETYPE aComponent,
       
   130 								  OMX_BUFFERHEADERTYPE* aBufferHeader);
       
   131 								  
       
   132 	OMX_ERRORTYPE DoEmptyBufferDone(OMX_HANDLETYPE aComponent,
       
   133 								   OMX_BUFFERHEADERTYPE* aBufferHeader);								 
       
   134 
       
   135 
       
   136 	void ConstructL();
       
   137 	CCallbackHandler(COmxGsTestBase& aCameraSourceTest);
       
   138 
       
   139 private:
       
   140 
       
   141 	COmxGsTestBase& iCameraSourceTest;
       
   142 	RMsgQueue<TOmxMessage> iMsgQueue;
       
   143 	OMX_CALLBACKTYPE iHandle;
       
   144 
       
   145 	};
       
   146 
       
   147 
       
   148 
       
   149 class COmxGsTestBase : public CTestStep
       
   150 	{
       
   151 	friend class COmxGsTestShutdown;
       
   152 	friend class COmxGsTestStateTransition;
       
   153 public:
       
   154 
       
   155 	COmxGsTestBase();
       
   156 
       
   157 	~COmxGsTestBase();
       
   158 	TVerdict doTestStepPreambleL(); 
       
   159 	TVerdict doTestStepPostambleL();
       
   160 	virtual TVerdict doTestStepL() = 0;
       
   161 	virtual void CloseTestStep() = 0;
       
   162 	void CloseTest();
       
   163 	
       
   164 	void InfoPrint1(const TDesC& aPrint);
       
   165 
       
   166 	virtual void DoFillBufferDone(OMX_HANDLETYPE aComponent,
       
   167 								  OMX_BUFFERHEADERTYPE* aBufferHeader) = 0;
       
   168 
       
   169 	virtual void DoEmptyBufferDone(OMX_HANDLETYPE aComponent,
       
   170 								   OMX_BUFFERHEADERTYPE* aBufferHeader) = 0;
       
   171    
       
   172 	virtual void DoEventHandler(OMX_HANDLETYPE aComponent,
       
   173 								OMX_EVENTTYPE aEvent,
       
   174 								TUint aData1,	
       
   175 								TUint aData2,
       
   176 								TAny* aExtra) = 0;
       
   177 
       
   178 
       
   179 	static OMX_ERRORTYPE ConvertSymbianErrorType(TInt aError);
       
   180 
       
   181 protected:
       
   182 	void PrintOmxState(OMX_STATETYPE aOmxState);
       
   183 	TInt PrintOmxError(OMX_ERRORTYPE aOmxError);
       
   184 
       
   185 	virtual void InitialiseOmxComponents();
       
   186 	virtual void InitialiseTestSpecificOmxComponents();
       
   187 	void CreateWindowL();
       
   188 	void SendCommand(
       
   189 					OMX_HANDLETYPE aComponent,
       
   190 					OMX_COMMANDTYPE aCmd,
       
   191 					OMX_U32 aParam1,
       
   192 					OMX_PTR aCmdData,
       
   193 					OMX_ERRORTYPE aExpError = OMX_ErrorNone);
       
   194 					
       
   195 	void GetState(OMX_HANDLETYPE aComponent,
       
   196 				  OMX_STATETYPE* aState,
       
   197 				  OMX_STATETYPE aExpectedState = OMX_StateMax);
       
   198 	
       
   199 	void SetParameter(
       
   200 					OMX_HANDLETYPE aComponent, 
       
   201             		OMX_INDEXTYPE aIndex,
       
   202             		OMX_PTR aComponentParameterStructure,
       
   203             		OMX_ERRORTYPE aExpError = OMX_ErrorNone);
       
   204 
       
   205 	void GetParameter(
       
   206 					OMX_HANDLETYPE aComponent, 
       
   207             		OMX_INDEXTYPE aIndex,
       
   208             		OMX_PTR aComponentParameterStructure,
       
   209             		OMX_ERRORTYPE aExpError = OMX_ErrorNone);
       
   210             		
       
   211     void SetConfig(
       
   212 					OMX_HANDLETYPE aComponent, 
       
   213             		OMX_INDEXTYPE aIndex,
       
   214             		OMX_PTR aComponentParameterStructure,
       
   215             		OMX_ERRORTYPE aExpError = OMX_ErrorNone);
       
   216 
       
   217 	void GetConfig(
       
   218 					OMX_HANDLETYPE aComponent, 
       
   219             		OMX_INDEXTYPE aIndex,
       
   220             		OMX_PTR aComponentParameterStructure,
       
   221             		OMX_ERRORTYPE aExpError = OMX_ErrorNone);        		
       
   222    
       
   223     void FreeBuffer(
       
   224     		OMX_HANDLETYPE aComponent,
       
   225             OMX_U32 aPortIndex,
       
   226             RPointerArray<OMX_BUFFERHEADERTYPE> aArrayBufferHeaderType,
       
   227             OMX_ERRORTYPE aExpError = OMX_ErrorNone);
       
   228 	
       
   229     void AllocateBuffer(
       
   230     		OMX_HANDLETYPE aComponent,
       
   231     		OMX_BUFFERHEADERTYPE** aBufferHeaderType,
       
   232             OMX_U32 aPortIndex,
       
   233             OMX_PTR aAppPrivate,
       
   234             OMX_U32 aSizeBytes,
       
   235             RPointerArray<OMX_BUFFERHEADERTYPE>* aArrayBufferHeaderType,
       
   236             OMX_U32 aCount,
       
   237             OMX_ERRORTYPE aExpError = OMX_ErrorNone);
       
   238     
       
   239     void FreeHandles();
       
   240     virtual TInt PostKickOffTestL(TInt aTimerId) = 0;
       
   241 	virtual TInt StateTransition(const TDesC& aStateTransitionName);
       
   242 	TInt InitialiseSurfaceManager();
       
   243 	TInt CreateAndMapSurface(const RSurfaceManager::TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId);
       
   244 	void StartTimer();
       
   245 	void WaitForCallbacks();
       
   246 	void PauseTimer();
       
   247 	
       
   248 protected:
       
   249 
       
   250 	CCallbackHandler* iCallbackHandler;
       
   251 //	OMX_COMPONENTTYPE* iCameraSourceCompHandle;
       
   252 //	OMX_COMPONENTTYPE* iCameraSourceCompHandlePort1;
       
   253 	OMX_COMPONENTTYPE* iGraphicSinkCompHandle;
       
   254 	OMX_COMPONENTTYPE* iGraphicSinkCompHandlePort1;
       
   255 	OMX_COMPONENTTYPE* iBufferSupplierComponent;
       
   256 	OMX_COMPONENTTYPE* iNonBufferSupplierComponent;
       
   257 //	OMX_COMPONENTTYPE* iFileSinkCompHandle;
       
   258 //	OMX_COMPONENTTYPE* iJpegEncoderCompHandle;
       
   259 //	OMX_COMPONENTTYPE* iXvidEncoderCompHandle;
       
   260 //	OMX_COMPONENTTYPE* i3gpMuxerCompHandle;
       
   261 //	OMX_COMPONENTTYPE* iClockCompHandle;
       
   262 //	OMX_COMPONENTTYPE* iImageWriterCompHandle;
       
   263 	OMX_ERRORTYPE iError;
       
   264 	OMX_STATETYPE iState;
       
   265 	OMX_INDEXTYPE iSurfaceConfigExt;
       
   266 	
       
   267 	COmxGsTestShutdown* iTestShutdown;
       
   268 	COmxGsTestShutdown* iTestPause;
       
   269 	COmxGsTestStateTransition* iTestStateTransition;
       
   270 	TTimeIntervalMicroSeconds32 iInterval;	
       
   271 	
       
   272 	volatile OMX_STATETYPE iCamPrevState;
       
   273 	volatile OMX_STATETYPE iGphxPrevState;	
       
   274 	volatile OMX_STATETYPE iBufferSupplierPrevState;
       
   275 	volatile OMX_STATETYPE iNonBufferSupplierPrevState;	
       
   276 	volatile OMX_STATETYPE iGphxPort1PrevState;
       
   277 	volatile OMX_STATETYPE iFilePrevState;
       
   278 	volatile OMX_STATETYPE iJpegEncoderPrevState;
       
   279 	volatile OMX_STATETYPE iXvidEncoderPrevState;
       
   280 	volatile OMX_STATETYPE i3gpMuxerPrevState;
       
   281 	volatile OMX_STATETYPE iClockPrevState;
       
   282 	volatile OMX_STATETYPE iImageWriterPrevState;
       
   283 	
       
   284 	RWsSession              iWsSession;
       
   285 	RWindowGroup            iWindowGroup;  // Window group of the AO windows. 
       
   286 	TInt                    iWindowHandle; // Window handle(s) for the AO windows. This handle
       
   287 	    	                                      //  is incremental and reused by various WServ artifacts. 
       
   288 	CWsScreenDevice         *iWsSd;        // Screen Device for this WServ session. 
       
   289 	CWindowGc               *iGc;     // Graphics Context associated with the window. 
       
   290 	RWindow					*iWindow;
       
   291 	CWindowGc               *iGc2;
       
   292 	RWindow					*iWindow2;
       
   293 	
       
   294     RSurfaceManager         iSurfaceManager;
       
   295     RSurfaceUpdateSession   iSurfaceUpdateSession;
       
   296 	RChunk iTestChunk;
       
   297 	TSurfaceId iSurfaceId;
       
   298 	CActiveScheduler* iScheduler;
       
   299 	};
       
   300 
       
   301 
       
   302 /**
       
   303  * Shutdown timer for tests.
       
   304  */
       
   305 class COmxGsTestShutdown : public CTimer
       
   306 	{
       
   307 public:
       
   308 	
       
   309 	static COmxGsTestShutdown* NewL(COmxGsTestBase* aOmxGsTest,TInt aTimerId = 1);
       
   310 	
       
   311 	COmxGsTestShutdown(COmxGsTestBase* aOmxGsTest,TInt aTimerId = 1);
       
   312 	~COmxGsTestShutdown();
       
   313 	void ConstructL();
       
   314 	void Start(TTimeIntervalMicroSeconds32 aInterval, TInt aReason, TVerdict aResult);
       
   315 
       
   316 private:
       
   317 
       
   318 	void RunL();
       
   319 	
       
   320 private:
       
   321 
       
   322 	COmxGsTestBase* iOmxGsTest;
       
   323 	TTimeIntervalMicroSeconds32 iInterval;
       
   324 	TInt iReason;
       
   325 	TVerdict iResult;
       
   326 	TInt iTimerId;
       
   327 	
       
   328 	};
       
   329 
       
   330 
       
   331 class COmxGsTestStateTransition : public CTimer
       
   332 	{
       
   333 	
       
   334 public:
       
   335 	
       
   336 	static COmxGsTestStateTransition* NewL(COmxGsTestBase* aOmxGsTest,TInt aPriority);
       
   337 	
       
   338 	COmxGsTestStateTransition(COmxGsTestBase* aOmxGsTest,TInt aPriority);
       
   339 	~COmxGsTestStateTransition();
       
   340 	void ConstructL();
       
   341 	void Start(TTimeIntervalMicroSeconds32 aInterval,const TDesC& aStateTransitionName);
       
   342 
       
   343 protected:	
       
   344 	TBuf<KMaxLenStateTransitionName> iStateTransitionName;
       
   345 
       
   346 private:
       
   347 
       
   348 	void RunL();
       
   349 	
       
   350 private:
       
   351 
       
   352 	COmxGsTestBase* iOmxGsTest;
       
   353 	TTimeIntervalMicroSeconds32 iInterval;
       
   354 	};
       
   355 
       
   356 
       
   357 
       
   358 #endif // OMXILGRAPHICSINKTESTBASE_H