|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 /** |
|
18 @file |
|
19 */ |
|
20 |
|
21 #ifndef TSU_OMXIL_COMPONENT_BASE_H |
|
22 #define TSU_OMXIL_COMPONENT_BASE_H |
|
23 |
|
24 #include <e32msgqueue.h> |
|
25 #include <testframework.h> |
|
26 #include <openmax/il/khronos/v1_x/OMX_Core.h> |
|
27 |
|
28 #include "tsu_omxil_component_constants.h" |
|
29 #include <openmax/il/common/omxilstatedefs.h> |
|
30 |
|
31 // Forward declarations |
|
32 class COmxILComponentIf; |
|
33 struct OMX_COMPONENTTYPE; |
|
34 class RAsyncTestStepOmxILComponentBase; |
|
35 class CMMFBuffer; |
|
36 |
|
37 |
|
38 class CAacTestFile : public CBase |
|
39 { |
|
40 |
|
41 public: |
|
42 |
|
43 static CAacTestFile* NewL(); |
|
44 |
|
45 ~CAacTestFile(); |
|
46 |
|
47 TInt ReadTestFileInBuffer(const TDesC& aFileName); |
|
48 void ReadNextBuffer(CMMFBuffer& aDataBuffer); |
|
49 void ResetPos(); |
|
50 TInt GetPos(); |
|
51 |
|
52 private: |
|
53 |
|
54 CAacTestFile(); |
|
55 void ConstructL(); |
|
56 |
|
57 |
|
58 private: |
|
59 |
|
60 HBufC8* iSourceFile; |
|
61 TInt iSourceFileReadPos; |
|
62 TBool iFinished; |
|
63 |
|
64 }; |
|
65 |
|
66 |
|
67 class CAacOutputTestFile : public CBase |
|
68 { |
|
69 |
|
70 public: |
|
71 |
|
72 static CAacOutputTestFile* NewL(); |
|
73 |
|
74 ~CAacOutputTestFile(); |
|
75 |
|
76 TInt SetUpOutputFile(const TDesC& aFileName); |
|
77 TInt WriteDataToFile(const CMMFBuffer& aDataBuffer); |
|
78 TInt AddWavHeader(); |
|
79 void CloseOutputFile(); |
|
80 |
|
81 private: |
|
82 |
|
83 CAacOutputTestFile(); |
|
84 void ConstructL(); |
|
85 |
|
86 |
|
87 private: |
|
88 |
|
89 RFs iFileServerSession; |
|
90 RFile iOutputFile; |
|
91 TInt iWrittenDataTotal; |
|
92 TInt iBuffersWrittenCount; |
|
93 |
|
94 }; |
|
95 |
|
96 class MTimerObserver |
|
97 { |
|
98 |
|
99 public: |
|
100 |
|
101 virtual void TimerExpired() = 0; |
|
102 |
|
103 }; |
|
104 |
|
105 class CUtilityTimer : public CTimer |
|
106 { |
|
107 |
|
108 public: |
|
109 |
|
110 static CUtilityTimer* NewL(TTimeIntervalMicroSeconds32& aDelay, |
|
111 MTimerObserver& aObserver); |
|
112 ~CUtilityTimer(); |
|
113 |
|
114 void InitializeTimer(); |
|
115 |
|
116 private: |
|
117 |
|
118 CUtilityTimer(MTimerObserver& aObserver); |
|
119 void ConstructL(TTimeIntervalMicroSeconds32& aDelay); |
|
120 |
|
121 // from CActive |
|
122 void RunL(); |
|
123 void DoCancel(); |
|
124 |
|
125 private: |
|
126 |
|
127 TTimeIntervalMicroSeconds32 iDelay; |
|
128 MTimerObserver& iObserver; |
|
129 |
|
130 }; |
|
131 |
|
132 |
|
133 class CCallbackHandler : public CActive |
|
134 { |
|
135 public: |
|
136 |
|
137 enum TMessageType |
|
138 { |
|
139 EFillBufferCallback, |
|
140 EEmptyBufferCallback, |
|
141 EEventCallback |
|
142 }; |
|
143 |
|
144 class TEventParams |
|
145 { |
|
146 public: |
|
147 OMX_EVENTTYPE iEvent; |
|
148 TUint iData1; |
|
149 TUint iData2; |
|
150 TAny* iExtra; |
|
151 }; |
|
152 |
|
153 class TOmxMessage |
|
154 { |
|
155 public: |
|
156 TMessageType iType; |
|
157 OMX_HANDLETYPE iComponent; |
|
158 union |
|
159 { |
|
160 OMX_BUFFERHEADERTYPE* iBuffer; |
|
161 TEventParams iEventParams; |
|
162 }; |
|
163 }; |
|
164 |
|
165 |
|
166 static const TInt KMaxMsgQueueEntries = 10; |
|
167 |
|
168 public: |
|
169 |
|
170 static CCallbackHandler* NewL(RAsyncTestStepOmxILComponentBase& aDecoderTest); |
|
171 virtual ~CCallbackHandler(); |
|
172 |
|
173 operator OMX_CALLBACKTYPE*(); |
|
174 |
|
175 void RunL(); |
|
176 void DoCancel(); |
|
177 |
|
178 static OMX_ERRORTYPE FillBufferDone(OMX_HANDLETYPE aComponent, |
|
179 TAny* aAppData, |
|
180 OMX_BUFFERHEADERTYPE* aBuffer); |
|
181 |
|
182 static OMX_ERRORTYPE EmptyBufferDone(OMX_HANDLETYPE aComponent, |
|
183 TAny* aAppData, |
|
184 OMX_BUFFERHEADERTYPE* aBuffer); |
|
185 |
|
186 static OMX_ERRORTYPE EventHandler(OMX_HANDLETYPE aComponent, |
|
187 TAny* aAppData, |
|
188 OMX_EVENTTYPE aEvent, |
|
189 TUint32 aData1, |
|
190 TUint32 aData2, |
|
191 TAny* aExtra); |
|
192 |
|
193 |
|
194 private: |
|
195 |
|
196 void ConstructL(); |
|
197 CCallbackHandler(RAsyncTestStepOmxILComponentBase& aDecoderTest); |
|
198 |
|
199 OMX_ERRORTYPE DoFillBufferDone(OMX_HANDLETYPE aComponent, |
|
200 OMX_BUFFERHEADERTYPE* aBuffer); |
|
201 OMX_ERRORTYPE DoEmptyBufferDone(OMX_HANDLETYPE aComponent, |
|
202 OMX_BUFFERHEADERTYPE* aBuffer); |
|
203 OMX_ERRORTYPE DoEventHandler(OMX_HANDLETYPE aComponent, |
|
204 TEventParams aParams); |
|
205 |
|
206 // |
|
207 // |
|
208 // |
|
209 |
|
210 |
|
211 private: |
|
212 |
|
213 RAsyncTestStepOmxILComponentBase& iDecoderTest; |
|
214 RMsgQueue<TOmxMessage> iMsgQueue; |
|
215 OMX_CALLBACKTYPE iHandle; |
|
216 |
|
217 }; |
|
218 |
|
219 |
|
220 class RAsyncTestStepOmxILComponentBase : public RAsyncTestStep |
|
221 { |
|
222 |
|
223 public: |
|
224 |
|
225 RAsyncTestStepOmxILComponentBase(const TDesC& aTestName, TInt aComponentUid); |
|
226 |
|
227 ~RAsyncTestStepOmxILComponentBase(); |
|
228 |
|
229 // From RAsyncTestStep |
|
230 void KickoffTestL(); |
|
231 void CloseTest(); |
|
232 |
|
233 // |
|
234 virtual void DoFillBufferDoneL(OMX_HANDLETYPE aComponent, |
|
235 OMX_BUFFERHEADERTYPE* aBuffer); |
|
236 |
|
237 virtual void DoEmptyBufferDoneL(OMX_HANDLETYPE aComponent, |
|
238 OMX_BUFFERHEADERTYPE* aBuffer); |
|
239 |
|
240 virtual void DoEventHandlerL(OMX_HANDLETYPE aComponent, |
|
241 OMX_EVENTTYPE aEvent, |
|
242 TUint aData1, |
|
243 TUint aData2, |
|
244 TAny* aExtra) = 0; |
|
245 |
|
246 |
|
247 static OMX_ERRORTYPE ConvertSymbianErrorType(TInt aError); |
|
248 |
|
249 |
|
250 |
|
251 protected: |
|
252 |
|
253 void PrintOmxState(OMX_STATETYPE aOmxState); |
|
254 |
|
255 // Async Call backs |
|
256 static TInt ComponentBaseCallBack(TAny* aPtr); |
|
257 void DoComponentBaseCallBack(); |
|
258 |
|
259 static TInt StopTestCallBack(TAny* aPtr); |
|
260 void DoStopTestCallBack(); |
|
261 |
|
262 protected: |
|
263 |
|
264 TInt iComponentUid; |
|
265 CAsyncCallBack* ipKickoffAOp; |
|
266 CAsyncCallBack* ipKickoffStop; |
|
267 COmxILComponentIf* ipCOmxILComponent; |
|
268 CCallbackHandler* ipCallbackHandler; |
|
269 CAacTestFile* ipTestFile; |
|
270 TPtrC iTestFileName; |
|
271 CAacOutputTestFile* ipOutputTestFile; |
|
272 OMX_COMPONENTTYPE* ipCompHandle; |
|
273 }; |
|
274 |
|
275 #endif // TSU_OMXIL_COMPONENT_BASE_H |