|
1 /* |
|
2 * Copyright (c) 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 |
|
20 |
|
21 #ifndef CGStreamerTestClass_H |
|
22 #define CGStreamerTestClass_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <StifLogger.h> |
|
26 #include <TestScripterInternal.h> |
|
27 #include <StifTestModule.h> |
|
28 |
|
29 #include <e32svr.h> |
|
30 #include <e32base.h> |
|
31 #include <e32cons.h> |
|
32 #include <gst/gst.h> |
|
33 |
|
34 #include "TimeoutController.h" |
|
35 #include "gstg711encoderinterface.h" |
|
36 #include "gstspeechencoderconfig.h" |
|
37 #include "gsterrorconcealmentinterface.h" |
|
38 #include "gstg711decoderinterface.h" |
|
39 #include "gstilbcdecoderinterface.h" |
|
40 #include "gstilbcencoderinterface.h" |
|
41 #include "gstg729encoderinterface.h" |
|
42 #include "gstg729decoderinterface.h" |
|
43 |
|
44 |
|
45 //global variables |
|
46 /*static GstElement *iPipeline; |
|
47 static GMainLoop *iLoop; |
|
48 static GstElement *iConverter; |
|
49 static GstElement *iResampler; |
|
50 static GstElement *iSink;*/ |
|
51 |
|
52 // CONSTANTS |
|
53 const TInt KErrBadTestParameter= -1000; // Error on configuration file |
|
54 |
|
55 const TInt KErrEventPending =-2000; // Timeout and not callback |
|
56 const TInt KErrCallbackErrorCode = -2001; // Callback return error code |
|
57 const TInt KErrUnexpectedValue =-2002; // Unexpected value at setting |
|
58 const TInt KErrTimeoutController = -2007; // Unexpected notification |
|
59 |
|
60 const TInt KShortTimeout = 1000; |
|
61 const TInt KMediumTimeout = 4000; |
|
62 const TInt KLongTimeout = 100000; |
|
63 |
|
64 |
|
65 _LIT( KMsgBadTestParameters, "[Error] No valid test case parameters"); |
|
66 |
|
67 // General |
|
68 _LIT( KTagLocation, "location"); |
|
69 |
|
70 // Common Properties |
|
71 _LIT( KTagRateProperty,"rate"); |
|
72 _LIT( KTagChannelsProperty,"channels"); |
|
73 _LIT( KTagLeftBalanceProperty,"leftbalance"); |
|
74 |
|
75 |
|
76 // Sink Properties |
|
77 _LIT( KTagVolumeProperty,"volume"); |
|
78 _LIT( KTagMaxVolumeProperty,"maxvolume"); |
|
79 _LIT( KTagSamplesPlayedProperty,"samplesplayed"); |
|
80 _LIT( KTagRightBalanceProperty,"rightbalance"); |
|
81 _LIT( KTagVolumeRampProperty,"volumeramp"); |
|
82 _LIT( KTagPriorityProperty,"priority"); |
|
83 _LIT( KTagPereferenceProperty,"preference"); |
|
84 _LIT( KTagFourCCProperty,"fourcc"); |
|
85 _LIT( KTagMimeTypeProperty,"mimetype"); |
|
86 |
|
87 // Source Properties |
|
88 _LIT( KTagGainProperty,"gain"); |
|
89 _LIT( KTagMaxGainProperty,"maxgain"); |
|
90 _LIT( KTagSamplesRecordedProperty,"samplesrecorded"); |
|
91 |
|
92 |
|
93 |
|
94 // MACROS |
|
95 //#define ?macro ?macro_def |
|
96 // Logging path |
|
97 #ifdef __WINSCW__ |
|
98 _LIT( KGStreamerTestClassLogPath, "\\logs\\testframework\\" ); |
|
99 #else |
|
100 _LIT( KGStreamerTestClassLogPath, "e:\\testing\\Log\\" ); |
|
101 #endif |
|
102 |
|
103 // Log file |
|
104 _LIT( KGStreamerTestClassLogFile, "GStreamerTestClass.txt" ); |
|
105 |
|
106 |
|
107 // FORWARD DECLARATIONS |
|
108 class CGStreamerTestClass; |
|
109 //typedef struct _GstObjects GstObjects; |
|
110 class CGlibEventHandler: public CActive |
|
111 { |
|
112 |
|
113 public: |
|
114 static CGlibEventHandler* NewL(); |
|
115 ~CGlibEventHandler(); |
|
116 |
|
117 void RunL(); |
|
118 void DoCancel(); |
|
119 void Start(); |
|
120 void Stop(); |
|
121 private: |
|
122 CGlibEventHandler(); |
|
123 void ConstructL(); |
|
124 |
|
125 RTimer iTimer; |
|
126 }; |
|
127 |
|
128 |
|
129 class CGstObjects : public CBase |
|
130 { |
|
131 public: |
|
132 |
|
133 static CGstObjects* NewL(void* aParent); |
|
134 virtual ~CGstObjects(); |
|
135 private: |
|
136 void ConstructL(); |
|
137 CGstObjects(void* aParent); |
|
138 |
|
139 public : |
|
140 |
|
141 GstElement *iPipeline; |
|
142 GMainLoop *iLoop; |
|
143 GstElement *iConverter; |
|
144 GstElement *iResampler; |
|
145 GstElement *iSink; |
|
146 GstElement *iSource; |
|
147 GstElement *iWavparse; |
|
148 |
|
149 GstElement *iDecoder; |
|
150 GstElement *iFakesink; |
|
151 GstElement *iFilesink; |
|
152 GstElement *iEncoder; |
|
153 GstElement *iFilter; |
|
154 GstElement *iWavenc; |
|
155 GstBus* iBus; |
|
156 GstCaps* iCaps; |
|
157 GstG711EncoderIntfc *iG711EncoderIntfc; |
|
158 GstG729EncoderIntfc *iG729EncoderIntfc; |
|
159 GstIlbcEncoderIntfc *iIlbcEncoderIntfc; |
|
160 GstSpeechEncoderConfigIntfc *iSpeechEncoderIntfc; |
|
161 GstErrorConcealmentIntfc *iErrconcealmentIntfc; |
|
162 GstG711DecoderIntfc *iG711DecoderIntfc; |
|
163 GstG729DecoderIntfc *iG729DecoderIntfc; |
|
164 GstIlbcDecoderIntfc *iIlbcDecoderIntfc; |
|
165 FILE* fp; |
|
166 CGlibEventHandler* iCGlibEventHandler; |
|
167 void *iParent; |
|
168 }; |
|
169 |
|
170 // CLASS DECLARATION |
|
171 |
|
172 /** |
|
173 * CGStreamerTestClass test class for STIF Test Framework TestScripter. |
|
174 * ?other_description_lines |
|
175 * |
|
176 * @lib ?library |
|
177 * @since Series60_3_2 |
|
178 */ |
|
179 NONSHARABLE_CLASS(CGStreamerTestClass) : public CScriptBase, |
|
180 public MTimeoutObserver |
|
181 { |
|
182 public: // Constructors and destructor |
|
183 |
|
184 /** |
|
185 * Two-phased constructor. |
|
186 */ |
|
187 static CGStreamerTestClass* NewL( CTestModuleIf& aTestModuleIf ); |
|
188 |
|
189 /** |
|
190 * Destructor. |
|
191 */ |
|
192 virtual ~CGStreamerTestClass(); |
|
193 |
|
194 |
|
195 enum TGSTExpectedEvent |
|
196 { |
|
197 EEOSReceived |
|
198 }; |
|
199 |
|
200 enum TGStreamerElements |
|
201 { |
|
202 EFILESOURCE = 1, |
|
203 EFILESINK, |
|
204 EFAKESOURCE, |
|
205 EFAKESINK, |
|
206 EWAVPARSE, |
|
207 EMP3DECODER, |
|
208 EWAVEENCODER, |
|
209 ERESAMPLER, |
|
210 ECONVERTER, |
|
211 EDEVSOUNDSRC, |
|
212 EDEVSOUNDSINK |
|
213 }; |
|
214 |
|
215 enum TElementCustomInterfaces |
|
216 { |
|
217 EG711ENCODER = 1, |
|
218 EG711DECODER, |
|
219 EG729ENCODER, |
|
220 EG729DECODER, |
|
221 EILBCENCODER, |
|
222 EILBCDECODER, |
|
223 ESPEECHENCODER, |
|
224 EERRORCONCEALMENT |
|
225 }; |
|
226 |
|
227 enum TG711DecCustomIntfcProp |
|
228 { |
|
229 EG711SetDecoderMode = 1, |
|
230 EG711SetCng, |
|
231 EG711GetCng, |
|
232 EG711SetPlc |
|
233 }; |
|
234 |
|
235 enum TILBCDecCustomIntfcProp |
|
236 { |
|
237 EIlbcSetDecoderMode = 1, |
|
238 EIlbcSetCng, |
|
239 EIlbcGetCng, |
|
240 }; |
|
241 |
|
242 enum TG729DecCustomIntfcProp |
|
243 { |
|
244 EG729BadLsfNextBuffer = 1 |
|
245 }; |
|
246 |
|
247 enum TG711EncCustomIntfcProp |
|
248 { |
|
249 EG711SetEncoderMode = 1, |
|
250 EG711SetVadMode, |
|
251 EG711GetVadMode |
|
252 }; |
|
253 |
|
254 enum TILBCEncCustomIntfcProp |
|
255 { |
|
256 EIlbcSetEncoderMode = 1, |
|
257 EIlbcSetVadMode, |
|
258 EIlbcGetVadMode |
|
259 }; |
|
260 |
|
261 enum TG729EncCustomIntfcProp |
|
262 { |
|
263 EG729SetVadMode = 1, |
|
264 EG729GetVadMode |
|
265 }; |
|
266 |
|
267 enum TSpEncCustomIntfcProp |
|
268 { |
|
269 ESPENGetSupportedBitrates = 1, |
|
270 ESPENSetBitrate, |
|
271 ESPENGetBitrate, |
|
272 ESPENSetVadMode, |
|
273 ESPENGetVadMode |
|
274 }; |
|
275 |
|
276 enum TErrorConcealCustomIntfcProp |
|
277 { |
|
278 EECConcealErrorForNextBuffer = 1, |
|
279 EECSetFrameMode, |
|
280 EECFrameModeRqrdForEC |
|
281 }; |
|
282 |
|
283 public: // New functions |
|
284 |
|
285 /** |
|
286 * ?member_description. |
|
287 * @since ?Series60_version |
|
288 * @param ?arg1 ?description |
|
289 * @return ?description |
|
290 */ |
|
291 //?type ?member_function( ?type ?arg1 ); |
|
292 |
|
293 public: // Functions from base classes |
|
294 |
|
295 /** |
|
296 * From CScriptBase Runs a script line. |
|
297 * @since ?Series60_version |
|
298 * @param aItem Script line containing method name and parameters |
|
299 * @return Symbian OS error code |
|
300 */ |
|
301 virtual TInt RunMethodL( CStifItemParser& aItem ); |
|
302 |
|
303 |
|
304 |
|
305 // From MTimeoutObserver |
|
306 |
|
307 /** |
|
308 * @since ?Series60_version |
|
309 * @param none |
|
310 * Review if all the expected events have ocurred once the time is over |
|
311 */ |
|
312 void HandleTimeout(TInt error); |
|
313 |
|
314 /** |
|
315 * Verify that the event was expected, removes it from the list |
|
316 * Signal the TestScripter with the returned error code |
|
317 * @since ?Series60_version |
|
318 */ |
|
319 void ProcessEvent(TGSTExpectedEvent aEvent, TInt aError); |
|
320 |
|
321 |
|
322 protected: // New functions |
|
323 |
|
324 /** |
|
325 * ?member_description. |
|
326 * @since ?Series60_version |
|
327 * @param ?arg1 ?description |
|
328 * @return ?description |
|
329 */ |
|
330 //?type ?member_function( ?type ?arg1 ); |
|
331 |
|
332 protected: // Functions from base classes |
|
333 |
|
334 /** |
|
335 * From ?base_class ?member_description |
|
336 */ |
|
337 //?type ?member_function(); |
|
338 |
|
339 private: |
|
340 |
|
341 /** |
|
342 * C++ default constructor. |
|
343 */ |
|
344 CGStreamerTestClass( CTestModuleIf& aTestModuleIf ); |
|
345 |
|
346 /** |
|
347 * By default Symbian 2nd phase constructor is private. |
|
348 */ |
|
349 void ConstructL(); |
|
350 |
|
351 // Prohibit copy constructor if not deriving from CBase. |
|
352 // ?classname( const ?classname& ); |
|
353 // Prohibit assigment operator if not deriving from CBase. |
|
354 // ?classname& operator=( const ?classname& ); |
|
355 |
|
356 /** |
|
357 * Frees all resources allocated from test methods. |
|
358 * @since ?Series60_version |
|
359 */ |
|
360 void Delete(); |
|
361 |
|
362 /** |
|
363 * Test methods are listed below. |
|
364 */ |
|
365 |
|
366 /** |
|
367 * Example test method. |
|
368 * @since ?Series60_version |
|
369 * @param aItem Script line containing parameters. |
|
370 * @return Symbian OS error code. |
|
371 */ |
|
372 |
|
373 /** |
|
374 * Set an event as expected and set default timeout |
|
375 * @since ?Series60_version |
|
376 */ |
|
377 void AddExpectedEvent(TGSTExpectedEvent event, TInt ms); |
|
378 |
|
379 |
|
380 /** |
|
381 * Unset an event as expected |
|
382 * @since ?Series60_version |
|
383 */ |
|
384 TBool RemoveExpectedEvent(TGSTExpectedEvent event); |
|
385 |
|
386 |
|
387 /** |
|
388 * @since ?Series60_version |
|
389 * @param none |
|
390 * Removes all expected events |
|
391 */ |
|
392 void RemoveAllExpectedEvents(); |
|
393 |
|
394 |
|
395 |
|
396 /** |
|
397 * Maps a event with a descriptor with its name |
|
398 * @since ?Series60_version |
|
399 */ |
|
400 TPtrC EventName( TInt aKey ); |
|
401 |
|
402 /* |
|
403 * Test methods are listed below. |
|
404 */ |
|
405 |
|
406 /** |
|
407 * Sets a timeout different since the default |
|
408 * @since Series60_3_2 |
|
409 * @param aItem Script line containing parameters. |
|
410 * @return Symbian OS error code. |
|
411 */ |
|
412 TInt SetTimeout( CStifItemParser& aItem ); |
|
413 |
|
414 /** |
|
415 * |
|
416 * @since Series60_3_2 |
|
417 * @param aItem Script line containing parameters. |
|
418 * @return Symbian OS error code. |
|
419 */ |
|
420 TInt SetExpectedEvents( CStifItemParser& aItem ); |
|
421 |
|
422 /** |
|
423 * |
|
424 * @since Series60_3_2 |
|
425 * @param aItem Script line containing parameters. |
|
426 * @return Symbian OS error code. |
|
427 */ |
|
428 TInt SetAllowedPanic( CStifItemParser& aItem ); |
|
429 |
|
430 /** |
|
431 * Connect to the default client to the server |
|
432 * @since ?Series60_version |
|
433 * @param aItem Script line containing parameters. |
|
434 * @return Symbian OS error code. |
|
435 */ |
|
436 |
|
437 TInt ExampleL( CStifItemParser& aItem ); |
|
438 |
|
439 TInt InitGStreamer( CStifItemParser& aItem ); |
|
440 TInt CreatePipeLine( CStifItemParser& aItem ); |
|
441 TInt CreateElement( CStifItemParser& aItem ); |
|
442 TInt SetElementProperties( CStifItemParser& aItem ); |
|
443 TInt GetElementProperties( CStifItemParser& aItem ); |
|
444 TInt AddElementToPipeline( CStifItemParser& aItem ); |
|
445 TInt SetPipelineState( CStifItemParser& aItem ); |
|
446 TInt InitPipeLine( CStifItemParser& aItem ); |
|
447 TInt LinkElementsInPipeline( CStifItemParser& aItem ); |
|
448 TInt GetElementsCustomIntfc( CStifItemParser& aItem ); |
|
449 TInt CustomIntfcProp( CStifItemParser& aItem ); |
|
450 |
|
451 TInt SetCapsInPipeLine( CStifItemParser& aItem ); |
|
452 |
|
453 TInt SetMainLoopRun( CStifItemParser& aItem ); |
|
454 TInt GetConfigureData(); |
|
455 TInt SetConfigureData(); |
|
456 |
|
457 |
|
458 |
|
459 public: // Data |
|
460 // ?one_line_short_description_of_data |
|
461 //?data_declaration; |
|
462 |
|
463 protected: // Data |
|
464 // ?one_line_short_description_of_data |
|
465 //?data_declaration; |
|
466 |
|
467 private: // Data |
|
468 |
|
469 // reference to TestModuleIf |
|
470 CTestModuleIf& iTestModuleIf; |
|
471 |
|
472 // Active object with a timer to timeout the test case |
|
473 CSimpleTimeout * iTimeoutController; |
|
474 |
|
475 // Indicates if the test case use a normal exit reason |
|
476 TBool iNormalExitReason; |
|
477 |
|
478 // List of expected events |
|
479 RArray<TGSTExpectedEvent> iExpectedEvents; |
|
480 |
|
481 // List of notification event (by the callback) |
|
482 RArray<TGSTExpectedEvent> iOcurredEvents; |
|
483 |
|
484 |
|
485 /*GstElement *iSource; |
|
486 GstElement *iWavparse; |
|
487 |
|
488 GstElement *iDecoder; |
|
489 GstElement *iFakesink; |
|
490 GstElement *iFilesink; |
|
491 GstElement *iEncoder; |
|
492 GstElement *iFilter; |
|
493 GstElement *iWavenc; |
|
494 GstBus* iBus; |
|
495 GstCaps* iCaps; |
|
496 GstG711EncoderIntfc *iG711EncoderIntfc; |
|
497 GstG729EncoderIntfc *iG729EncoderIntfc; |
|
498 GstIlbcEncoderIntfc *iIlbcEncoderIntfc; |
|
499 GstSpeechEncoderConfigIntfc *iSpeechEncoderIntfc; |
|
500 GstErrorConcealmentIntfc *iErrconcealmentIntfc; |
|
501 GstG711DecoderIntfc *iG711DecoderIntfc; |
|
502 GstG729DecoderIntfc *iG729DecoderIntfc; |
|
503 GstIlbcDecoderIntfc *iIlbcDecoderIntfc;*/ |
|
504 |
|
505 CGstObjects* iObjects; |
|
506 |
|
507 }; |
|
508 |
|
509 #endif // CGStreamerTestClass_H |
|
510 |
|
511 // End of File |