1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18 #include "test_engine.h"
19
20 #include "alloc_dealloc_test.h"
21 #include "init_test.h"
22 #include "init_cancel_test.h"
23 #ifndef NO_2WAY_324
24 #include "video_only_test.h"
25 #include "av_test.h"
26 #include "user_input_test.h"
27 #include "connect_test.h"
28 #include "connect_cancel_test.h"
29 #include "audio_only_test.h"
30 #include "av_duplicate_test.h"
31 #include "pvmf_fileoutput_factory.h"
32 #endif
33
34 #include "oscl_string_utils.h"
35 #include "oscl_mem_audit.h"
36
37
38 #include "tsc_h324m_config_interface.h"
39
40 #define AUDIO_FIRST 0
41 #define VIDEO_FIRST 1
42
43 #define MAX_SIP_TEST 27
44 #define MAX_324_TEST 25
45 #define SIP_TEST_OFFSET 200
46 #define SIP_TEST_MAP(x) (x+SIP_TEST_OFFSET)
47 #define NUM_SIP_ARGS 10
48
49
50 int start_test();
51
52 FILE* fileoutput;
53 cmd_line *global_cmd_line;
54
55 //Find test range args:
56 //To run a range of tests by enum ID:
57 // -test 17 29
58
59 char engine_test::iProfileName[32] = "";
60 uint32 engine_test::iMediaPorts[2] = { 0, 0 };
61 char engine_test::iPeerAddress[64] = "";
62
63
FindTestRange(cmd_line * command_line,int32 & iFirstTest,int32 & iLastTest,FILE * aFile)64 void FindTestRange(cmd_line* command_line,
65 int32& iFirstTest,
66 int32 &iLastTest,
67 FILE* aFile)
68 {
69 //default is to run all tests.
70 iFirstTest = 0;
71 iLastTest = MAX_324_TEST;
72
73 int iTestArgument = 0;
74 char *iTestArgStr1 = NULL;
75 char *iTestArgStr2 = NULL;
76 bool cmdline_iswchar = command_line->is_wchar();
77
78 int count = command_line->get_count();
79
80 // Search for the "-test" argument
81 char *iSourceFind = NULL;
82 if (cmdline_iswchar)
83 {
84 iSourceFind = new char[256];
85 }
86
87 int iTestSearch = 0;
88 while (iTestSearch < count)
89 {
90 bool iTestFound = false;
91 // Go through each argument
92 for (; iTestSearch < count; iTestSearch++)
93 {
94 // Convert to UTF8 if necessary
95 if (cmdline_iswchar)
96 {
97 OSCL_TCHAR* cmd = NULL;
98 command_line->get_arg(iTestSearch, cmd);
99 oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iSourceFind, 256);
100 }
101 else
102 {
103 iSourceFind = NULL;
104 command_line->get_arg(iTestSearch, iSourceFind);
105 }
106
107 // Do the string compare
108 if (oscl_strcmp(iSourceFind, "-help") == 0)
109 {
110 fprintf(aFile, "Test cases to run option. Default is ALL:\n");
111 fprintf(aFile, " -test x y\n");
112 fprintf(aFile, " Specify a range of test cases to run. To run one test case, use the\n");
113 fprintf(aFile, " same index for x and y.\n");
114
115 fprintf(aFile, " -test G\n");
116 fprintf(aFile, " Run 324M test cases only.\n");
117
118 exit(0);
119 }
120 else if (oscl_strcmp(iSourceFind, "-test") == 0)
121 {
122 iTestFound = true;
123 iTestArgument = ++iTestSearch;
124 break;
125 }
126 }
127
128 if (cmdline_iswchar)
129 {
130 delete[] iSourceFind;
131 iSourceFind = NULL;
132 }
133
134 if (iTestFound)
135 {
136 // Convert to UTF8 if necessary
137 if (cmdline_iswchar)
138 {
139 iTestArgStr1 = new char[256];
140 OSCL_TCHAR* cmd;
141 command_line->get_arg(iTestArgument, cmd);
142 if (cmd)
143 {
144 oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iTestArgStr1, 256);
145 }
146
147 iTestArgStr2 = new char[256];
148 command_line->get_arg(iTestArgument + 1, cmd);
149 if (cmd)
150 {
151 oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iTestArgStr2, 256);
152 }
153 }
154 else
155 {
156 command_line->get_arg(iTestArgument, iTestArgStr1);
157 command_line->get_arg(iTestArgument + 1, iTestArgStr2);
158 }
159
160 //Pull out 2 integers...
161 if (iTestArgStr1
162 && '0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9'
163 && iTestArgStr2
164 && '0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9')
165 {
166 int len = oscl_strlen(iTestArgStr1);
167 switch (len)
168 {
169 case 3:
170 iFirstTest = 0;
171 if ('0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9')
172 {
173 iFirstTest = iFirstTest + 100 * (iTestArgStr1[0] - '0');
174 }
175
176 if ('0' <= iTestArgStr1[1] && iTestArgStr1[1] <= '9')
177 {
178 iFirstTest = iFirstTest + 10 * (iTestArgStr1[1] - '0');
179 }
180
181 if ('0' <= iTestArgStr1[2] && iTestArgStr1[2] <= '9')
182 {
183 iFirstTest = iFirstTest + 1 * (iTestArgStr1[2] - '0');
184 }
185 break;
186
187 case 2:
188 iFirstTest = 0;
189 if ('0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9')
190 {
191 iFirstTest = iFirstTest + 10 * (iTestArgStr1[0] - '0');
192 }
193
194 if ('0' <= iTestArgStr1[1] && iTestArgStr1[1] <= '9')
195 {
196 iFirstTest = iFirstTest + 1 * (iTestArgStr1[1] - '0');
197 }
198 break;
199
200 case 1:
201 iFirstTest = 0;
202 if ('0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9')
203 {
204 iFirstTest = iFirstTest + 1 * (iTestArgStr1[0] - '0');
205 }
206 break;
207
208 default:
209 break;
210 }
211
212 len = oscl_strlen(iTestArgStr2);
213 switch (len)
214 {
215 case 3:
216 iLastTest = 0;
217 if ('0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9')
218 {
219 iLastTest = iLastTest + 100 * (iTestArgStr2[0] - '0');
220 }
221
222 if ('0' <= iTestArgStr2[1] && iTestArgStr2[1] <= '9')
223 {
224 iLastTest = iLastTest + 10 * (iTestArgStr2[1] - '0');
225 }
226
227 if ('0' <= iTestArgStr2[2] && iTestArgStr2[2] <= '9')
228 {
229 iLastTest = iLastTest + 1 * (iTestArgStr2[2] - '0');
230 }
231 break;
232
233 case 2:
234 iLastTest = 0;
235 if ('0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9')
236 {
237 iLastTest = iLastTest + 10 * (iTestArgStr2[0] - '0');
238 }
239
240 if ('0' <= iTestArgStr2[1] && iTestArgStr2[1] <= '9')
241 {
242 iLastTest = iLastTest + 1 * (iTestArgStr2[1] - '0');
243 }
244 break;
245
246 case 1:
247 iLastTest = 0;
248 if ('0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9')
249 {
250 iLastTest = iLastTest + 1 * (iTestArgStr2[0] - '0');
251 }
252 break;
253
254 default:
255 break;
256 }
257 }
258
259 #ifndef NO_2WAY_324
260 else if (iTestArgStr1
261 && iTestArgStr1[0] == 'G')
262 {
263 //download tests
264 iFirstTest = 0;
265 iLastTest = MAX_324_TEST;
266 }
267 #endif
268 }
269
270 if (cmdline_iswchar)
271 {
272 if (iTestArgStr1)
273 {
274 delete[] iTestArgStr1;
275 iTestArgStr1 = NULL;
276 }
277
278 if (iTestArgStr2)
279 {
280 delete[] iTestArgStr2;
281 iTestArgStr2 = NULL;
282 }
283
284 if (iSourceFind)
285 {
286 delete[] iSourceFind;
287 iSourceFind = NULL;
288 }
289 }
290 iTestSearch += 2;
291 }
292 }
293
294
engine_test_suite()295 engine_test_suite::engine_test_suite() : test_case()
296 {
297 // setting iProxy
298 //proxy_tests(false);
299
300 proxy_tests(true);
301 }
302
303
proxy_tests(const bool aProxy)304 void engine_test_suite::proxy_tests(const bool aProxy)
305 {
306 //Basic 2way tests
307 fprintf(fileoutput, "Basic engine tests.\n");
308
309 int32 firstTest = 0;
310 int32 lastTest = MAX_324_TEST;
311 FindTestRange(global_cmd_line, firstTest, lastTest, fileoutput);
312 #ifndef NO_2WAY_324
313 if (firstTest == 0)
314 adopt_test_case(new alloc_dealloc_test(aProxy));
315 if (firstTest <= 2 && lastTest >= 2)
316 adopt_test_case(new init_test(aProxy, 1));
317 if (firstTest <= 3 && lastTest >= 3)
318 adopt_test_case(new init_test(aProxy, 2));
319
320 if (firstTest <= 4 && lastTest >= 4)
321 adopt_test_case(new init_cancel_test(aProxy));
322
323 if (firstTest <= 5 && lastTest >= 5)
324 adopt_test_case(new connect_test(aProxy, 1));
325
326 if (firstTest <= 6 && lastTest >= 6)
327 adopt_test_case(new connect_cancel_test(aProxy));
328
329 if (firstTest <= 7 && lastTest >= 7)
330 {
331 adopt_test_case(new audio_only_test(aProxy, PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2));
332 }
333 if (firstTest <= 8 && lastTest >= 8)
334 {
335 adopt_test_case(new audio_only_test(aProxy, PVMF_MIME_PCM16, PVMF_MIME_AMR_IF2));
336 }
337 if (firstTest <= 9 && lastTest >= 9)
338 {
339 adopt_test_case(new audio_only_test(aProxy, PVMF_MIME_AMR_IF2, PVMF_MIME_PCM16));
340 }
341
342 if (firstTest <= 10 && lastTest >= 10)
343 {
344 adopt_test_case(new audio_only_test(aProxy, PVMF_MIME_PCM16, PVMF_MIME_PCM16));
345 }
346
347 if (firstTest <= 11 && lastTest >= 11)
348 {
349 adopt_test_case(new video_only_test(PVMF_MIME_YUV420, PVMF_MIME_YUV420, aProxy));
350 }
351 if (firstTest <= 12 && lastTest >= 12)
352 {
353 adopt_test_case(new video_only_test(PVMF_MIME_YUV420, PVMF_MIME_H2632000, aProxy));
354 }
355 if (firstTest <= 13 && lastTest >= 13)
356 {
357 adopt_test_case(new video_only_test(PVMF_MIME_H2632000, PVMF_MIME_YUV420, aProxy));
358 }
359 if (firstTest <= 14 && lastTest >= 14)
360 {
361 adopt_test_case(new video_only_test(PVMF_MIME_M4V, PVMF_MIME_YUV420, aProxy));
362 }
363 if (firstTest <= 15 && lastTest >= 15)
364 {
365 adopt_test_case(new video_only_test(PVMF_MIME_YUV420, PVMF_MIME_M4V, aProxy));
366 }
367
368 if (firstTest <= 16 && lastTest >= 16)
369 {
370 adopt_test_case(new av_test(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aProxy));
371 }
372
373 if (firstTest <= 17 && lastTest >= 17)
374 {
375 adopt_test_case(new av_test(PVMF_MIME_AMR_IF2, PVMF_MIME_PCM16, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aProxy));
376 }
377 if (firstTest <= 18 && lastTest >= 18)
378 {
379 adopt_test_case(new av_test(PVMF_MIME_PCM16, PVMF_MIME_AMR_IF2, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aProxy));
380
381 }
382 if (firstTest <= 19 && lastTest >= 19)
383 {
384 adopt_test_case(new av_test(PVMF_MIME_PCM16, PVMF_MIME_PCM16, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aProxy));
385 }
386
387 if (firstTest <= 20 && lastTest >= 20)
388 {
389 adopt_test_case(new av_test(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_YUV420, PVMF_MIME_H2632000, aProxy));
390 }
391 if (firstTest <= 21 && lastTest >= 21)
392 {
393 adopt_test_case(new av_test(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_H2632000, PVMF_MIME_YUV420, aProxy));
394 }
395 if (firstTest <= 22 && lastTest >= 22)
396 {
397 adopt_test_case(new av_test(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_H2632000, PVMF_MIME_H2632000, aProxy));
398 }
399
400 if (firstTest <= 23 && lastTest >= 23)
401 {
402 adopt_test_case(new av_test(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_YUV420, PVMF_MIME_M4V, aProxy));
403 }
404 if (firstTest <= 24 && lastTest >= 24)
405 {
406 adopt_test_case(new av_test(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_M4V, PVMF_MIME_YUV420, aProxy));
407 }
408 if (firstTest <= 25 && lastTest >= 25)
409 {
410 adopt_test_case(new av_test(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_M4V, PVMF_MIME_M4V, aProxy));
411 }
412
413 if (firstTest <= 26 && lastTest >= 26)
414 {
415 adopt_test_case(new connect_test(aProxy, 1, true));
416 }
417
418
419 #endif
420
421
422 }
423
create_sink_source()424 void engine_test::create_sink_source()
425 {
426 #ifndef NO_2WAY_324
427 iCommSettings.iMediaFormat = PVMF_MIME_H223;
428 iCommSettings.iTestObserver = NULL;
429 iCommServerIOControl = PvmiMIOCommLoopbackFactory::Create(iCommSettings);
430 bool enableBitstreamLogging = true;
431 iCommServer = PVCommsIONodeFactory::Create(iCommServerIOControl, enableBitstreamLogging);
432 #endif
433
434 // create the audio source
435 iAudioSourceFileSettings.iMediaFormat = PVMF_MIME_AMR_IF2;
436 iAudioSourceFileSettings.iLoopInputFile = true;
437 iAudioSourceFileSettings.iFileName = AUDIO_SOURCE_FILENAME;
438 iAudioSourceFileSettings.iSamplingFrequency = 8000;
439 iAudioSourceFileSettings.iNumChannels = 1;
440 iAudioSourceIOControl = PvmiMIOFileInputFactory::Create(iAudioSourceFileSettings);
441 iAudioSource = PvmfMediaInputNodeFactory::Create(iAudioSourceIOControl);
442
443 iAudioSourceRawFileSettings.iMediaFormat = PVMF_MIME_PCM16;
444 iAudioSourceRawFileSettings.iLoopInputFile = true;
445 iAudioSourceRawFileSettings.iFileName = AUDIO_SOURCE_RAW_FILENAME;
446 iAudioSourceRawFileSettings.iSamplingFrequency = 8000;
447 iAudioSourceRawFileSettings.iNumChannels = 1;
448 iAudioSourceRawIOControl = PvmiMIOFileInputFactory::Create(iAudioSourceRawFileSettings);
449 iAudioSourceRaw = PvmfMediaInputNodeFactory::Create(iAudioSourceRawIOControl);
450
451 iAudioSource2FileSettings.iMediaFormat = PVMF_MIME_AMR_IF2;
452 iAudioSource2FileSettings.iLoopInputFile = true;
453 iAudioSource2FileSettings.iFileName = AUDIO_SOURCE_FILENAME;
454 iAudioSource2FileSettings.iSamplingFrequency = 8000;
455 iAudioSource2FileSettings.iNumChannels = 1;
456 iAudioSource2IOControl = PvmiMIOFileInputFactory::Create(iAudioSource2FileSettings);
457 iAudioSource2 = PvmfMediaInputNodeFactory::Create(iAudioSource2IOControl);
458
459 iAudioSource3FileSettings.iMediaFormat = PVMF_MIME_AMR_IETF;
460 iAudioSource3FileSettings.iLoopInputFile = true;
461 iAudioSource3FileSettings.iFileName = AUDIO_SOURCE3_FILENAME;
462 iAudioSource3FileSettings.iSamplingFrequency = 8000;
463 iAudioSource3FileSettings.iNum20msFramesPerChunk = 1;
464 iAudioSource3FileSettings.iNumChannels = 1;
465 iAudioSource3IOControl = PvmiMIOFileInputFactory::Create(iAudioSource3FileSettings);
466 iAudioSource3 = PvmfMediaInputNodeFactory::Create(iAudioSource3IOControl);
467
468 // create the audio sinks
469
470 iAudioSinkFileName = AUDIO_SINK_FILENAME;
471 iAudioSinkIOControl = new PVRefFileOutput(iAudioSinkFileName, MEDIATYPE_AUDIO, true);
472 iAudioSink = PVMediaOutputNodeFactory::CreateMediaOutputNode(iAudioSinkIOControl);
473
474 iAudioSinkRawFileName = AUDIO_SINK_RAW_FILENAME;
475 iAudioSinkRawIOControl = new PVRefFileOutput(iAudioSinkRawFileName, MEDIATYPE_AUDIO, false);
476 iAudioSinkRaw = PVMediaOutputNodeFactory::CreateMediaOutputNode(iAudioSinkRawIOControl);
477
478 iAudioSink2FileName = AUDIO_SINK2_FILENAME;
479 iAudioSink2IOControl = new PVRefFileOutput(iAudioSink2FileName, MEDIATYPE_AUDIO, true);
480 iAudioSink2 = PVMediaOutputNodeFactory::CreateMediaOutputNode(iAudioSink2IOControl);
481
482 // create the video sources
483 iVideoSourceYUVFileSettings.iMediaFormat = PVMF_MIME_YUV420;
484 iVideoSourceYUVFileSettings.iLoopInputFile = true;
485 iVideoSourceYUVFileSettings.iFileName = VIDEO_SOURCE_YUV_FILENAME;
486 iVideoSourceYUVFileSettings.iTimescale = 1000;
487 iVideoSourceYUVFileSettings.iFrameHeight = 144;
488 iVideoSourceYUVFileSettings.iFrameWidth = 176;
489 iVideoSourceYUVFileSettings.iFrameRate = 5;
490 iVideoSourceYUVIOControl = PvmiMIOFileInputFactory::Create(iVideoSourceYUVFileSettings);
491 iVideoSourceYUV = PvmfMediaInputNodeFactory::Create(iVideoSourceYUVIOControl);
492
493
494 iVideoSourceH263FileSettings.iMediaFormat = PVMF_MIME_H2632000;
495 iVideoSourceH263FileSettings.iLoopInputFile = true;
496 iVideoSourceH263FileSettings.iFileName = VIDEO_SOURCE_H263_FILENAME;
497 iVideoSourceH263FileSettings.iTimescale = 1000;
498 iVideoSourceH263FileSettings.iFrameHeight = 144;
499 iVideoSourceH263FileSettings.iFrameWidth = 176;
500 iVideoSourceH263FileSettings.iFrameRate = 5;
501
502
503 iVideoSourceH263IOControl = PvmiMIOFileInputFactory::Create(iVideoSourceH263FileSettings);
504 iVideoSourceH263 = PvmfMediaInputNodeFactory::Create(iVideoSourceH263IOControl);
505
506 // create another video source
507 iVideoSourceM4VFileSettings.iMediaFormat = PVMF_MIME_M4V;
508 iVideoSourceM4VFileSettings.iLoopInputFile = true;
509 iVideoSourceM4VFileSettings.iFileName = VIDEO_SOURCE_M4V_FILENAME;
510 iVideoSourceM4VFileSettings.iTimescale = 1000;
511 iVideoSourceM4VFileSettings.iFrameHeight = 144;
512 iVideoSourceM4VFileSettings.iFrameWidth = 176;
513 iVideoSourceM4VFileSettings.iFrameRate = 5;
514
515 iVideoSourceM4VIOControl = PvmiMIOFileInputFactory::Create(iVideoSourceM4VFileSettings);
516 iVideoSourceM4V = PvmfMediaInputNodeFactory::Create(iVideoSourceM4VIOControl);
517
518 // create the video sinks
519 iVideoSinkYUVFileName = VIDEO_SINK_YUV_FILENAME;
520 iVideoSinkYUVIOControl = new PVRefFileOutput(iVideoSinkYUVFileName, MEDIATYPE_VIDEO, false);
521
522 iVideoSinkYUV = PVMediaOutputNodeFactory::CreateMediaOutputNode(iVideoSinkYUVIOControl);
523
524 iVideoSinkH263FileName = VIDEO_SINK_H263_FILENAME;
525 iVideoSinkH263IOControl = new PVRefFileOutput(iVideoSinkH263FileName, MEDIATYPE_VIDEO, true);
526 iVideoSinkH263 = PVMediaOutputNodeFactory::CreateMediaOutputNode(iVideoSinkH263IOControl);
527
528
529 iVideoSinkM4VFileName = VIDEO_SINK_M4V_FILENAME;
530 iVideoSinkM4VIOControl = new PVRefFileOutput(iVideoSinkM4VFileName, MEDIATYPE_VIDEO, true);
531 iVideoSinkM4V = PVMediaOutputNodeFactory::CreateMediaOutputNode(iVideoSinkM4VIOControl);
532
533 }
534
destroy_sink_source()535 void engine_test::destroy_sink_source()
536 {
537 #ifndef NO_2WAY_324
538 if (iCommServer)
539 {
540 PVCommsIONodeFactory::Delete(iCommServer);
541 iCommServer = NULL;
542 }
543
544 if (iCommServerIOControl)
545 {
546 PvmiMIOCommLoopbackFactory::Delete(iCommServerIOControl);
547 iCommServerIOControl = NULL;
548 }
549 #endif
550 if (iAudioSource)
551 {
552 PvmfMediaInputNodeFactory::Delete(iAudioSource);
553 iAudioSource = NULL;
554 }
555
556 if (iAudioSourceRaw)
557 {
558 PvmfMediaInputNodeFactory::Delete(iAudioSourceRaw);
559 iAudioSourceRaw = NULL;
560 }
561
562 if (iAudioSource2)
563 {
564 PvmfMediaInputNodeFactory::Delete(iAudioSource2);
565 iAudioSource2 = NULL;
566 }
567
568 if (iAudioSource3)
569 {
570 PvmfMediaInputNodeFactory::Delete(iAudioSource3);
571 iAudioSource3 = NULL;
572 }
573
574 if (iAudioSourceIOControl)
575 {
576 PvmiMIOFileInputFactory::Delete(iAudioSourceIOControl);
577 iAudioSourceIOControl = NULL;
578 }
579
580 if (iAudioSourceRawIOControl)
581 {
582 PvmiMIOFileInputFactory::Delete(iAudioSourceRawIOControl);
583 iAudioSourceRawIOControl = NULL;
584 }
585
586 if (iAudioSource2IOControl)
587 {
588 PvmiMIOFileInputFactory::Delete(iAudioSource2IOControl);
589 iAudioSource2IOControl = NULL;
590 }
591
592 if (iAudioSource3IOControl)
593 {
594 PvmiMIOFileInputFactory::Delete(iAudioSource3IOControl);
595 iAudioSource3IOControl = NULL;
596 }
597
598 if (iVideoSourceYUV)
599 {
600 PvmfMediaInputNodeFactory::Delete(iVideoSourceYUV);
601 iVideoSourceYUV = NULL;
602 }
603
604 if (iVideoSourceH263)
605 {
606 PvmfMediaInputNodeFactory::Delete(iVideoSourceH263);
607 iVideoSourceH263 = NULL;
608 }
609
610 if (iVideoSourceM4V)
611 {
612 PvmfMediaInputNodeFactory::Delete(iVideoSourceM4V);
613 iVideoSourceM4V = NULL;
614 }
615
616 if (iVideoSourceYUVIOControl)
617 {
618 PvmiMIOFileInputFactory::Delete(iVideoSourceYUVIOControl);
619 iVideoSourceYUVIOControl = NULL;
620 }
621
622 if (iVideoSourceM4VIOControl)
623 {
624 PvmiMIOFileInputFactory::Delete(iVideoSourceM4VIOControl);
625 iVideoSourceM4VIOControl = NULL;
626 }
627
628 if (iVideoSourceH263IOControl)
629 {
630 PvmiMIOFileInputFactory::Delete(iVideoSourceH263IOControl);
631 iVideoSourceH263IOControl = NULL;
632 }
633
634 if (iAudioSink)
635 {
636 PVMediaOutputNodeFactory::DeleteMediaOutputNode(iAudioSink);
637 iAudioSink = NULL;
638 }
639
640 if (iAudioSinkRaw)
641 {
642 PVMediaOutputNodeFactory::DeleteMediaOutputNode(iAudioSinkRaw);
643 iAudioSinkRaw = NULL;
644 }
645
646 if (iAudioSink2)
647 {
648 PVMediaOutputNodeFactory::DeleteMediaOutputNode(iAudioSink2);
649 iAudioSink2 = NULL;
650 }
651 if (iAudioSinkIOControl)
652 {
653 PvmiMIOFileInputFactory::Delete(iAudioSinkIOControl);
654 iAudioSinkIOControl = NULL;
655 }
656
657 if (iAudioSinkRawIOControl)
658 {
659 PvmiMIOFileInputFactory::Delete(iAudioSinkRawIOControl);
660 iAudioSinkRawIOControl = NULL;
661 }
662
663 if (iAudioSink2IOControl)
664 {
665 PvmiMIOFileInputFactory::Delete(iAudioSinkIOControl);
666 iAudioSink2IOControl = NULL;
667 }
668 if (iVideoSinkYUV)
669 {
670 PVMediaOutputNodeFactory::DeleteMediaOutputNode(iVideoSinkYUV);
671 iVideoSinkYUV = NULL;
672 }
673
674 if (iVideoSinkH263)
675 {
676 PVMediaOutputNodeFactory::DeleteMediaOutputNode(iVideoSinkH263);
677 iVideoSinkH263 = NULL;
678 }
679
680 if (iVideoSinkM4V)
681 {
682 PVMediaOutputNodeFactory::DeleteMediaOutputNode(iVideoSinkM4V);
683 iVideoSinkM4V = NULL;
684 }
685
686 if (iVideoSinkYUVIOControl)
687 {
688 PvmiMIOFileInputFactory::Delete(iVideoSinkYUVIOControl);
689 iVideoSinkYUVIOControl = NULL;
690 }
691
692 if (iVideoSinkM4VIOControl)
693 {
694 PvmiMIOFileInputFactory::Delete(iVideoSinkM4VIOControl);
695 iVideoSinkM4VIOControl = NULL;
696 }
697
698 if (iVideoSinkH263IOControl)
699 {
700 PvmiMIOFileInputFactory::Delete(iVideoSinkH263IOControl);
701 iVideoSinkH263IOControl = NULL;
702 }
703
704 }
705
get_audio_source(PVMFFormatType format)706 PVMFNodeInterface *engine_test::get_audio_source(PVMFFormatType format)
707 {
708 if (format == PVMF_MIME_AMR_IF2)
709 return iAudioSource;
710 else if (format == PVMF_MIME_PCM16)
711 return iAudioSourceRaw;
712 else
713 return NULL;
714
715 }
716
get_audio_sink(PVMFFormatType format)717 PVMFNodeInterface *engine_test::get_audio_sink(PVMFFormatType format)
718 {
719 if (format == PVMF_MIME_AMR_IF2)
720 return iAudioSink;
721 if (format == PVMF_MIME_PCM16)
722 return iAudioSinkRaw;
723 else
724 return NULL;
725 }
726
get_video_source(PVMFFormatType format)727 PVMFNodeInterface *engine_test::get_video_source(PVMFFormatType format)
728 {
729 if (format == PVMF_MIME_YUV420)
730 return iVideoSourceYUV;
731 else if (format == PVMF_MIME_M4V)
732 return iVideoSourceM4V;
733 else if (format == PVMF_MIME_H2632000)
734 return iVideoSourceH263;
735 else
736 return NULL;
737 }
738
get_video_sink(PVMFFormatType format)739 PVMFNodeInterface *engine_test::get_video_sink(PVMFFormatType format)
740 {
741 if (format == PVMF_MIME_YUV420)
742 return iVideoSinkYUV;
743 else if (format == PVMF_MIME_M4V)
744 return iVideoSinkM4V;
745 else if (format == PVMF_MIME_H2632000 || format == PVMF_MIME_H2631998)
746 return iVideoSinkH263;
747 else
748 return NULL;
749 }
750
init_mime_strings()751 void engine_test::init_mime_strings()
752 {
753 }
test_wrapper()754 int test_wrapper()
755 {
756 int result;
757
758 OsclErrorTrap::Init();
759 OsclScheduler::Init("PV2WayEngineFactory");
760
761 result = start_test();
762
763 OsclScheduler::Cleanup();
764 OsclErrorTrap::Cleanup();
765
766 return result;
767 }
768
769
local_main(FILE * filehandle,cmd_line * command_line)770 int local_main(FILE* filehandle, cmd_line *command_line)
771 {
772 OSCL_UNUSED_ARG(command_line);
773 int result;
774 global_cmd_line = command_line;
775
776 fileoutput = filehandle;
777 fprintf(fileoutput, "Test Program for PV Engine class.\n");
778
779 CPV2WayEngineFactory::Init();
780 #ifndef OSCL_BYPASS_MEMMGT
781 #ifndef NDEBUG
782 #ifdef MEM_AUDIT_2WAY
783 OsclAuditCB auditCB;
784 OsclMemInit(auditCB);
785 auditCB.pAudit->MM_SetMode(auditCB.pAudit->MM_GetMode() |
786 MM_AUDIT_VALIDATE_ON_FREE_FLAG | MM_AUDIT_ALLOC_NODE_ENABLE_FLAG);
787 #endif
788 #endif
789 #endif
790 result = test_wrapper();
791
792 PVLogger::Cleanup();
793 #ifndef OSCL_BYPASS_MEMMGT
794 #ifndef NDEBUG
795 #ifdef MEM_AUDIT_2WAY
796 //Check for memory leaks before cleaning up OsclMem.
797
798 uint32 leaks = 0;
799
800 if (auditCB.pAudit)
801 {
802 MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
803 if (stats)
804 {
805 fprintf(fileoutput, "Memory Stats:\n");
806 fprintf(fileoutput, " peakNumAllocs %d\n", stats->peakNumAllocs);
807 fprintf(fileoutput, " peakNumBytes %d\n", stats->peakNumBytes);
808 fprintf(fileoutput, " numAllocFails %d\n", stats->numAllocFails);
809 if (stats->numAllocs)
810 {
811 fprintf(fileoutput, " ERROR: Memory Leaks! numAllocs %d, numBytes %d\n", stats->numAllocs, stats->numBytes);
812 }
813 }
814 leaks = auditCB.pAudit->MM_GetNumAllocNodes();
815 if (leaks != 0)
816 {
817 fprintf(fileoutput, "ERROR: %d Memory leaks detected!\n", leaks);
818 MM_AllocQueryInfo*info = auditCB.pAudit->MM_CreateAllocNodeInfo(leaks);
819 uint32 leakinfo = auditCB.pAudit->MM_GetAllocNodeInfo(info, leaks, 0);
820 if (leakinfo != leaks)
821 {
822 fprintf(fileoutput, "ERROR: Leak info is incomplete.\n");
823 }
824 for (uint32 i = 0; i < leakinfo; i++)
825 {
826 fprintf(fileoutput, "Leak Info:\n");
827 fprintf(fileoutput, " allocNum %d\n", info[i].allocNum);
828 fprintf(fileoutput, " fileName %s\n", info[i].fileName);
829 fprintf(fileoutput, " lineNo %d\n", info[i].lineNo);
830 fprintf(fileoutput, " size %d\n", info[i].size);
831 fprintf(fileoutput, " pMemBlock 0x%x\n", info[i].pMemBlock);
832 fprintf(fileoutput, " tag %s\n", info[i].tag);
833 }
834 auditCB.pAudit->MM_ReleaseAllocNodeInfo(info);
835 }
836 }
837 #endif
838 #endif
839 #endif
840 PVLogger::Init();
841 CPV2WayEngineFactory::Cleanup();
842
843 return (result);
844 }
845
846
start_test()847 int start_test()
848 {
849 int32 leave;
850 engine_test_suite engine_tests;
851
852 OSCL_TRY(leave, engine_tests.run_test());
853
854 if (leave != 0)
855 fprintf(fileoutput, "Leave %d\n", leave);
856
857 text_test_interpreter interp;
858 _STRING rs = interp.interpretation(engine_tests.last_result());
859 fprintf(fileoutput, rs.c_str());
860 const test_result the_result = engine_tests.last_result();
861
862 return(the_result.success_count() != the_result.total_test_count());
863 }
864
865 #if (LINUX_MAIN==1)
866
main(int argc,char * argv[])867 int main(int argc, char *argv[])
868 {
869 local_main(stdout, NULL);
870 return 0;
871 }
872
873 #endif
874
875