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 "oscl_base.h"
19
20 #ifndef TEST_PV_PLAYER_ENGINE_TESTSET5_H_INCLUDED
21 #include "test_pv_player_engine_testset5.h"
22 #endif
23
24 #ifndef OSCL_ERROR_CODES_H_INCLUDED
25 #include "oscl_error_codes.h"
26 #endif
27
28 #ifndef OSCL_TICKCOUNT_H_INCLUDED
29 #include "oscl_tickcount.h"
30 #endif
31
32 #ifndef OSCL_UTF8CONV_H
33 #include "oscl_utf8conv.h"
34 #endif
35
36 #ifndef PV_PLAYER_DATASOURCEURL_H_INCLUDED
37 #include "pv_player_datasourceurl.h"
38 #endif
39
40 #ifndef PV_PLAYER_DATASINKPVMFNODE_H_INCLUDED
41 #include "pv_player_datasinkpvmfnode.h"
42 #endif
43
44 #ifndef PVMI_MEDIA_IO_FILEOUTPUT_H_INCLUDED
45 #include "pvmi_media_io_fileoutput.h"
46 #endif
47
48 #ifndef PV_MEDIA_OUTPUT_NODE_FACTORY_H_INCLUDED
49 #include "pv_media_output_node_factory.h"
50 #endif
51
52 #ifndef PVMF_DOWNLOAD_DATA_SOURCE_H_INCLUDED
53 #include "pvmf_download_data_source.h"
54 #endif
55 #include "pvmf_source_context_data.h"
56
57 #ifndef PVMF_CPMPLUGIN_PASSTHRU_OMA1_FACTORY_H_INCLUDED
58 #include "pvmf_cpmplugin_passthru_oma1_factory.h"
59 #endif
60
61 #ifndef PVMF_CPMPLUGIN_PASSTHRU_OMA1_TYPES_H_INCLUDED
62 #include "pvmf_cpmplugin_passthru_oma1_types.h"
63 #endif
64
65 #ifndef PVMF_DURATIONINFOMESSAGE_EXTENSION_H_INCLUDED
66 #include "pvmf_durationinfomessage_extension.h"
67 #endif
68
69 #ifndef PVMF_ERRORINFOMESSAGE_EXTENSION_H_INCLUDED
70 #include "pvmf_errorinfomessage_extension.h"
71 #endif
72
73 #ifndef PVMF_MP4FFPARSER_EVENTS_H_INCLUDED
74 #include "pvmf_mp4ffparser_events.h"
75 #endif
76
77 #ifndef PVMF_FILEFORMAT_EVENTS_H_INCLUDED
78 #include "pvmf_fileformat_events.h"
79 #endif
80
81 #ifndef PVMI_KVP_H_INCLUDED
82 #include "pvmi_kvp.h"
83 #endif
84
85 #ifndef PVMI_KVP_UTIL_H_INCLUDED
86 #include "pvmi_kvp_util.h"
87 #endif
88
89 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED
90 #include "pvmf_node_interface.h"
91 #endif
92
93 #ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
94 #include "pvmi_config_and_capability.h"
95 #endif
96
97 #ifndef PVMF_PROTOCOL_ENGINE_NODE_EVENTS_H_INCLUDED
98 #include "pvmf_protocol_engine_node_events.h"
99 #endif
100
101 #ifndef PVMF_SOCKET_NODE_EVENTS_H_INCLUDED
102 #include "pvmf_socket_node_events.h"
103 #endif
104
105 #ifndef PVMF_METADTA_INFOMESSAGE_H
106 #include "pvmf_metadata_infomessage.h"
107 #endif
108
109 #if(RUN_CPMJANUS_TESTCASES)
110
111 #ifndef PVMF_JANUS_TYPES_H_INCLUDED
112 #include "pvmf_janus_types.h"
113 #endif
114
115 #if !(JANUS_IS_LOADABLE_MODULE)
116 #ifndef PVMF_JANUS_PLUGIN_FACTORY_H_INCLUDED
117 #include "pvmf_janus_plugin_factory.h"
118 #endif
119 #endif
120
121 #ifndef PVMI_DRM_KVP_H_INCLUDED
122 #include "pvmi_drm_kvp.h"
123 #endif
124
125 #ifndef TEST_PV_PLAYER_ENGINE_TESTSET_CPMJANUS_TYPES_H_INCLUDED
126 #include "test_pv_player_engine_testset_cpmjanus_types.h"
127 #endif
128 #endif//RUN_CPMJANUS_TESTCASES
129
130
131 //Default Fast-track download file
132 #define DEFAULT_FASTTRACK_DL_FILE "test.pvx"
133
134 //Default 3gpp download URL, in both single and wide-char versions.
135 #if(RUN_MP4FILE_TESTCASES)
136 #undef DEFAULT_3GPPDL_URL
137 #define DEFAULT_3GPPDL_URL "http://pvwmsoha.pv.com:7070/MediaDownloadContent/MP4/prog_dl/mpeg4+aac_metadata_qt.mp4"
138 //#define DEFAULT_3GPPDL_URL "http://pvwmsoha.pv.com:7070/MediaDownloadContent/MP4/prog_dl/ec36-av-clon-100-10-h176x144p-uc-g7a24;16s-rvdqmt.mp4"
139 #elif(RUN_ASFFILE_TESTCASES)
140 #undef DEFAULT_3GPPDL_URL
141 #define DEFAULT_3GPPDL_URL "http://pvwmsoha.pv.com:7070/MediaDownloadContent/UserUploads/av5.wmv"
142 #endif
143
144 #if(RUN_ASFFILE_TESTCASES)
145 //For slow download use this one
146 #define DEFAULT_3GPPDL_URL_SLOW "http://reallinux.pv.com:1415/av5.wmv?bitrate=100000"
147 #elif (RUN_MP4FILE_TESTCASES)
148 #define DEFAULT_3GPPDL_URL_SLOW "http://reallinux.pv.com:1415/at_vh264qc128_1_amr_12.2_of.3gp?bitrate=100000"
149 #endif
150
151 //Default Bad URL for the error-case test
152 #define DEFAULT_BADURL "http://reallinux.pv.com:1415/xxxxx_320x240_15fps_200kbps_wmv7.wmv"
153
154 #define DEFAULT_TRUNCATED_TEST_URL "http://reallinux.pv.com:1415/av5.wmv?no_content_length=true"
155
156 #define DEFAULT_CANCEL_DURING_INIT_TEST_URL "http://reallinux.pv.com:1415/av5.wmv?bitrate=1000"
157
158 #define DEFAULT_CANCEL_DURING_INIT_DELAY_TEST_URL "http://reallinux.pv.com:1415/blz4-110302-aac-h263.mp4?bitrate=1000000"
159
160 #define DEFAULT_3GPP_PPB_URL "http://wms.pv.com:7070/MediaDownloadContent/UserUploads/youtube_singer.3gp"
161
162 #define DEFAULT_SHOUTCAST_URL "http://scfire-dtc-aa05.stream.aol.com/stream/1018"
163
164 extern FILE* file;
165
166
167
168 //#define USING_PROXY
169
170 //
171 //pvplayer_async_test_downloadbase section
172 //
~pvplayer_async_test_downloadbase()173 pvplayer_async_test_downloadbase::~pvplayer_async_test_downloadbase()
174 {
175 delete iDownloadContextData;
176 }
177
PrintMetadata()178 void pvplayer_async_test_downloadbase::PrintMetadata()
179 {
180 for (uint32 i = 0; i < iMetadataValueList.size(); i++)
181 {
182 if (!iMetadataValueList[i].key)
183 {
184 fprintf(file, " Metadata Key Missing!, value ?\n");
185 PVPATB_TEST_IS_TRUE(false);
186 }
187 else if (oscl_strstr(iMetadataValueList[i].key, "valtype=char*"))
188 {
189 fprintf(file, " Metadata Key '%s', value '%s'\n", iMetadataValueList[i].key, iMetadataValueList[i].value.pChar_value);
190 }
191 else if (oscl_strstr(iMetadataValueList[i].key, "valtype=wchar*"))
192 {
193 OSCL_HeapString<OsclMemAllocator> ostr;
194 char buf[2];
195 buf[1] = '\0';
196 for (uint32 j = 0;; j++)
197 {
198 if (iMetadataValueList[i].value.pWChar_value[j] == '\0')
199 break;
200 buf[0] = iMetadataValueList[i].value.pWChar_value[j];
201 ostr += buf;
202 }
203 fprintf(file, " Metadata Key '%s', value '%s'\n", iMetadataValueList[i].key, ostr.get_str());
204 }
205 else if (oscl_strstr(iMetadataValueList[i].key, "valtype=uint32"))
206 {
207 fprintf(file, " Metadata Key '%s', value %d\n", iMetadataValueList[i].key, iMetadataValueList[i].value.uint32_value);
208 }
209 else if (oscl_strstr(iMetadataValueList[i].key, "valtype=bool"))
210 {
211 fprintf(file, " Metadata Key '%s', value %d\n", iMetadataValueList[i].key, iMetadataValueList[i].value.bool_value);
212 }
213 else if (oscl_strstr(iMetadataValueList[i].key, "valtype=uint8*"))
214 {
215 fprintf(file, " Metadata Key '%s', len %d\n", iMetadataValueList[i].key, iMetadataValueList[i].length);
216 }
217 else
218 {
219 fprintf(file, " Metadata Key '%s', value ?\n", iMetadataValueList[i].key);
220 }
221 if ((oscl_strstr(iMetadataValueList[i].key, "duration")) && iSessionDuration == 0)
222 {
223 iSessionDuration = iMetadataValueList[i].value.uint32_value;
224
225 // Check the timescale. If not available, assume millisecond (1000)
226 const char *retTSstr;
227 retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
228 uint32 retTSstrLen = 0;
229 uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
230 if (retTSstr != NULL)
231 {
232 retTSstrLen = oscl_strlen(retTSstr);
233 if (retTSstrLen > tsstrlen)
234 {
235 uint32 timescale = 0;
236 PV_atoi((char*)(retTSstr + tsstrlen), 'd', (retTSstrLen - tsstrlen), timescale);
237 if (timescale > 0 && timescale != 1000)
238 {
239 // Convert to milliseconds
240 MediaClockConverter mcc(timescale);
241 mcc.update_clock(iSessionDuration);
242 iSessionDuration = mcc.get_converted_ts(1000);
243 }
244 }
245 }
246 }
247 }
248 fprintf(file, "\n\n");
249 }
250
StartTest()251 void pvplayer_async_test_downloadbase::StartTest()
252 {
253 AddToScheduler();
254 iState = STATE_CREATE;
255 RunIfNotReady();
256 }
257
258
Run()259 void pvplayer_async_test_downloadbase::Run()
260 {
261 int error = 0;
262
263 switch (iState)
264 {
265 case STATE_CREATE:
266 {
267 iPlayer = NULL;
268
269 OSCL_TRY(error, iPlayer = PVPlayerFactory::CreatePlayer(this, this, this));
270 if (error)
271 {
272 PVPATB_TEST_IS_TRUE(false);
273 iObserver->TestCompleted(*iTestCase);
274 }
275 else
276 {
277 iState = STATE_QUERYINTERFACE;
278 RunIfNotReady();
279 }
280 }
281 break;
282
283 case STATE_QUERYINTERFACE:
284 {
285 fprintf(iTestMsgOutputFile, "***Query Interface...\n");
286 PVUuid capconfigifuuid = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
287 OSCL_TRY(error, iCurrentCmdId = iPlayer->QueryInterface(capconfigifuuid, (PVInterface*&)iPlayerCapConfigIF, (OsclAny*) & iContextObject));
288 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
289 }
290 break;
291
292 case STATE_ADDDATASOURCE:
293 CreateDataSource();
294 OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
295 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
296 break;
297
298 case STATE_CONFIGPARAMS:
299 {
300 fprintf(iTestMsgOutputFile, "***Configuring Params...\n");
301
302 //set user-agent, make sure to set as "PVPLAYER VersionNumber" to satisfy Fast Track PV server for Fast Track test
303
304 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*;mode=download");
305 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
306
307 // OSCL_wHeapString<OsclMemAllocator> userAgent(_STRLIT_WCHAR("PVPLAYER 18akljfaljfa"));
308 OSCL_wHeapString<OsclMemAllocator> userAgent(_STRLIT_WCHAR("PVPLAYER 18.07.00.02"));
309 iKVPSetAsync.value.pWChar_value = userAgent.get_str();
310 iErrorKVP = NULL;
311 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
312 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
313
314 // set http version number
315 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/http-version;valtype=uint32");
316 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
317 iKVPSetAsync.value.uint32_value = 0;
318 iErrorKVP = NULL;
319 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
320 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
321
322 // set http timeout
323 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/http-timeout;valtype=uint32");
324 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
325 iKVPSetAsync.value.uint32_value = 20;
326 iErrorKVP = NULL;
327 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
328 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
329
330 // set number of redirects
331 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/num-redirect-attempts;valtype=uint32");
332 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
333 iKVPSetAsync.value.uint32_value = 4;
334 iErrorKVP = NULL;
335 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
336 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
337
338 // set extension header
339 // set arbitrary extension header one by one
340 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*");
341 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
342 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeader(_STRLIT_CHAR("key=PVPlayerCoreEngineTest;value=Test;method=GET,HEAD"));
343 iKVPSetAsync.value.pChar_value = protocolExtensionHeader.get_str();
344 iKVPSetAsync.capacity = protocolExtensionHeader.get_size();
345 iErrorKVP = NULL;
346 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
347 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
348
349 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*");
350 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
351 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderGet(_STRLIT_CHAR("key=PVPlayerCoreEngineTest;value=GetHeader;method=GET"));
352 iKVPSetAsync.value.pChar_value = protocolExtensionHeaderGet.get_str();
353 iKVPSetAsync.capacity = protocolExtensionHeaderGet.get_size();
354 iErrorKVP = NULL;
355 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
356 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
357
358 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*");
359 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
360 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderHead(_STRLIT_CHAR("key=PVPlayerCoreEngineTest;value=HeadHeader;method=HEAD"));
361 iKVPSetAsync.value.pChar_value = protocolExtensionHeaderHead.get_str();
362 iKVPSetAsync.capacity = protocolExtensionHeaderHead.get_size();
363 iErrorKVP = NULL;
364 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
365 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
366
367 // Unnecessary Header should not display
368 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*");
369 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
370 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderPost(_STRLIT_CHAR("key=PVPlayerCoreEngineTest;value=PostHeader;method=POST"));
371 iKVPSetAsync.value.pChar_value = protocolExtensionHeaderPost.get_str();
372 iKVPSetAsync.capacity = protocolExtensionHeaderPost.get_size();
373 iErrorKVP = NULL;
374 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
375 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
376
377
378 // set extension header
379 // set arbitrary extension headers all together
380 PvmiKvp kvpheader[3];
381 //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=download"));
382 OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=download;purge-on-redirect"));
383 //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;purge-on-redirect"));
384 //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*"));
385 //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=streaming"));
386
387
388 kvpheader[0].key = paramkey.get_str();
389 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeader1(_STRLIT_CHAR("key=X1;value=Y1;method=GET,HEAD"));
390 kvpheader[0].value.pChar_value = protocolExtensionHeader1.get_str();
391 kvpheader[0].capacity = protocolExtensionHeader1.get_size();
392
393 kvpheader[1].key = paramkey.get_str();
394 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderGet1(_STRLIT_CHAR("key=X2;value=Y2;method=GET"));
395 kvpheader[1].value.pChar_value = protocolExtensionHeaderGet1.get_str();
396 kvpheader[1].capacity = protocolExtensionHeaderGet1.get_size();
397
398 kvpheader[2].key = paramkey.get_str();
399 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderHead1(_STRLIT_CHAR("key=X3;value=Y3;method=HEAD"));
400 kvpheader[2].value.pChar_value = protocolExtensionHeaderHead1.get_str();
401 kvpheader[2].capacity = protocolExtensionHeaderHead1.get_size();
402
403 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, kvpheader, 3, iErrorKVP));
404 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
405
406 // enable or disable HEAD request
407 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/http-header-request-disabled;valtype=bool");
408 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
409 iKVPSetAsync.value.bool_value = true;
410 iErrorKVP = NULL;
411 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
412 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
413
414 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/max-tcp-recv-buffer-size-download;valtype=uint32");
415 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
416 iKVPSetAsync.value.uint32_value = 64000;
417 iErrorKVP = NULL;
418 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
419 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
420
421 //set number of TCP recv buffers for progressive playback.
422 if (iDownloadContextData
423 && iDownloadContextData->DownloadHTTPData()
424 && iDownloadContextData->DownloadHTTPData()->iPlaybackControl == PVMFSourceContextDataDownloadHTTP::ENoSaveToFile)
425 {
426 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/max-tcp-recv-buffer-count-download;valtype=uint32");
427 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
428 iKVPSetAsync.value.uint32_value = 8;
429 iErrorKVP = NULL;
430 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
431 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
432 }
433
434 /////////////////////////////////////////////////////////
435 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;purge-on-redirect");
436 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
437 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderCookie(_STRLIT_CHAR("key=Cookie; value=key1=value1; key2=value2"));
438 iKVPSetAsync.value.pChar_value = protocolExtensionHeaderCookie.get_str();
439 iKVPSetAsync.capacity = protocolExtensionHeaderCookie.get_size();
440 iErrorKVP = NULL;
441 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
442 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
443 /////////////////////////////////////////////////////////
444
445
446 iState = STATE_INIT;
447 RunIfNotReady();
448 }
449 break;
450
451 case STATE_INIT:
452 {
453 OSCL_TRY(error, iCurrentCmdId = iPlayer->Init((OsclAny*) & iContextObject));
454 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
455 }
456 break;
457
458 case STATE_WAIT_FOR_BUFFCOMPLETE:
459 if (iNumBufferingComplete > 0)
460 {
461 //Download is complete!
462 if (iDownloadOnly)
463 {
464 //download-only cases can finish now.
465 iState = STATE_RESET;
466 RunIfNotReady();
467 }
468 else
469 {
470 if (iPauseAfterDownloadComplete == true)
471 {
472 iState = STATE_PAUSE;
473 RunIfNotReady(5*1000*1000);
474 }
475 else if (iRepositionAfterDownloadComplete == true)
476 {
477 iState = STATE_SETPLAYBACKRANGE;
478 RunIfNotReady();
479 }
480 else
481 {
482 //playback cases play 10 more seconds then stop.
483 iState = STATE_STOP;
484 if (iPlayUntilEOS == false)
485 {
486 RunIfNotReady(10*1000*1000);
487 }
488 else
489 {
490 //wait for EOS
491 }
492 if (iPauseResumeAfterUnderflow == true)
493 {
494 fprintf(file, "\n Buffering Complete before Underflow event, pass the test case but Scenario not tested\n\n");
495 // pass the test case but scenario is not tested, print a message for the user,
496 // now either play for 5 seconds or wait till the EOS.
497 }
498 }
499 }
500 }
501 else
502 {
503 //timed out while waiting.
504 PVPATB_TEST_IS_TRUE(false);
505 iState = STATE_CLEANUPANDCOMPLETE;
506 RunIfNotReady();
507 }
508 break;
509
510 case STATE_ADDDATASINK_VIDEO:
511 {
512 CreateDataSinkVideo();
513 OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
514 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
515 }
516 break;
517
518
519 case STATE_ADDDATASINK_AUDIO:
520 {
521 CreateDataSinkAudio();
522 OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
523 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
524 }
525 break;
526
527 case STATE_PREPARE:
528 case STATE_PREPARE2:
529 {
530 fprintf(iTestMsgOutputFile, "***Preparing\n");
531 OSCL_TRY(error, iCurrentCmdId = iPlayer->Prepare((OsclAny*) & iContextObject));
532 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
533 }
534 break;
535
536 case STATE_GETMETADATAKEYLIST:
537 {
538 iMetadataKeyList.clear();
539 OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataKeys(iMetadataKeyList, 0, 100, NULL, (OsclAny*) & iContextObject));
540 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
541 }
542 break;
543
544 case STATE_GETMETADATAVALUELIST:
545 {
546 iMetadataValueList.clear();
547 iNumValues = 0;
548 OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, 100, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
549 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
550 }
551 break;
552
553 case STATE_WAIT_FOR_DATAREADY:
554 {
555 if (iNumDataReady > 0)
556 {
557 //playback cases wait on data ready, then start engine.
558 iState = STATE_START;
559 RunIfNotReady();
560 }
561 else
562 {
563 //timed out while waiting.
564 PVPATB_TEST_IS_TRUE(false);
565 iState = STATE_CLEANUPANDCOMPLETE;
566 RunIfNotReady();
567 }
568 }
569 break;
570
571 case STATE_START:
572 case STATE_START2:
573 {
574 fprintf(iTestMsgOutputFile, "***Starting\n");
575 OSCL_TRY(error, iCurrentCmdId = iPlayer->Start((OsclAny*) & iContextObject));
576 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
577 }
578 break;
579
580 case STATE_PAUSE:
581 {
582 fprintf(iTestMsgOutputFile, "***Pausing\n");
583 OSCL_TRY(error, iCurrentCmdId = iPlayer->Pause((OsclAny*) & iContextObject));
584 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
585 }
586 break;
587
588 case STATE_RESUME:
589 {
590 fprintf(iTestMsgOutputFile, "***Resuming...\n");
591 OSCL_TRY(error, iCurrentCmdId = iPlayer->Resume((OsclAny*) & iContextObject));
592 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
593 }
594 break;
595
596 case STATE_SETPLAYBACKRANGE:
597 {
598 if (iSessionDuration > 0)
599 {
600 fprintf(iTestMsgOutputFile, "***Repositioning to %d ms\n", (iSessionDuration / 4));
601 PVPPlaybackPosition start, end;
602 start.iIndeterminate = false;
603 start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
604 start.iMode = PVPPBPOS_MODE_NOW;
605 start.iPosValue.millisec_value = iSessionDuration / 4;
606 end.iIndeterminate = true;
607 OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
608 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
609 }
610 else
611 {
612 fprintf(iTestMsgOutputFile, "***Set PlayBack Range Not Supported for a session with unknown duration...\n");
613 //just play for 10 seconds then stop
614 iState = STATE_STOP;
615 RunIfNotReady(10*1000*1000);
616 }
617 }
618 break;
619
620 case STATE_STOP:
621 case STATE_STOP2:
622 {
623 fprintf(iTestMsgOutputFile, "***Stopping\n");
624 OSCL_TRY(error, iCurrentCmdId = iPlayer->Stop((OsclAny*) & iContextObject));
625 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
626 }
627 break;
628
629 case STATE_REMOVEDATASINK_VIDEO:
630 {
631 OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
632 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
633 }
634 break;
635
636 case STATE_REMOVEDATASINK_AUDIO:
637 {
638 OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
639 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
640 }
641 break;
642
643 case STATE_RESET:
644 {
645 fprintf(iTestMsgOutputFile, "***Resetting\n");
646 OSCL_TRY(error, iCurrentCmdId = iPlayer->Reset((OsclAny*) & iContextObject));
647 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
648 }
649 break;
650
651 case STATE_REMOVEDATASOURCE:
652 {
653 OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
654 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
655 }
656 break;
657
658 case STATE_CLEANUPANDCOMPLETE:
659 {
660 fprintf(file, "Events:\n");
661 fprintf(file, " Num BuffStart %d\n", iNumBufferingStart);
662 fprintf(file, " Num BuffComplete %d\n", iNumBufferingComplete);
663 fprintf(file, " Num Data Ready %d\n", iNumDataReady);
664 fprintf(file, " Num Underflow %d\n", iNumUnderflow);
665
666 PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
667 iPlayer = NULL;
668
669 delete iDataSource;
670 iDataSource = NULL;
671
672 delete iDataSinkVideo;
673 iDataSinkVideo = NULL;
674
675 delete iDataSinkAudio;
676 iDataSinkAudio = NULL;
677
678 PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeVideo);
679 iIONodeVideo = NULL;
680
681 PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeAudio);
682 iIONodeAudio = NULL;
683
684 iMioFactory->DestroyVideoOutput(iMIOFileOutVideo);
685 iMIOFileOutVideo = NULL;
686
687 iMioFactory->DestroyAudioOutput(iMIOFileOutAudio);
688 iMIOFileOutAudio = NULL;
689
690 //call the test-case specific cleanup.
691 CleanupData();
692
693 iObserver->TestCompleted(*iTestCase);
694 }
695 break;
696 case STATE_CANCELALL: //Added for the derived class pvplayer_async_test_cnclall_prtcl_rllovr
697 {
698 fprintf(iTestMsgOutputFile, "***CancelAllCommands...\n");
699 OSCL_TRY(error, iCancelAllCmdId = iPlayer->CancelAllCommands((OsclAny*) & iContextObject));
700 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
701 iState = STATE_WAIT_FOR_CANCELALL;
702 RunIfNotReady(1000 * 1000 * 10); //if cancell all doesnt get completed in 10 sec, assume failure
703 }
704 break;
705 case STATE_WAIT_FOR_CANCELALL:
706 {
707 fprintf(iTestMsgOutputFile, "***Cancel did not complete in time...\n");
708 // Cancel did not complete in time
709 PVPATB_TEST_IS_TRUE(false);
710 iState = STATE_CLEANUPANDCOMPLETE;
711 RunIfNotReady();
712 }
713 break;
714 default:
715 break;
716
717 }
718 }
719
720
CommandCompleted(const PVCmdResponse & aResponse)721 void pvplayer_async_test_downloadbase::CommandCompleted(const PVCmdResponse& aResponse)
722 {
723 if (aResponse.GetCmdId() != iCurrentCmdId)
724 {
725 // Wrong command ID.
726 PVPATB_TEST_IS_TRUE(false);
727 iState = STATE_CLEANUPANDCOMPLETE;
728 RunIfNotReady();
729 return;
730 }
731
732 if (aResponse.GetContext() != NULL)
733 {
734 if (aResponse.GetContext() == (OsclAny*)&iContextObject)
735 {
736 if (iContextObject != iContextObjectRefValue)
737 {
738 // Context data value was corrupted
739 PVPATB_TEST_IS_TRUE(false);
740 iState = STATE_CLEANUPANDCOMPLETE;
741 RunIfNotReady();
742 return;
743 }
744 }
745 else
746 {
747 // Context data pointer was corrupted
748 PVPATB_TEST_IS_TRUE(false);
749 iState = STATE_CLEANUPANDCOMPLETE;
750 RunIfNotReady();
751 return;
752 }
753 }
754
755 //#if(RUN_CPMJANUS_TESTCASES)
756
757 switch (iState)
758 {
759 case STATE_QUERYINTERFACE:
760 if (aResponse.GetCmdStatus() == PVMFSuccess)
761 {
762 iState = STATE_ADDDATASOURCE;
763 RunIfNotReady();
764 }
765 else
766 {
767 // QueryInterface failed
768 PVPATB_TEST_IS_TRUE(false);
769 iState = STATE_CLEANUPANDCOMPLETE;
770 RunIfNotReady();
771 }
772 break;
773
774 case STATE_ADDDATASOURCE:
775 if (aResponse.GetCmdStatus() == PVMFSuccess)
776 {
777 iState = STATE_CONFIGPARAMS;
778 RunIfNotReady();
779 }
780 else
781 {
782 // AddDataSource failed
783 PVPATB_TEST_IS_TRUE(false);
784 iState = STATE_CLEANUPANDCOMPLETE;
785 RunIfNotReady();
786 }
787 break;
788
789 case STATE_CONFIGPARAMS:
790 iState = STATE_INIT;
791 RunIfNotReady();
792 break;
793
794 case STATE_INIT:
795 if (aResponse.GetCmdStatus() == PVMFSuccess)
796 {
797 if (iDownloadOnly)
798 {
799 //For download-only, just wait on the buffering complete event
800 //and then reset engine.
801 if (iNumBufferingComplete > 0)
802 {
803 //If the clip is really short it's possible it may
804 //already be downloaded by now.
805 iState = STATE_RESET;
806 RunIfNotReady();
807 }
808 else
809 {
810 //wait on download to complete.
811 fprintf(file, "***Wait for BufferingComplete...\n");
812 iState = STATE_WAIT_FOR_BUFFCOMPLETE;
813 if (iPlayUntilEOS == false)
814 {
815 //5 minute error timeout
816 RunIfNotReady(5*60*1000*1000);
817 }
818 }
819 }
820 else
821 {
822 //normal playback case, continue to add data sinks.
823 iState = STATE_ADDDATASINK_VIDEO;
824 RunIfNotReady();
825 }
826 }
827 else
828 {
829 if ((iContentTooLarge) &&
830 (aResponse.GetCmdStatus() == PVMFErrContentTooLarge))
831 {
832 // Test success in this case
833 fprintf(file, " INIT returned PVMFErrContentTooLarge\n");
834 PVPATB_TEST_IS_TRUE(true);
835 iState = STATE_REMOVEDATASOURCE;
836 RunIfNotReady();
837 }
838 else
839 {
840 // Init failed
841 PVPATB_TEST_IS_TRUE(false);
842 iState = STATE_CLEANUPANDCOMPLETE;
843 RunIfNotReady();
844 }
845 }
846 break;
847
848 case STATE_ADDDATASINK_VIDEO:
849 if (aResponse.GetCmdStatus() == PVMFSuccess)
850 {
851 iState = STATE_ADDDATASINK_AUDIO;
852 RunIfNotReady();
853 }
854 else
855 {
856 // AddDataSink failed
857 PVPATB_TEST_IS_TRUE(false);
858 iState = STATE_CLEANUPANDCOMPLETE;
859 RunIfNotReady();
860 }
861 break;
862
863 case STATE_ADDDATASINK_AUDIO:
864 if (aResponse.GetCmdStatus() == PVMFSuccess)
865 {
866 iState = STATE_PREPARE;
867 RunIfNotReady();
868 }
869 else
870 {
871 // AddDataSink failed
872 PVPATB_TEST_IS_TRUE(false);
873 iState = STATE_CLEANUPANDCOMPLETE;
874 RunIfNotReady();
875 }
876 break;
877
878 case STATE_PREPARE:
879 if (aResponse.GetCmdStatus() == PVMFSuccess)
880 {
881 iState = STATE_GETMETADATAKEYLIST;
882 RunIfNotReady();
883 }
884 else
885 {
886 // Prepare failed
887 PVPATB_TEST_IS_TRUE(false);
888 iState = STATE_CLEANUPANDCOMPLETE;
889 RunIfNotReady();
890 }
891 break;
892
893 case STATE_PREPARE2:
894 if (aResponse.GetCmdStatus() == PVMFSuccess)
895 {
896 iState = STATE_START2;
897 RunIfNotReady();
898 }
899 else
900 {
901 // Prepare failed
902 PVPATB_TEST_IS_TRUE(false);
903 iState = STATE_CLEANUPANDCOMPLETE;
904 RunIfNotReady();
905 }
906 break;
907
908 case STATE_WAIT_FOR_DATAREADY:
909 case STATE_WAIT_FOR_BUFFCOMPLETE:
910 //shouldn't get here-- there are no engine commands active in this state.
911 PVPATB_TEST_IS_TRUE(false);
912 break;
913
914 case STATE_GETMETADATAKEYLIST:
915 if (aResponse.GetCmdStatus() == PVMFSuccess || aResponse.GetCmdStatus() == PVMFErrArgument)
916 {
917 iState = STATE_GETMETADATAVALUELIST;
918 RunIfNotReady();
919 }
920 else
921 {
922 // GetMetadataKeys failed
923 PVPATB_TEST_IS_TRUE(false);
924 iState = STATE_CLEANUPANDCOMPLETE;
925 RunIfNotReady();
926 }
927 break;
928
929 case STATE_GETMETADATAVALUELIST:
930 if (aResponse.GetCmdStatus() == PVMFSuccess || aResponse.GetCmdStatus() == PVMFErrArgument)
931 {
932 //Display the resulting metadata.
933 PrintMetadata();
934
935 //wait for data ready, unless we already got it.
936 if (iNumDataReady > 0)
937 {
938 iState = STATE_START;
939 RunIfNotReady();
940 }
941 else
942 {
943 fprintf(file, "***Wait for DataReady...\n");
944 iState = STATE_WAIT_FOR_DATAREADY;
945 if (iPlayUntilEOS == false)
946 {
947 //5 minute error timeout
948 RunIfNotReady(5*60*1000*1000);
949 }
950 }
951 }
952 else
953 {
954 // GetMetadataValue failed
955 PVPATB_TEST_IS_TRUE(false);
956 iState = STATE_CLEANUPANDCOMPLETE;
957 RunIfNotReady();
958 }
959 break;
960
961 case STATE_START:
962 if (aResponse.GetCmdStatus() == PVMFSuccess)
963 {
964 if (iPlayStopPlay)
965 {
966 //play for 10 seconds then stop
967 iState = STATE_STOP;
968 RunIfNotReady(10*1000*1000);
969 break;
970 }
971 if (iProgPlayback)
972 {
973 //play for 10 seconds or until EOS.
974 iState = STATE_STOP;
975 if (!iPlayUntilEOS)
976 RunIfNotReady(10*1000*1000);
977 break;
978 }
979 //most other cases wait for buff complete.
980 if (iNumBufferingComplete)
981 {
982 if (iDownloadThenPlay)
983 {
984 if (iPauseAfterDownloadComplete)
985 {
986 //play for 5 sec then pause
987 iState = STATE_PAUSE;
988 RunIfNotReady(5*1000*1000);
989 break;
990 }
991 else if (iRepositionAfterDownloadComplete)
992 {
993 //play for 5 sec then repos
994 iState = STATE_SETPLAYBACKRANGE;
995 RunIfNotReady(5*1000*1000);
996 break;
997 }
998 }
999 //play for 10 sec or until EOS.
1000 iState = STATE_STOP;
1001 if (!iPlayUntilEOS)
1002 RunIfNotReady(10*1000*1000);
1003 break;
1004 }
1005 else
1006 {
1007 //wait for buff complete
1008 iState = STATE_WAIT_FOR_BUFFCOMPLETE;
1009 if (!iPlayUntilEOS)
1010 {
1011 //5 minute error timeout to avoid test case hang.
1012 RunIfNotReady(5*60*1000*1000);
1013 break;
1014 }
1015 }
1016 }
1017 else
1018 {
1019 // Start failed
1020 PVPATB_TEST_IS_TRUE(false);
1021 iState = STATE_CLEANUPANDCOMPLETE;
1022 RunIfNotReady();
1023 }
1024 break;
1025
1026 case STATE_START2:
1027 if (aResponse.GetCmdStatus() == PVMFSuccess)
1028 {
1029 //play for 10 seconds then stop
1030 iState = STATE_STOP2;
1031 RunIfNotReady(10*1000*1000);
1032 break;
1033 }
1034 else
1035 {
1036 // Start failed
1037 PVPATB_TEST_IS_TRUE(false);
1038 iState = STATE_CLEANUPANDCOMPLETE;
1039 RunIfNotReady();
1040 }
1041 break;
1042
1043 case STATE_PAUSE:
1044 if (aResponse.GetCmdStatus() == PVMFSuccess)
1045 {
1046 iState = STATE_RESUME;
1047 if (iPauseResumeAfterUnderflow == true)
1048 RunIfNotReady();
1049 else
1050 /* Stay paused for 10 seconds */
1051 RunIfNotReady(5*1000*1000);
1052 }
1053 else
1054 {
1055 // Pause failed
1056 PVPATB_TEST_IS_TRUE(false);
1057 iState = STATE_CLEANUPANDCOMPLETE;
1058 RunIfNotReady();
1059 }
1060 break;
1061
1062 case STATE_RESUME:
1063 if (aResponse.GetCmdStatus() == PVMFSuccess)
1064 {
1065 if (iPauseResumeAfterUnderflow == false)
1066 {
1067 iState = STATE_STOP;
1068 if (iPlayUntilEOS == false)
1069 {
1070 //just play for 10 seconds then stop
1071 RunIfNotReady(10*1000*1000);
1072 }
1073 else
1074 {
1075 // wait for EOS
1076 }
1077 }
1078 }
1079 else
1080 {
1081 // Resume failed
1082 PVPATB_TEST_IS_TRUE(false);
1083 iState = STATE_CLEANUPANDCOMPLETE;
1084 RunIfNotReady();
1085 }
1086 break;
1087
1088 case STATE_SETPLAYBACKRANGE:
1089 if (aResponse.GetCmdStatus() == PVMFSuccess)
1090 {
1091 fprintf(iTestMsgOutputFile, "***Repositioning Success...\n");
1092 //just play for 10 seconds then stop
1093 iState = STATE_STOP;
1094 RunIfNotReady(10*1000*1000);
1095 }
1096 else
1097 {
1098 fprintf(iTestMsgOutputFile, "***Repositioning Failed...\n");
1099 // Repos failed
1100 PVPATB_TEST_IS_TRUE(false);
1101 iState = STATE_CLEANUPANDCOMPLETE;
1102 RunIfNotReady();
1103 }
1104 break;
1105
1106 case STATE_STOP:
1107 if (aResponse.GetCmdStatus() == PVMFSuccess)
1108 {
1109 if (iPlayStopPlay)
1110 {
1111 iState = STATE_PREPARE2;
1112 RunIfNotReady();
1113 break;
1114 }
1115 iState = STATE_REMOVEDATASINK_VIDEO;
1116 RunIfNotReady();
1117 }
1118 else
1119 {
1120 PVPATB_TEST_IS_TRUE(false);
1121 iState = STATE_CLEANUPANDCOMPLETE;
1122 RunIfNotReady();
1123 }
1124 break;
1125
1126 case STATE_STOP2:
1127 if (aResponse.GetCmdStatus() == PVMFSuccess)
1128 {
1129 iState = STATE_REMOVEDATASINK_VIDEO;
1130 RunIfNotReady();
1131 }
1132 else
1133 {
1134 PVPATB_TEST_IS_TRUE(false);
1135 iState = STATE_CLEANUPANDCOMPLETE;
1136 RunIfNotReady();
1137 }
1138 break;
1139
1140 case STATE_REMOVEDATASINK_VIDEO:
1141 if (aResponse.GetCmdStatus() == PVMFSuccess)
1142 {
1143 iState = STATE_REMOVEDATASINK_AUDIO;
1144 RunIfNotReady();
1145 }
1146 else
1147 {
1148 // RemoveDataSink failed
1149 PVPATB_TEST_IS_TRUE(false);
1150 iState = STATE_CLEANUPANDCOMPLETE;
1151 RunIfNotReady();
1152 }
1153 break;
1154
1155 case STATE_REMOVEDATASINK_AUDIO:
1156 if (aResponse.GetCmdStatus() == PVMFSuccess)
1157 {
1158 iState = STATE_RESET;
1159 RunIfNotReady();
1160 }
1161 else
1162 {
1163 // RemoveDataSink failed
1164 PVPATB_TEST_IS_TRUE(false);
1165 iState = STATE_CLEANUPANDCOMPLETE;
1166 RunIfNotReady();
1167 }
1168 break;
1169
1170 case STATE_RESET:
1171 if (aResponse.GetCmdStatus() == PVMFSuccess)
1172 {
1173 iState = STATE_REMOVEDATASOURCE;
1174 RunIfNotReady();
1175 }
1176 else
1177 {
1178 // Reset failed
1179 PVPATB_TEST_IS_TRUE(false);
1180 iState = STATE_CLEANUPANDCOMPLETE;
1181 RunIfNotReady();
1182 }
1183 break;
1184
1185 case STATE_REMOVEDATASOURCE:
1186 if (aResponse.GetCmdStatus() == PVMFSuccess)
1187 {
1188 PVPATB_TEST_IS_TRUE(true);
1189 iState = STATE_CLEANUPANDCOMPLETE;
1190 RunIfNotReady();
1191 }
1192 else
1193 {
1194 // RemoveDataSource failed
1195 PVPATB_TEST_IS_TRUE(false);
1196 iState = STATE_CLEANUPANDCOMPLETE;
1197 RunIfNotReady();
1198 }
1199 break;
1200
1201 default:
1202 {
1203 // Testing error if this is reached
1204 PVPATB_TEST_IS_TRUE(false);
1205 iState = STATE_CLEANUPANDCOMPLETE;
1206 RunIfNotReady();
1207 }
1208 break;
1209 }
1210
1211 if (aResponse.GetCmdStatus() != PVMFSuccess)
1212 {
1213 PVInterface* iface = (PVInterface*)(aResponse.GetEventExtensionInterface());
1214 if (iface != NULL)
1215 {
1216 PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
1217 PVMFErrorInfoMessageInterface* infomsgiface = NULL;
1218 if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
1219 {
1220 PVUuid engerruuid;
1221 int32 errCodeEng;
1222 infomsgiface->GetCodeUUID(errCodeEng, engerruuid);
1223
1224 if (engerruuid == PVPlayerErrorInfoEventTypesUUID)
1225 {
1226 PVMFErrorInfoMessageInterface* sourceNodeErrorIF =
1227 infomsgiface->GetNextMessage();
1228
1229 if (sourceNodeErrorIF != NULL)
1230 {
1231 PVUuid eventuuid;
1232 int32 srcErrCode;
1233 sourceNodeErrorIF->GetCodeUUID(srcErrCode, eventuuid);
1234 if (eventuuid == PVMFSocketNodeEventTypeUUID)
1235 {
1236 HandleSocketNodeErrors(srcErrCode);
1237 }
1238 else if (eventuuid == PVProtocolEngineNodeErrorEventTypesUUID)
1239 {
1240 HandleProtocolEngineNodeErrors(srcErrCode, aResponse.GetEventData());
1241 }
1242
1243 }
1244 }
1245 }
1246 }
1247 }
1248 }
1249
HandleSocketNodeErrors(int32 aErr)1250 void pvplayer_async_test_downloadbase::HandleSocketNodeErrors(int32 aErr)
1251 {
1252 if (aErr == PVMFSocketNodeErrorSocketServerCreateError)
1253 {
1254 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorSocketServerCreateError\n");
1255 }
1256 else if (aErr == PVMFSocketNodeErrorSocketServConnectError)
1257 {
1258 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorSocketServConnectError\n");
1259 }
1260 else if (aErr == PVMFSocketNodeErrorUDPSocketRecvError)
1261 {
1262 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorUDPSocketRecvError\n");
1263 }
1264 else if (aErr == PVMFSocketNodeErrorUDPSocketSendError)
1265 {
1266 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorUDPSocketSendError\n");
1267 }
1268 else if (aErr == PVMFSocketNodeError_TCPSocketConnect)
1269 {
1270 fprintf(iTestMsgOutputFile, "PVMFSocketNodeError_TCPSocketConnect\n");
1271 }
1272 else if (aErr == PVMFSocketNodeError_DNSLookup)
1273 {
1274 fprintf(iTestMsgOutputFile, "PVMFSocketNodeError_DNSLookup\n");
1275 }
1276 else if (aErr == PVMFSocketNodeErrorSocketFailure)
1277 {
1278 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorSocketFailure\n");
1279 }
1280 else if (aErr == PVMFSocketNodeErrorSocketTimeOut)
1281 {
1282 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorSocketTimeOut\n");
1283 }
1284 else if (aErr == PVMFSocketNodeErrorInvalidPortTag)
1285 {
1286 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorInvalidPortTag\n");
1287 }
1288 else if (aErr == PVMFSocketNodeErrorInvalidPortConfig)
1289 {
1290 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorInvalidPortConfig\n");
1291 }
1292 else
1293 {
1294 fprintf(iTestMsgOutputFile, "PVMFSocketNode- Unknown Error Code\n");
1295 }
1296 }
1297
1298
HandleProtocolEngineNodeErrors(int32 aErr,OsclAny * aEventData)1299 void pvplayer_async_test_downloadbase::HandleProtocolEngineNodeErrors(int32 aErr, OsclAny* aEventData)
1300 {
1301 // The HTTP status errors are propagated up from the Protocol Engine node and
1302 // are enumerated in pvmf_protocol_engine_node_events.h. The raw value of the error
1303 // code can be calculated as an offset from aErr - PVProtocolEngineNodeErrorEventStart.
1304 if ((aErr >= PVProtocolEngineNodeErrorHTTPErrorCode400) &&
1305 (aErr <= PVProtocolEngineNodeErrorHTTPCode4xxUnknown))
1306 {
1307 if (aErr == PVProtocolEngineNodeErrorHTTPErrorCode401 && aEventData)
1308 {
1309 char *realmString = (char *)aEventData;
1310 fprintf(iTestMsgOutputFile, " PVMFInfoMFFailure (HTTP Status code = 401), realm = %s\n", realmString);
1311 }
1312 else
1313 {
1314 fprintf(iTestMsgOutputFile, "PVProtocolEngineNodeError4xx HTTP Status Code %d\n",
1315 aErr - PVProtocolEngineNodeErrorEventStart);
1316 }
1317 }
1318 else if ((aErr >= PVProtocolEngineNodeErrorHTTPErrorCode500) &&
1319 (aErr < PVProtocolEngineNodeErrorHTTPCode5xxUnknownStart))
1320 {
1321 fprintf(file, " ERROR: PVProtocolEngineNodeError5xx HTTP Status Code %d\n",
1322 aErr - PVProtocolEngineNodeErrorEventStart);
1323 }
1324 else if ((aErr >= PVProtocolEngineNodeErrorHTTPRedirectCodeStart) &&
1325 (aErr <= PVProtocolEngineNodeErrorHTTPRedirectCodeEnd))
1326 {
1327 fprintf(file, " ERROR IN REDIRECT: PVProtocolEngineNodeError3xx HTTP Status Code %d\n",
1328 aErr - PVProtocolEngineNodeErrorEventStart);
1329 }
1330 else if (aErr < PVProtocolEngineNodeErrorNotHTTPErrorStart || aErr > PVProtocolEngineNodeErrorNotHTTPErrorEnd)
1331 {
1332 fprintf(file, " ERROR: PVProtocolEngineNodeError HTTP Unknown Status Code %d\n",
1333 aErr - PVProtocolEngineNodeErrorEventStart);
1334 }
1335 else
1336 {
1337 fprintf(file, " ERROR: PVProtocolEngineNodeError General Error %d\n", aErr);
1338 }
1339 }
1340
PrintJanusError(const PVCmdResponse & aResp)1341 void pvplayer_async_test_downloadbase::PrintJanusError(const PVCmdResponse& aResp)
1342 {
1343 #if(RUN_CPMJANUS_TESTCASES)
1344 //#if 0
1345 //Get the extended error info.
1346 if (aResp.GetCmdStatus() != PVMFSuccess)
1347 {
1348 PVInterface* iface = (PVInterface*)(aResp.GetEventExtensionInterface());
1349 if (iface)
1350 {
1351 PVUuid errUuid(PVMFErrorInfoMessageInterfaceUUID);
1352 PVMFErrorInfoMessageInterface* errMsg = NULL;
1353 if (iface->queryInterface(errUuid, (PVInterface*&)errMsg))
1354 {
1355 //search for a janus error in the error list.
1356 PVUuid janusUuid(PVMFJanusPluginErrorMessageUuid);
1357 PVMFJanusPluginErrorMessage* janusErr = NULL;
1358 PVMFErrorInfoMessageInterface* nextErr = errMsg->GetNextMessage();
1359 while (nextErr)
1360 {
1361 if (nextErr->queryInterface(janusUuid, (PVInterface*&)janusErr))
1362 {
1363 uint32 drmErr = janusErr->DrmResult();
1364 fprintf(file, " Janus DRM Error! 0x%x\n", drmErr);
1365 break;
1366 }
1367 nextErr = nextErr->GetNextMessage();
1368 }
1369 }
1370 }
1371 }
1372 #else
1373 OSCL_UNUSED_ARG(aResp);
1374 #endif
1375 }
1376
HandleErrorEvent(const PVAsyncErrorEvent & aEvent)1377 void pvplayer_async_test_downloadbase::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
1378 {
1379 switch (aEvent.GetEventType())
1380 {
1381 case PVMFErrResourceConfiguration:
1382 // Just log the error
1383 PVPATB_TEST_IS_TRUE(false);
1384 fprintf(file, " GOT PVMFErrResourceConfiguration error event\n");
1385 break;
1386
1387 case PVMFErrResource:
1388 // Just log the error
1389 PVPATB_TEST_IS_TRUE(false);
1390 fprintf(file, " GOT PVMFErrResource error event\n");
1391 break;
1392
1393 case PVMFErrCorrupt:
1394 // Just log the error
1395 PVPATB_TEST_IS_TRUE(false);
1396 fprintf(file, " GOT PVMFErrCorrupt error event\n");
1397 break;
1398
1399 case PVMFErrProcessing:
1400 // Just log the error
1401 PVPATB_TEST_IS_TRUE(false);
1402 fprintf(file, " GOT PVMFErrProcessing error event\n");
1403 break;
1404
1405 case PVMFErrTimeout:
1406
1407 PVPATB_TEST_IS_TRUE(false);
1408 fprintf(file, " GOT PVMFErrTimeout error event");
1409 break;
1410
1411 default:
1412 // Unknown error and just log the error
1413 PVPATB_TEST_IS_TRUE(false);
1414 break;
1415 }
1416
1417 // Wait for engine to handle the error
1418 Cancel();
1419 }
1420
1421
HandleInformationalEvent(const PVAsyncInformationalEvent & aEvent)1422 void pvplayer_async_test_downloadbase::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
1423 {
1424 if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
1425 {
1426 fprintf(file, "PVMFInfoErrorHandlingStart...\n");
1427 }
1428 if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
1429 {
1430 fprintf(file, "PVMFInfoErrorHandlingComplete...\n");
1431 iState = STATE_CLEANUPANDCOMPLETE;
1432 RunIfNotReady();
1433 }
1434
1435 // Check for EOS event
1436 if (aEvent.GetEventType() == PVMFInfoEndOfData)
1437 {
1438 PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
1439 if (iface == NULL)
1440 {
1441 return;
1442 }
1443 PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
1444 PVMFErrorInfoMessageInterface* infomsgiface = NULL;
1445 if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
1446 {
1447 int32 infocode;
1448 PVUuid infouuid;
1449 infomsgiface->GetCodeUUID(infocode, infouuid);
1450 if ((infouuid == PVPlayerErrorInfoEventTypesUUID) && (infocode == PVPlayerInfoEndOfClipReached))
1451 {
1452 fprintf(file, " GOT PVPlayerInfoEndOfClipReached EVENT\n");
1453 iNumEOS++;
1454 if (iState == STATE_STOP)
1455 {
1456 Cancel();
1457 RunIfNotReady();
1458 }
1459 }
1460 }
1461 }
1462
1463 //Print some events
1464 switch (aEvent.GetEventType())
1465 {
1466 case PVMFInfoBufferingStatus:
1467 {
1468 int32 *percent = (int32*)aEvent.GetLocalBuffer();
1469 if (iPlayStopPlay)
1470 {
1471 //download percent shouldn't go backward after the re-start,
1472 //since that would suggest we're re-starting the download.
1473 //(don't do this test for PPB case since download gets repositioned
1474 //along with playback.)
1475 if (*percent < iLastBufferingStatusVal && !iProgPlayback)
1476 {
1477 PVPATB_TEST_IS_TRUE(false);
1478 }
1479 }
1480 iLastBufferingStatusVal = *percent;
1481 if (iLastBufferingStatusVal == 0 || iLastBufferingStatusVal == 100)
1482 {
1483 fprintf(file, " PVMFInfoBufferingStatus %d\n", iLastBufferingStatusVal);
1484 }
1485 else
1486 {
1487 fprintf(file, ".%d.", iLastBufferingStatusVal);
1488 }
1489 }
1490 break;
1491 case PVMFInfoBufferingStart:
1492 fprintf(file, " PVMFInfoBufferingStart\n");
1493 iNumBufferingStart++;
1494 if (iPlayStopPlay)
1495 {
1496 //we should only get 1 or 2 of these.
1497 if (iNumBufferingStart == 3)
1498 PVPATB_TEST_IS_TRUE(false);
1499 }
1500 else
1501 {
1502 //we should only get one of these.
1503 if (iNumBufferingStart == 2)
1504 PVPATB_TEST_IS_TRUE(false);
1505 }
1506 break;
1507
1508 case PVMFInfoBufferingComplete:
1509 {
1510 PVExclusivePtr eventData;
1511 aEvent.GetEventData(eventData);
1512 uint32 contentSize = (uint32)(eventData);
1513 fprintf(file, " PVMFInfoBufferingComplete (contentSize=%d)\n", contentSize);
1514 iNumBufferingComplete++;
1515 if (iPlayStopPlay)
1516 {
1517 //we should only get 1 or 2 of these.
1518 if (iNumBufferingComplete == 3)
1519 PVPATB_TEST_IS_TRUE(false);
1520 }
1521 else
1522 {
1523 //we should only get one of these.
1524 if (iNumBufferingComplete == 2)
1525 PVPATB_TEST_IS_TRUE(false);
1526 }
1527 if (iNumBufferingComplete == 1)
1528 {
1529 if (iState == STATE_WAIT_FOR_BUFFCOMPLETE)
1530 {
1531 Cancel();
1532 RunIfNotReady();
1533 }
1534 }
1535 }
1536 break;
1537
1538 case PVMFInfoDataReady:
1539 iNumDataReady++;
1540 fprintf(file, "\n PVMFInfoDataReady\n");
1541 //special handling for very first data ready event.
1542 if (iNumDataReady == 1)
1543 {
1544 if (iState == STATE_WAIT_FOR_DATAREADY)
1545 {
1546 Cancel();
1547 RunIfNotReady();
1548 }
1549 //for download-then-play test, we should not get data ready
1550 //until download is complete
1551 if (iDownloadThenPlay)
1552 {
1553 if (iNumBufferingComplete == 0)
1554 PVPATB_TEST_IS_TRUE(false);
1555 }
1556 //for download-only test, we should not get data ready at all.
1557 if (iDownloadOnly)
1558 {
1559 PVPATB_TEST_IS_TRUE(false);
1560 }
1561 }
1562 break;
1563 case PVMFInfoUnderflow:
1564 iNumUnderflow++;
1565 fprintf(file, "\n PVMFInfoUnderflow\n");
1566 if (iPauseResumeAfterUnderflow == true)
1567 {
1568 iState = STATE_PAUSE;
1569 RunIfNotReady();
1570 }
1571 //we should not get underflow before data ready
1572 if (iNumUnderflow == 1
1573 && iNumDataReady == 0)
1574 PVPATB_TEST_IS_TRUE(false);
1575 break;
1576 case PVMFInfoContentLength:
1577 {
1578 PVExclusivePtr eventData;
1579 aEvent.GetEventData(eventData);
1580 uint32 contentSize = (uint32)(eventData);
1581 fprintf(file, " PVMFInfoContentLength = %d\n", contentSize);
1582 }
1583 break;
1584
1585 case PVMFInfoContentTruncated:
1586 {
1587 PVExclusivePtr eventData;
1588 aEvent.GetEventData(eventData);
1589 uint32 downloadSize = (uint32)(eventData);
1590 fprintf(file, "\n PVMFInfoContentTruncated! downloadSize = %d\n", downloadSize);
1591
1592 // check extension info code
1593 PVMFErrorInfoMessageInterface *msg = NULL;
1594 if (aEvent.GetEventExtensionInterface() &&
1595 aEvent.GetEventExtensionInterface()->queryInterface(PVMFErrorInfoMessageInterfaceUUID, (PVInterface*&)msg))
1596 {
1597 //extract the event code and event UUID.
1598 int32 eventcode;
1599 PVUuid eventUuid;
1600 msg->GetCodeUUID(eventcode, eventUuid);
1601 if (eventUuid == PVPlayerErrorInfoEventTypesUUID)
1602 {
1603 PVMFErrorInfoMessageInterface* sourceNodeInfoIF = msg->GetNextMessage();
1604
1605 if (sourceNodeInfoIF != NULL)
1606 {
1607 PVUuid infoUUID;
1608 int32 srcInfoCode;
1609 sourceNodeInfoIF->GetCodeUUID(srcInfoCode, infoUUID);
1610
1611 if (infoUUID == PVMFPROTOCOLENGINENODEInfoEventTypesUUID &&
1612 srcInfoCode == PVMFPROTOCOLENGINENODEInfo_TruncatedContentByServerDisconnect)
1613 {
1614 fprintf(file, " PVMFInfoContentTruncated! TruncatedContentByServerDisconnect!\n");
1615 }
1616 }
1617 }
1618 }
1619
1620 }
1621 break;
1622
1623 case PVMFInfoContentType:
1624 {
1625 PVExclusivePtr eventData;
1626 aEvent.GetEventData(eventData);
1627 char *constentType = (char *)(eventData);
1628 fprintf(file, " PVMFInfoContentType = %s\n", constentType);
1629 }
1630 break;
1631
1632 case PVMFInfoUnexpectedData:
1633 fprintf(file, " PVMFInfoUnexpectedData! Downloaded more data than content-length\n");
1634 if (iNumBufferingComplete == 0) PVPATB_TEST_IS_TRUE(false); // we should get this info event after buffer complete event
1635 break;
1636
1637 case PVMFInfoSessionDisconnect:
1638 fprintf(file, " PVMFInfoSessionDisconnect! Got server disconnect after download is complete\n");
1639 if (iNumBufferingComplete == 0) PVPATB_TEST_IS_TRUE(false); // we should get this info event after buffer complete event
1640 break;
1641
1642 case PVMFInfoRemoteSourceNotification:
1643 {
1644 //Examine the extended info message to see if this is the
1645 //"not progressive downloadable" event. If so, notify the
1646 //UI. They may choose to abort the download at this point.
1647 PVMFErrorInfoMessageInterface *msg = NULL;
1648 if (aEvent.GetEventExtensionInterface()
1649 && aEvent.GetEventExtensionInterface()->queryInterface(PVMFErrorInfoMessageInterfaceUUID, (PVInterface*&)msg))
1650 {
1651 //extract the event code and event UUID.
1652 int32 eventcode;
1653 PVUuid eventUuid;
1654 msg->GetCodeUUID(eventcode, eventUuid);
1655 if (eventUuid == PVPlayerErrorInfoEventTypesUUID)
1656 {
1657 PVMFErrorInfoMessageInterface* sourceNodeInfoIF =
1658 msg->GetNextMessage();
1659
1660 if (sourceNodeInfoIF != NULL)
1661 {
1662 PVUuid infoUUID;
1663 int32 srcInfoCode;
1664 sourceNodeInfoIF->GetCodeUUID(srcInfoCode, infoUUID);
1665 if (infoUUID == PVMFFileFormatEventTypesUUID
1666 && srcInfoCode == PVMFMP4FFParserInfoNotPseudostreamableFile)
1667 {
1668 fprintf(file, " PVMFInfoRemoteSourceNotification (not progressive-downloadable)\n");
1669 }
1670 else if (infoUUID == PVMFPROTOCOLENGINENODEInfoEventTypesUUID
1671 && (srcInfoCode >= PVMFPROTOCOLENGINENODEInfo_HTTPRedirectCode300 &&
1672 srcInfoCode <= PVMFPROTOCOLENGINENODEInfo_HTTPRedirectCode307))
1673 {
1674 PVExclusivePtr eventData;
1675 aEvent.GetEventData(eventData);
1676 char *redirectUrl = (char *)(eventData);
1677 fprintf(file, " PVMFInfoRemoteSourceNotification (HTTP Status code = %d), redirectUrl = %s\n",
1678 srcInfoCode - PVMFPROTOCOLENGINENODEInfo_Redirect, redirectUrl);
1679 }
1680
1681 }
1682 }
1683 }
1684 }
1685 break;
1686 case PVMFInfoTrackDisable:
1687 {
1688 PVExclusivePtr aPtr;
1689 aEvent.GetEventData(aPtr);
1690 int32 iDisableTrack = (int32)aPtr;
1691 if (!iDisableTrack)
1692 {
1693 fprintf(iTestMsgOutputFile, "###PVMFInfoTrackDisable - DisableTrack=%d\n", iDisableTrack);
1694 }
1695 }
1696 break;
1697 default:
1698 break;
1699 }
1700 }
1701
1702 #if RUN_FASTTRACK_TESTCASES
1703 //
1704 // pvplayer_async_test_ftdlnormal section
1705 //
~pvplayer_async_test_ftdlnormal()1706 pvplayer_async_test_ftdlnormal::~pvplayer_async_test_ftdlnormal()
1707 {
1708 }
1709
CreateDataSource()1710 void pvplayer_async_test_ftdlnormal::CreateDataSource()
1711 {
1712 //fasttrack download using PVX.
1713
1714 //read the pvx file into a memory fragment.
1715 OsclMemoryFragment pvxmemfrag;
1716 {
1717 Oscl_FileServer fs;
1718 fs.Connect();
1719 Oscl_File file;
1720 OSCL_StackString<64> filename;
1721
1722 if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
1723 {
1724 filename = SOURCENAME_PREPEND_STRING;
1725 filename += DEFAULT_FASTTRACK_DL_FILE;
1726 }
1727 else
1728 {
1729 filename = iFileName;
1730 }
1731
1732 if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
1733 {
1734 PVPATB_TEST_IS_TRUE(false);
1735 iObserver->TestCompleted(*iTestCase);
1736 return;
1737 }
1738
1739 int32 size = file.Read(iPVXFileBuf, 1, 4096);
1740 pvxmemfrag.len = size;
1741 pvxmemfrag.ptr = iPVXFileBuf;
1742 file.Close();
1743 fs.Close();
1744 }
1745
1746 //Parse, extracting iDownloadPvxInfo and url8.
1747 OSCL_HeapString<OsclMemAllocator> url8;
1748 {
1749 CPVXParser* parser = NULL;
1750 parser = new CPVXParser;
1751 if (parser == NULL)
1752 {
1753 PVPATB_TEST_IS_TRUE(false);
1754 iObserver->TestCompleted(*iTestCase);
1755 return;
1756 }
1757 CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
1758 delete parser;
1759 if (status != CPVXParser::CPVXParser_Success)
1760 {
1761 PVPATB_TEST_IS_TRUE(false);
1762 iObserver->TestCompleted(*iTestCase);
1763 return;
1764 }
1765 //set the playback mode in the test case base class to match
1766 //the PVX setting.
1767 switch (iDownloadPvxInfo.iPlaybackControl)
1768 {
1769 case CPVXInfo::ENoPlayback:
1770 iDownloadOnly = true;
1771 break;
1772 case CPVXInfo::EAfterDownload:
1773 iDownloadThenPlay = true;
1774 break;
1775 case CPVXInfo::EAsap:
1776 break;
1777 default:
1778 break;
1779 }
1780 }
1781
1782 //convert the url8 to unicode iDownloadURL
1783 {
1784 oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
1785 if (wtemp == NULL)
1786 {
1787 // Memory allocation failure
1788 PVPATB_TEST_IS_TRUE(false);
1789 iObserver->TestCompleted(*iTestCase);
1790 return;
1791 }
1792 int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
1793 iDownloadURL.set(wtemp, wtemplen);
1794 delete [] wtemp;
1795 }
1796
1797 //create the opaque data
1798 iDownloadProxy = _STRLIT_CHAR("");
1799 int32 iDownloadProxyPort = 0;
1800
1801 iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
1802 iDownloadConfigFilename += _STRLIT_WCHAR("mydlconfig");
1803
1804 iDownloadMaxfilesize = 0x7FFFFFFF;
1805
1806 iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
1807 iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.loc");
1808
1809 iContentTooLarge = false;
1810
1811 //bool aIsNewSession = false;
1812 bool aIsNewSession = true;
1813
1814 iDownloadContextData = new PVMFSourceContextData();
1815 iDownloadContextData->EnableCommonSourceContext();
1816 iDownloadContextData->EnableDownloadPVXSourceContext();
1817 iDownloadContextData->DownloadPVXData()->bIsNewSession = aIsNewSession;
1818 iDownloadContextData->DownloadPVXData()->iConfigFileName = iDownloadConfigFilename;
1819 iDownloadContextData->DownloadPVXData()->iDownloadFileName = iDownloadFilename;
1820 iDownloadContextData->DownloadPVXData()->iMaxFileSize = iDownloadMaxfilesize;
1821 iDownloadContextData->DownloadPVXData()->iProxyName = iDownloadProxy;
1822 iDownloadContextData->DownloadPVXData()->iProxyPort = iDownloadProxyPort;
1823 iDownloadContextData->DownloadPVXData()->iPvxInfo = &iDownloadPvxInfo;
1824
1825 iDataSource = new PVPlayerDataSourceURL;
1826 iDataSource->SetDataSourceURL(iDownloadURL);
1827 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_PVX_FILE);
1828 iDataSource->SetDataSourceContextData(iDownloadContextData);
1829
1830 }
CreateDataSinkVideo()1831 void pvplayer_async_test_ftdlnormal::CreateDataSinkVideo()
1832 {
1833 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
1834 sinkfile += _STRLIT_WCHAR("test_player_ftdlnormal_video.dat");
1835 iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
1836 iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
1837 iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
1838 ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
1839 }
CreateDataSinkAudio()1840 void pvplayer_async_test_ftdlnormal::CreateDataSinkAudio()
1841 {
1842 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
1843 sinkfile += _STRLIT_WCHAR("test_player_ftdlnormal_audio.dat");
1844 iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
1845 iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
1846 iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
1847 ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
1848 }
1849 #endif
1850
1851 //
1852 // pvplayer_async_test_3gppdlnormal section
1853 //
~pvplayer_async_test_3gppdlnormal()1854 pvplayer_async_test_3gppdlnormal::~pvplayer_async_test_3gppdlnormal()
1855 {
1856 }
1857
CreateDataSource()1858 void pvplayer_async_test_3gppdlnormal::CreateDataSource()
1859 {
1860
1861 OSCL_HeapString<OsclMemAllocator> url(iFileName);
1862 OSCL_HeapString<OsclMemAllocator> default_source(SOURCENAME_PREPEND_STRING);
1863 default_source += DEFAULTSOURCEFILENAME;
1864 if (url == default_source)
1865 {
1866 if (iPlayStopPlay)
1867 {//use slow download simulator so we test stop during download.
1868 fprintf(file, "Setting source to %s\n", DEFAULT_3GPPDL_URL_SLOW);
1869 url = DEFAULT_3GPPDL_URL_SLOW;
1870 }
1871 else
1872 {
1873 fprintf(file, "Setting source to %s\n", DEFAULT_3GPPDL_URL);
1874 url = DEFAULT_3GPPDL_URL;
1875 }
1876 }
1877 oscl_wchar wbuf[2];
1878 wbuf[1] = '\0';
1879 for (uint32 i = 0; i < url.get_size(); i++)
1880 {
1881 wbuf[0] = (oscl_wchar)url.get_cstr()[i];
1882 iDownloadURL += wbuf;
1883 }
1884 iDataSource = new PVPlayerDataSourceURL;
1885 iDataSource->SetDataSourceURL(iDownloadURL);
1886
1887 if (iProtocolRollOver == true)
1888 {
1889 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
1890 iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
1891 }
1892 else
1893 {
1894 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
1895 }
1896
1897 iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
1898 iDownloadFilename += _STRLIT_WCHAR("test_3gppdownload.loc");
1899
1900 int32 iDownloadProxyPort;
1901 #if PVPLAYER_TEST_ENABLE_PROXY
1902 iDownloadProxy = _STRLIT_CHAR("");
1903 iDownloadProxyPort = 7070;
1904 #else
1905 iDownloadProxy = _STRLIT_CHAR("");
1906 iDownloadProxyPort = 0;
1907 #endif
1908
1909 iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
1910 iDownloadConfigFilename += _STRLIT_WCHAR("my3gppdl.cfg");
1911
1912 iContentTooLarge = false;
1913 uint32 iMaxFileSize = 0x7FFFFFFF;
1914 bool aIsNewSession = true;
1915
1916 #if(RUN_CPMJANUS_TESTCASES) && !(JANUS_IS_LOADABLE_MODULE)
1917 //Select the device info configuration.
1918 bool ok = GetJanusFactories(iTestNumber
1919 , iDrmDeviceInfoFactory
1920 , iDrmSystemClockFactory);
1921 if (!ok)
1922 PVPATB_TEST_IS_TRUE(false);
1923
1924 //Define the janus configuration.
1925 PVMFJanusPluginConfiguration config;
1926 config.iDeviceInfoFactory = iDrmDeviceInfoFactory;
1927 config.iSystemClockFactory = iDrmSystemClockFactory;
1928 if (!RegisterJanusPlugin(config))
1929 {
1930 PVPATB_TEST_IS_TRUE(false);
1931 iState = STATE_CLEANUPANDCOMPLETE;
1932 RunIfNotReady();
1933 return;
1934 }
1935 #endif
1936
1937 iDownloadContextData = new PVMFSourceContextData();
1938 iDownloadContextData->EnableCommonSourceContext();
1939 iDownloadContextData->EnableDownloadHTTPSourceContext();
1940 iDownloadContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
1941 iDownloadContextData->DownloadHTTPData()->iConfigFileName = iDownloadConfigFilename;
1942 iDownloadContextData->DownloadHTTPData()->iDownloadFileName = iDownloadFilename;
1943 iDownloadContextData->DownloadHTTPData()->iMaxFileSize = iMaxFileSize;
1944 iDownloadContextData->DownloadHTTPData()->iProxyName = iDownloadProxy;
1945 iDownloadContextData->DownloadHTTPData()->iProxyPort = iDownloadProxyPort;
1946 iDownloadContextData->DownloadHTTPData()->iUserID = _STRLIT_CHAR("abc");
1947 iDownloadContextData->DownloadHTTPData()->iUserPasswd = _STRLIT_CHAR("xyz");
1948 iDownloadContextData->DownloadHTTPData()->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::EAsap;
1949
1950 iDataSource->SetDataSourceContextData(iDownloadContextData);
1951 }
1952
1953 #if !(JANUS_IS_LOADABLE_MODULE)
1954 #if RUN_CPMJANUS_TESTCASES
RegisterJanusPlugin(PVMFJanusPluginConfiguration & aConfig)1955 bool pvplayer_async_test_3gppdlnormal::RegisterJanusPlugin(PVMFJanusPluginConfiguration& aConfig)
1956 {
1957 #if(RUN_CPMJANUS_TESTCASES)
1958 //#if 0
1959 //Connect to plugin registry
1960 PVMFStatus status;
1961 status = iPluginRegistryClient.Connect();
1962 if (status != PVMFSuccess)
1963 {
1964 PVPATB_TEST_IS_TRUE(false);
1965 return false;
1966 }
1967 //Create & the plugin factory.
1968 iPluginFactory = new PVMFJanusPluginFactory(aConfig);
1969 if (!iPluginFactory)
1970 {
1971 PVPATB_TEST_IS_TRUE(false);
1972 return false;
1973 }
1974 //Register the plugin factory.
1975 iPluginMimeType = PVMF_CPM_MIME_JANUS_PLUGIN;
1976 if (iPluginRegistryClient.RegisterPlugin(iPluginMimeType, *iPluginFactory) != PVMFSuccess)
1977 {
1978 PVPATB_TEST_IS_TRUE(false);
1979 return false;
1980 }
1981 return true;
1982 #else
1983 //OSCL_UNUSED_ARG(aConfig);
1984 return false;
1985 #endif
1986 }
1987 #endif
1988 #endif
1989
CleanupData()1990 void pvplayer_async_test_3gppdlnormal::CleanupData()
1991 {
1992 #if(RUN_CPMJANUS_TESTCASES) && !(JANUS_IS_LOADABLE_MODULE)
1993 //close the plugin registry client session.
1994 iPluginRegistryClient.Close();
1995
1996 //delete the plugin factory.
1997 if (iPluginFactory)
1998 {
1999 delete iPluginFactory;
2000 iPluginFactory = NULL;
2001 }
2002 CleanupJanusFactories(iTestNumber,
2003 iDrmDeviceInfoFactory,
2004 iDrmSystemClockFactory);
2005 #endif
2006 }
2007
CreateDataSinkVideo()2008 void pvplayer_async_test_3gppdlnormal::CreateDataSinkVideo()
2009 {
2010 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
2011 sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_video.dat");
2012 iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
2013 iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
2014 iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
2015 ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
2016 }
CreateDataSinkAudio()2017 void pvplayer_async_test_3gppdlnormal::CreateDataSinkAudio()
2018 {
2019 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
2020 sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_audio.dat");
2021 iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
2022 iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
2023 iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
2024 ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
2025 }
2026
2027 //
2028 // pvplayer_async_test_ppbnormal section
2029 //
~pvplayer_async_test_ppbnormal()2030 pvplayer_async_test_ppbnormal::~pvplayer_async_test_ppbnormal()
2031 {
2032 }
2033
CreateDataSource()2034 void pvplayer_async_test_ppbnormal::CreateDataSource()
2035 {
2036
2037 OSCL_HeapString<OsclMemAllocator> url(iFileName);
2038
2039 OSCL_HeapString<OsclMemAllocator> default_source(SOURCENAME_PREPEND_STRING);
2040 default_source += DEFAULTSOURCEFILENAME;
2041 if (url == default_source)
2042 {
2043 fprintf(file, "Setting source to %s\n", DEFAULT_3GPPDL_URL);
2044 url = DEFAULT_3GPPDL_URL;
2045 }
2046 oscl_wchar wbuf[2];
2047 wbuf[1] = '\0';
2048 for (uint32 i = 0; i < url.get_size(); i++)
2049 {
2050 wbuf[0] = (oscl_wchar)url.get_cstr()[i];
2051 iDownloadURL += wbuf;
2052 }
2053 iDataSource = new PVPlayerDataSourceURL;
2054 iDataSource->SetDataSourceURL(iDownloadURL);
2055
2056 if (iProtocolRollOver == true)
2057 {
2058 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
2059 iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
2060 }
2061 else
2062 {
2063 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
2064 }
2065
2066 iDownloadFilename = NULL;
2067
2068 int32 iDownloadProxyPort;
2069 #if PVPLAYER_TEST_ENABLE_PROXY
2070 iDownloadProxy = _STRLIT_CHAR("");
2071 iDownloadProxyPort = 7070;
2072 #else
2073 iDownloadProxy = _STRLIT_CHAR("");
2074 iDownloadProxyPort = 0;
2075 #endif
2076
2077 iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
2078 iDownloadConfigFilename += _STRLIT_WCHAR("ppbnormal.cfg");
2079
2080 iContentTooLarge = false;
2081 uint32 iMaxFileSize = 0x7FFFFFFF;
2082 bool aIsNewSession = true;
2083
2084 iDownloadContextData = new PVMFSourceContextData();
2085 iDownloadContextData->EnableCommonSourceContext();
2086 iDownloadContextData->EnableDownloadHTTPSourceContext();
2087 iDownloadContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
2088 iDownloadContextData->DownloadHTTPData()->iConfigFileName = iDownloadConfigFilename;
2089 iDownloadContextData->DownloadHTTPData()->iDownloadFileName = iDownloadFilename;
2090 iDownloadContextData->DownloadHTTPData()->iMaxFileSize = iMaxFileSize;
2091 iDownloadContextData->DownloadHTTPData()->iProxyName = iDownloadProxy;
2092 iDownloadContextData->DownloadHTTPData()->iProxyPort = iDownloadProxyPort;
2093 iDownloadContextData->DownloadHTTPData()->iUserID = _STRLIT_CHAR("abc");
2094 iDownloadContextData->DownloadHTTPData()->iUserPasswd = _STRLIT_CHAR("xyz");
2095 iDownloadContextData->DownloadHTTPData()->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::ENoSaveToFile;
2096
2097 iDataSource->SetDataSourceContextData(iDownloadContextData);
2098 }
2099
CreateDataSinkVideo()2100 void pvplayer_async_test_ppbnormal::CreateDataSinkVideo()
2101 {
2102 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
2103 sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_video.dat");
2104 iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
2105 iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
2106 iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
2107 ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
2108 }
CreateDataSinkAudio()2109 void pvplayer_async_test_ppbnormal::CreateDataSinkAudio()
2110 {
2111 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
2112 sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_audio.dat");
2113 iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
2114 iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
2115 iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
2116 ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
2117 }
2118
2119 // pvplayer_async_test_3gppdlnormal_dlthenplay section
2120 //
~pvplayer_async_test_3gppdlnormal_dlthenplay()2121 pvplayer_async_test_3gppdlnormal_dlthenplay::~pvplayer_async_test_3gppdlnormal_dlthenplay()
2122 {
2123 }
2124
CreateDataSource()2125 void pvplayer_async_test_3gppdlnormal_dlthenplay::CreateDataSource()
2126 {
2127 OSCL_HeapString<OsclMemAllocator> url(iFileName);
2128 OSCL_HeapString<OsclMemAllocator> default_source(SOURCENAME_PREPEND_STRING);
2129 default_source += DEFAULTSOURCEFILENAME;
2130 if (url == default_source)
2131 {
2132 fprintf(file, "Setting source to %s\n", DEFAULT_3GPPDL_URL);
2133 url = DEFAULT_3GPPDL_URL;
2134 }
2135 oscl_wchar wbuf[2];
2136 wbuf[1] = '\0';
2137 for (uint32 i = 0; i < url.get_size(); i++)
2138 {
2139 wbuf[0] = (oscl_wchar)url.get_cstr()[i];
2140 iDownloadURL += wbuf;
2141 }
2142 iDataSource = new PVPlayerDataSourceURL;
2143 iDataSource->SetDataSourceURL(iDownloadURL);
2144 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
2145
2146 iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
2147 iDownloadFilename += _STRLIT_WCHAR("test_3gppdownload_dlthenplay.loc");
2148
2149 int32 iDownloadProxyPort;
2150 #if PVPLAYER_TEST_ENABLE_PROXY
2151 iDownloadProxy = _STRLIT_CHAR("");
2152 iDownloadProxyPort = 7070;
2153 #else
2154 iDownloadProxy = _STRLIT_CHAR("");
2155 iDownloadProxyPort = 0;
2156 #endif
2157
2158 iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
2159 iDownloadConfigFilename += _STRLIT_WCHAR("my3gppdl_dlthenplay.cfg");
2160
2161 iContentTooLarge = false;
2162 uint32 iMaxFileSize = 0x7FFFFFFF;
2163 bool aIsNewSession = true;
2164
2165 iDownloadThenPlay = true;
2166
2167 iDownloadContextData = new PVMFSourceContextData();
2168 iDownloadContextData->EnableCommonSourceContext();
2169 iDownloadContextData->EnableDownloadHTTPSourceContext();
2170 iDownloadContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
2171 iDownloadContextData->DownloadHTTPData()->iConfigFileName = iDownloadConfigFilename;
2172 iDownloadContextData->DownloadHTTPData()->iDownloadFileName = iDownloadFilename;
2173 iDownloadContextData->DownloadHTTPData()->iMaxFileSize = iMaxFileSize;
2174 iDownloadContextData->DownloadHTTPData()->iProxyName = iDownloadProxy;
2175 iDownloadContextData->DownloadHTTPData()->iProxyPort = iDownloadProxyPort;
2176 iDownloadContextData->DownloadHTTPData()->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::EAfterDownload;
2177
2178 iDataSource->SetDataSourceContextData(iDownloadContextData);
2179 }
2180
CreateDataSinkVideo()2181 void pvplayer_async_test_3gppdlnormal_dlthenplay::CreateDataSinkVideo()
2182 {
2183 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
2184 sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_dlthenplay_video.dat");
2185 iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
2186 iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
2187 iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
2188 ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
2189 }
CreateDataSinkAudio()2190 void pvplayer_async_test_3gppdlnormal_dlthenplay::CreateDataSinkAudio()
2191 {
2192 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
2193 sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_dlthenplay_audio.dat");
2194 iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
2195 iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
2196 iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
2197 ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
2198 }
2199 //
2200 // pvplayer_async_test_3gppdlnormal_dlonly section
2201 //
~pvplayer_async_test_3gppdlnormal_dlonly()2202 pvplayer_async_test_3gppdlnormal_dlonly::~pvplayer_async_test_3gppdlnormal_dlonly()
2203 {
2204 }
2205
CreateDataSource()2206 void pvplayer_async_test_3gppdlnormal_dlonly::CreateDataSource()
2207 {
2208
2209 OSCL_HeapString<OsclMemAllocator> url(iFileName);
2210 OSCL_HeapString<OsclMemAllocator> default_source(SOURCENAME_PREPEND_STRING);
2211 default_source += DEFAULTSOURCEFILENAME;
2212 if (url == default_source)
2213 {
2214 fprintf(file, "Setting source to %s\n", DEFAULT_3GPPDL_URL);
2215 url = DEFAULT_3GPPDL_URL;
2216 }
2217 oscl_wchar wbuf[2];
2218 wbuf[1] = '\0';
2219 for (uint32 i = 0; i < url.get_size(); i++)
2220 {
2221 wbuf[0] = (oscl_wchar)url.get_cstr()[i];
2222 iDownloadURL += wbuf;
2223 }
2224 iDataSource = new PVPlayerDataSourceURL;
2225 iDataSource->SetDataSourceURL(iDownloadURL);
2226 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
2227
2228 iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
2229 iDownloadFilename += _STRLIT_WCHAR("test_3gppdownload_dlonly.loc");
2230
2231 int32 iDownloadProxyPort;
2232 #if PVPLAYER_TEST_ENABLE_PROXY
2233 iDownloadProxy = _STRLIT_CHAR("");
2234 iDownloadProxyPort = 7070;
2235 #else
2236 iDownloadProxy = _STRLIT_CHAR("");
2237 iDownloadProxyPort = 0;
2238 #endif
2239
2240 iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
2241 iDownloadConfigFilename += _STRLIT_WCHAR("my3gppdl_dlonly.cfg");
2242
2243 iContentTooLarge = false;
2244 uint32 iMaxFileSize = 0x7FFFFFFF;
2245 bool aIsNewSession = true;
2246
2247 iDownloadOnly = true;
2248
2249 iDownloadContextData = new PVMFSourceContextData();
2250 iDownloadContextData->EnableCommonSourceContext();
2251 iDownloadContextData->EnableDownloadHTTPSourceContext();
2252 iDownloadContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
2253 iDownloadContextData->DownloadHTTPData()->iConfigFileName = iDownloadConfigFilename;
2254 iDownloadContextData->DownloadHTTPData()->iDownloadFileName = iDownloadFilename;
2255 iDownloadContextData->DownloadHTTPData()->iMaxFileSize = iMaxFileSize;
2256 iDownloadContextData->DownloadHTTPData()->iProxyName = iDownloadProxy;
2257 iDownloadContextData->DownloadHTTPData()->iProxyPort = iDownloadProxyPort;
2258 iDownloadContextData->DownloadHTTPData()->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::ENoPlayback;
2259
2260 iDataSource->SetDataSourceContextData(iDownloadContextData);
2261 }
2262
CreateDataSinkVideo()2263 void pvplayer_async_test_3gppdlnormal_dlonly::CreateDataSinkVideo()
2264 {
2265 //won't be called
2266 PVPATB_TEST_IS_TRUE(false);
2267 }
2268
CreateDataSinkAudio()2269 void pvplayer_async_test_3gppdlnormal_dlonly::CreateDataSinkAudio()
2270 {
2271 //won't be called
2272 PVPATB_TEST_IS_TRUE(false);
2273 }
2274
2275 //
2276 // pvplayer_async_test_3gppdlcancelduringinit section
2277 //
StartTest()2278 void pvplayer_async_test_3gppdlcancelduringinit::StartTest()
2279 {
2280 AddToScheduler();
2281 iState = STATE_CREATE;
2282 RunIfNotReady();
2283 }
2284
2285
Run()2286 void pvplayer_async_test_3gppdlcancelduringinit::Run()
2287 {
2288 int error = 0;
2289
2290 switch (iState)
2291 {
2292 case STATE_CREATE:
2293 {
2294 iPlayer = NULL;
2295
2296 OSCL_TRY(error, iPlayer = PVPlayerFactory::CreatePlayer(this, this, this));
2297 if (error)
2298 {
2299 PVPATB_TEST_IS_TRUE(false);
2300 iObserver->TestCompleted(*iTestCase);
2301 }
2302 else
2303 {
2304 iState = STATE_ADDDATASOURCE;
2305 RunIfNotReady();
2306 }
2307 }
2308 break;
2309
2310 case STATE_ADDDATASOURCE:
2311 {
2312 OSCL_HeapString<OsclMemAllocator> url(iFileName);
2313 OSCL_HeapString<OsclMemAllocator> default_source(SOURCENAME_PREPEND_STRING);
2314 default_source += DEFAULTSOURCEFILENAME;
2315 if (url == default_source)
2316 {
2317 fprintf(file, "Setting source to %s\n", DEFAULT_CANCEL_DURING_INIT_TEST_URL);
2318 url = DEFAULT_CANCEL_DURING_INIT_TEST_URL;
2319 }
2320 oscl_wchar wbuf[2];
2321 wbuf[1] = '\0';
2322 for (uint32 i = 0; i < url.get_size(); i++)
2323 {
2324 wbuf[0] = (oscl_wchar)url.get_cstr()[i];
2325 iDownloadURL += wbuf;
2326 }
2327
2328 iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
2329 iDownloadFilename += _STRLIT_WCHAR("test_3gppdlcancelduringinit.loc");
2330
2331 iDownloadProxy = _STRLIT_CHAR("");
2332 int32 iDownloadProxyPort = 0;
2333
2334 iConfigFileName = OUTPUTNAME_PREPEND_WSTRING;
2335 iConfigFileName += _STRLIT_WCHAR("my3gppdlcancel.cfg");
2336
2337 uint32 iMaxFileSize = 0x7FFFFFFF;
2338 bool aIsNewSession = true;
2339 PVMFDownloadDataSourceHTTP::TPVPlaybackControl iPlaybackMode = PVMFDownloadDataSourceHTTP::EAsap;
2340 iDownloadHttpContextData = new PVMFDownloadDataSourceHTTP(aIsNewSession,
2341 iConfigFileName,
2342 iDownloadFilename,
2343 iMaxFileSize,
2344 iDownloadProxy,
2345 iDownloadProxyPort,
2346 iPlaybackMode);
2347
2348 iDataSource = new PVPlayerDataSourceURL;
2349 iDataSource->SetDataSourceURL(iDownloadURL);
2350 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
2351 iDataSource->SetDataSourceContextData(iDownloadHttpContextData);
2352 OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
2353 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
2354 }
2355 break;
2356
2357 case STATE_INIT:
2358 {
2359 OSCL_TRY(error, iCurrentCmdId = iPlayer->Init((OsclAny*) & iContextObject));
2360 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
2361
2362 iState = STATE_CANCELALL;
2363 //if this is commmented out. The BufferingStart(change below) could do RunIfInactiv()
2364 //RunIfNotReady(10*1000*1000);
2365 }
2366 break;
2367
2368 case STATE_CANCELALL:
2369 {
2370 if (iCancelCommandExecuted)
2371 {
2372 fprintf(file, "\nError - Cancel command being executed multiple times, please verify ...\n");
2373 }
2374 fprintf(file, "\n Cancel all ...\n");
2375 OSCL_TRY(error, iCurrentCmdId = iPlayer->CancelAllCommands((OsclAny*) & iContextObject));
2376 iCancelCommandExecuted = true;
2377 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
2378
2379 iState = STATE_WAIT_FOR_CANCELALL;
2380 }
2381 break;
2382
2383 case STATE_WAIT_FOR_CANCELALL:
2384 {
2385 // Cancel did not complete in time
2386 PVPATB_TEST_IS_TRUE(false);
2387 iState = STATE_CLEANUPANDCOMPLETE;
2388 RunIfNotReady();
2389 }
2390 break;
2391
2392 case STATE_RESET:
2393 {
2394 OSCL_TRY(error, iCurrentCmdId = iPlayer->Reset((OsclAny*) & iContextObject));
2395 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
2396 }
2397 break;
2398
2399 case STATE_REMOVEDATASOURCE:
2400 {
2401 OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
2402 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
2403 }
2404 break;
2405
2406 case STATE_CLEANUPANDCOMPLETE:
2407 {
2408 PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
2409 iPlayer = NULL;
2410
2411 delete iDataSource;
2412 iDataSource = NULL;
2413
2414 delete iDownloadHttpContextData;
2415 iDownloadHttpContextData = NULL;
2416
2417 iObserver->TestCompleted(*iTestCase);
2418 }
2419 break;
2420
2421 default:
2422 break;
2423
2424 }
2425 }
2426
2427
CommandCompleted(const PVCmdResponse & aResponse)2428 void pvplayer_async_test_3gppdlcancelduringinit::CommandCompleted(const PVCmdResponse& aResponse)
2429 {
2430 if (aResponse.GetContext() != NULL)
2431 {
2432 if (aResponse.GetContext() == (OsclAny*)&iContextObject)
2433 {
2434 if (iContextObject != iContextObjectRefValue)
2435 {
2436 // Context data value was corrupted
2437 PVPATB_TEST_IS_TRUE(false);
2438 iState = STATE_CLEANUPANDCOMPLETE;
2439 RunIfNotReady();
2440 return;
2441 }
2442 }
2443 else
2444 {
2445 // Context data pointer was corrupted
2446 PVPATB_TEST_IS_TRUE(false);
2447 iState = STATE_CLEANUPANDCOMPLETE;
2448 RunIfNotReady();
2449 return;
2450 }
2451 }
2452
2453 switch (iState)
2454 {
2455
2456 case STATE_ADDDATASOURCE:
2457 if (aResponse.GetCmdStatus() == PVMFSuccess)
2458 {
2459 iState = STATE_INIT;
2460 RunIfNotReady();
2461 }
2462 else
2463 {
2464 // AddDataSource failed
2465 PVPATB_TEST_IS_TRUE(false);
2466 iState = STATE_CLEANUPANDCOMPLETE;
2467 RunIfNotReady();
2468 }
2469 break;
2470
2471 case STATE_CANCELALL:
2472 if (!iCancelCommandExecuted)
2473 {
2474 fprintf(file, "\n Error - Cancel command not executed, Pass the test case but scenario not tested...\n");
2475 }
2476 if (aResponse.GetCmdStatus() == PVMFSuccess)
2477 {
2478 // Init should not complete
2479 iState = STATE_RESET;
2480 RunIfNotReady();
2481 }
2482 else
2483 {
2484 // Init failed
2485 PVPATB_TEST_IS_TRUE(false);
2486 iState = STATE_CLEANUPANDCOMPLETE;
2487 RunIfNotReady();
2488 }
2489 break;
2490
2491 case STATE_WAIT_FOR_CANCELALL:
2492 if (aResponse.GetCmdStatus() == PVMFSuccess)
2493 {
2494 if (aResponse.GetCmdId() != iCurrentCmdId)
2495 {
2496 // Init success. Ignore.
2497 fprintf(file, "\n Init Completed ...\n");
2498 }
2499 else
2500 {
2501 fprintf(file, "\n Cancel all complete ...\n");
2502 // Cancel succeeded so test passed
2503 PVPATB_TEST_IS_TRUE(true);
2504 iState = STATE_CLEANUPANDCOMPLETE;
2505 if (IsBusy())
2506 {
2507 Cancel();
2508 }
2509 RunIfNotReady();
2510 }
2511 }
2512 else if (aResponse.GetCmdStatus() == PVMFErrCancelled)
2513 {
2514 PVPATB_TEST_IS_TRUE(true);
2515 // Init being cancelled. Ignore.
2516 }
2517 else
2518 {
2519 // Cancel failed
2520 PVPATB_TEST_IS_TRUE(false);
2521 iState = STATE_CLEANUPANDCOMPLETE;
2522 RunIfNotReady();
2523 }
2524 break;
2525
2526 case STATE_RESET:
2527 if (aResponse.GetCmdStatus() == PVMFSuccess)
2528 {
2529 iState = STATE_REMOVEDATASOURCE;
2530 RunIfNotReady();
2531 }
2532 else
2533 {
2534 // Reset failed
2535 PVPATB_TEST_IS_TRUE(false);
2536 iState = STATE_CLEANUPANDCOMPLETE;
2537 RunIfNotReady();
2538 }
2539 break;
2540
2541 case STATE_REMOVEDATASOURCE:
2542 if (aResponse.GetCmdStatus() == PVMFSuccess)
2543 {
2544 iState = STATE_CLEANUPANDCOMPLETE;
2545 RunIfNotReady();
2546 }
2547 else
2548 {
2549 // RemoveDataSource failed
2550 PVPATB_TEST_IS_TRUE(false);
2551 iState = STATE_CLEANUPANDCOMPLETE;
2552 RunIfNotReady();
2553 }
2554 break;
2555
2556 default:
2557 {
2558 // Testing error if this is reached
2559 PVPATB_TEST_IS_TRUE(false);
2560 iState = STATE_CLEANUPANDCOMPLETE;
2561 RunIfNotReady();
2562 }
2563 break;
2564 }
2565 }
2566
2567
HandleErrorEvent(const PVAsyncErrorEvent & aEvent)2568 void pvplayer_async_test_3gppdlcancelduringinit::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
2569 {
2570 switch (aEvent.GetEventType())
2571 {
2572 case PVMFErrResourceConfiguration:
2573 // Just log the error
2574 PVPATB_TEST_IS_TRUE(false);
2575 break;
2576
2577 case PVMFErrResource:
2578 // Just log the error
2579 PVPATB_TEST_IS_TRUE(false);
2580 break;
2581
2582 case PVMFErrCorrupt:
2583 // Just log the error
2584 PVPATB_TEST_IS_TRUE(false);
2585 break;
2586
2587 case PVMFErrProcessing:
2588 // Just log the error
2589 PVPATB_TEST_IS_TRUE(false);
2590 break;
2591
2592 default:
2593 // Unknown error and just log the error
2594 PVPATB_TEST_IS_TRUE(false);
2595 break;
2596 }
2597
2598 // Wait for engine to handle the error
2599 Cancel();
2600 }
2601
2602
HandleInformationalEvent(const PVAsyncInformationalEvent & aEvent)2603 void pvplayer_async_test_3gppdlcancelduringinit::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
2604 {
2605 if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
2606 {
2607 fprintf(file, "PVMFInfoErrorHandlingStart...\n");
2608 }
2609 if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
2610 {
2611 fprintf(file, "PVMFInfoErrorHandlingComplete...\n");
2612 iState = STATE_CLEANUPANDCOMPLETE;
2613 RunIfNotReady();
2614 }
2615
2616 if (iState == STATE_CANCELALL && aEvent.GetEventType() == PVMFInfoBufferingStart)
2617 {
2618 RunIfNotReady(10*1000);
2619 }
2620
2621 switch (aEvent.GetEventType())
2622 {
2623 case PVMFInfoBufferingStatus:
2624 {
2625 int32 *percent = (int32*)aEvent.GetLocalBuffer();
2626 if (*percent == 0 || *percent == 100)
2627 {
2628 fprintf(file, " PVMFInfoBufferingStatus %d\n", *percent);
2629 }
2630 else
2631 {
2632 fprintf(file, ".%d.", *percent);
2633 }
2634 }
2635 break;
2636 case PVMFInfoBufferingStart:
2637 fprintf(file, " PVMFInfoBufferingStart\n");
2638 break;
2639 case PVMFInfoBufferingComplete:
2640 fprintf(file, " PVMFInfoBufferingComplete\n");
2641 break;
2642 case PVMFInfoContentLength:
2643 {
2644 PVExclusivePtr eventData;
2645 aEvent.GetEventData(eventData);
2646 uint32 contentSize = (uint32)(eventData);
2647 fprintf(file, " PVMFInfoContentLength = %d\n", contentSize);
2648 }
2649 break;
2650 case PVMFInfoContentTruncated:
2651 {
2652 PVExclusivePtr eventData;
2653 aEvent.GetEventData(eventData);
2654 uint32 downloadSize = (uint32)(eventData);
2655 fprintf(file, "\n PVMFInfoContentTruncated! downloadSize = %d\n", downloadSize);
2656 }
2657 break;
2658
2659 case PVMFInfoContentType:
2660 {
2661 PVExclusivePtr eventData;
2662 aEvent.GetEventData(eventData);
2663 char *constentType = (char *)(eventData);
2664 fprintf(file, " PVMFInfoContentType = %s\n", constentType);
2665 }
2666 break;
2667
2668 case PVMFInfoRemoteSourceNotification:
2669 {
2670 //Examine the extended info message to see if this is the
2671 //"not progressive downloadable" event. If so, notify the
2672 //UI. They may choose to abort the download at this point.
2673 PVMFErrorInfoMessageInterface *msg = NULL;
2674 if (aEvent.GetEventExtensionInterface()
2675 && aEvent.GetEventExtensionInterface()->queryInterface(PVMFErrorInfoMessageInterfaceUUID, (PVInterface*&)msg))
2676 {
2677 //extract the event code and event UUID.
2678 int32 eventcode;
2679 PVUuid eventUuid;
2680 msg->GetCodeUUID(eventcode, eventUuid);
2681 if (eventUuid == PVPlayerErrorInfoEventTypesUUID)
2682 {
2683 PVMFErrorInfoMessageInterface* sourceNodeInfoIF =
2684 msg->GetNextMessage();
2685
2686 if (sourceNodeInfoIF != NULL)
2687 {
2688 PVUuid infoUUID;
2689 int32 srcInfoCode;
2690 sourceNodeInfoIF->GetCodeUUID(srcInfoCode, infoUUID);
2691 if (infoUUID == PVMFFileFormatEventTypesUUID
2692 && srcInfoCode == PVMFMP4FFParserInfoNotPseudostreamableFile)
2693 {
2694 fprintf(file, " PVMFInfoRemoteSourceNotification (not progressive-downloadable)\n");
2695 }
2696 else if (infoUUID == PVMFPROTOCOLENGINENODEInfoEventTypesUUID
2697 && (srcInfoCode >= PVMFPROTOCOLENGINENODEInfo_HTTPRedirectCode300 &&
2698 srcInfoCode <= PVMFPROTOCOLENGINENODEInfo_HTTPRedirectCode307))
2699 {
2700 PVExclusivePtr eventData;
2701 aEvent.GetEventData(eventData);
2702 char *redirectUrl = (char *)(eventData);
2703 fprintf(file, " PVMFInfoRemoteSourceNotification (HTTP Status code = %d), redirectUrl = %s\n",
2704 srcInfoCode - PVMFPROTOCOLENGINENODEInfo_Redirect, redirectUrl);
2705 }
2706
2707 }
2708 }
2709 }
2710 }
2711 break;
2712 default:
2713 break;
2714 }
2715 }
2716
2717
2718 ////////////////////////////////////////////////////////////////////////////////////////
2719 //
2720 // pvplayer_async_test_3gppdlcancelduringinitdelay section
2721 // This test is the same as 105 above, except we delay the cancel call
2722 // It is only made once we receive download status events thus ensuring that Init has
2723 // been received by the parser. This method will fail for small files or high bandwidth!
StartTest()2724 void pvplayer_async_test_3gppdlcancelduringinitdelay::StartTest()
2725 {
2726 AddToScheduler();
2727 iState = STATE_CREATE;
2728 RunIfNotReady();
2729 }
2730
2731
Run()2732 void pvplayer_async_test_3gppdlcancelduringinitdelay::Run()
2733 {
2734 int error = 0;
2735
2736 switch (iState)
2737 {
2738 case STATE_CREATE:
2739 {
2740 iPlayer = NULL;
2741
2742 OSCL_TRY(error, iPlayer = PVPlayerFactory::CreatePlayer(this, this, this));
2743 if (error)
2744 {
2745 PVPATB_TEST_IS_TRUE(false);
2746 iObserver->TestCompleted(*iTestCase);
2747 }
2748 else
2749 {
2750 iState = STATE_ADDDATASOURCE;
2751 RunIfNotReady();
2752 }
2753 }
2754 break;
2755
2756 case STATE_ADDDATASOURCE:
2757 {
2758 OSCL_HeapString<OsclMemAllocator> url(iFileName);
2759 OSCL_HeapString<OsclMemAllocator> default_source(SOURCENAME_PREPEND_STRING);
2760 default_source += DEFAULTSOURCEFILENAME;
2761 if (url == default_source)
2762 {
2763 fprintf(file, "Setting source to %s\n", DEFAULT_CANCEL_DURING_INIT_DELAY_TEST_URL);
2764 url = DEFAULT_CANCEL_DURING_INIT_DELAY_TEST_URL;
2765 }
2766 oscl_wchar wbuf[2];
2767 wbuf[1] = '\0';
2768 for (uint32 i = 0; i < url.get_size(); i++)
2769 {
2770 wbuf[0] = (oscl_wchar)url.get_cstr()[i];
2771 iDownloadURL += wbuf;
2772 }
2773
2774 iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
2775 iDownloadFilename += _STRLIT_WCHAR("test_3gppdlcancelduringinit.loc");
2776
2777 iDownloadProxy = _STRLIT_CHAR("");
2778 int32 iDownloadProxyPort = 0;
2779
2780 iConfigFileName = OUTPUTNAME_PREPEND_WSTRING;
2781 iConfigFileName += _STRLIT_WCHAR("my3gppdlcancel.cfg");
2782
2783 uint32 iMaxFileSize = 0x7FFFFFFF;
2784 bool aIsNewSession = true;
2785 PVMFDownloadDataSourceHTTP::TPVPlaybackControl iPlaybackMode = PVMFDownloadDataSourceHTTP::EAsap;
2786 iDownloadHttpContextData = new PVMFDownloadDataSourceHTTP(aIsNewSession,
2787 iConfigFileName,
2788 iDownloadFilename,
2789 iMaxFileSize,
2790 iDownloadProxy,
2791 iDownloadProxyPort,
2792 iPlaybackMode);
2793
2794 iDataSource = new PVPlayerDataSourceURL;
2795 iDataSource->SetDataSourceURL(iDownloadURL);
2796 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
2797 iDataSource->SetDataSourceContextData(iDownloadHttpContextData);
2798 OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
2799 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
2800 }
2801 break;
2802
2803 case STATE_INIT:
2804 {
2805 OSCL_TRY(error, iInitCmdId = iPlayer->Init((OsclAny*) & iContextObject));
2806 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
2807
2808 //change state but don't call runifinactive yet.
2809 // wait for first Buffering Status event first because by then most nodes will
2810 // actually have started processing Init. This will fail for short clips though
2811 // where Init returns immediately.
2812 iState = STATE_CANCELALL;
2813 }
2814 break;
2815
2816 case STATE_CANCELALL:
2817 {
2818 if (iCancelCommandExecuted)
2819 {
2820 fprintf(file, "\nError - Cancel command being executed multiple times, please verify ...\n");
2821 }
2822 fprintf(file, "\n Cancel all waiting 15 seconds to complete or cancel download ...\n");
2823 OSCL_TRY(error, iCurrentCmdId = iPlayer->CancelAllCommands((OsclAny*) & iContextObject));
2824 iCancelCommandExecuted = true;
2825 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
2826
2827 iState = STATE_WAIT_FOR_CANCELALL;
2828 // 15 second watchdog timer. if Init and cancelAll do not complete until then-> error
2829 RunIfNotReady(15*1000*1000);
2830 }
2831 break;
2832
2833 case STATE_WAIT_FOR_CANCELALL:
2834 {
2835 // Cancel did not complete in time
2836 PVPATB_TEST_IS_TRUE(false);
2837 iState = STATE_CLEANUPANDCOMPLETE;
2838 RunIfNotReady();
2839 }
2840 break;
2841
2842 case STATE_RESET:
2843 {
2844 OSCL_TRY(error, iCurrentCmdId = iPlayer->Reset((OsclAny*) & iContextObject));
2845 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
2846 }
2847 break;
2848
2849 case STATE_REMOVEDATASOURCE:
2850 {
2851 OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
2852 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
2853 }
2854 break;
2855
2856 case STATE_CLEANUPANDCOMPLETE:
2857 {
2858 PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
2859 iPlayer = NULL;
2860
2861 delete iDataSource;
2862 iDataSource = NULL;
2863
2864 delete iDownloadHttpContextData;
2865 iDownloadHttpContextData = NULL;
2866
2867 iObserver->TestCompleted(*iTestCase);
2868 }
2869 break;
2870
2871 default:
2872 break;
2873
2874 }
2875 }
2876
2877
CommandCompleted(const PVCmdResponse & aResponse)2878 void pvplayer_async_test_3gppdlcancelduringinitdelay::CommandCompleted(const PVCmdResponse& aResponse)
2879 {
2880 if (aResponse.GetContext() != NULL)
2881 {
2882 if (aResponse.GetContext() == (OsclAny*)&iContextObject)
2883 {
2884 if (iContextObject != iContextObjectRefValue)
2885 {
2886 // Context data value was corrupted
2887 PVPATB_TEST_IS_TRUE(false);
2888 iState = STATE_CLEANUPANDCOMPLETE;
2889 RunIfNotReady();
2890 return;
2891 }
2892 }
2893 else
2894 {
2895 // Context data pointer was corrupted
2896 PVPATB_TEST_IS_TRUE(false);
2897 iState = STATE_CLEANUPANDCOMPLETE;
2898 RunIfNotReady();
2899 return;
2900 }
2901 }
2902
2903 switch (iState)
2904 {
2905
2906 case STATE_ADDDATASOURCE:
2907 if (aResponse.GetCmdStatus() == PVMFSuccess)
2908 {
2909 iState = STATE_INIT;
2910 RunIfNotReady();
2911 }
2912 else
2913 {
2914 // AddDataSource failed
2915 PVPATB_TEST_IS_TRUE(false);
2916 iState = STATE_CLEANUPANDCOMPLETE;
2917 RunIfNotReady();
2918 }
2919 break;
2920
2921 case STATE_CANCELALL:
2922 if (!iCancelCommandExecuted)
2923 {
2924 fprintf(file, "\n Init complete before CancelAll was issued. Test case passed but scenario not tested \n");
2925 }
2926 if (aResponse.GetCmdStatus() == PVMFSuccess)
2927 {
2928 // Init completed early, pass the test case but scenario not tested.
2929 iState = STATE_RESET;
2930 RunIfNotReady();
2931 }
2932 else
2933 {
2934 // Init failed
2935 PVPATB_TEST_IS_TRUE(false);
2936 iState = STATE_CLEANUPANDCOMPLETE;
2937 RunIfNotReady();
2938 }
2939 break;
2940
2941 case STATE_WAIT_FOR_CANCELALL:
2942 if (aResponse.GetCmdId() == iCurrentCmdId && // cancel command returns
2943 iInitCmdId == -1 && // init has been completed
2944 aResponse.GetCmdStatus() == PVMFSuccess) // cancel was successful
2945 {
2946 fprintf(file, "\n Cancel all complete ...\n");
2947
2948 // Cancel succeeded so test passed
2949 PVPATB_TEST_IS_TRUE(true);
2950 iState = STATE_CLEANUPANDCOMPLETE;
2951 if (IsBusy())
2952 {
2953 Cancel();
2954 }
2955 RunIfNotReady();
2956 }
2957 else if (aResponse.GetCmdStatus() == PVMFErrCancelled && // init was cancelled
2958 aResponse.GetCmdId() == iInitCmdId)
2959 {
2960 PVPATB_TEST_IS_TRUE(true);
2961 // Init has been cancelled - mark as done
2962 iInitCmdId = -1;
2963 }
2964 else
2965 {
2966 // Cancel failed
2967 fprintf(file, "\n Previous command was not cancelled or cancel failed ...\n");
2968
2969 PVPATB_TEST_IS_TRUE(false);
2970 iState = STATE_CLEANUPANDCOMPLETE;
2971 RunIfNotReady();
2972 }
2973 break;
2974
2975 case STATE_RESET:
2976 if (aResponse.GetCmdStatus() == PVMFSuccess)
2977 {
2978 iState = STATE_REMOVEDATASOURCE;
2979 RunIfNotReady();
2980 }
2981 else
2982 {
2983 // Reset failed
2984 PVPATB_TEST_IS_TRUE(false);
2985 iState = STATE_CLEANUPANDCOMPLETE;
2986 RunIfNotReady();
2987 }
2988 break;
2989
2990 case STATE_REMOVEDATASOURCE:
2991 if (aResponse.GetCmdStatus() == PVMFSuccess)
2992 {
2993 iState = STATE_CLEANUPANDCOMPLETE;
2994 RunIfNotReady();
2995 }
2996 else
2997 {
2998 // RemoveDataSource failed
2999 PVPATB_TEST_IS_TRUE(false);
3000 iState = STATE_CLEANUPANDCOMPLETE;
3001 RunIfNotReady();
3002 }
3003 break;
3004
3005 default:
3006 {
3007 // Testing error if this is reached
3008 PVPATB_TEST_IS_TRUE(false);
3009 iState = STATE_CLEANUPANDCOMPLETE;
3010 RunIfNotReady();
3011 }
3012 break;
3013 }
3014 }
3015
3016
HandleErrorEvent(const PVAsyncErrorEvent & aEvent)3017 void pvplayer_async_test_3gppdlcancelduringinitdelay::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
3018 {
3019 switch (aEvent.GetEventType())
3020 {
3021 case PVMFErrResourceConfiguration:
3022 // Just log the error
3023 PVPATB_TEST_IS_TRUE(false);
3024 break;
3025
3026 case PVMFErrResource:
3027 // Just log the error
3028 PVPATB_TEST_IS_TRUE(false);
3029 break;
3030
3031 case PVMFErrCorrupt:
3032 // Just log the error
3033 PVPATB_TEST_IS_TRUE(false);
3034 break;
3035
3036 case PVMFErrProcessing:
3037 // Just log the error
3038 PVPATB_TEST_IS_TRUE(false);
3039 break;
3040
3041 default:
3042 // Unknown error and just log the error
3043 PVPATB_TEST_IS_TRUE(false);
3044 break;
3045 }
3046
3047 // Wait for engine to handle the error
3048 Cancel();
3049 }
3050
3051
HandleInformationalEvent(const PVAsyncInformationalEvent & aEvent)3052 void pvplayer_async_test_3gppdlcancelduringinitdelay::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
3053 {
3054 if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
3055 {
3056 fprintf(file, "PVMFInfoErrorHandlingStart...\n");
3057 }
3058 if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
3059 {
3060 fprintf(file, "PVMFInfoErrorHandlingComplete...\n");
3061 iState = STATE_CLEANUPANDCOMPLETE;
3062 RunIfNotReady();
3063 }
3064
3065 switch (aEvent.GetEventType())
3066 {
3067 case PVMFInfoBufferingStatus:
3068 {
3069 int32 *percent = (int32*)aEvent.GetLocalBuffer();
3070 if (*percent == 0 || *percent == 100)
3071 {
3072 fprintf(file, " PVMFInfoBufferingStatus %d\n", *percent);
3073 }
3074 else
3075 {
3076 fprintf(file, ".%d.", *percent);
3077 }
3078 if (iState == STATE_CANCELALL && !iCancelCommandExecuted)
3079 {
3080 // now is the time to call CancelAll since processing of download has started
3081 RunIfNotReady();
3082 }
3083 }
3084 break;
3085 case PVMFInfoBufferingStart:
3086 fprintf(file, " PVMFInfoBufferingStart\n");
3087 break;
3088 case PVMFInfoBufferingComplete:
3089 fprintf(file, " PVMFInfoBufferingComplete\n");
3090 break;
3091 case PVMFInfoContentLength:
3092 {
3093 PVExclusivePtr eventData;
3094 aEvent.GetEventData(eventData);
3095 uint32 contentSize = (uint32)(eventData);
3096 fprintf(file, " PVMFInfoContentLength = %d\n", contentSize);
3097 }
3098 break;
3099 case PVMFInfoContentTruncated:
3100 {
3101 PVExclusivePtr eventData;
3102 aEvent.GetEventData(eventData);
3103 uint32 downloadSize = (uint32)(eventData);
3104 fprintf(file, "\n PVMFInfoContentTruncated! downloadSize = %d\n", downloadSize);
3105 }
3106 break;
3107
3108 case PVMFInfoContentType:
3109 {
3110 PVExclusivePtr eventData;
3111 aEvent.GetEventData(eventData);
3112 char *constentType = (char *)(eventData);
3113 fprintf(file, " PVMFInfoContentType = %s\n", constentType);
3114 }
3115 break;
3116
3117 case PVMFInfoRemoteSourceNotification:
3118 {
3119 //Examine the extended info message to see if this is the
3120 //"not progressive downloadable" event. If so, notify the
3121 //UI. They may choose to abort the download at this point.
3122 PVMFErrorInfoMessageInterface *msg = NULL;
3123 if (aEvent.GetEventExtensionInterface()
3124 && aEvent.GetEventExtensionInterface()->queryInterface(PVMFErrorInfoMessageInterfaceUUID, (PVInterface*&)msg))
3125 {
3126 //extract the event code and event UUID.
3127 int32 eventcode;
3128 PVUuid eventUuid;
3129 msg->GetCodeUUID(eventcode, eventUuid);
3130 if (eventUuid == PVPlayerErrorInfoEventTypesUUID)
3131 {
3132 PVMFErrorInfoMessageInterface* sourceNodeInfoIF =
3133 msg->GetNextMessage();
3134
3135 if (sourceNodeInfoIF != NULL)
3136 {
3137 PVUuid infoUUID;
3138 int32 srcInfoCode;
3139 sourceNodeInfoIF->GetCodeUUID(srcInfoCode, infoUUID);
3140 if (infoUUID == PVMFFileFormatEventTypesUUID
3141 && srcInfoCode == PVMFMP4FFParserInfoNotPseudostreamableFile)
3142 {
3143 fprintf(file, " PVMFInfoRemoteSourceNotification (not progressive-downloadable)\n");
3144 }
3145 else if (infoUUID == PVMFPROTOCOLENGINENODEInfoEventTypesUUID
3146 && (srcInfoCode >= PVMFPROTOCOLENGINENODEInfo_HTTPRedirectCode300 &&
3147 srcInfoCode <= PVMFPROTOCOLENGINENODEInfo_HTTPRedirectCode307))
3148 {
3149 PVExclusivePtr eventData;
3150 aEvent.GetEventData(eventData);
3151 char *redirectUrl = (char *)(eventData);
3152 fprintf(file, " PVMFInfoRemoteSourceNotification (HTTP Status code = %d), redirectUrl = %s\n",
3153 srcInfoCode - PVMFPROTOCOLENGINENODEInfo_Redirect, redirectUrl);
3154 }
3155
3156 }
3157 }
3158 }
3159 }
3160 break;
3161 default:
3162 break;
3163 }
3164 }
3165 ////////////////////////////////////////////////////////////////////////////////////////
3166
3167 //
3168 // pvplayer_async_test_3gppdlcontenttoolarge section
3169 //
~pvplayer_async_test_3gppdlcontenttoolarge()3170 pvplayer_async_test_3gppdlcontenttoolarge::~pvplayer_async_test_3gppdlcontenttoolarge()
3171 {
3172 }
3173
3174
CreateDataSource()3175 void pvplayer_async_test_3gppdlcontenttoolarge::CreateDataSource()
3176 {
3177 OSCL_HeapString<OsclMemAllocator> url(iFileName);
3178 OSCL_HeapString<OsclMemAllocator> default_source(SOURCENAME_PREPEND_STRING);
3179 default_source += DEFAULTSOURCEFILENAME;
3180 if (url == default_source)
3181 {
3182 fprintf(file, "Setting source to %s\n", DEFAULT_3GPPDL_URL);
3183 url = DEFAULT_3GPPDL_URL;
3184 }
3185 oscl_wchar wbuf[2];
3186 wbuf[1] = '\0';
3187 for (uint32 i = 0; i < url.get_size(); i++)
3188 {
3189 wbuf[0] = (oscl_wchar)url.get_cstr()[i];
3190 iDownloadURL += wbuf;
3191 }
3192 iDataSource = new PVPlayerDataSourceURL;
3193 iDataSource->SetDataSourceURL(iDownloadURL);
3194 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
3195
3196 iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
3197 iDownloadFilename += _STRLIT_WCHAR("test_3gppcontenttoolarge.loc");
3198
3199 iDownloadProxy = _STRLIT_CHAR("");
3200 int32 iDownloadProxyPort = 0;
3201
3202 iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
3203 iDownloadConfigFilename += _STRLIT_WCHAR("my3gppdl_contenttoolarge.cfg");
3204
3205 // Set the max file size to a small number
3206 uint32 iMaxFileSize = 0x7FFF;
3207 fprintf(file, " Setting iMaxFileSize to %d\n", iMaxFileSize);
3208
3209 // Set the iContentTooLarge to TRUE. This will return success
3210 // for INIT failure of PVMFErrContentTooLarge
3211 iContentTooLarge = true;
3212
3213 bool aIsNewSession = true;
3214
3215 iDownloadOnly = true;
3216
3217 iDownloadContextData = new PVMFSourceContextData();
3218 iDownloadContextData->EnableCommonSourceContext();
3219 iDownloadContextData->EnableDownloadHTTPSourceContext();
3220 iDownloadContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
3221 iDownloadContextData->DownloadHTTPData()->iConfigFileName = iDownloadConfigFilename;
3222 iDownloadContextData->DownloadHTTPData()->iDownloadFileName = iDownloadFilename;
3223 iDownloadContextData->DownloadHTTPData()->iMaxFileSize = iMaxFileSize;
3224 iDownloadContextData->DownloadHTTPData()->iProxyName = iDownloadProxy;
3225 iDownloadContextData->DownloadHTTPData()->iProxyPort = iDownloadProxyPort;
3226 iDownloadContextData->DownloadHTTPData()->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::ENoPlayback;
3227
3228 iDataSource->SetDataSourceContextData(iDownloadContextData);
3229 }
3230
CreateDataSinkVideo()3231 void pvplayer_async_test_3gppdlcontenttoolarge::CreateDataSinkVideo()
3232 {
3233 //won't be called
3234 PVPATB_TEST_IS_TRUE(false);
3235 }
3236
CreateDataSinkAudio()3237 void pvplayer_async_test_3gppdlcontenttoolarge::CreateDataSinkAudio()
3238 {
3239 //won't be called
3240 PVPATB_TEST_IS_TRUE(false);
3241 }
3242
3243
3244 //
3245 // pvplayer_async_test_3gppdlContentTruncated section
3246 //
~pvplayer_async_test_3gppdlContentTruncated()3247 pvplayer_async_test_3gppdlContentTruncated::~pvplayer_async_test_3gppdlContentTruncated()
3248 {
3249 }
3250
CreateDataSource()3251 void pvplayer_async_test_3gppdlContentTruncated::CreateDataSource()
3252 {
3253 OSCL_HeapString<OsclMemAllocator> url(iFileName);
3254 OSCL_HeapString<OsclMemAllocator> default_source(SOURCENAME_PREPEND_STRING);
3255 default_source += DEFAULTSOURCEFILENAME;
3256 if (url == default_source)
3257 {
3258 fprintf(file, "Setting source to %s\n", DEFAULT_TRUNCATED_TEST_URL);
3259 url = DEFAULT_TRUNCATED_TEST_URL;
3260 }
3261 oscl_wchar wbuf[2];
3262 wbuf[1] = '\0';
3263 for (uint32 i = 0; i < url.get_size(); i++)
3264 {
3265 wbuf[0] = (oscl_wchar)url.get_cstr()[i];
3266 iDownloadURL += wbuf;
3267 }
3268 iDataSource = new PVPlayerDataSourceURL;
3269 iDataSource->SetDataSourceURL(iDownloadURL);
3270 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
3271
3272 iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
3273 iDownloadFilename += _STRLIT_WCHAR("test_3gppdownload_truncated.loc");
3274
3275 iDownloadProxy = _STRLIT_CHAR("");
3276 int32 iDownloadProxyPort = 0;
3277
3278 iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
3279 iDownloadConfigFilename += _STRLIT_WCHAR("my3gppdl_truncated.cfg");
3280
3281 iContentTooLarge = false;
3282
3283 // Set the iMaxFileSize smaller than the downloading file
3284 uint32 iMaxFileSize = 3000; //0x7FFFF;
3285
3286 bool aIsNewSession = true;
3287
3288 iDownloadContextData = new PVMFSourceContextData();
3289 iDownloadContextData->EnableCommonSourceContext();
3290 iDownloadContextData->EnableDownloadHTTPSourceContext();
3291 iDownloadContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
3292 iDownloadContextData->DownloadHTTPData()->iConfigFileName = iDownloadConfigFilename;
3293 iDownloadContextData->DownloadHTTPData()->iDownloadFileName = iDownloadFilename;
3294 iDownloadContextData->DownloadHTTPData()->iMaxFileSize = iMaxFileSize;
3295 iDownloadContextData->DownloadHTTPData()->iProxyName = iDownloadProxy;
3296 iDownloadContextData->DownloadHTTPData()->iProxyPort = iDownloadProxyPort;
3297 iDownloadContextData->DownloadHTTPData()->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::EAsap;
3298
3299 iDataSource->SetDataSourceContextData(iDownloadContextData);
3300 }
3301
CreateDataSinkVideo()3302 void pvplayer_async_test_3gppdlContentTruncated::CreateDataSinkVideo()
3303 {
3304 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
3305 sinkfile += _STRLIT_WCHAR("test_player_3gppdl_truncated_video.dat");
3306 iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
3307 iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
3308 iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
3309 ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
3310 }
CreateDataSinkAudio()3311 void pvplayer_async_test_3gppdlContentTruncated::CreateDataSinkAudio()
3312 {
3313 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
3314 sinkfile += _STRLIT_WCHAR("test_player_3gppdl_truncated_audio.dat");
3315 iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
3316 iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
3317 iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
3318 ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
3319 }
3320
3321
3322 //
3323 //pvplayer_async_test_ppb_base section
3324 //
3325
PrintMetadata()3326 void pvplayer_async_test_ppb_base::PrintMetadata()
3327 {
3328 for (uint32 i = 0; i < iMetadataValueList.size(); i++)
3329 {
3330 if (!iMetadataValueList[i].key)
3331 {
3332 fprintf(file, " Metadata Key Missing!, value ?\n");
3333 PVPATB_TEST_IS_TRUE(false);
3334 }
3335 else if (oscl_strstr(iMetadataValueList[i].key, "valtype=char*"))
3336 {
3337 fprintf(file, " Metadata Key '%s', value '%s'\n", iMetadataValueList[i].key, iMetadataValueList[i].value.pChar_value);
3338 }
3339 else if (oscl_strstr(iMetadataValueList[i].key, "valtype=wchar*"))
3340 {
3341 OSCL_HeapString<OsclMemAllocator> ostr;
3342 char buf[2];
3343 buf[1] = '\0';
3344 for (uint32 j = 0;; j++)
3345 {
3346 if (iMetadataValueList[i].value.pWChar_value[j] == '\0')
3347 break;
3348 buf[0] = iMetadataValueList[i].value.pWChar_value[j];
3349 ostr += buf;
3350 }
3351 fprintf(file, " Metadata Key '%s', value '%s'\n", iMetadataValueList[i].key, ostr.get_str());
3352 }
3353 else if (oscl_strstr(iMetadataValueList[i].key, "valtype=uint32"))
3354 {
3355 fprintf(file, " Metadata Key '%s', value %d\n", iMetadataValueList[i].key, iMetadataValueList[i].value.uint32_value);
3356 }
3357 else if (oscl_strstr(iMetadataValueList[i].key, "valtype=bool"))
3358 {
3359 fprintf(file, " Metadata Key '%s', value %d\n", iMetadataValueList[i].key, iMetadataValueList[i].value.bool_value);
3360 }
3361 else if (oscl_strstr(iMetadataValueList[i].key, "valtype=uint8*"))
3362 {
3363 fprintf(file, " Metadata Key '%s', len %d\n", iMetadataValueList[i].key, iMetadataValueList[i].length);
3364 }
3365 else
3366 {
3367 fprintf(file, " Metadata Key '%s', value ?\n", iMetadataValueList[i].key);
3368 }
3369 if ((oscl_strstr(iMetadataValueList[i].key, "duration")) && iSessionDuration == 0)
3370 {
3371 iSessionDuration = iMetadataValueList[i].value.uint32_value;
3372
3373 // Check the timescale. If not available, assume millisecond (1000)
3374 const char *retTSstr;
3375 retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
3376 uint32 retTSstrLen = 0;
3377 uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
3378 if (retTSstr != NULL)
3379 {
3380 retTSstrLen = oscl_strlen(retTSstr);
3381 if (retTSstrLen > tsstrlen)
3382 {
3383 uint32 timescale = 0;
3384 PV_atoi((char*)(retTSstr + tsstrlen), 'd', (retTSstrLen - tsstrlen), timescale);
3385 if (timescale > 0 && timescale != 1000)
3386 {
3387 // Convert to milliseconds
3388 MediaClockConverter mcc(timescale);
3389 mcc.update_clock(iSessionDuration);
3390 iSessionDuration = mcc.get_converted_ts(1000);
3391 }
3392 }
3393 }
3394 }
3395 }
3396 fprintf(file, "\n\n");
3397 }
3398
StartTest()3399 void pvplayer_async_test_ppb_base::StartTest()
3400 {
3401 AddToScheduler();
3402 iState = STATE_CREATE;
3403 RunIfNotReady();
3404 }
3405
3406
Run()3407 void pvplayer_async_test_ppb_base::Run()
3408 {
3409 int error = 0;
3410
3411 switch (iState)
3412 {
3413 case STATE_CREATE:
3414 {
3415 iPlayer = NULL;
3416
3417 OSCL_TRY(error, iPlayer = PVPlayerFactory::CreatePlayer(this, this, this));
3418 if (error)
3419 {
3420 PVPATB_TEST_IS_TRUE(false);
3421 iObserver->TestCompleted(*iTestCase);
3422 }
3423 else
3424 {
3425 iState = STATE_QUERYINTERFACE;
3426 RunIfNotReady();
3427 }
3428 }
3429 break;
3430
3431 case STATE_QUERYINTERFACE:
3432 {
3433 fprintf(iTestMsgOutputFile, "***Query Interface...\n");
3434 PVUuid capconfigifuuid = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
3435 OSCL_TRY(error, iCurrentCmdId = iPlayer->QueryInterface(capconfigifuuid, (PVInterface*&)iPlayerCapConfigIF, (OsclAny*) & iContextObject));
3436 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3437 }
3438 break;
3439
3440 case STATE_ADDDATASOURCE:
3441 CreateDataSource();
3442 OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
3443 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3444 break;
3445
3446 case STATE_CONFIGPARAMS:
3447 {
3448 fprintf(iTestMsgOutputFile, "***Configuring Params...\n");
3449
3450 //set user-agent, make sure to set as "PVPLAYER VersionNumber" to satisfy Fast Track PV server for Fast Track test
3451
3452 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*;mode=download");
3453 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
3454
3455 // OSCL_wHeapString<OsclMemAllocator> userAgent(_STRLIT_WCHAR("PVPLAYER 18akljfaljfa"));
3456 OSCL_wHeapString<OsclMemAllocator> userAgent(_STRLIT_WCHAR("PVPLAYER 18.07.00.02"));
3457 iKVPSetAsync.value.pWChar_value = userAgent.get_str();
3458 iErrorKVP = NULL;
3459 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
3460 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3461
3462 // set http version number
3463 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/http-version;valtype=uint32");
3464 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
3465 iKVPSetAsync.value.uint32_value = 0;
3466 iErrorKVP = NULL;
3467 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
3468 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3469
3470 // set http timeout
3471 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/http-timeout;valtype=uint32");
3472 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
3473 iKVPSetAsync.value.uint32_value = 20;
3474 iErrorKVP = NULL;
3475 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
3476 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3477
3478 // set number of redirects
3479 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/num-redirect-attempts;valtype=uint32");
3480 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
3481 iKVPSetAsync.value.uint32_value = 4;
3482 iErrorKVP = NULL;
3483 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
3484 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3485
3486 // set extension header
3487 // set arbitrary extension header one by one
3488 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*");
3489 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
3490 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeader(_STRLIT_CHAR("key=PVPlayerCoreEngineTest;value=Test;method=GET,HEAD"));
3491 iKVPSetAsync.value.pChar_value = protocolExtensionHeader.get_str();
3492 iKVPSetAsync.capacity = protocolExtensionHeader.get_size();
3493 iErrorKVP = NULL;
3494 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
3495 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3496
3497 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*");
3498 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
3499 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderGet(_STRLIT_CHAR("key=PVPlayerCoreEngineTest;value=GetHeader;method=GET"));
3500 iKVPSetAsync.value.pChar_value = protocolExtensionHeaderGet.get_str();
3501 iKVPSetAsync.capacity = protocolExtensionHeaderGet.get_size();
3502 iErrorKVP = NULL;
3503 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
3504 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3505
3506 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*");
3507 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
3508 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderHead(_STRLIT_CHAR("key=PVPlayerCoreEngineTest;value=HeadHeader;method=HEAD"));
3509 iKVPSetAsync.value.pChar_value = protocolExtensionHeaderHead.get_str();
3510 iKVPSetAsync.capacity = protocolExtensionHeaderHead.get_size();
3511 iErrorKVP = NULL;
3512 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
3513 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3514
3515 // Unnecessary Header should not display
3516 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*");
3517 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
3518 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderPost(_STRLIT_CHAR("key=PVPlayerCoreEngineTest;value=PostHeader;method=POST"));
3519 iKVPSetAsync.value.pChar_value = protocolExtensionHeaderPost.get_str();
3520 iKVPSetAsync.capacity = protocolExtensionHeaderPost.get_size();
3521 iErrorKVP = NULL;
3522 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
3523 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3524
3525
3526 // set extension header
3527 // set arbitrary extension headers all together
3528 PvmiKvp kvpheader[3];
3529 //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=download"));
3530 OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=download;purge-on-redirect"));
3531 //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;purge-on-redirect"));
3532 //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*"));
3533 //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=streaming"));
3534
3535
3536 kvpheader[0].key = paramkey.get_str();
3537 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeader1(_STRLIT_CHAR("key=X1;value=Y1;method=GET,HEAD"));
3538 kvpheader[0].value.pChar_value = protocolExtensionHeader1.get_str();
3539 kvpheader[0].capacity = protocolExtensionHeader1.get_size();
3540
3541 kvpheader[1].key = paramkey.get_str();
3542 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderGet1(_STRLIT_CHAR("key=X2;value=Y2;method=GET"));
3543 kvpheader[1].value.pChar_value = protocolExtensionHeaderGet1.get_str();
3544 kvpheader[1].capacity = protocolExtensionHeaderGet1.get_size();
3545
3546 kvpheader[2].key = paramkey.get_str();
3547 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderHead1(_STRLIT_CHAR("key=X3;value=Y3;method=HEAD"));
3548 kvpheader[2].value.pChar_value = protocolExtensionHeaderHead1.get_str();
3549 kvpheader[2].capacity = protocolExtensionHeaderHead1.get_size();
3550
3551 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, kvpheader, 3, iErrorKVP));
3552 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3553
3554 // enable or disable HEAD request
3555 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/http-header-request-disabled;valtype=bool");
3556 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
3557 iKVPSetAsync.value.bool_value = true;
3558 iErrorKVP = NULL;
3559 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
3560 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3561
3562 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/max-tcp-recv-buffer-size-download;valtype=uint32");
3563 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
3564 iKVPSetAsync.value.uint32_value = 64000;
3565 iErrorKVP = NULL;
3566 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
3567 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3568
3569 /////////////////////////////////////////////////////////
3570 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;purge-on-redirect");
3571 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
3572 OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderCookie(_STRLIT_CHAR("key=Cookie; value=key1=value1; key2=value2"));
3573 iKVPSetAsync.value.pChar_value = protocolExtensionHeaderCookie.get_str();
3574 iKVPSetAsync.capacity = protocolExtensionHeaderCookie.get_size();
3575 iErrorKVP = NULL;
3576 OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
3577 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
3578 /////////////////////////////////////////////////////////
3579
3580
3581 iState = STATE_INIT;
3582 RunIfNotReady();
3583 }
3584 break;
3585
3586 case STATE_INIT:
3587 {
3588 OSCL_TRY(error, iCurrentCmdId = iPlayer->Init((OsclAny*) & iContextObject));
3589 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3590 }
3591 break;
3592
3593 case STATE_WAIT_FOR_BUFFCOMPLETE:
3594 if (iNumBufferingComplete > 0)
3595 {
3596 if (iRepositionAfterDownloadComplete == false)
3597 {
3598 //playback cases play 10 more seconds then stop.
3599 iState = STATE_STOP;
3600 if (iPlayUntilEOS == false)
3601 {
3602 RunIfNotReady(10*1000*1000);
3603 }
3604 else
3605 {
3606 //wait for EOS
3607 }
3608 }
3609 else
3610 {
3611 iState = STATE_SETPLAYBACKRANGE;
3612 RunIfNotReady();
3613 }
3614 }
3615 else
3616 {
3617 //timed out while waiting.
3618 PVPATB_TEST_IS_TRUE(false);
3619 iState = STATE_CLEANUPANDCOMPLETE;
3620 RunIfNotReady();
3621 }
3622 break;
3623
3624 case STATE_ADDDATASINK_VIDEO:
3625 {
3626 CreateDataSinkVideo();
3627 OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
3628 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3629 }
3630 break;
3631
3632
3633 case STATE_ADDDATASINK_AUDIO:
3634 {
3635 CreateDataSinkAudio();
3636 OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
3637 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3638 }
3639 break;
3640
3641 case STATE_PREPARE:
3642 case STATE_PREPARE_AFTERSTOP:
3643 {
3644 OSCL_TRY(error, iCurrentCmdId = iPlayer->Prepare((OsclAny*) & iContextObject));
3645 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3646 }
3647 break;
3648
3649 case STATE_GETMETADATAKEYLIST:
3650 {
3651 iMetadataKeyList.clear();
3652 OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataKeys(iMetadataKeyList, 0, 100, NULL, (OsclAny*) & iContextObject));
3653 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3654 }
3655 break;
3656
3657 case STATE_GETMETADATAVALUELIST:
3658 {
3659 iMetadataValueList.clear();
3660 iNumValues = 0;
3661 OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, 100, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
3662 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3663 }
3664 break;
3665
3666 case STATE_WAIT_FOR_DATAREADY:
3667 {
3668 if (iNumDataReady > 0)
3669 {
3670 //playback cases wait on data ready, then start engine.
3671 iState = STATE_START;
3672 RunIfNotReady();
3673 }
3674 else
3675 {
3676 //timed out while waiting.
3677 PVPATB_TEST_IS_TRUE(false);
3678 iState = STATE_CLEANUPANDCOMPLETE;
3679 RunIfNotReady();
3680 }
3681 }
3682 break;
3683
3684 case STATE_START:
3685 case STATE_START_AFTERSTOP:
3686 {
3687 OSCL_TRY(error, iCurrentCmdId = iPlayer->Start((OsclAny*) & iContextObject));
3688 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3689 }
3690 break;
3691
3692 case STATE_SETPLAYBACKRANGE:
3693 {
3694 if (iSessionDuration > 0)
3695 {
3696 fprintf(iTestMsgOutputFile, "***Repositioning to %d ms\n", (iSessionDuration / 4));
3697 PVPPlaybackPosition start, end;
3698 start.iIndeterminate = false;
3699 start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
3700 start.iMode = PVPPBPOS_MODE_NOW;
3701 start.iPosValue.millisec_value = iSessionDuration / 4;
3702 end.iIndeterminate = true;
3703 OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
3704 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3705 }
3706 else
3707 {
3708 fprintf(iTestMsgOutputFile, "***Set PlayBack Range Not Supported for a session with unknown duration...\n");
3709 }
3710 }
3711 break;
3712
3713 case STATE_SETPLAYBACKRANGE_AFTERSTART:
3714 {
3715 // default clip duration is ~206000ms
3716 // seek to almost the end of duration (forward)
3717 // so to trigger a download complete condition
3718 PVPPlaybackPosition start, end;
3719 start.iIndeterminate = false;
3720 start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
3721 start.iMode = PVPPBPOS_MODE_NOW;
3722 if (iForwardStep)
3723 {
3724 fprintf(iTestMsgOutputFile, "\n***Repositioning to %d ms\n", iForwardSeekTime);
3725 start.iPosValue.millisec_value = iForwardSeekTime;
3726 if (iForwardSeekTime < iEndTime)
3727 {
3728 iForwardSeekTime += iForwardSeekStep;
3729 }
3730 else
3731 {
3732 iForwardSeekTime = iBeginTime;
3733 }
3734 }
3735 else
3736 {
3737 fprintf(iTestMsgOutputFile, "\n***Repositioning to %d ms\n", 180000);
3738 start.iPosValue.millisec_value = 180000;
3739 }
3740 end.iIndeterminate = true;
3741 OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
3742 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3743 }
3744 break;
3745
3746 case STATE_SETPLAYBACKRANGE_BEFORESTART:
3747 {
3748 // default clip duration is ~206000ms
3749 // seek to 3/4 of duration
3750 fprintf(iTestMsgOutputFile, "\n***Repositioning to %d ms\n", 120000);
3751 PVPPlaybackPosition start, end;
3752 start.iIndeterminate = false;
3753 start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
3754 start.iMode = PVPPBPOS_MODE_NOW;
3755 start.iPosValue.millisec_value = 120000;
3756 end.iIndeterminate = true;
3757 OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
3758 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3759 }
3760 break;
3761
3762 case STATE_SETPLAYBACKRANGE_AFTERSTART_TWICE:
3763 {
3764 // default clip duration is ~206000ms
3765 // seek to 1/2 duration (backward)
3766 PVPPlaybackPosition start, end;
3767 start.iIndeterminate = false;
3768 start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
3769 start.iMode = PVPPBPOS_MODE_NOW;
3770 if (iForwardStep)
3771 {
3772 fprintf(iTestMsgOutputFile, "\n***Repositioning to %d ms\n", iForwardSeekTime);
3773 start.iPosValue.millisec_value = iForwardSeekTime;
3774 if (iForwardSeekTime < iEndTime)
3775 {
3776 iForwardSeekTime += iForwardSeekStep;
3777 }
3778 else
3779 {
3780 iForwardSeekTime = iBeginTime;
3781 }
3782 }
3783 else
3784 {
3785 fprintf(iTestMsgOutputFile, "\n***Repositioning to %d ms\n", 100000);
3786 start.iPosValue.millisec_value = 100000;
3787 }
3788 end.iIndeterminate = true;
3789 OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
3790 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3791 }
3792 break;
3793
3794 case STATE_SETPLAYBACKRANGE_AFTERDOWNLOADCOMPLETE:
3795 {
3796 PVPPlaybackPosition start, end, current;
3797 start.iIndeterminate = false;
3798 start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
3799 start.iMode = PVPPBPOS_MODE_NOW;
3800 end.iIndeterminate = true;
3801 if (iSeekToBOC)
3802 {
3803 // download has completed, rewind back to 0 sec
3804 fprintf(iTestMsgOutputFile, "\n***Repositioning to 0 ms\n");
3805 start.iPosValue.millisec_value = 0;
3806 }
3807 else if (iSeekInCache)
3808 {
3809 current.iPosUnit = PVPPBPOSUNIT_MILLISEC;
3810 iPlayer->GetCurrentPositionSync(current);
3811 // download has completed, seek to a position in cache (the rest of the clip should be there)
3812 fprintf(iTestMsgOutputFile, "\n***Repositioning to %d ms", current.iPosValue.millisec_value + 5000);
3813 start.iPosValue.millisec_value = current.iPosValue.millisec_value + 5000;
3814 }
3815 OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
3816 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3817 }
3818 break;
3819
3820 case STATE_PAUSE:
3821 case STATE_PAUSE_TWICE:
3822 case STATE_PAUSE_AFTERDOWNLOADCOMPLETE:
3823 {
3824 OSCL_TRY(error, iCurrentCmdId = iPlayer->Pause((OsclAny*) & iContextObject));
3825 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3826 }
3827 break;
3828
3829 case STATE_RESUME:
3830 case STATE_RESUME_TWICE:
3831 case STATE_RESUME_AFTERDOWNLOADCOMPLETE:
3832 {
3833 OSCL_TRY(error, iCurrentCmdId = iPlayer->Resume((OsclAny*) & iContextObject));
3834 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3835 }
3836 break;
3837
3838 case STATE_STOP:
3839 case STATE_STOP_TWICE:
3840 {
3841 if (iState == STATE_STOP)
3842 {
3843 if (iSessionDuration == 0)
3844 fprintf(file, " DURATION Not Received\n");
3845 else
3846 fprintf(file, " GOT Duration %d \n\n", iSessionDuration);
3847 }
3848 OSCL_TRY(error, iCurrentCmdId = iPlayer->Stop((OsclAny*) & iContextObject));
3849 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3850 }
3851 break;
3852
3853 case STATE_REMOVEDATASINK_VIDEO:
3854 {
3855 OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
3856 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3857 }
3858 break;
3859
3860 case STATE_REMOVEDATASINK_AUDIO:
3861 {
3862 OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
3863 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3864 }
3865 break;
3866
3867 case STATE_RESET:
3868 {
3869 OSCL_TRY(error, iCurrentCmdId = iPlayer->Reset((OsclAny*) & iContextObject));
3870 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3871 }
3872 break;
3873
3874 case STATE_REMOVEDATASOURCE:
3875 {
3876 OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
3877 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
3878 }
3879 break;
3880
3881 case STATE_CLEANUPANDCOMPLETE:
3882 {
3883 fprintf(file, "Events:\n");
3884 fprintf(file, " Num BuffStart %d\n", iNumBufferingStart);
3885 fprintf(file, " Num BuffComplete %d\n", iNumBufferingComplete);
3886 fprintf(file, " Num Data Ready %d\n", iNumDataReady);
3887 fprintf(file, " Num Underflow %d\n", iNumUnderflow);
3888
3889 PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
3890 iPlayer = NULL;
3891
3892 delete iDataSource;
3893 iDataSource = NULL;
3894
3895 delete iDownloadContextData;
3896 iDownloadContextData = NULL;
3897
3898 delete iDataSinkVideo;
3899 iDataSinkVideo = NULL;
3900
3901 delete iDataSinkAudio;
3902 iDataSinkAudio = NULL;
3903
3904 PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeVideo);
3905 iIONodeVideo = NULL;
3906
3907 PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeAudio);
3908 iIONodeAudio = NULL;
3909
3910 iMioFactory->DestroyVideoOutput(iMIOFileOutVideo);
3911 iMIOFileOutVideo = NULL;
3912
3913 iMioFactory->DestroyAudioOutput(iMIOFileOutAudio);
3914 iMIOFileOutAudio = NULL;
3915
3916 //call the test-case specific cleanup.
3917 CleanupData();
3918
3919 iObserver->TestCompleted(*iTestCase);
3920 }
3921 break;
3922
3923 default:
3924 break;
3925
3926 }
3927 }
3928
3929
CommandCompleted(const PVCmdResponse & aResponse)3930 void pvplayer_async_test_ppb_base::CommandCompleted(const PVCmdResponse& aResponse)
3931 {
3932 if (aResponse.GetCmdId() != iCurrentCmdId)
3933 {
3934 // Wrong command ID.
3935 PVPATB_TEST_IS_TRUE(false);
3936 iState = STATE_CLEANUPANDCOMPLETE;
3937 RunIfNotReady();
3938 return;
3939 }
3940
3941 if (aResponse.GetContext() != NULL)
3942 {
3943 if (aResponse.GetContext() == (OsclAny*)&iContextObject)
3944 {
3945 if (iContextObject != iContextObjectRefValue)
3946 {
3947 // Context data value was corrupted
3948 PVPATB_TEST_IS_TRUE(false);
3949 iState = STATE_CLEANUPANDCOMPLETE;
3950 RunIfNotReady();
3951 return;
3952 }
3953 }
3954 else
3955 {
3956 // Context data pointer was corrupted
3957 PVPATB_TEST_IS_TRUE(false);
3958 iState = STATE_CLEANUPANDCOMPLETE;
3959 RunIfNotReady();
3960 return;
3961 }
3962 }
3963
3964 //#if(RUN_CPMJANUS_TESTCASES)
3965
3966 switch (iState)
3967 {
3968 case STATE_QUERYINTERFACE:
3969 if (aResponse.GetCmdStatus() == PVMFSuccess)
3970 {
3971 iState = STATE_ADDDATASOURCE;
3972 RunIfNotReady();
3973 }
3974 else
3975 {
3976 // QueryInterface failed
3977 PVPATB_TEST_IS_TRUE(false);
3978 iState = STATE_CLEANUPANDCOMPLETE;
3979 RunIfNotReady();
3980 }
3981 break;
3982
3983 case STATE_ADDDATASOURCE:
3984 if (aResponse.GetCmdStatus() == PVMFSuccess)
3985 {
3986 iState = STATE_CONFIGPARAMS;
3987 RunIfNotReady();
3988 }
3989 else
3990 {
3991 // AddDataSource failed
3992 PVPATB_TEST_IS_TRUE(false);
3993 iState = STATE_CLEANUPANDCOMPLETE;
3994 RunIfNotReady();
3995 }
3996 break;
3997
3998 case STATE_CONFIGPARAMS:
3999 iState = STATE_INIT;
4000 RunIfNotReady();
4001 break;
4002
4003 case STATE_INIT:
4004 if (aResponse.GetCmdStatus() == PVMFSuccess)
4005 {
4006 //normal playback case, continue to add data sinks.
4007 iState = STATE_ADDDATASINK_VIDEO;
4008 RunIfNotReady();
4009 }
4010 else
4011 {
4012 if ((iContentTooLarge) &&
4013 (aResponse.GetCmdStatus() == PVMFErrContentTooLarge))
4014 {
4015 // Test success in this case
4016 fprintf(file, " INIT returned PVMFErrContentTooLarge\n");
4017 PVPATB_TEST_IS_TRUE(true);
4018 iState = STATE_REMOVEDATASOURCE;
4019 RunIfNotReady();
4020 }
4021 else
4022 {
4023 // Init failed
4024 PVPATB_TEST_IS_TRUE(false);
4025 iState = STATE_CLEANUPANDCOMPLETE;
4026 RunIfNotReady();
4027 }
4028 }
4029 break;
4030
4031 case STATE_ADDDATASINK_VIDEO:
4032 if (aResponse.GetCmdStatus() == PVMFSuccess)
4033 {
4034 iState = STATE_ADDDATASINK_AUDIO;
4035 RunIfNotReady();
4036 }
4037 else
4038 {
4039 // AddDataSink failed
4040 PVPATB_TEST_IS_TRUE(false);
4041 iState = STATE_CLEANUPANDCOMPLETE;
4042 RunIfNotReady();
4043 }
4044 break;
4045
4046 case STATE_ADDDATASINK_AUDIO:
4047 if (aResponse.GetCmdStatus() == PVMFSuccess)
4048 {
4049 if (iSeekBeforeStart)
4050 {
4051 iState = STATE_SETPLAYBACKRANGE_BEFORESTART;
4052 }
4053 else
4054 {
4055 iState = STATE_PREPARE;
4056 }
4057 RunIfNotReady();
4058 }
4059 else
4060 {
4061 // AddDataSink failed
4062 PVPATB_TEST_IS_TRUE(false);
4063 iState = STATE_CLEANUPANDCOMPLETE;
4064 RunIfNotReady();
4065 }
4066 break;
4067
4068 case STATE_SETPLAYBACKRANGE_BEFORESTART:
4069 if (aResponse.GetCmdStatus() == PVMFSuccess)
4070 {
4071 iState = STATE_PREPARE;
4072 RunIfNotReady();
4073 }
4074 else
4075 {
4076 PVPATB_TEST_IS_TRUE(false);
4077 iState = STATE_CLEANUPANDCOMPLETE;
4078 RunIfNotReady();
4079 }
4080
4081 break;
4082
4083
4084 case STATE_PREPARE:
4085 if (aResponse.GetCmdStatus() == PVMFSuccess)
4086 {
4087 iState = STATE_GETMETADATAKEYLIST;
4088 RunIfNotReady();
4089 }
4090 else
4091 {
4092 // Prepare failed
4093 PVPATB_TEST_IS_TRUE(false);
4094 iState = STATE_CLEANUPANDCOMPLETE;
4095 RunIfNotReady();
4096 }
4097 break;
4098
4099 case STATE_PREPARE_AFTERSTOP:
4100 if (aResponse.GetCmdStatus() == PVMFSuccess)
4101 {
4102 iState = STATE_START_AFTERSTOP;
4103 RunIfNotReady();
4104 }
4105 else
4106 {
4107 // Prepare failed
4108 PVPATB_TEST_IS_TRUE(false);
4109 iState = STATE_CLEANUPANDCOMPLETE;
4110 RunIfNotReady();
4111 }
4112 break;
4113
4114 case STATE_WAIT_FOR_DATAREADY:
4115 case STATE_WAIT_FOR_BUFFCOMPLETE:
4116 //shouldn't get here-- there are no engine commands active in this state.
4117 PVPATB_TEST_IS_TRUE(false);
4118 break;
4119
4120 case STATE_GETMETADATAKEYLIST:
4121 if (aResponse.GetCmdStatus() == PVMFSuccess || aResponse.GetCmdStatus() == PVMFErrArgument)
4122 {
4123 iState = STATE_GETMETADATAVALUELIST;
4124 RunIfNotReady();
4125 }
4126 else
4127 {
4128 // GetMetadataKeys failed
4129 PVPATB_TEST_IS_TRUE(false);
4130 iState = STATE_CLEANUPANDCOMPLETE;
4131 RunIfNotReady();
4132 }
4133 break;
4134
4135 case STATE_GETMETADATAVALUELIST:
4136 if (aResponse.GetCmdStatus() == PVMFSuccess || aResponse.GetCmdStatus() == PVMFErrArgument)
4137 {
4138 //Display the resulting metadata.
4139 PrintMetadata();
4140
4141 //wait for data ready, unless we already got it.
4142 if (iNumDataReady > 0)
4143 {
4144 iState = STATE_START;
4145 RunIfNotReady();
4146 }
4147 else
4148 {
4149 iState = STATE_WAIT_FOR_DATAREADY;
4150 if (iPlayUntilEOS == false)
4151 {
4152 //5 minute error timeout
4153 RunIfNotReady(5*60*1000*1000);
4154 }
4155 }
4156 }
4157 else
4158 {
4159 // GetMetadataValue failed
4160 PVPATB_TEST_IS_TRUE(false);
4161 iState = STATE_CLEANUPANDCOMPLETE;
4162 RunIfNotReady();
4163 }
4164 break;
4165
4166 case STATE_START:
4167 if (aResponse.GetCmdStatus() == PVMFSuccess)
4168 {
4169 if (iNumDataReady)
4170 {
4171 if (iLongPauseResume || iShortPauseResume)
4172 {
4173 iState = STATE_PAUSE;
4174
4175 if (iShoutcastSession)
4176 {
4177 //just play for 1 minutes then stop
4178 RunIfNotReady(iSCListenTime);
4179 }
4180 else
4181 {
4182 //just play for 20 seconds then stop
4183 RunIfNotReady(20*1000*1000);
4184 }
4185 }
4186 else if (iSeekAfterDownloadComplete && 0 == iNumBufferingComplete)
4187 {
4188 iState = STATE_PAUSE_AFTERDOWNLOADCOMPLETE;
4189 }
4190 else if (!iPlayUntilEOS)
4191 {
4192 iState = STATE_STOP;
4193
4194 if (iShoutcastSession)
4195 {
4196 //just play for 5 minutes then stop
4197 // or 1 minute when it is play stop play
4198 RunIfNotReady(iSCListenTime);
4199 }
4200 else
4201 {
4202 //just play for 20 second then stop
4203 RunIfNotReady(20*1000*1000);
4204 }
4205 }
4206 else
4207 {
4208 // wait for EOS
4209 iState = STATE_STOP;
4210 }
4211 }
4212 else
4213 {
4214 //wait for data ready, then we'll play 20 seconds more,
4215 //or until EOS.
4216 iState = STATE_WAIT_FOR_DATAREADY;
4217 if (iPlayUntilEOS == false)
4218 {
4219 //5 minute error timeout.
4220 RunIfNotReady(5*60*1000*1000);
4221 }
4222 else
4223 {
4224 // wait for EOS
4225 }
4226 }
4227 }
4228 else
4229 {
4230 // Start failed
4231 PVPATB_TEST_IS_TRUE(false);
4232 iState = STATE_CLEANUPANDCOMPLETE;
4233 RunIfNotReady();
4234 }
4235 break;
4236
4237 case STATE_START_AFTERSTOP:
4238 if (aResponse.GetCmdStatus() == PVMFSuccess)
4239 {
4240 if (iNumDataReady)
4241 {
4242 if (iEOSStopPlay)
4243 {
4244 iState = STATE_STOP_TWICE;
4245 RunIfNotReady(3*1000*1000); // Play for 3 seconds
4246 }
4247 else if (iShoutcastPlayStopPlay)
4248 {
4249 iState = STATE_STOP_TWICE;
4250 RunIfNotReady(iSCListenTime); // Play for another minute
4251 }
4252 }
4253 }
4254 else
4255 {
4256 // Start failed
4257 PVPATB_TEST_IS_TRUE(false);
4258 iState = STATE_CLEANUPANDCOMPLETE;
4259 RunIfNotReady();
4260 }
4261 break;
4262
4263 case STATE_SETPLAYBACKRANGE:
4264 if (aResponse.GetCmdStatus() == PVMFSuccess)
4265 {
4266 fprintf(iTestMsgOutputFile, "***Repositioning Success...\n");
4267 //just play for 10 seconds then stop
4268 iState = STATE_STOP;
4269 RunIfNotReady(10*1000*1000);
4270 }
4271 else
4272 {
4273 fprintf(iTestMsgOutputFile, "***Repositioning Failed...\n");
4274 // Repos failed
4275 PVPATB_TEST_IS_TRUE(false);
4276 iState = STATE_CLEANUPANDCOMPLETE;
4277 RunIfNotReady();
4278 }
4279 break;
4280
4281
4282 case STATE_PAUSE:
4283 if (aResponse.GetCmdStatus() == PVMFSuccess)
4284 {
4285 if (iSeekAfterStart)
4286 {
4287 iState = STATE_SETPLAYBACKRANGE_AFTERSTART;
4288 RunIfNotReady();
4289 }
4290 else
4291 {
4292 iState = STATE_RESUME;
4293 if (iShortPauseResume)
4294 {
4295 // wait for 20 second
4296 // and resume
4297 RunIfNotReady(20*1000*1000);
4298 }
4299 else if (iLongPauseResume)
4300 {
4301 // wait for 90 seconds
4302 // and resume
4303 RunIfNotReady(90*1000*1000);
4304 }
4305 }
4306 }
4307 else
4308 {
4309 PVPATB_TEST_IS_TRUE(false);
4310 iState = STATE_CLEANUPANDCOMPLETE;
4311 RunIfNotReady();
4312 }
4313 break;
4314
4315 case STATE_PAUSE_AFTERDOWNLOADCOMPLETE:
4316 if (aResponse.GetCmdStatus() == PVMFSuccess)
4317 {
4318 iState = STATE_SETPLAYBACKRANGE_AFTERDOWNLOADCOMPLETE;
4319 RunIfNotReady();
4320 }
4321 else
4322 {
4323 PVPATB_TEST_IS_TRUE(false);
4324 iState = STATE_CLEANUPANDCOMPLETE;
4325 RunIfNotReady();
4326 }
4327 break;
4328
4329 case STATE_SETPLAYBACKRANGE_AFTERSTART:
4330 case STATE_SETPLAYBACKRANGE_AFTERDOWNLOADCOMPLETE:
4331 if (aResponse.GetCmdStatus() == PVMFSuccess)
4332 {
4333 iState = STATE_RESUME;
4334 RunIfNotReady();
4335 }
4336 else
4337 {
4338 PVPATB_TEST_IS_TRUE(false);
4339 iState = STATE_CLEANUPANDCOMPLETE;
4340 RunIfNotReady();
4341 }
4342
4343 break;
4344
4345 case STATE_RESUME:
4346 if (aResponse.GetCmdStatus() == PVMFSuccess)
4347 {
4348 if (((iLoop > 0) || iTwice) && (iLongPauseResume || iShortPauseResume))
4349 {
4350 iState = STATE_PAUSE_TWICE;
4351 if (iStepInterval != 0)
4352 {
4353 RunIfNotReady(iStepInterval * 1000);
4354 }
4355 else
4356 {
4357 // play for 20 more sec
4358 RunIfNotReady(20*1000*1000);
4359 }
4360 }
4361 else
4362 {
4363 iState = STATE_STOP;
4364 if (iPlayUntilEOS)
4365 {
4366 // play until EOS
4367 ;
4368 }
4369 else
4370 {
4371
4372 if (iShoutcastSession)
4373 {
4374 //just play for 1 minutes then stop
4375 RunIfNotReady(iSCListenTime);
4376 }
4377 else
4378 {
4379 // play for another 20 seconds and stop
4380 RunIfNotReady(20*1000*1000);
4381 }
4382 }
4383 }
4384 }
4385 else
4386 {
4387 PVPATB_TEST_IS_TRUE(false);
4388 iState = STATE_CLEANUPANDCOMPLETE;
4389 RunIfNotReady();
4390 }
4391 break;
4392
4393 case STATE_PAUSE_TWICE:
4394 if (aResponse.GetCmdStatus() == PVMFSuccess)
4395 {
4396 if (iSeekAfterStart)
4397 {
4398 iState = STATE_SETPLAYBACKRANGE_AFTERSTART_TWICE;
4399 RunIfNotReady();
4400 }
4401 else
4402 {
4403 iState = STATE_RESUME_TWICE;
4404 if (iShortPauseResume)
4405 {
4406 // wait for 20 second
4407 // and resume
4408 RunIfNotReady(20*1000*1000);
4409 }
4410 else if (iLongPauseResume)
4411 {
4412 // wait for 90 seconds
4413 // and resume
4414 RunIfNotReady(90*1000*1000);
4415 }
4416 }
4417 }
4418 else
4419 {
4420 PVPATB_TEST_IS_TRUE(false);
4421 iState = STATE_CLEANUPANDCOMPLETE;
4422 RunIfNotReady();
4423 }
4424 break;
4425
4426 case STATE_SETPLAYBACKRANGE_AFTERSTART_TWICE:
4427 if (aResponse.GetCmdStatus() == PVMFSuccess)
4428 {
4429 iState = STATE_RESUME_TWICE;
4430 RunIfNotReady();
4431 }
4432 else
4433 {
4434 PVPATB_TEST_IS_TRUE(false);
4435 iState = STATE_CLEANUPANDCOMPLETE;
4436 RunIfNotReady();
4437 }
4438
4439 break;
4440
4441 case STATE_RESUME_TWICE:
4442 if (aResponse.GetCmdStatus() == PVMFSuccess)
4443 {
4444 fprintf(file, "\n End of Loop %d\n", iLoopReq - iLoop);
4445 if (--iLoop > 0)
4446 {
4447 iState = STATE_PAUSE;
4448 if (iStepInterval != 0)
4449 {
4450 RunIfNotReady(iStepInterval * 1000);
4451 }
4452 else
4453 {
4454 RunIfNotReady(20*1000*1000);
4455 }
4456 }
4457 else
4458 {
4459 iState = STATE_STOP;
4460 if (iPlayUntilEOS)
4461 {
4462 // play until EOS
4463 ;
4464 }
4465 else
4466 {
4467 // play for another 20 seconds and stop
4468 RunIfNotReady(20*1000*1000);
4469 }
4470 }
4471 }
4472 else
4473 {
4474 PVPATB_TEST_IS_TRUE(false);
4475 iState = STATE_CLEANUPANDCOMPLETE;
4476 RunIfNotReady();
4477 }
4478 break;
4479
4480 case STATE_STOP:
4481 if (aResponse.GetCmdStatus() == PVMFSuccess)
4482 {
4483 if (iEOSStopPlay || iShoutcastPlayStopPlay)
4484 {
4485 iState = STATE_PREPARE_AFTERSTOP;
4486 }
4487 else
4488 {
4489 iState = STATE_REMOVEDATASINK_VIDEO;
4490 }
4491 RunIfNotReady();
4492 }
4493 else
4494 {
4495 PVPATB_TEST_IS_TRUE(false);
4496 iState = STATE_CLEANUPANDCOMPLETE;
4497 RunIfNotReady();
4498 }
4499 break;
4500
4501 case STATE_STOP_TWICE:
4502 if (aResponse.GetCmdStatus() == PVMFSuccess)
4503 {
4504 iState = STATE_REMOVEDATASINK_VIDEO;
4505 RunIfNotReady();
4506 }
4507 else
4508 {
4509 PVPATB_TEST_IS_TRUE(false);
4510 iState = STATE_CLEANUPANDCOMPLETE;
4511 RunIfNotReady();
4512 }
4513 break;
4514
4515 case STATE_REMOVEDATASINK_VIDEO:
4516 if (aResponse.GetCmdStatus() == PVMFSuccess)
4517 {
4518 iState = STATE_REMOVEDATASINK_AUDIO;
4519 RunIfNotReady();
4520 }
4521 else
4522 {
4523 // RemoveDataSink failed
4524 PVPATB_TEST_IS_TRUE(false);
4525 iState = STATE_CLEANUPANDCOMPLETE;
4526 RunIfNotReady();
4527 }
4528 break;
4529
4530 case STATE_REMOVEDATASINK_AUDIO:
4531 if (aResponse.GetCmdStatus() == PVMFSuccess)
4532 {
4533 iState = STATE_RESET;
4534 RunIfNotReady();
4535 }
4536 else
4537 {
4538 // RemoveDataSink failed
4539 PVPATB_TEST_IS_TRUE(false);
4540 iState = STATE_CLEANUPANDCOMPLETE;
4541 RunIfNotReady();
4542 }
4543 break;
4544
4545 case STATE_RESET:
4546 if (aResponse.GetCmdStatus() == PVMFSuccess)
4547 {
4548 iState = STATE_REMOVEDATASOURCE;
4549 RunIfNotReady();
4550 }
4551 else
4552 {
4553 // Reset failed
4554 PVPATB_TEST_IS_TRUE(false);
4555 iState = STATE_CLEANUPANDCOMPLETE;
4556 RunIfNotReady();
4557 }
4558 break;
4559
4560 case STATE_REMOVEDATASOURCE:
4561 if (aResponse.GetCmdStatus() == PVMFSuccess)
4562 {
4563 PVPATB_TEST_IS_TRUE(true);
4564 iState = STATE_CLEANUPANDCOMPLETE;
4565 RunIfNotReady();
4566 }
4567 else
4568 {
4569 // RemoveDataSource failed
4570 PVPATB_TEST_IS_TRUE(false);
4571 iState = STATE_CLEANUPANDCOMPLETE;
4572 RunIfNotReady();
4573 }
4574 break;
4575
4576 default:
4577 {
4578 // Testing error if this is reached
4579 PVPATB_TEST_IS_TRUE(false);
4580 iState = STATE_CLEANUPANDCOMPLETE;
4581 RunIfNotReady();
4582 }
4583 break;
4584 }
4585
4586 if (aResponse.GetCmdStatus() != PVMFSuccess)
4587 {
4588 PVInterface* iface = (PVInterface*)(aResponse.GetEventExtensionInterface());
4589 if (iface != NULL)
4590 {
4591 PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
4592 PVMFErrorInfoMessageInterface* infomsgiface = NULL;
4593 if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
4594 {
4595 PVUuid engerruuid;
4596 int32 errCodeEng;
4597 infomsgiface->GetCodeUUID(errCodeEng, engerruuid);
4598
4599 if (engerruuid == PVPlayerErrorInfoEventTypesUUID)
4600 {
4601 PVMFErrorInfoMessageInterface* sourceNodeErrorIF =
4602 infomsgiface->GetNextMessage();
4603
4604 if (sourceNodeErrorIF != NULL)
4605 {
4606 PVUuid eventuuid;
4607 int32 srcErrCode;
4608 sourceNodeErrorIF->GetCodeUUID(srcErrCode, eventuuid);
4609 if (eventuuid == PVMFSocketNodeEventTypeUUID)
4610 {
4611 HandleSocketNodeErrors(srcErrCode);
4612 }
4613 else if (eventuuid == PVProtocolEngineNodeErrorEventTypesUUID)
4614 {
4615 HandleProtocolEngineNodeErrors(srcErrCode);
4616 }
4617
4618 }
4619 }
4620 }
4621 }
4622 }
4623 }
4624
HandleSocketNodeErrors(int32 aErr)4625 void pvplayer_async_test_ppb_base::HandleSocketNodeErrors(int32 aErr)
4626 {
4627 if (aErr == PVMFSocketNodeErrorSocketServerCreateError)
4628 {
4629 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorSocketServerCreateError\n");
4630 }
4631
4632 else if (aErr == PVMFSocketNodeErrorSocketServConnectError)
4633 {
4634 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorSocketServConnectError\n");
4635 }
4636 else if (aErr == PVMFSocketNodeErrorUDPSocketRecvError)
4637 {
4638 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorUDPSocketRecvError\n");
4639 }
4640 else if (aErr == PVMFSocketNodeErrorUDPSocketSendError)
4641 {
4642 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorUDPSocketSendError\n");
4643 }
4644 else if (aErr == PVMFSocketNodeError_TCPSocketConnect)
4645 {
4646 fprintf(iTestMsgOutputFile, "PVMFSocketNodeError_TCPSocketConnect\n");
4647 }
4648 else if (aErr == PVMFSocketNodeError_DNSLookup)
4649 {
4650 fprintf(iTestMsgOutputFile, "PVMFSocketNodeError_DNSLookup\n");
4651 }
4652 else if (aErr == PVMFSocketNodeErrorSocketFailure)
4653 {
4654 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorSocketFailure\n");
4655 }
4656 else if (aErr == PVMFSocketNodeErrorSocketTimeOut)
4657 {
4658 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorSocketTimeOut\n");
4659 }
4660 else if (aErr == PVMFSocketNodeErrorInvalidPortTag)
4661 {
4662 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorInvalidPortTag\n");
4663 }
4664 else if (aErr == PVMFSocketNodeErrorInvalidPortConfig)
4665 {
4666 fprintf(iTestMsgOutputFile, "PVMFSocketNodeErrorInvalidPortConfig\n");
4667 }
4668 else
4669 {
4670 fprintf(iTestMsgOutputFile, "PVMFSocketNode- Unknown Error Code\n");
4671 }
4672 }
4673
HandleProtocolEngineNodeErrors(int32 aErr)4674 void pvplayer_async_test_ppb_base::HandleProtocolEngineNodeErrors(int32 aErr)
4675 {
4676 // The HTTP status errors are propagated up from the Protocol Engine node and
4677 // are enumerated in pvmf_protocol_engine_node_events.h. The raw value of the error
4678 // code can be calculated as an offset from aErr - PVProtocolEngineNodeErrorEventStart.
4679 if ((aErr >= PVProtocolEngineNodeErrorHTTPErrorCode400) &&
4680 (aErr <= PVProtocolEngineNodeErrorHTTPCode4xxUnknown))
4681 {
4682 fprintf(file, " ERROR: PVProtocolEngineNodeError4xx HTTP Status Code %d\n",
4683 aErr - PVProtocolEngineNodeErrorEventStart);
4684 }
4685 else if ((aErr >= PVProtocolEngineNodeErrorHTTPErrorCode500) &&
4686 (aErr < PVProtocolEngineNodeErrorHTTPCode5xxUnknownStart))
4687 {
4688 fprintf(file, " ERROR: PVProtocolEngineNodeError5xx HTTP Status Code %d\n",
4689 aErr - PVProtocolEngineNodeErrorEventStart);
4690 }
4691 else if ((aErr >= PVProtocolEngineNodeErrorHTTPRedirectCodeStart) &&
4692 (aErr <= PVProtocolEngineNodeErrorHTTPRedirectCodeEnd))
4693 {
4694 fprintf(file, " ERROR IN REDIRECT: PVProtocolEngineNodeError3xx HTTP Status Code %d\n",
4695 aErr - PVProtocolEngineNodeErrorEventStart);
4696 }
4697 else if (aErr < PVProtocolEngineNodeErrorNotHTTPErrorStart || aErr > PVProtocolEngineNodeErrorNotHTTPErrorEnd)
4698 {
4699 fprintf(file, " ERROR: PVProtocolEngineNodeError HTTP Unknown Status Code %d\n",
4700 aErr - PVProtocolEngineNodeErrorEventStart);
4701 }
4702 else
4703 {
4704 fprintf(file, " ERROR: PVProtocolEngineNodeError General Error %d\n", aErr);
4705 }
4706 }
PrintJanusError(const PVCmdResponse & aResp)4707 void pvplayer_async_test_ppb_base::PrintJanusError(const PVCmdResponse& aResp)
4708 {
4709 #if(RUN_CPMJANUS_TESTCASES)
4710 //#if 0
4711 //Get the extended error info.
4712 if (aResp.GetCmdStatus() != PVMFSuccess)
4713 {
4714 PVInterface* iface = (PVInterface*)(aResp.GetEventExtensionInterface());
4715 if (iface)
4716 {
4717 PVUuid errUuid(PVMFErrorInfoMessageInterfaceUUID);
4718 PVMFErrorInfoMessageInterface* errMsg = NULL;
4719 if (iface->queryInterface(errUuid, (PVInterface*&)errMsg))
4720 {
4721 //search for a janus error in the error list.
4722 PVUuid janusUuid(PVMFJanusPluginErrorMessageUuid);
4723 PVMFJanusPluginErrorMessage* janusErr = NULL;
4724 PVMFErrorInfoMessageInterface* nextErr = errMsg->GetNextMessage();
4725 while (nextErr)
4726 {
4727 if (nextErr->queryInterface(janusUuid, (PVInterface*&)janusErr))
4728 {
4729 uint32 drmErr = janusErr->DrmResult();
4730 fprintf(file, " Janus DRM Error! 0x%x\n", drmErr);
4731 break;
4732 }
4733 nextErr = nextErr->GetNextMessage();
4734 }
4735 }
4736 }
4737 }
4738 #else
4739 OSCL_UNUSED_ARG(aResp);
4740 #endif
4741 }
4742
HandleErrorEvent(const PVAsyncErrorEvent & aEvent)4743 void pvplayer_async_test_ppb_base::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
4744 {
4745 switch (aEvent.GetEventType())
4746 {
4747 case PVMFErrResourceConfiguration:
4748 // Just log the error
4749 PVPATB_TEST_IS_TRUE(false);
4750 fprintf(file, " GOT PVMFErrResourceConfiguration error event\n");
4751 break;
4752
4753 case PVMFErrResource:
4754 // Just log the error
4755 PVPATB_TEST_IS_TRUE(false);
4756 fprintf(file, " GOT PVMFErrResource error event\n");
4757 break;
4758
4759 case PVMFErrCorrupt:
4760 // Just log the error
4761 PVPATB_TEST_IS_TRUE(false);
4762 fprintf(file, " GOT PVMFErrCorrupt error event\n");
4763 break;
4764
4765 case PVMFErrProcessing:
4766 // Just log the error
4767 PVPATB_TEST_IS_TRUE(false);
4768 fprintf(file, " GOT PVMFErrProcessing error event\n");
4769 break;
4770
4771 case PVMFErrTimeout:
4772
4773 PVPATB_TEST_IS_TRUE(false);
4774 fprintf(file, " GOT PVMFErrTimeout error event");
4775 break;
4776
4777 default:
4778 // Unknown error and just log the error
4779 PVPATB_TEST_IS_TRUE(false);
4780 break;
4781 }
4782
4783 // Wait for engine to handle the error
4784 Cancel();
4785 }
4786
HandleInformationalEvent(const PVAsyncInformationalEvent & aEvent)4787 void pvplayer_async_test_ppb_base::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
4788 {
4789 if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
4790 {
4791 fprintf(file, "PVMFInfoErrorHandlingStart...\n");
4792 }
4793 if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
4794 {
4795 fprintf(file, "PVMFInfoErrorHandlingComplete...\n");
4796 iState = STATE_CLEANUPANDCOMPLETE;
4797 RunIfNotReady();
4798 }
4799 // Check for EOS event
4800 if (aEvent.GetEventType() == PVMFInfoEndOfData)
4801 {
4802 PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
4803 if (iface == NULL)
4804 {
4805 return;
4806 }
4807 PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
4808 PVMFErrorInfoMessageInterface* infomsgiface = NULL;
4809 if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
4810 {
4811 int32 infocode;
4812 PVUuid infouuid;
4813 infomsgiface->GetCodeUUID(infocode, infouuid);
4814 if ((infouuid == PVPlayerErrorInfoEventTypesUUID) && (infocode == PVPlayerInfoEndOfClipReached))
4815 {
4816 fprintf(file, " GOT PVPlayerInfoEndOfClipReached EVENT\n");
4817 iNumEOS++;
4818 if (iState == STATE_STOP)
4819 {
4820 Cancel();
4821 RunIfNotReady();
4822 }
4823 else if ((iState == STATE_PAUSE) && iSeekAfterStart)
4824 {
4825 iState = STATE_SETPLAYBACKRANGE_AFTERSTART;
4826 RunIfNotReady();
4827 }
4828 else if ((iState == STATE_PAUSE_TWICE) && iSeekAfterStart)
4829 {
4830 // end of clip received before Pause() is called
4831 // change the state
4832 iState = STATE_SETPLAYBACKRANGE_AFTERSTART_TWICE;
4833 RunIfNotReady();
4834 }
4835 }
4836 }
4837 }
4838
4839 //Print some events
4840 switch (aEvent.GetEventType())
4841 {
4842 case PVMFInfoBufferingStatus:
4843 {
4844 int32 *percent = (int32*)aEvent.GetLocalBuffer();
4845 if (*percent == 0 || *percent == 100)
4846 {
4847 fprintf(file, " PVMFInfoBufferingStatus %d\n", *percent);
4848 }
4849 else
4850 {
4851 fprintf(file, ".%d.", *percent);
4852 }
4853
4854 // get buffer fullness
4855 PVExclusivePtr eventData;
4856 aEvent.GetEventData(eventData);
4857 uint32 aBufferFullness = (uint32)(eventData);
4858 fprintf(file, ".(%d%%).", aBufferFullness);
4859
4860 }
4861 break;
4862 case PVMFInfoBufferingStart:
4863 fprintf(file, " PVMFInfoBufferingStart\n");
4864 iNumBufferingStart++;
4865 //we should only get one of these.
4866 if (iNumBufferingStart == 2)
4867 {
4868 if (!iEOSStopPlay && !iShoutcastPlayStopPlay)
4869 PVPATB_TEST_IS_TRUE(false);
4870 }
4871 break;
4872
4873 case PVMFInfoBufferingComplete:
4874 {
4875 PVExclusivePtr eventData;
4876 aEvent.GetEventData(eventData);
4877 uint32 contentSize = (uint32)(eventData);
4878 iNumBufferingComplete++;
4879 fprintf(file, " PVMFInfoBufferingComplete (contentSize=%d), iNumBufferingComplete=%d\n", contentSize, iNumBufferingComplete);
4880 //we should only get one of these.
4881 if (iNumBufferingComplete == 2 && !iEOSStopPlay && iLoopReq == 0)
4882 PVPATB_TEST_IS_TRUE(false);
4883
4884 if (iNumBufferingComplete == 1)
4885 {
4886 // if seek after download complete or waiting for download complete
4887 if ((iState == STATE_PAUSE_AFTERDOWNLOADCOMPLETE) || (iState == STATE_WAIT_FOR_BUFFCOMPLETE))
4888 {
4889 Cancel();
4890 RunIfNotReady();
4891 }
4892 }
4893 }
4894 break;
4895
4896 case PVMFInfoDataReady:
4897 iNumDataReady++;
4898 fprintf(file, "\n PVMFInfoDataReady\n");
4899 //special handling for very first data ready event.
4900 if (iNumDataReady == 1)
4901 {
4902 if (iState == STATE_WAIT_FOR_DATAREADY)
4903 {
4904 Cancel();
4905 RunIfNotReady();
4906 }
4907 }
4908 break;
4909 case PVMFInfoUnderflow:
4910 iNumUnderflow++;
4911 fprintf(file, "\n PVMFInfoUnderflow\n");
4912 //we should not get underflow before data ready
4913 if (iNumUnderflow == 1
4914 && iNumDataReady == 0)
4915 PVPATB_TEST_IS_TRUE(false);
4916 break;
4917 case PVMFInfoContentLength:
4918 {
4919 PVExclusivePtr eventData;
4920 aEvent.GetEventData(eventData);
4921 uint32 contentSize = (uint32)(eventData);
4922 fprintf(file, " PVMFInfoContentLength = %d\n", contentSize);
4923 }
4924 break;
4925
4926 case PVMFInfoContentTruncated:
4927 {
4928 PVExclusivePtr eventData;
4929 aEvent.GetEventData(eventData);
4930 uint32 downloadSize = (uint32)(eventData);
4931 fprintf(file, "\n PVMFInfoContentTruncated! downloadSize = %d\n", downloadSize);
4932
4933 // check extension info code
4934 PVMFErrorInfoMessageInterface *msg = NULL;
4935 if (aEvent.GetEventExtensionInterface() &&
4936 aEvent.GetEventExtensionInterface()->queryInterface(PVMFErrorInfoMessageInterfaceUUID, (PVInterface*&)msg))
4937 {
4938 //extract the event code and event UUID.
4939 int32 eventcode;
4940 PVUuid eventUuid;
4941 msg->GetCodeUUID(eventcode, eventUuid);
4942 if (eventUuid == PVPlayerErrorInfoEventTypesUUID)
4943 {
4944 PVMFErrorInfoMessageInterface* sourceNodeInfoIF = msg->GetNextMessage();
4945
4946 if (sourceNodeInfoIF != NULL)
4947 {
4948 PVUuid infoUUID;
4949 int32 srcInfoCode;
4950 sourceNodeInfoIF->GetCodeUUID(srcInfoCode, infoUUID);
4951
4952 if (infoUUID == PVMFPROTOCOLENGINENODEInfoEventTypesUUID &&
4953 srcInfoCode == PVMFPROTOCOLENGINENODEInfo_TruncatedContentByServerDisconnect)
4954 {
4955 fprintf(file, " PVMFInfoContentTruncated! TruncatedContentByServerDisconnect!\n");
4956 }
4957 }
4958 }
4959 }
4960
4961 }
4962 break;
4963
4964 case PVMFInfoContentType:
4965 {
4966 PVExclusivePtr eventData;
4967 aEvent.GetEventData(eventData);
4968 char *constentType = (char *)(eventData);
4969 fprintf(file, " PVMFInfoContentType = %s\n", constentType);
4970 }
4971 break;
4972
4973 case PVMFInfoUnexpectedData:
4974 fprintf(file, " PVMFInfoUnexpectedData! Downloaded more data than content-length\n");
4975 if (iNumBufferingComplete == 0) PVPATB_TEST_IS_TRUE(false); // we should get this info event after buffer complete event
4976 break;
4977
4978 case PVMFInfoSessionDisconnect:
4979 fprintf(file, " PVMFInfoSessionDisconnect! Got server disconnect after download is complete\n");
4980 if (iNumBufferingComplete == 0) PVPATB_TEST_IS_TRUE(false); // we should get this info event after buffer complete event
4981 break;
4982
4983 case PVMFInfoRemoteSourceNotification:
4984 {
4985 //Examine the extended info message to see if this is the
4986 //"not progressive downloadable" event. If so, notify the
4987 //UI. They may choose to abort the download at this point.
4988 PVMFErrorInfoMessageInterface *msg = NULL;
4989 if (aEvent.GetEventExtensionInterface()
4990 && aEvent.GetEventExtensionInterface()->queryInterface(PVMFErrorInfoMessageInterfaceUUID, (PVInterface*&)msg))
4991 {
4992 //extract the event code and event UUID.
4993 int32 eventcode;
4994 PVUuid eventUuid;
4995 msg->GetCodeUUID(eventcode, eventUuid);
4996 if (eventUuid == PVPlayerErrorInfoEventTypesUUID)
4997 {
4998 PVMFErrorInfoMessageInterface* sourceNodeInfoIF =
4999 msg->GetNextMessage();
5000
5001 if (sourceNodeInfoIF != NULL)
5002 {
5003 PVUuid infoUUID;
5004 int32 srcInfoCode;
5005 sourceNodeInfoIF->GetCodeUUID(srcInfoCode, infoUUID);
5006 if (infoUUID == PVMFFileFormatEventTypesUUID
5007 && srcInfoCode == PVMFMP4FFParserInfoNotPseudostreamableFile)
5008 {
5009 fprintf(file, " PVMFInfoRemoteSourceNotification (not progressive-downloadable)\n");
5010 }
5011 else if (infoUUID == PVMFPROTOCOLENGINENODEInfoEventTypesUUID
5012 && (srcInfoCode >= PVMFPROTOCOLENGINENODEInfo_HTTPRedirectCode300 &&
5013 srcInfoCode <= PVMFPROTOCOLENGINENODEInfo_HTTPRedirectCode307))
5014 {
5015 PVExclusivePtr eventData;
5016 aEvent.GetEventData(eventData);
5017 char *redirectUrl = (char *)(eventData);
5018 fprintf(file, " PVMFInfoRemoteSourceNotification (HTTP Status code = %d), redirectUrl = %s\n",
5019 srcInfoCode - PVMFPROTOCOLENGINENODEInfo_Redirect, redirectUrl);
5020 }
5021
5022 }
5023 }
5024 }
5025 }
5026 break;
5027 case PVMFInfoDurationAvailable:
5028 {
5029 PVMFDurationInfoMessageInterface* eventMsg = NULL;
5030 PVInterface* infoExtInterface = aEvent.GetEventExtensionInterface();
5031
5032 if (infoExtInterface &&
5033 infoExtInterface->queryInterface(PVMFDurationInfoMessageInterfaceUUID, (PVInterface*&)eventMsg))
5034 {
5035 PVUuid eventuuid;
5036 int32 infoCode;
5037 eventMsg->GetCodeUUID(infoCode, eventuuid);
5038 if (eventuuid == PVMFDurationInfoMessageInterfaceUUID)
5039 {
5040 iSessionDuration = eventMsg->GetDuration();
5041 }
5042 }
5043 }
5044 break;
5045 case PVMFInfoMetadataAvailable:
5046 {
5047 PVUuid infomsguuid = PVMFMetadataInfoMessageInterfaceUUID;
5048 PVMFMetadataInfoMessageInterface* eventMsg = NULL;
5049 PVInterface* infoExtInterface = aEvent.GetEventExtensionInterface();
5050 if (infoExtInterface &&
5051 infoExtInterface->queryInterface(infomsguuid, (PVInterface*&)eventMsg))
5052 {
5053 PVUuid eventuuid;
5054 int32 infoCode;
5055 eventMsg->GetCodeUUID(infoCode, eventuuid);
5056 if (eventuuid == infomsguuid)
5057 {
5058 Oscl_Vector<PvmiKvp, OsclMemAllocator> kvpVector = eventMsg->GetMetadataVector();
5059 for (uint32 i = 0; i < kvpVector.size(); i++)
5060 {
5061 //arora
5062 if (oscl_strstr(kvpVector[i].key, "valtype=char*"))
5063 {
5064 fprintf(file, "\n*********************************");
5065 fprintf(file, "\nMetadata Key '%s', value '%s'\n", kvpVector[i].key, kvpVector[i].value.pChar_value);
5066 fprintf(file, "\n*********************************");
5067 }
5068 else if (oscl_strstr(kvpVector[i].key, "valtype=wchar*"))
5069 {
5070 OSCL_HeapString<OsclMemAllocator> ostr;
5071 char buf[2];
5072 buf[1] = '\0';
5073 for (uint32 j = 0;; j++)
5074 {
5075 if (kvpVector[i].value.pWChar_value[j] == '\0')
5076 break;
5077 buf[0] = kvpVector[i].value.pWChar_value[j];
5078 ostr += buf;
5079 }
5080 fprintf(file, "\n*********************************");
5081 fprintf(file, " Metadata Key '%s', value '%s'\n", kvpVector[i].key, ostr.get_str());
5082 fprintf(file, "\n*********************************");
5083 }
5084 }
5085 }
5086 }
5087 }
5088
5089 default:
5090 break;
5091 }
5092 }
5093
5094
5095 //
5096 // pvplayer_async_test_ppb_normal
5097 //
~pvplayer_async_test_ppb_normal()5098 pvplayer_async_test_ppb_normal::~pvplayer_async_test_ppb_normal()
5099 {
5100 iDownloadContextData = NULL;
5101 }
5102
CreateDataSource()5103 void pvplayer_async_test_ppb_normal::CreateDataSource()
5104 {
5105 OSCL_HeapString<OsclMemAllocator> url(iFileName);
5106 OSCL_HeapString<OsclMemAllocator> default_source(SOURCENAME_PREPEND_STRING);
5107 default_source += DEFAULTSOURCEFILENAME;
5108
5109 if (iFileType == PVMF_MIME_DATA_SOURCE_SHOUTCAST_URL)
5110 {
5111 iShoutcastSession = true;
5112 }
5113
5114 if (url == default_source)
5115 {
5116 if (iFileType == PVMF_MIME_DATA_SOURCE_SHOUTCAST_URL)
5117 {
5118 fprintf(file, "Setting source to %s\n", DEFAULT_SHOUTCAST_URL);
5119 url = DEFAULT_SHOUTCAST_URL;
5120 }
5121 else
5122 {
5123 fprintf(file, "Setting source to %s\n", DEFAULT_3GPP_PPB_URL);
5124 url = DEFAULT_3GPP_PPB_URL;
5125 }
5126 }
5127
5128 oscl_wchar wbuf[2];
5129 wbuf[1] = '\0';
5130 for (uint32 i = 0; i < url.get_size(); i++)
5131 {
5132 wbuf[0] = (oscl_wchar)url.get_cstr()[i];
5133 iDownloadURL += wbuf;
5134 }
5135 iDataSource = new PVPlayerDataSourceURL;
5136 iDataSource->SetDataSourceURL(iDownloadURL);
5137
5138 if (iFileType == PVMF_MIME_DATA_SOURCE_SHOUTCAST_URL)
5139 {
5140 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_SHOUTCAST_URL);
5141 }
5142 else
5143 {
5144 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
5145 }
5146
5147 iDownloadFilename = NULL;
5148
5149 iDownloadProxy = _STRLIT_CHAR("");
5150 int32 iDownloadProxyPort = 0;
5151
5152 iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
5153 iDownloadConfigFilename += _STRLIT_WCHAR("my3gp_ppb_normal.cfg");
5154
5155 iContentTooLarge = false;
5156
5157 uint32 iMaxFileSize = 0x7FFFFFFF;
5158
5159 bool aIsNewSession = true;
5160
5161 iDownloadContextData = new PVMFSourceContextData();
5162 iDownloadContextData->EnableCommonSourceContext();
5163 iDownloadContextData->EnableDownloadHTTPSourceContext();
5164 iDownloadContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
5165 iDownloadContextData->DownloadHTTPData()->iConfigFileName = iDownloadConfigFilename;
5166 iDownloadContextData->DownloadHTTPData()->iDownloadFileName = iDownloadFilename;
5167 iDownloadContextData->DownloadHTTPData()->iMaxFileSize = iMaxFileSize;
5168 iDownloadContextData->DownloadHTTPData()->iProxyName = iDownloadProxy;
5169 iDownloadContextData->DownloadHTTPData()->iProxyPort = iDownloadProxyPort;
5170 iDownloadContextData->DownloadHTTPData()->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::ENoSaveToFile;
5171
5172 iDataSource->SetDataSourceContextData(iDownloadContextData);
5173 }
5174
CreateDataSinkVideo()5175 void pvplayer_async_test_ppb_normal::CreateDataSinkVideo()
5176 {
5177 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
5178 sinkfile += _STRLIT_WCHAR("test_player_3gp_ppb_");
5179
5180 if (iShortPauseResume)
5181 {
5182 sinkfile += _STRLIT_WCHAR("sht_ps_rsm_");
5183 }
5184 else if (iLongPauseResume)
5185 {
5186 sinkfile += _STRLIT_WCHAR("lng_ps_rsm_");
5187 }
5188
5189 if (iSeekAfterStart)
5190 {
5191 sinkfile += _STRLIT_WCHAR("sk_aft_strt_");
5192 }
5193 else if (iSeekBeforeStart)
5194 {
5195 sinkfile += _STRLIT_WCHAR("sk_b4_strt_");
5196 }
5197
5198 if (iForwardStep)
5199 {
5200 sinkfile += _STRLIT_WCHAR("fstp_");
5201 }
5202
5203 if (iLoop)
5204 {
5205 sinkfile += _STRLIT_WCHAR("lp_");
5206 }
5207
5208 if (iPlayUntilEOS)
5209 {
5210 sinkfile += _STRLIT_WCHAR("utl_eos_video.dat");
5211 }
5212 else
5213 {
5214 sinkfile += _STRLIT_WCHAR("nml_video.dat");
5215 }
5216
5217 iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
5218 iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
5219 iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
5220 ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
5221 }
5222
CreateDataSinkAudio()5223 void pvplayer_async_test_ppb_normal::CreateDataSinkAudio()
5224 {
5225 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
5226 if (iShoutcastSession)
5227 {
5228 sinkfile += _STRLIT_WCHAR("test_player_shout_");
5229 }
5230 else
5231 {
5232 sinkfile += _STRLIT_WCHAR("test_player_3gp_ppb_");
5233 }
5234 if (iShortPauseResume)
5235 {
5236 sinkfile += _STRLIT_WCHAR("sht_ps_rsm_");
5237 }
5238 else if (iLongPauseResume)
5239 {
5240 sinkfile += _STRLIT_WCHAR("lng_ps_rsm_");
5241 }
5242
5243 if (iSeekAfterStart)
5244 {
5245 sinkfile += _STRLIT_WCHAR("sk_aft_strt_");
5246 }
5247 else if (iSeekBeforeStart)
5248 {
5249 sinkfile += _STRLIT_WCHAR("sk_b4_strt_");
5250 }
5251
5252 if (iForwardStep)
5253 {
5254 sinkfile += _STRLIT_WCHAR("fstp_");
5255 }
5256
5257 if (iLoop)
5258 {
5259 sinkfile += _STRLIT_WCHAR("lp_");
5260 }
5261
5262 if (iShoutcastPlayStopPlay)
5263 {
5264 sinkfile += _STRLIT_WCHAR("ply_stp_ply_");
5265 }
5266
5267 if (iPlayUntilEOS)
5268 {
5269 sinkfile += _STRLIT_WCHAR("utl_eos_audio.dat");
5270 }
5271 else
5272 {
5273 sinkfile += _STRLIT_WCHAR("nml_audio.dat");
5274 }
5275
5276 iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
5277 iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
5278 iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
5279 ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
5280 }
5281
5282
5283 //
5284 // pvplayer_async_test_PDLPauseResumeAfterUnderFlow section
5285 //
~pvplayer_async_test_PDLPauseResumeAfterUnderFlow()5286 pvplayer_async_test_PDLPauseResumeAfterUnderFlow::~pvplayer_async_test_PDLPauseResumeAfterUnderFlow()
5287 {
5288 }
5289
CreateDataSource()5290 void pvplayer_async_test_PDLPauseResumeAfterUnderFlow::CreateDataSource()
5291 {
5292
5293 OSCL_HeapString<OsclMemAllocator> url(iFileName);
5294 OSCL_HeapString<OsclMemAllocator> default_source(SOURCENAME_PREPEND_STRING);
5295 default_source += DEFAULTSOURCEFILENAME;
5296 if (url == default_source)
5297 {
5298 fprintf(file, "Setting source to %s\n", DEFAULT_3GPPDL_URL);
5299 url = DEFAULT_3GPPDL_URL;
5300 }
5301 oscl_wchar wbuf[2];
5302 wbuf[1] = '\0';
5303 for (uint32 i = 0; i < url.get_size(); i++)
5304 {
5305 wbuf[0] = (oscl_wchar)url.get_cstr()[i];
5306 iDownloadURL += wbuf;
5307 }
5308 iDataSource = new PVPlayerDataSourceURL;
5309 iDataSource->SetDataSourceURL(iDownloadURL);
5310
5311 if (iProtocolRollOver == true)
5312 {
5313 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
5314 iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
5315 }
5316 else
5317 {
5318 iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
5319 }
5320
5321 iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
5322 iDownloadFilename += _STRLIT_WCHAR("test_3gppdownload.loc");
5323
5324 int32 iDownloadProxyPort;
5325 #if PVPLAYER_TEST_ENABLE_PROXY
5326 iDownloadProxy = _STRLIT_CHAR("");
5327 iDownloadProxyPort = 7070;
5328 #else
5329 iDownloadProxy = _STRLIT_CHAR("");
5330 iDownloadProxyPort = 0;
5331 #endif
5332
5333 iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
5334 iDownloadConfigFilename += _STRLIT_WCHAR("my3gppdl.cfg");
5335
5336 iContentTooLarge = false;
5337 uint32 iMaxFileSize = 0x7FFFFFFF;
5338 bool aIsNewSession = true;
5339 iPauseResumeAfterUnderflow = true;
5340
5341 iDownloadContextData = new PVMFSourceContextData();
5342 iDownloadContextData->EnableCommonSourceContext();
5343 iDownloadContextData->EnableDownloadHTTPSourceContext();
5344 iDownloadContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
5345 iDownloadContextData->DownloadHTTPData()->iConfigFileName = iDownloadConfigFilename;
5346 iDownloadContextData->DownloadHTTPData()->iDownloadFileName = iDownloadFilename;
5347 iDownloadContextData->DownloadHTTPData()->iMaxFileSize = iMaxFileSize;
5348 iDownloadContextData->DownloadHTTPData()->iProxyName = iDownloadProxy;
5349 iDownloadContextData->DownloadHTTPData()->iProxyPort = iDownloadProxyPort;
5350 iDownloadContextData->DownloadHTTPData()->iUserID = _STRLIT_CHAR("abc");
5351 iDownloadContextData->DownloadHTTPData()->iUserPasswd = _STRLIT_CHAR("xyz");
5352 iDownloadContextData->DownloadHTTPData()->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::EAsap;
5353
5354 iDataSource->SetDataSourceContextData(iDownloadContextData);
5355 }
CreateDataSinkVideo()5356 void pvplayer_async_test_PDLPauseResumeAfterUnderFlow::CreateDataSinkVideo()
5357 {
5358 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
5359 sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_video.dat");
5360 iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
5361 iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
5362 iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
5363 ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
5364 }
CreateDataSinkAudio()5365 void pvplayer_async_test_PDLPauseResumeAfterUnderFlow::CreateDataSinkAudio()
5366 {
5367 OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
5368 sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_audio.dat");
5369 iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
5370 iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
5371 iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
5372 ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
5373 }
CleanupData()5374 void pvplayer_async_test_PDLPauseResumeAfterUnderFlow::CleanupData()
5375 {
5376 }
5377