|
1 /* |
|
2 * Copyright (c) 2008 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 OMXSCRIPTPARSER_H_ |
|
20 #define OMXSCRIPTPARSER_H_ |
|
21 |
|
22 #include <f32file.h> |
|
23 #include <xml/contenthandler.h> |
|
24 #include <xml/documentparameters.h> |
|
25 |
|
26 #include <openmax/il/khronos/v1_x/OMX_Component.h> |
|
27 |
|
28 |
|
29 // a bit naughty, bit it will do for now |
|
30 using namespace Xml; |
|
31 |
|
32 enum TVideoFitMode |
|
33 { |
|
34 EVideoFitCentre, |
|
35 EVideoFitScaleAndCentre, |
|
36 EVideoFitRotateScaleAndCentre |
|
37 }; |
|
38 |
|
39 enum TTransitionOrder |
|
40 { |
|
41 ELoadOrder, |
|
42 EAutoOrder |
|
43 }; |
|
44 |
|
45 /** |
|
46 * High-level elementary test actions. This interface can be driven by the COmxScriptParser. |
|
47 */ |
|
48 class MOmxScriptIf |
|
49 { |
|
50 public: |
|
51 virtual TBool MosLoadComponentL(const TDesC8& aComp, const TDesC8& aName, TBool aBaseProfile, const TDesC8* aBaseImpl, TBool aLoadInCoreServerThread) = 0; |
|
52 virtual TBool MosSetupTunnel(const TDesC8& aSourceComp, TInt aSourcePort, |
|
53 const TDesC8& aSinkComp, TInt aSinkPort, OMX_ERRORTYPE aExpectedError) = 0; |
|
54 virtual TBool MosSetupNonTunnel(const TDesC8& aSourceComp, TInt aSourcePort, |
|
55 const TDesC8& aSinkComp, TInt aSinkPort, |
|
56 OMX_BUFFERSUPPLIERTYPE aSupplier) = 0; |
|
57 |
|
58 virtual TBool MosAllTransitionL(OMX_STATETYPE aState,OMX_ERRORTYPE aExpectedError, TTransitionOrder order) = 0; |
|
59 virtual TBool MosTransition(const TDesC8& aComp, OMX_STATETYPE aState, TBool aAsync) = 0; |
|
60 virtual TBool MosFailingTransition(const TDesC8& aComp, OMX_STATETYPE aState, OMX_ERRORTYPE aExpectedError) = 0; |
|
61 virtual TBool MosWaitEOS() = 0; |
|
62 virtual TBool MosSetFilename(const TDesC8& aComp, const TDesC& aFilename) = 0; |
|
63 virtual TBool MosGetFilename(const TDesC8& aComp, TDesC& aFilename) = 0; |
|
64 virtual TBool MosSetBadFilename(const TDesC8& aComp) = 0; |
|
65 |
|
66 virtual TBool MosSetBufferCount(const TDesC8& aComp, TInt aPortIndex, TInt aCount, OMX_ERRORTYPE aExpectedError) = 0; |
|
67 |
|
68 virtual TBool MosBufferSupplierOverrideL(const TDesC8& aSourceComp, TInt aSourcePort, |
|
69 const TDesC8& aSinkComp, TInt aSinkPort, |
|
70 OMX_BUFFERSUPPLIERTYPE aSupplier, |
|
71 OMX_ERRORTYPE aExpectedSourceError, OMX_ERRORTYPE aExpectedSinkError) = 0; |
|
72 virtual 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) = 0; |
|
73 |
|
74 virtual void MosParseError(const TDesC& aError) = 0; |
|
75 virtual TBool MosWaitL(TTimeIntervalMicroSeconds32 aDelay) = 0; |
|
76 virtual TBool MosExpectEventL(const TDesC8& aComp, OMX_EVENTTYPE aEvent, TUint32 nData1, TUint32 nData2) = 0; |
|
77 virtual TBool MosWaitForAllEventsL() = 0; |
|
78 virtual TBool MosCheckStateL(const TDesC8& aComp, OMX_STATETYPE aState) = 0; |
|
79 virtual TBool MosCheckVideoPortDefL(const TDesC8& aComp, TInt aPortIndex, TInt aWidth, TInt aHeight, OMX_VIDEO_CODINGTYPE aCoding, OMX_COLOR_FORMATTYPE aColorFormat) = 0; |
|
80 virtual TBool MosCheckMetaDataL(const TDesC8& aComp, TInt aPortIndex, OMX_METADATASCOPETYPE aScope, const TDesC8& aAtomType, TUint32 aAtomIndex, const TDesC8& aData) = 0; |
|
81 virtual TBool MosGetParameterUnknownIndexTypeL(const TDesC8& aComp, TInt aPortIndex, OMX_METADATASCOPETYPE aScope, const TDesC8& aAtomType, TUint32 aAtomIndex, const TDesC8& aData) = 0; |
|
82 virtual TBool MosSetParameterUnknownIndexTypeL(const TDesC8& aComp, TInt aPortIndex, OMX_METADATASCOPETYPE aScope, const TDesC8& aAtomType, TUint32 aAtomIndex, const TDesC8& aData) = 0; |
|
83 |
|
84 virtual TBool MosDisablePort(const TDesC8& aComp, TInt aPortIndex) = 0; |
|
85 virtual TBool MosEnablePort(const TDesC8& aComp, TInt aPortIndex) = 0; |
|
86 virtual TBool MosIgnoreEventL(const TDesC8& aComp, OMX_EVENTTYPE aEvent, TUint32 nData1, TUint32 nData2) = 0; |
|
87 virtual 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) = 0; |
|
88 virtual TBool MosSetConfigAudioVolumeL(const TDesC8& aComp, TInt aPortIndex, TBool aLinear, TInt aMinVolume, TInt aMaxVolume, TInt aVolume, OMX_ERRORTYPE aExpectedError) = 0; |
|
89 virtual TBool MosCheckConfigAudioVolumeL(const TDesC8& aComp, TInt aPortIndex, TBool aLinear, TInt aMinVolume, TInt aMaxVolume, TInt aVolume) = 0; |
|
90 virtual TBool MosCheckConfigAudioMuteL(const TDesC8& aComp, TInt aPortIndex, TBool aMute) = 0; |
|
91 virtual TBool MosSetConfigAudioMuteL(const TDesC8& aComp, TInt aPortIndex, TBool aMute) = 0; |
|
92 virtual 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) = 0; |
|
93 virtual TBool MosSetAudioPortDefL(const TDesC8& aComp, TInt aPortIndex, OMX_AUDIO_CODINGTYPE* aCodingType) = 0; |
|
94 virtual TBool MosSetRefClockTypeL(const TDesC8& aComp, OMX_TIME_REFCLOCKTYPE aRefClockType) = 0; |
|
95 virtual TBool MosSetClockTimeScale(const TDesC8& aComp, OMX_S32 aScale) = 0; |
|
96 virtual TBool MosSetClockStateL(const TDesC8& aComp, OMX_TIME_CLOCKSTATE aClockState, TInt aStartTime, TInt aOffset, TUint32 aWaitMask) = 0; |
|
97 virtual TBool MosCheckClockStateL(const TDesC8& aComp, OMX_TIME_CLOCKSTATE aClockState) = 0; |
|
98 virtual TBool MosCheckTimePositionL(const TDesC8& aComp, TInt aPortIndex, TInt aTimestamp) = 0; |
|
99 virtual TBool MosSetTimePositionL(const TDesC8& aComp, TInt aPortIndex, TInt aTimestamp) = 0; |
|
100 virtual TBool MosSetClientStartTimeL(const TDesC8& aComp, TInt aPortIndex, TInt aTimestamp) = 0; |
|
101 virtual TBool MosSetCurrentAudioReferenceTimeL(const TDesC8& aComp, TInt aPortIndex, TInt aTimestamp) = 0; |
|
102 virtual TBool MosSetVideoFitModeL(TVideoFitMode aVideoFitMode) = 0; |
|
103 |
|
104 virtual TBool MosSetActiveStream(const TDesC8& aComp, TUint32 aPortIndex)= 0; |
|
105 virtual TBool MosGetActiveStream(const TDesC8& aComp, TUint32 aPortIndex) = 0; |
|
106 |
|
107 |
|
108 virtual TBool MosMarkBuffer(const TDesC8& aComp, TInt aPortIndex, const TDesC8& aTargetComp, TInt markData) = 0; |
|
109 // mpeg4 encoder component |
|
110 virtual TBool MosSetVideoEncQuantL(const TDesC8& aComp, TInt aPortIndex, TInt aQpb) = 0; |
|
111 virtual TBool MosSetVideoEncMotionVectL(const TDesC8& aComp, TInt aPortIndex, TInt aAccuracy, TInt aSxSearchrange, TInt aSySearchrange, OMX_ERRORTYPE aExpectedError) = 0; |
|
112 virtual TBool MosSetVideoEncMpeg4TypeL(const TDesC8& aComp, TInt aPortIndex, OMX_VIDEO_MPEG4PROFILETYPE aMpeg4Profile, OMX_VIDEO_MPEG4LEVELTYPE aMpeg4Level, OMX_ERRORTYPE aExpectedError) = 0; |
|
113 virtual TBool MosSetVideoEncBitRateL(const TDesC8& aComp, TInt aPortIndex, OMX_VIDEO_CONTROLRATETYPE aControlRate, TInt aTargetBitrate, OMX_ERRORTYPE aExpectedError) = 0; |
|
114 |
|
115 |
|
116 virtual TBool MosGetExtensionIndex(const TDesC8& aComp, const TDesC8& aParameterName, OMX_ERRORTYPE aExpectedError) = 0; |
|
117 |
|
118 virtual TBool MosCheckTimeClockState(const TDesC8& aComp, OMX_TIME_CLOCKSTATE aExpectedState) = 0; |
|
119 virtual TBool MosCheckMediaTime(const TDesC8& aComp, TInt aPortIndex, OMX_TICKS aMediaTime, TBool aMoreThan) = 0; |
|
120 |
|
121 |
|
122 virtual TBool MosWaitEOS(const TDesC8& aComp) = 0; |
|
123 |
|
124 virtual 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) = 0; |
|
125 virtual TBool MosSetupBufferForPortL(const TDesC8& comp,TInt aPortIndex, const TDesC& aFileName,TInt aHeaderLength,OMX_BUFFERSUPPLIERTYPE aSupplier) = 0; |
|
126 |
|
127 // Camera |
|
128 |
|
129 virtual TBool MosSetSensorModeTypeL(const TDesC8& aComp, TInt aPort, TInt aFrameRate, TBool aOneShot, TInt aWidth, TInt aHeight) = 0; |
|
130 virtual TBool MosSetCaptureModeTypeL(const TDesC8& aComp, TInt aPort, TBool aContinuous, TBool aFrameLimited, TInt aFrameLimit) = 0; |
|
131 |
|
132 |
|
133 // Debugging/Utility functions. |
|
134 virtual TBool MosDeleteFileL(const TDesC& aFileName, TBool aFileMustExist) = 0; |
|
135 virtual TBool MosLogAllEventsL() = 0; |
|
136 |
|
137 // Methods supporting generic Base Profile communications support with components |
|
138 virtual TBool MosBaseSupportPortL(const TDesC8& aComp, TInt aPortIndex) = 0; |
|
139 virtual TBool MosBaseSetAutonomous(const TDesC8& aComp, TInt aPortIndex, TBool aEnabled) = 0; |
|
140 virtual TBool MosBaseAllocateBuffersL(const TDesC8& aComp, TInt aPortIndex, TInt aNumberBuffers) = 0; |
|
141 virtual TBool MosBaseFreeAllocatedBuffersL(const TDesC8& aComp) = 0; |
|
142 virtual TBool MosBaseSetBufSupplier(const TDesC8& aComp, TInt aPortIndex, TBool aComponentSupplier) = 0; |
|
143 virtual TBool MosBaseFillThisBuffer(const TDesC8& aComp, TInt aPortIndex, TInt aPortRelBufIndex) = 0; |
|
144 virtual TBool MosBaseEmptyThisBuffer(const TDesC8& aComp, TInt aPortIndex, TInt aPortRelBufIndex) = 0; |
|
145 virtual TBool MosBaseWaitForBuffer(const TDesC8& aComp, TInt aPortIndex, TInt aPortRelBufIndex) = 0; |
|
146 |
|
147 // Methods supporting the Timestamp checking implementation for Base Profile testing |
|
148 virtual TBool MosBaseTimestampPassClock(const TDesC8& aCompReceiving, const TDesC8& aClockCompToPass) = 0; |
|
149 virtual TBool MosBaseTimestampCheckTimestampL(const TDesC8& aComp, TInt aPortIndex, TUint aExpectedTime, TUint aTolerance) = 0; |
|
150 virtual TBool MosBaseTimestampCompareWithRefClockL(const TDesC8& aComp, TInt aPortIndex, TUint aTolerance) = 0; |
|
151 |
|
152 virtual TBool MosStartBuffersforPort( const TDesC8& aComp, TInt aPortIndex) = 0; |
|
153 |
|
154 }; |
|
155 |
|
156 /** |
|
157 * This parses an XML file to drive the operation of a MOmxScriptIf. |
|
158 */ |
|
159 NONSHARABLE_CLASS(COmxScriptParser) : public CBase, public Xml::MContentHandler |
|
160 { |
|
161 public: |
|
162 static COmxScriptParser* NewL(RFs& aFs, const TDesC& aFilename, MOmxScriptIf& aCallback); |
|
163 ~COmxScriptParser(); |
|
164 |
|
165 TBool RunScriptL(const TDesC& aSectionName); |
|
166 |
|
167 // Xml::MContentHandler interface |
|
168 void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode); |
|
169 void OnEndDocumentL(TInt aErrorCode); |
|
170 void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, |
|
171 TInt aErrorCode); |
|
172 void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); |
|
173 void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
174 void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, |
|
175 TInt aErrorCode); |
|
176 void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
177 void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
178 void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
179 void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, |
|
180 TInt aErrorCode); |
|
181 void OnError(TInt aErrorCode); |
|
182 TAny* GetExtendedInterface(const TInt32 aUid); |
|
183 |
|
184 protected: |
|
185 COmxScriptParser(RFs& aFs, MOmxScriptIf& aCallback); |
|
186 void ConstructL(const TDesC& aFilename); |
|
187 |
|
188 private: |
|
189 static const TDesC8* FindAttribute(const RArray<RAttribute>& aArray, const TDesC8& aAttribName); |
|
190 const TDesC8& FindAttributeL(const RArray<RAttribute>& aArray, const TDesC8& aAttribName); |
|
191 static void ParseCompPortL(const TDesC8& aInput, TPtrC8& aNameOut, TInt& aPortOut); |
|
192 static OMX_STATETYPE ParseOmxStateL(const TDesC8& aStateDes); |
|
193 static OMX_BUFFERSUPPLIERTYPE ParseOmxSupplierL(const TDesC8& aSupplierDes, TBool aAllowUnspecified = EFalse); |
|
194 void CheckForAbortL(TBool success); |
|
195 static TInt ParseOptionalIntL(const RArray<RAttribute>& aArray, const TDesC8& aAttribName, TInt aDefaultValue); |
|
196 static TReal ParseOptionalRealL(const RArray<RAttribute>& aArray, const TDesC8& aAttribName, TReal aDefaultValue); |
|
197 static OMX_COLOR_FORMATTYPE ParseOmxColorFormatL(const TDesC8& aDes); |
|
198 static OMX_EVENTTYPE ParseOmxEventL(const TDesC8& aEventDes); |
|
199 static TUint32 ParseUint32L(const TDesC8& aDes); |
|
200 static TReal32 ParseReal32L(const TDesC8& aDes); |
|
201 static OMX_VIDEO_CODINGTYPE ParseOmxVideoCodingL(const TDesC8& aDes); |
|
202 static TBool ParseOptionalBooleanL(const RArray<RAttribute>& aArray, const TDesC8& aAttribName, TBool aDefaultValue); |
|
203 static TBool ParseBooleanL(const TDesC8& aBool); |
|
204 |
|
205 static OMX_METADATASCOPETYPE ParseOmxScopeTypeL(const TDesC8& aScopeDes); |
|
206 static OMX_AUDIO_CODINGTYPE ParseOmxAudioCodingL(const TDesC8& aDes); |
|
207 static OMX_TIME_REFCLOCKTYPE ParseOmxRefClockTypeL(const TDesC8& aDes); |
|
208 static OMX_TIME_CLOCKSTATE ParseOmxClockStateL(const TDesC8& aDes); |
|
209 static TVideoFitMode ParseVideoFitModeL(const TDesC8& aMode); |
|
210 static OMX_COMMANDTYPE ParseOmxCommandL(const TDesC8& aDes); |
|
211 static OMX_ERRORTYPE ParseOmxErrorL(const TDesC8& aDes); |
|
212 static TBool ParseBoolean(const TDesC8& aDes); |
|
213 |
|
214 static OMX_ERRORTYPE ParseOmxErrorCode(const TDesC8& aErrorCode); |
|
215 static OMX_VIDEO_MPEG4PROFILETYPE ParseOmxMpeg4ProfileL(const TDesC8& aDes); |
|
216 static OMX_VIDEO_MPEG4LEVELTYPE ParseOmxMpeg4LevelL(const TDesC8& aDes); |
|
217 static OMX_VIDEO_CONTROLRATETYPE ParseOmxControlRateL(const TDesC8& aDes); |
|
218 static OMX_AUDIO_AACPROFILETYPE ParseOmxAACProfileL(const TDesC8& aProfileDes); |
|
219 static OMX_AUDIO_AACSTREAMFORMATTYPE ParseOmxAACStreamFormatL(const TDesC8& aFormatDes); |
|
220 static OMX_AUDIO_CHANNELMODETYPE ParseOmxAudioChannelModeL(const TDesC8& aChannelModeDes); |
|
221 static TInt ParseSystemErrorCode(const TDesC8& aErrorCode); |
|
222 static OMX_AUDIO_AACSTREAMFORMATTYPE ParseAacStreamFormatL(const TDesC8& aStreamFormatStr); |
|
223 static OMX_NUMERICALDATATYPE ParseNumericalDataL(const TDesC8& aDes); |
|
224 static OMX_ENDIANTYPE ParseEndianL(const TDesC8& aDes); |
|
225 static OMX_BOOL ParseBoolL(const TDesC8& aDes); |
|
226 |
|
227 private: |
|
228 RFs& iFs; |
|
229 RBuf iFilename; |
|
230 MOmxScriptIf& iCallback; |
|
231 |
|
232 // state to allow filtering for a specific section within the XML document |
|
233 const TDesC* iSectionName; // not owned |
|
234 TBool iInTest; |
|
235 TBool iFoundTest; |
|
236 TBool iCallbackAborted; |
|
237 }; |
|
238 |
|
239 #endif /*OMXSCRIPTPARSER_H_*/ |