|
1 /* |
|
2 * Copyright (c) 2008-2009 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 #ifndef OMXSCRIPTTEST_H_ |
|
20 #define OMXSCRIPTTEST_H_ |
|
21 |
|
22 #include "omxscriptparser.h" |
|
23 #include "asbreakeventhandler.h" |
|
24 #include "videotesttimer.h" |
|
25 #include <e32msgqueue.h> |
|
26 #include "omxthreadrequest.h" |
|
27 #include "omx_xml_script.h" |
|
28 //#include <multimedia/mmfbuffershared.h> |
|
29 #include <openmax/il/khronos/v1_x/OMX_IVCommon.h> |
|
30 #include <openmax/il/khronos/v1_x/OMX_Types.h> |
|
31 #include "portbufferhandler.h" |
|
32 |
|
33 class CNonTunneledHandler; |
|
34 class CVideoBufferHandler; |
|
35 class CVideoBufferSinkHandler; |
|
36 class CBaseProfileHandler; |
|
37 class CWindowManager; |
|
38 |
|
39 const OMX_VERSIONTYPE KOmxVersion = { OMX_VERSION_MAJOR, OMX_VERSION_MINOR, OMX_VERSION_REVISION, OMX_VERSION_STEP }; |
|
40 |
|
41 /** |
|
42 * Class to parse and execute an OMX test case specified in |
|
43 * an XML file. |
|
44 */ |
|
45 NONSHARABLE_CLASS(ROmxScriptTest) : public MOmxScriptIf, public MASBreakCallback, public MTimerObserver |
|
46 { |
|
47 public: |
|
48 |
|
49 NONSHARABLE_CLASS(CComponentInfo) : public CBase |
|
50 { |
|
51 public: |
|
52 static CComponentInfo* NewL(ROmxScriptTest& aTestController); |
|
53 ~CComponentInfo(); |
|
54 |
|
55 private: |
|
56 CComponentInfo(ROmxScriptTest& aTestController); |
|
57 void ConstructL(); |
|
58 |
|
59 public: |
|
60 HBufC8* iShortName; |
|
61 HBufC8* iComponentName; |
|
62 OMX_COMPONENTTYPE* iComponent; |
|
63 CBaseProfileHandler* iBaseHandler; //NULL if not being used via OMX IL Base Profile |
|
64 COmxThreadRequest* iThreadRequest; |
|
65 |
|
66 private: |
|
67 ROmxScriptTest& iTestController; |
|
68 }; |
|
69 |
|
70 class TExpectedEvent |
|
71 { |
|
72 public: |
|
73 OMX_COMPONENTTYPE* iComponent; |
|
74 OMX_EVENTTYPE iEvent; |
|
75 TUint32 iData1; |
|
76 TUint32 iData2; |
|
77 TAny* iEventData; |
|
78 }; |
|
79 typedef void (*THashFilter)(RBuf8&); |
|
80 THashFilter GetHashFilterByName(const TDesC8& aName); |
|
81 |
|
82 ROmxScriptTest(MOmxScriptTestLogger& aLogger); |
|
83 void Close(); |
|
84 |
|
85 void RunTestL(const TDesC& aScriptFilename, const TDesC& aScriptSection); |
|
86 |
|
87 // MOmxScriptIf |
|
88 TBool MosLoadComponentL(const TDesC8& aComp, const TDesC8& aName, TBool aBaseProfile, const TDesC8* aBaseImpl, TBool aLoadInCoreServerThread); |
|
89 TBool MosSetupTunnel(const TDesC8& aSourceComp, TInt aSourcePort, |
|
90 const TDesC8& aSinkComp, TInt aSinkPort, OMX_ERRORTYPE aExpectedError); |
|
91 TBool MosSetupNonTunnel(const TDesC8& aSourceComp, TInt aSourcePort, |
|
92 const TDesC8& aSinkComp, TInt aSinkPort, |
|
93 OMX_BUFFERSUPPLIERTYPE aSupplier); |
|
94 |
|
95 TBool MosAllTransitionL(OMX_STATETYPE aState,OMX_ERRORTYPE aExpectedError, TTransitionOrder aOrder); |
|
96 TBool MosWaitEOS(); |
|
97 TBool MosWaitEOS(const TDesC8& aComp); |
|
98 TBool MosSetFilename(const TDesC8& aComp, const TDesC& aFilename); |
|
99 TBool MosSetBadFilename(const TDesC8& aComp); |
|
100 TBool MosGetFilename(const TDesC8& aComp, TDesC& aFilename); |
|
101 |
|
102 TBool MosSetBufferCount(const TDesC8& aComp, TInt aPortIndex, TInt aCount, OMX_ERRORTYPE aExpectedError); |
|
103 |
|
104 TBool MosBufferSupplierOverrideL(const TDesC8& aSourceComp, TInt aSourcePort, |
|
105 const TDesC8& aSinkComp, TInt aSinkPort, |
|
106 OMX_BUFFERSUPPLIERTYPE aSupplier, |
|
107 OMX_ERRORTYPE aExpectedSourceError, OMX_ERRORTYPE aExpectedSinkError); |
|
108 TBool MosSetVideoPortDefL(const TDesC8& aComp, TInt aPortIndex, TInt aWidth, TInt aHeight, OMX_COLOR_FORMATTYPE* aColorFormat, OMX_VIDEO_CODINGTYPE* aCodingType, TInt aStride, TReal aFps, OMX_ERRORTYPE aExpectedError); |
|
109 |
|
110 void MosParseError(const TDesC& aError); |
|
111 TBool MosWaitL(TTimeIntervalMicroSeconds32 aDelay); |
|
112 TBool MosExpectEventL(const TDesC8& aComp, OMX_EVENTTYPE aEvent, TUint32 nData1, TUint32 nData2); |
|
113 TBool MosWaitForAllEventsL(); |
|
114 TBool MosTransition(const TDesC8& aComp, OMX_STATETYPE aState, TBool aAsync); |
|
115 TBool MosFailingTransition(const TDesC8& aComp, OMX_STATETYPE aState,OMX_ERRORTYPE aExpectedError); |
|
116 TBool MosCheckStateL(const TDesC8& aComp, OMX_STATETYPE aState); |
|
117 TBool MosCheckVideoPortDefL(const TDesC8& aComp, TInt aPortIndex, TInt aWidth, TInt aHeight, OMX_VIDEO_CODINGTYPE aCoding, OMX_COLOR_FORMATTYPE aColorFormat); |
|
118 TBool MosCheckMetaDataL(const TDesC8& aComp, TInt aPortIndex, OMX_METADATASCOPETYPE aScope, const TDesC8& aAtomType, TUint32 aAtomIndex, const TDesC8& aData); |
|
119 TBool MosGetParameterUnknownIndexTypeL(const TDesC8& aComp, TInt aPortIndex, OMX_METADATASCOPETYPE aScope, const TDesC8& aAtomType, TUint32 aAtomIndex, const TDesC8& aData); |
|
120 TBool MosSetParameterUnknownIndexTypeL(const TDesC8& aComp, TInt aPortIndex, OMX_METADATASCOPETYPE aScope, const TDesC8& aAtomType, TUint32 aAtomIndex, const TDesC8& aData); |
|
121 |
|
122 TBool MosDisablePort(const TDesC8& aComp, TInt aPortIndex); |
|
123 TBool MosEnablePort(const TDesC8& aComp, TInt aPortIndex); |
|
124 TBool MosIgnoreEventL(const TDesC8& aComp, OMX_EVENTTYPE aEvent, TUint32 nData1, TUint32 nData2); |
|
125 TBool MosSetPcmAudioPortDefL(const TDesC8& aComp, TInt aPortIndex, TInt aNumChannels, TInt aSamplingRate, TInt aBitsperSample, OMX_NUMERICALDATATYPE aNumData, OMX_ENDIANTYPE aEndian, OMX_BOOL* aInterleaved, const TDesC8* aEncoding); |
|
126 TBool MosSetConfigAudioVolumeL(const TDesC8& aComp, TInt aPortIndex, TBool aLinear, TInt aMinVolume, TInt aMaxVolume, TInt aVolume, OMX_ERRORTYPE aExpectedError); |
|
127 TBool MosCheckConfigAudioVolumeL(const TDesC8& aComp, TInt aPortIndex, TBool aLinear, TInt aMinVolume, TInt aMaxVolume, TInt aVolume); |
|
128 TBool MosCheckConfigAudioMuteL(const TDesC8& aComp, TInt aPortIndex, TBool aMute); |
|
129 TBool MosSetConfigAudioMuteL(const TDesC8& aComp, TInt aPortIndex, TBool aMute); |
|
130 TBool MosSetAacAudioPortDefL(const TDesC8& aComp, TInt aPortIndex, TInt aNumChannels, TInt aSamplingRate, TInt aBitRate, TInt aAudioBandwidth, TInt aFrameLength, TInt aAacTools, TInt aAacErTools, TInt aProfile, TInt aStreamFormat, TInt aChannelMode); |
|
131 TBool MosSetAudioPortDefL(const TDesC8& aComp, TInt aPortIndex, OMX_AUDIO_CODINGTYPE* aCodingType); |
|
132 TBool MosSetRefClockTypeL(const TDesC8& aComp, OMX_TIME_REFCLOCKTYPE aRefClockType); |
|
133 TBool MosSetClockTimeScale(const TDesC8& aComp, OMX_S32 aScale); |
|
134 TBool MosSetClockStateL(const TDesC8& aComp, OMX_TIME_CLOCKSTATE aClockState, TInt aStartTime, TInt aOffset, TUint32 aWaitMask); |
|
135 TBool MosCheckClockStateL(const TDesC8& aComp, OMX_TIME_CLOCKSTATE aClockState); |
|
136 TBool MosCheckTimePositionL(const TDesC8& aComp, TInt aPortIndex, TInt aTimestamp); |
|
137 TBool MosSetTimePositionL(const TDesC8& aComp, TInt aPortIndex, TInt aTimestamp); |
|
138 TBool MosSetClientStartTimeL(const TDesC8& aComp, TInt aPortIndex, TInt aTimestamp); |
|
139 TBool MosSetCurrentAudioReferenceTimeL(const TDesC8& aComp, TInt aPortIndex, TInt aTimestamp); |
|
140 TBool MosSetVideoFitModeL(TVideoFitMode aVideoFitMode); |
|
141 TBool MosForceFlushBuffer(const TDesC8& aComp, TInt aPortIndex, OMX_ERRORTYPE aExpectedError); |
|
142 TBool MosSetActiveStream(const TDesC8& aComp, TUint32 aPortIndex); |
|
143 TBool MosGetActiveStream(const TDesC8& aComp, TUint32 aPortIndex); |
|
144 TBool MosGetExtensionIndex(const TDesC8& aComp, const TDesC8& aParameterName, OMX_ERRORTYPE aExpectedError); |
|
145 |
|
146 TBool MosCheckTimeClockState(const TDesC8& aComp, OMX_TIME_CLOCKSTATE aExpectedState); |
|
147 TBool MosCheckMediaTime(const TDesC8& aComp, TInt aPortIndex, OMX_TICKS aMediaTime, TBool aMoreThan); |
|
148 TBool MosBaseSupportPortL(const TDesC8& aComp, TInt aPortIndex); |
|
149 TBool MosBaseSetAutonomous(const TDesC8& aComp, TInt aPortIndex, TBool aEnabled); |
|
150 TBool MosBaseAllocateBuffersL(const TDesC8& aComp, TInt aPortIndex, TInt aNumberBuffers); |
|
151 TBool MosBaseFreeAllocatedBuffersL(const TDesC8& aComp); |
|
152 TBool MosBaseSetBufSupplier(const TDesC8& aComp, TInt aPortIndex, TBool aComponentSupplier); |
|
153 TBool MosBaseFillThisBuffer(const TDesC8& aComp, TInt aPortIndex, TInt aPortRelBufIndex); |
|
154 TBool MosBaseEmptyThisBuffer(const TDesC8& aComp, TInt aPortIndex, TInt aPortRelBufIndex); |
|
155 TBool MosBaseWaitForBuffer(const TDesC8& aComp, TInt aPortIndex, TInt aPortRelBufIndex); |
|
156 TBool MosBaseTimestampPassClock(const TDesC8& aCompReceiving, const TDesC8& aClockCompToPass); |
|
157 TBool MosBaseTimestampCheckTimestampL(const TDesC8& aComp, TInt aPortIndex, TUint aExpectedTime, TUint aTolerance); |
|
158 TBool MosBaseTimestampCompareWithRefClockL(const TDesC8& aComp, TInt aPortIndex, TUint aTolerance); |
|
159 TBool MosMarkBuffer(const TDesC8& aComp, TInt aPortIndex, const TDesC8& aTargetComp, TInt markData); |
|
160 |
|
161 // mpeg4 encoder component |
|
162 TBool MosSetVideoEncQuantL(const TDesC8& aComp, TInt aPortIndex, TInt aQpb); |
|
163 TBool MosSetVideoEncMotionVectL(const TDesC8& aComp, TInt aPortIndex, TInt aAccuracy, TInt aSxSearchrange, TInt aSySearchrange, OMX_ERRORTYPE aExpectedError); |
|
164 TBool MosSetVideoEncMpeg4TypeL(const TDesC8& aComp, TInt aPortIndex, OMX_VIDEO_MPEG4PROFILETYPE aMpeg4Profile, OMX_VIDEO_MPEG4LEVELTYPE aMpeg4Level, OMX_ERRORTYPE aExpectedError); |
|
165 TBool MosSetVideoEncBitRateL(const TDesC8& aComp, TInt aPortIndex, OMX_VIDEO_CONTROLRATETYPE aControlRate, TInt aTargetBitrate, OMX_ERRORTYPE aExpectedError); |
|
166 |
|
167 TBool MosSetAACProfileL(const TDesC8& aComp, TInt aPortIndex, TInt aChannels, TInt aSamplingRate, TInt aBitRate, TInt aAudioBandwidth, TInt aFrameLength, TInt aAACTools, TInt aAACERTools, OMX_AUDIO_AACPROFILETYPE aProfile, OMX_AUDIO_AACSTREAMFORMATTYPE aStreamFormat, OMX_AUDIO_CHANNELMODETYPE aChannelMode); |
|
168 |
|
169 // Camera |
|
170 |
|
171 TBool MosSetSensorModeTypeL(const TDesC8& aComp, TInt aPort, TInt aFrameRate, TBool aOneShot, TInt aWidth, TInt aHeight); |
|
172 TBool MosSetCaptureModeTypeL(const TDesC8& aComp, TInt aPort, TBool aContinuous, TBool aFrameLimited, TInt aFrameLimit); |
|
173 |
|
174 |
|
175 // Debugging/Utility functions. |
|
176 TBool MosDeleteFileL(const TDesC& aFileName, TBool aFileMustExist); |
|
177 TBool MosLogAllEventsL(); |
|
178 |
|
179 // MASBreakCallback |
|
180 void AllComponentsEOS(); |
|
181 void AllComponentsTransitioned(OMX_STATETYPE aNewState, |
|
182 OMX_STATETYPE aOldState); |
|
183 void EventReceived(OMX_COMPONENTTYPE* aComponent, OMX_EVENTTYPE aEvent, TUint32 aData1, TUint32 aData2, TAny* aEventData); |
|
184 void ComponentTransitioned(OMX_STATETYPE aNewState, |
|
185 OMX_STATETYPE aOldState); |
|
186 void BufferDone(OMX_COMPONENTTYPE* aComponent, OMX_BUFFERHEADERTYPE* aBufHdr, TBool aSource); |
|
187 |
|
188 // MTimerObserver |
|
189 void TimerExpired(); |
|
190 |
|
191 TBool MosSetupBufferForPortL(const TDesC8& comp,TInt aPortIndex, const TDesC& aFileName,TInt aHeaderLength,OMX_BUFFERSUPPLIERTYPE aSupplier); |
|
192 TBool MosStartBuffersforPort(const TDesC8& aComp, TInt aPortIndex); |
|
193 |
|
194 |
|
195 public: |
|
196 enum TOmxScriptTestVerdict |
|
197 { |
|
198 EPass, EFail, EPending |
|
199 }; |
|
200 |
|
201 TInt Reason() const; |
|
202 TOmxScriptTestVerdict Verdict() const; |
|
203 void FailWithOmxError(const TDesC& aOperation, OMX_ERRORTYPE aError); |
|
204 void StopTest(TOmxScriptTestVerdict aVerdict); |
|
205 void StopTest(TInt aError, TOmxScriptTestVerdict aVerdict); |
|
206 void FailTest(const TDesC& aErrorMsg); |
|
207 |
|
208 |
|
209 static TBool ShortNameMatchComparison(const TDesC8* aShortName, const ROmxScriptTest::CComponentInfo& aComponentInfo); |
|
210 |
|
211 void BeginWait(); |
|
212 void EndWait(); |
|
213 |
|
214 private: |
|
215 TBool ComponentLogicalIL(const TDesC8& aName); |
|
216 TBool ComponentPhysicalIL(const TDesC8& aName); |
|
217 OMX_COMPONENTTYPE* ComponentByName(const TDesC8& aName); |
|
218 void GetComponentName(const OMX_COMPONENTTYPE* aHandle, TDes& aName); |
|
219 void FailWithOmxError(const TDesC8& aComponent, const TDesC& aOperation, OMX_ERRORTYPE aError); |
|
220 // static void CleanupOmxComponent(TAny*); |
|
221 static void FormatHex(const TDesC8& bin, TDes& hex); |
|
222 void WriteInt32(TUint8* aPtr, TInt32 aData); |
|
223 |
|
224 TBool HandleNonTunneledBuffers(OMX_STATETYPE aNewState, OMX_COMPONENTTYPE* aComp); |
|
225 TBool HandlePortBufferHandler(OMX_STATETYPE aNewState, OMX_COMPONENTTYPE* aComp); |
|
226 |
|
227 void LogExtra(const TText8* aFile, TInt aLine, TOmxScriptSeverity aSeverity, |
|
228 TRefByValue<const TDesC16> aFmt,...); |
|
229 void RegisterTunnel(OMX_COMPONENTTYPE* aSourceComp, TInt aSourcePort, OMX_COMPONENTTYPE* aSinkComp, TInt aSinkPort); |
|
230 |
|
231 class TComponentInfo |
|
232 { |
|
233 public: |
|
234 HBufC8* iShortName; |
|
235 HBufC8* iComponentName; |
|
236 OMX_COMPONENTTYPE* iComponent; |
|
237 }; |
|
238 class TFilledBufferHeaderV2_xml |
|
239 { |
|
240 public: |
|
241 /** Amount of buffer filled with actual data */ |
|
242 TUint iFilledLength; |
|
243 /** Any timestamp associated with the buffer */ |
|
244 TInt64 iTimeStamp; |
|
245 /** Combination of OMX_BUFFERFLAG_*, specified at page 68 in the OpenMAX spec. */ |
|
246 TUint iFlags; |
|
247 /** offset **/ |
|
248 TUint32 iOffset; |
|
249 }; |
|
250 class TTunnelInfo |
|
251 { |
|
252 public: |
|
253 OMX_COMPONENTTYPE* iSourceComponent; |
|
254 TInt iSourcePort; |
|
255 OMX_COMPONENTTYPE* iSinkComponent; |
|
256 TInt iSinkPort; |
|
257 }; |
|
258 |
|
259 RArray<TTunnelInfo> iTunnels; |
|
260 typedef RArray<TTunnelInfo> RTunnelRelations; |
|
261 void FindTransitionOrderL(const RPointerArray<CComponentInfo>& aComponents, |
|
262 const RTunnelRelations& aTunnelRelations, |
|
263 RArray<TInt>& aOrder); |
|
264 |
|
265 private: |
|
266 TBool iCoreLoaded; |
|
267 RPointerArray<CComponentInfo> iComponents; |
|
268 RASBreakEventHandler iEventHandler; |
|
269 OMX_STATETYPE iState; |
|
270 |
|
271 // Symbian graphic sink specialisation |
|
272 CWindowManager* iWindowManager; |
|
273 TVideoFitMode iVideoFitMode; |
|
274 OMX_INDEXTYPE iExtSurfaceConfigIndex; |
|
275 OMX_COMPONENTTYPE* iGraphicSink; |
|
276 |
|
277 CVideoTestTimer *iTimer; |
|
278 |
|
279 RArray<TExpectedEvent> iExpectedEvents; |
|
280 TBool iWaitingForEvents; |
|
281 |
|
282 CNonTunneledHandler* iNonTunneledHandler; |
|
283 RArray<TExpectedEvent> iIgnoredEvents; |
|
284 |
|
285 // Buffer component handler |
|
286 CVideoBufferHandler* iBufferHandler; |
|
287 CVideoBufferSinkHandler* iBufferSinkHandler; |
|
288 |
|
289 TInt iReason; |
|
290 TOmxScriptTestVerdict iVerdict; |
|
291 MOmxScriptTestLogger& iLogger; |
|
292 |
|
293 CAsyncCallBack* iStopSchedulerCallback; |
|
294 |
|
295 RMsgQueue<TFilledBufferHeaderV2_xml> iMsgQueue; |
|
296 CPortBufferHandler* iPortBufferHandler; |
|
297 }; |
|
298 |
|
299 #endif /*OMXSCRIPTTEST_H_*/ |