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 #ifndef TEST_PV_AUTHOR_ENGINE_TESTSET7_H_INCLUDED 19 #include "test_pv_author_engine_testset8.h" 20 #endif 21 22 #ifndef PVMF_COMPOSER_SIZE_AND_DURATION_H_INCLUDED 23 #include "pvmf_composer_size_and_duration.h" 24 #endif 25 26 #ifndef PVMF_FILEOUTPUT_CONFIG_H_INCLUDED 27 #include "pvmf_fileoutput_config.h" 28 #endif 29 30 #ifndef PVMP4FFCN_CLIPCONFIG_H_INCLUDED 31 #include "pvmp4ffcn_clipconfig.h" 32 #endif 33 34 #ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED 35 #include "pvmp4h263encextension.h" 36 #endif 37 38 #ifndef PVAETEST_NODE_CONFIG_H_INCLUDED 39 #include "pvaetest_node_config.h" 40 #endif 41 42 void pv_mediainput_async_test_delete::StartTest() 43 { 44 AddToScheduler(); 45 iState = PVAE_CMD_CREATE; 46 RunIfNotReady(); 47 } 48 49 //////////////////////////////////////////////////////////////////////////// 50 void pv_mediainput_async_test_delete::HandleErrorEvent(const PVAsyncErrorEvent& aEvent) 51 { 52 OSCL_UNUSED_ARG(aEvent); 53 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "pv_mediainput_async_test_delete::HandleErrorEvent")); 54 iState = PVAE_CMD_RESET; 55 RunIfNotReady(); 56 } 57 58 //////////////////////////////////////////////////////////////////////////// 59 void pv_mediainput_async_test_delete::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent) 60 { 61 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE, 62 (0, "pv_mediainput_async_test_delete::HandleInformationalEvent")); 63 OsclAny* eventData = NULL; 64 switch (aEvent.GetEventType()) 65 { 66 case PVMF_COMPOSER_MAXFILESIZE_REACHED: 67 case PVMF_COMPOSER_MAXDURATION_REACHED: 68 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, 69 (0, "pv_mediainput_async_test_delete::HandleNodeInformationalEvent: Max file size reached")); 70 Cancel(); 71 PVPATB_TEST_IS_TRUE(true); 72 iObserver->CompleteTest(*iTestCase); 73 break; 74 75 case PVMF_COMPOSER_DURATION_PROGRESS: 76 aEvent.GetEventData(eventData); 77 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, 78 (0, "pv_mediainput_async_test_delete::HandleNodeInformationalEvent: Duration progress: %d ms", 79 (int32)eventData)); 80 break; 81 82 case PVMF_COMPOSER_FILESIZE_PROGRESS: 83 aEvent.GetEventData(eventData); 84 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, 85 (0, "pv_mediainput_async_test_delete::HandleNodeInformationalEvent: File size progress: %d bytes", 86 (int32)eventData)); 87 break; 88 89 case PVMF_COMPOSER_EOS_REACHED: 90 //Engine already stopped at EOS so send reset command. 91 iState = PVAE_CMD_RESET; 92 //cancel recording timeout scheduled for timer object. 93 Cancel(); 94 RunIfNotReady(); 95 break; 96 97 default: 98 break; 99 } 100 } 101 102 //////////////////////////////////////////////////////////////////////////// 103 bool pv_mediainput_async_test_delete::CreateTestInputs() 104 { 105 int32 status = 0; 106 int32 error = 0; 107 iFileParser = NULL; 108 iFileServer.Connect(); 109 110 if (iMediaInputType == PVMF_MIME_AVIFF) 111 { 112 OSCL_TRY(error, iFileParser = PVAviFile::CreateAviFileParser(iInputFileName, error, &iFileServer);); 113 114 if (error || (NULL == iFileParser)) 115 { 116 if (iFileParser) 117 { 118 goto ERROR_CODE; 119 } 120 else 121 { 122 return false; 123 } 124 } 125 126 uint32 numStreams = ((PVAviFile*)iFileParser)->GetNumStreams(); 127 128 iAddAudioMediaTrack = false; 129 iAddVideoMediaTrack = false; 130 131 for (uint32 ii = 0; ii < numStreams; ii++) 132 { 133 if (oscl_strstr(((PVAviFile*)iFileParser)->GetStreamMimeType(ii).get_cstr(), "audio")) 134 { 135 iAddAudioMediaTrack = true; 136 } 137 138 if (oscl_strstr(((PVAviFile*)iFileParser)->GetStreamMimeType(ii).get_cstr(), "video")) 139 { 140 iAddVideoMediaTrack = true; 141 } 142 143 } 144 145 } 146 if (iMediaInputType == PVMF_MIME_WAVFF) 147 { 148 OSCL_TRY(error, iFileParser = OSCL_NEW(PV_Wav_Parser, ());); 149 if (error || (NULL == iFileParser)) 150 { 151 return false; 152 } 153 if (((PV_Wav_Parser*)iFileParser)->InitWavParser(iInputFileName, NULL) != PVWAVPARSER_OK) 154 { 155 goto ERROR_CODE; 156 } 157 158 iAddAudioMediaTrack = true; 159 iAddVideoMediaTrack = false; 160 } 161 162 { 163 PVMIOControlComp MIOComp(iMediaInputType, (OsclAny*)iFileParser, 0); 164 165 status = MIOComp.CreateMIOInputNode(false, iMediaInputType, iInputFileName); 166 if (status != PVMFSuccess) 167 { 168 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, 169 (0, "pv_mediainput_async_test_opencomposestop::CreateTestInputs: Error - CreateMIOInputNode failed")); 170 171 goto ERROR_CODE; 172 173 } 174 175 iMIOComponent = MIOComp; 176 if (!AddDataSource()) 177 { 178 //delete any MIO Comp created. 179 MIOComp.DeleteInputNode(); 180 goto ERROR_CODE; 181 } 182 183 return true; 184 } 185 186 ERROR_CODE: 187 { 188 //remove file parser 189 if (iMediaInputType == PVMF_MIME_AVIFF) 190 { 191 PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser); 192 PVAviFile::DeleteAviFileParser(fileparser); 193 fileparser = NULL; 194 iFileParser = NULL; 195 } 196 if (iMediaInputType == PVMF_MIME_WAVFF) 197 { 198 PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser); 199 delete(fileparser); 200 fileparser = NULL; 201 iFileParser = NULL; 202 } 203 204 return false; 205 } 206 207 } 208 //////////////////////////////////////////////////////////////////////////// 209 bool pv_mediainput_async_test_delete::AddDataSource() 210 { 211 int32 err = 0; 212 uint32 noOfNodes = iMIOComponent.iMIONode.size(); 213 214 OSCL_TRY(err, 215 for (uint32 ii = 0; ii < noOfNodes; ii++) 216 { 217 AddEngineCommand(); 218 219 //OSCL_TRY(err, iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor);); 220 iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor); 221 } 222 ); 223 if (err != OSCL_ERR_NONE) 224 { 225 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, 226 (0, "pvauthor_async_test_miscellaneous::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err)); 227 228 iMIOComponent.DeleteInputNode(); 229 return false; 230 } 231 return true; 232 } 233 234 //////////////////////////////////////////////////////////////////////////// 235 bool pv_mediainput_async_test_delete::ConfigComposer() 236 { 237 if (!ConfigOutputFile()) 238 { 239 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, 240 (0, "pv_mediainput_async_test_delete::ConfigComposer: Error - ConfigOutputFile failed")); 241 242 return false; 243 } 244 245 if ((oscl_strstr(iComposerMimeType.get_str(), "mp4")) || (oscl_strstr(iComposerMimeType.get_str(), "3gp"))) 246 { 247 if (!ConfigMp43gpComposer()) 248 { 249 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, 250 (0, "pv_mediainput_async_test_delete::ConfigComposer: Error - ConfigMp43gpComposer failed")); 251 252 return false; 253 } 254 } 255 256 return true; 257 } 258 259 //////////////////////////////////////////////////////////////////////////// 260 bool pv_mediainput_async_test_delete::ConfigOutputFile() 261 { 262 263 PvmfFileOutputNodeConfigInterface* clipConfig = OSCL_STATIC_CAST(PvmfFileOutputNodeConfigInterface*, iComposerConfig); 264 if (!clipConfig) 265 { 266 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, 267 (0, "pv_mediainput_async_test_delete::ConfigOutputFile: Error - Invalid iComposerConfig")); 268 269 return false; 270 } 271 272 if (clipConfig->SetOutputFileName(iOutputFileName) != PVMFSuccess) 273 { 274 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, 275 (0, "pv_mediainput_async_test_delete::ConfigOutputFile: Error - SetOutputFileName failed")); 276 277 return false; 278 } 279 280 return true; 281 } 282 283 //////////////////////////////////////////////////////////////////////////// 284 bool pv_mediainput_async_test_delete::ConfigMp43gpComposer() 285 { 286 287 PVMp4FFCNClipConfigInterface* clipConfig; 288 clipConfig = OSCL_STATIC_CAST(PVMp4FFCNClipConfigInterface*, iComposerConfig); 289 if (!clipConfig) 290 { 291 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, 292 (0, "pv_mediainput_async_test_delete::ConfigMp43gpComposer: Error - iComposerConfig==NULL")); 293 294 return false; 295 } 296 297 OSCL_wHeapString<OsclMemAllocator> versionString = _STRLIT("version"); 298 OSCL_wHeapString<OsclMemAllocator> titleString = _STRLIT("title"); 299 OSCL_wHeapString<OsclMemAllocator> authorString = _STRLIT("author"); 300 OSCL_wHeapString<OsclMemAllocator> copyrightString = _STRLIT("copyright"); 301 OSCL_wHeapString<OsclMemAllocator> descriptionString = _STRLIT("description"); 302 OSCL_wHeapString<OsclMemAllocator> ratingString = _STRLIT("rating"); 303 OSCL_wHeapString<OsclMemAllocator> iAlbumTitle = _STRLIT("albumtitle"); 304 uint16 iRecordingYear = 2008; 305 OSCL_HeapString<OsclMemAllocator> lang_code = "eng"; 306 307 clipConfig->SetOutputFileName(iOutputFileName); 308 clipConfig->SetPresentationTimescale(1000); 309 clipConfig->SetVersion(versionString, lang_code); 310 clipConfig->SetTitle(titleString, lang_code); 311 clipConfig->SetAuthor(authorString, lang_code); 312 clipConfig->SetCopyright(copyrightString, lang_code); 313 clipConfig->SetDescription(descriptionString, lang_code); 314 clipConfig->SetRating(ratingString, lang_code); 315 clipConfig->SetAlbumInfo(iAlbumTitle, lang_code); 316 clipConfig->SetRecordingYear(iRecordingYear); 317 318 319 return true; 320 } 321 322 //////////////////////////////////////////////////////////////////////////// 323 bool pv_mediainput_async_test_delete::AddMediaTrack() 324 { 325 PVMIOControlComp MIOComp; 326 327 if (iAddAudioMediaTrack) 328 { 329 if (iMediaInputType == PVMF_MIME_AVIFF) 330 { 331 Oscl_Vector<uint32, OsclMemAllocator> audioStrNum; 332 333 audioStrNum = (iMIOComponent.iPVAviFile)->GetAudioStreamCountList(); 334 335 if (audioStrNum.size() == 0) 336 { 337 return false; 338 } 339 340 iAuthor->AddMediaTrack(*(iMIOComponent.iMIONode[audioStrNum[0]]), iAudioEncoderMimeType, 341 iComposer, iAudioEncoderConfig, (OsclAny*)iAuthor); 342 343 AddEngineCommand(); 344 345 } 346 if (iMediaInputType == PVMF_MIME_WAVFF) 347 { 348 PVWAVFileInfo wavFileInfo; 349 (iMIOComponent.iPVWavFile)->RetrieveFileInfo(wavFileInfo); 350 351 352 iAuthor->AddMediaTrack(*(iMIOComponent.iMIONode[0]), iAudioEncoderMimeType, 353 iComposer, iAudioEncoderConfig, (OsclAny*)iAuthor); 354 355 AddEngineCommand(); 356 357 358 } 359 360 361 } 362 363 if (iAddVideoMediaTrack) 364 { 365 if (iMediaInputType == PVMF_MIME_AVIFF) 366 { 367 Oscl_Vector<uint32, OsclMemAllocator> vidStrNum; 368 vidStrNum = (iMIOComponent.iPVAviFile)->GetVideoStreamCountList(); 369 370 if (vidStrNum.size() == 0) 371 { 372 return false; 373 } 374 375 iAuthor->AddMediaTrack(*(iMIOComponent.iMIONode[vidStrNum[0]]), iVideoEncoderMimeType, 376 iComposer, iVideoEncoderConfig, (OsclAny*)iAuthor); 377 378 AddEngineCommand(); 379 380 } 381 if (iMediaInputType == PVMF_MIME_WAVFF) 382 { 383 return false; 384 } 385 386 } 387 388 return true; 389 } 390 391 //////////////////////////////////////////////////////////////////////////// 392 bool pv_mediainput_async_test_delete::ConfigureVideoEncoder() 393 { 394 395 PVMp4H263EncExtensionInterface* config; 396 config = OSCL_STATIC_CAST(PVMp4H263EncExtensionInterface*, iVideoEncoderConfig); 397 if (!config) 398 { 399 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, 400 (0, "pv_mediainput_async_test_delete::ConfigureVideoEncoder: No configuration needed")); 401 402 return true; 403 } 404 405 uint32 width = 0; 406 uint32 height = 0; 407 OsclFloat frameRate = 0; 408 uint32 frameInterval = 0; 409 410 if (iMediaInputType == PVMF_MIME_AVIFF) 411 { 412 Oscl_Vector<uint32, OsclMemAllocator> vidStrNum = 413 (iMIOComponent.iPVAviFile)->GetVideoStreamCountList(); 414 415 width = (iMIOComponent.iPVAviFile)->GetWidth(vidStrNum[0]); 416 bool orient = false; 417 height = (iMIOComponent.iPVAviFile)->GetHeight(orient, vidStrNum[0]); 418 frameRate = (iMIOComponent.iPVAviFile)->GetFrameRate(vidStrNum[0]); 419 frameInterval = (iMIOComponent.iPVAviFile)->GetFrameDuration(); 420 421 } 422 423 config->SetNumLayers(KNumLayers); 424 config->SetOutputBitRate(0, KVideoBitrate); 425 config->SetOutputFrameSize(0, width , height); 426 config->SetOutputFrameRate(0, frameRate); 427 config->SetIFrameInterval(KVideoIFrameInterval); 428 config->SetSceneDetection(true); 429 430 return true; 431 } 432 433 bool pv_mediainput_async_test_delete::ConfigureAudioEncoder() 434 { 435 436 PVAudioEncExtensionInterface* config; 437 config = OSCL_STATIC_CAST(PVAudioEncExtensionInterface*, iAudioEncoderConfig); 438 if (!config) 439 { 440 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, 441 (0, "pv_mediainput_async_test_delete::Encoder: No configuration needed")); 442 443 return true; 444 } 445 446 if (!PVAETestNodeConfig::ConfigureAudioEncoder(iAudioEncoderConfig, iAudioEncoderMimeType)) 447 { 448 return false; 449 } 450 return true; 451 } 452 453 //////////////////////////////////////////////////////////////////////////// 454 void pv_mediainput_async_test_delete::ResetAuthorConfig() 455 { 456 if (iComposerConfig) 457 { 458 iComposerConfig->removeRef(); 459 iComposerConfig = NULL; 460 } 461 if (iAudioEncoderConfig) 462 { 463 iAudioEncoderConfig->removeRef(); 464 iAudioEncoderConfig = NULL; 465 } 466 if (iVideoEncoderConfig) 467 { 468 iVideoEncoderConfig->removeRef(); 469 iVideoEncoderConfig = NULL; 470 } 471 } 472 473 //////////////////////////////////////////////////////////////////////////// 474 void pv_mediainput_async_test_delete::Cleanup() 475 { 476 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "pv_mediainput_async_test_delete::Cleanup")); 477 478 iComposer = NULL; 479 480 ResetAuthorConfig(); 481 if (iAuthor) 482 { 483 PVAuthorEngineFactory::DeleteAuthor(iAuthor); 484 iAuthor = NULL; 485 } 486 487 iOutputFileName = NULL; 488 iMIOComponent.DeleteInputNode(); 489 if (iMediaInputType == PVMF_MIME_AVIFF) 490 { 491 PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser); 492 PVAviFile::DeleteAviFileParser(fileparser); 493 fileparser = NULL; 494 iFileParser = NULL; 495 } 496 if (iMediaInputType == PVMF_MIME_WAVFF) 497 { 498 PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser); 499 delete(fileparser); 500 fileparser = NULL; 501 iFileParser = NULL; 502 } 503 iFileParser = NULL; 504 505 } 506 507 508 //////////////////////////////////////////////////////////////////////////// 509 void pv_mediainput_async_test_delete::Run() 510 { 511 if (IsEngineCmdPending()) 512 { 513 return; 514 } 515 516 switch (iState) 517 { 518 case PVAE_CMD_CREATE: 519 { 520 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, 521 (0, "******pv_mediainput_async_test_delete::iTestCaseNum:%d******", iTestCaseNum)); 522 523 iAuthor = PVAuthorEngineFactory::CreateAuthor(this, this, this); 524 if (!iAuthor) 525 { 526 PVPATB_TEST_IS_TRUE(false); 527 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 528 RunIfNotReady(); 529 530 } 531 else 532 { 533 if (PVAE_CMD_CREATE == iCurrentResetState) 534 { 535 iNextResetState = PVAE_CMD_OPEN; 536 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 537 PVPATB_TEST_IS_TRUE(true); 538 RunIfNotReady(); 539 } 540 else 541 { 542 iState = PVAE_CMD_OPEN; 543 RunIfNotReady(); 544 } 545 } 546 } 547 break; 548 549 case PVAE_CMD_OPEN: 550 { 551 iAuthor->Open((OsclAny*)iAuthor); 552 } 553 break; 554 555 case PVAE_CMD_ADD_DATA_SOURCE: 556 { 557 bool aStatus = CreateTestInputs(); 558 if (aStatus == 0) //Failed while creating test input 559 { 560 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, 561 (0, "pv_mediainput_async_test_delete::CreateTestInputs: Error - failed")); 562 563 PVPATB_TEST_IS_TRUE(true); //expected to come here 564 565 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 566 567 RunIfNotReady(); 568 } 569 570 } 571 break; 572 573 case PVAE_CMD_SELECT_COMPOSER: 574 { 575 iAuthor->SelectComposer(iComposerMimeType, iComposerConfig, 576 (OsclAny*)iAuthor); 577 } 578 break; 579 580 case PVAE_CMD_ADD_MEDIA_TRACK: 581 { 582 if (!AddMediaTrack()) 583 { 584 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, 585 (0, "pv_mediainput_async_test_opencomposestop::AddMediaTrack Error - No track added")); 586 PVPATB_TEST_IS_TRUE(false); 587 iState = PVAE_CMD_REMOVE_DATA_SOURCE; 588 RunIfNotReady(); 589 } 590 } 591 break; 592 593 case PVAE_CMD_INIT: 594 { 595 iAuthor->Init((OsclAny*)iAuthor); 596 } 597 break; 598 599 case PVAE_CMD_START: 600 { 601 iAuthor->Start(); 602 } 603 break; 604 605 case PVAE_CMD_STOP: 606 { 607 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, 608 (0, "pv_mediainput_async_test_delete::Run: Command Stop")); 609 610 iAuthor->Stop((OsclAny*)iAuthor); 611 } 612 break; 613 614 case PVAE_CMD_RESET: 615 { 616 ResetAuthorConfig(); 617 if (iAuthor->GetPVAuthorState() != PVAE_STATE_IDLE) 618 { 619 iAuthor->Reset((OsclAny*)iAuthor); 620 } 621 else 622 { 623 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, 624 (0, "pv_mediainput_async_test_opencomposestop::PVAE_CMD_RESET - State PVAE_STATE_IDLE")); 625 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 626 RunIfNotReady(); 627 } 628 } 629 break; 630 631 case PVAE_CMD_REMOVE_DATA_SOURCE: 632 { 633 for (uint32 ii = 0; ii < iMIOComponent.iMIONode.size(); ii++) 634 { 635 iAuthor->RemoveDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor); 636 AddEngineCommand(); 637 } 638 } 639 break; 640 641 case PVAE_CMD_CLOSE: 642 { 643 iAuthor->Close((OsclAny*)iAuthor); 644 } 645 break; 646 647 case PVAE_CMD_PAUSE: 648 { 649 iAuthor->Pause((OsclAny*)iAuthor); 650 } 651 break; 652 653 case PVAE_CMD_RESUME: 654 { 655 iAuthor->Resume((OsclAny*)iAuthor); 656 } 657 break; 658 659 case PVAE_CMD_CLEANUPANDCOMPLETE: 660 { 661 Cleanup(); 662 iObserver->CompleteTest(*iTestCase); 663 } 664 break; 665 666 case PVAE_CMD_QUERY_INTERFACE2: 667 case PVAE_CMD_ADD_DATA_SINK: 668 case PVAE_CMD_REMOVE_DATA_SINK: 669 break; 670 671 case PVAE_CMD_RECORDING: 672 { 673 if (PVAE_CMD_RECORDING == iCurrentResetState) 674 { 675 iNextResetState = PVAE_CMD_STOP; 676 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 677 PVPATB_TEST_IS_TRUE(true); 678 RunIfNotReady(); 679 } 680 else 681 { 682 iState = PVAE_CMD_STOP; 683 RunIfNotReady(iTestDuration); 684 } 685 686 } 687 break; 688 689 default: 690 break; 691 } //end switch 692 } 693 694 //////////////////////////////////////////////////////////////////////////// 695 void pv_mediainput_async_test_delete::CommandCompleted(const PVCmdResponse& aResponse) 696 { 697 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, 698 (0, "pv_mediainput_async_test_delete::CommandCompleted iState:%d", iState)); 699 700 if (aResponse.GetCmdStatus() != PVMFSuccess) 701 { 702 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, 703 (0, "pv_mediainput_async_test_delete::CommandCompleted iState:%d FAILED", iState)); 704 } 705 706 switch (iState) 707 { 708 case PVAE_CMD_OPEN: 709 { 710 if (aResponse.GetCmdStatus() == PVMFSuccess) 711 { 712 if (PVAE_CMD_OPEN == iCurrentResetState) 713 { 714 iNextResetState = PVAE_CMD_ADD_DATA_SOURCE; 715 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 716 PVPATB_TEST_IS_TRUE(true); 717 } 718 else 719 { 720 iState = PVAE_CMD_ADD_DATA_SOURCE; 721 } 722 723 RunIfNotReady(); 724 } 725 else 726 { 727 // Open failed 728 PVPATB_TEST_IS_TRUE(false); 729 iState = PVAE_CMD_RESET; 730 RunIfNotReady(); 731 } 732 } 733 break; 734 735 case PVAE_CMD_ADD_DATA_SOURCE: 736 { 737 if (EngineCmdComplete()) 738 { 739 if (PVAE_CMD_ADD_DATA_SOURCE == iCurrentResetState) 740 { 741 iNextResetState = PVAE_CMD_SELECT_COMPOSER; 742 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 743 PVPATB_TEST_IS_TRUE(true); 744 } 745 else 746 { 747 iState = PVAE_CMD_SELECT_COMPOSER; 748 } 749 } 750 751 if (aResponse.GetCmdStatus() == PVMFSuccess) 752 { 753 RunIfNotReady(); 754 } 755 else 756 { 757 // AddDataSource failed 758 PVPATB_TEST_IS_TRUE(false); 759 iState = PVAE_CMD_RESET; 760 RunIfNotReady(); 761 } 762 } 763 break; 764 765 case PVAE_CMD_SELECT_COMPOSER: 766 { 767 if (aResponse.GetCmdStatus() == PVMFSuccess) 768 { 769 iComposer = aResponse.GetResponseData(); 770 if (!ConfigComposer()) 771 { 772 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, 773 (0, "pv_mediainput_async_test_delete::CommandCompleted: Error - ConfigComposer failed")); 774 775 PVPATB_TEST_IS_TRUE(false); 776 iState = PVAE_CMD_RESET; 777 RunIfNotReady(); 778 return; 779 } 780 else 781 { 782 if (PVAE_CMD_SELECT_COMPOSER == iCurrentResetState) 783 { 784 iNextResetState = PVAE_CMD_ADD_MEDIA_TRACK; 785 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 786 PVPATB_TEST_IS_TRUE(true); 787 } 788 else 789 { 790 iState = PVAE_CMD_ADD_MEDIA_TRACK; 791 } 792 793 RunIfNotReady(); 794 } 795 } 796 else 797 { 798 // SelectComposer failed 799 PVPATB_TEST_IS_TRUE(false); 800 iState = PVAE_CMD_RESET; 801 RunIfNotReady(); 802 } 803 } 804 break; 805 806 case PVAE_CMD_ADD_MEDIA_TRACK: 807 { 808 if (EngineCmdComplete()) 809 { 810 if (iAddVideoMediaTrack) 811 { 812 ConfigureVideoEncoder(); 813 } 814 if (iAddAudioMediaTrack) 815 { 816 ConfigureAudioEncoder(); 817 } 818 if (PVAE_CMD_ADD_MEDIA_TRACK == iCurrentResetState) 819 { 820 iNextResetState = PVAE_CMD_INIT; 821 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 822 PVPATB_TEST_IS_TRUE(true); 823 } 824 else 825 { 826 iState = PVAE_CMD_INIT; 827 } 828 829 } 830 831 if (aResponse.GetCmdStatus() == PVMFSuccess) 832 { 833 RunIfNotReady(); 834 } 835 else 836 { 837 // AddMediaTrack failed 838 PVPATB_TEST_IS_TRUE(false); 839 iState = PVAE_CMD_RESET; 840 RunIfNotReady(); 841 } 842 } 843 break; 844 845 case PVAE_CMD_INIT: 846 { 847 if (aResponse.GetCmdStatus() == PVMFSuccess) 848 { 849 if (PVAE_CMD_INIT == iCurrentResetState) 850 { 851 iNextResetState = PVAE_CMD_START; 852 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 853 PVPATB_TEST_IS_TRUE(true); 854 } 855 else 856 { 857 iState = PVAE_CMD_START; 858 } 859 860 RunIfNotReady(); 861 } 862 else 863 { 864 // Init failed 865 PVPATB_TEST_IS_TRUE(false); 866 iState = PVAE_CMD_RESET; 867 RunIfNotReady(); 868 } 869 } 870 break; 871 872 case PVAE_CMD_START: 873 { 874 if (aResponse.GetCmdStatus() == PVMFSuccess) 875 { 876 if (iPauseResumeEnable) 877 { 878 if (PVAE_CMD_START == iCurrentResetState) 879 { 880 iNextResetState = PVAE_CMD_PAUSE; 881 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 882 PVPATB_TEST_IS_TRUE(true); 883 } 884 else 885 { 886 iState = PVAE_CMD_PAUSE; 887 } 888 889 RunIfNotReady(KPauseDuration); //Pause after 5 sec 890 } 891 else 892 { 893 if (PVAE_CMD_START == iCurrentResetState) 894 { 895 iNextResetState = PVAE_CMD_RECORDING; 896 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 897 PVPATB_TEST_IS_TRUE(true); 898 } 899 else 900 { 901 iState = PVAE_CMD_RECORDING; 902 } 903 904 RunIfNotReady(); 905 } 906 } 907 else 908 { 909 // Start failed 910 PVPATB_TEST_IS_TRUE(false); 911 iState = PVAE_CMD_RESET; 912 RunIfNotReady(); 913 } 914 } 915 break; 916 917 case PVAE_CMD_PAUSE: 918 { 919 if (aResponse.GetCmdStatus() == PVMFSuccess) 920 { 921 if (PVAE_CMD_PAUSE == iCurrentResetState) 922 { 923 iNextResetState = PVAE_CMD_STOP; 924 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 925 PVPATB_TEST_IS_TRUE(true); 926 RunIfNotReady(); 927 } 928 else 929 { 930 iState = PVAE_CMD_RESUME; 931 /* Stay paused for 10 seconds */ 932 RunIfNotReady(10*1000*1000); 933 } 934 935 } 936 else 937 { 938 //Pause failed 939 PVPATB_TEST_IS_TRUE(false); 940 iState = PVAE_CMD_RESET; 941 RunIfNotReady(); 942 } 943 } 944 break; 945 946 case PVAE_CMD_RESUME: 947 { 948 if (aResponse.GetCmdStatus() == PVMFSuccess) 949 { 950 iState = PVAE_CMD_STOP; 951 iNextResetState = PVAE_CMD_STOP; 952 //Run for another 10 sec before stopping 953 RunIfNotReady(10*1000*1000); 954 } 955 else 956 { 957 //Resume failed 958 PVPATB_TEST_IS_TRUE(false); 959 iState = PVAE_CMD_RESET; 960 RunIfNotReady(); 961 } 962 } 963 break; 964 965 case PVAE_CMD_STOP: 966 { 967 if (aResponse.GetCmdStatus() == PVMFSuccess) 968 { 969 iOutputFileName = NULL; 970 iState = PVAE_CMD_RESET; 971 RunIfNotReady(); 972 } 973 else 974 { 975 // Stop failed 976 PVPATB_TEST_IS_TRUE(false); 977 iState = PVAE_CMD_RESET; 978 RunIfNotReady(); 979 } 980 } 981 break; 982 983 case PVAE_CMD_RESET: 984 { 985 if (aResponse.GetCmdStatus() == PVMFSuccess) 986 { 987 if ((iMIOComponent.iMediaInput.size() == 0) || (iMIOComponent.iMIONode.size() == 0)) 988 { 989 if (aResponse.GetCmdStatus() == PVMFSuccess) 990 { 991 PVPATB_TEST_IS_TRUE(true); 992 } 993 else 994 { 995 PVPATB_TEST_IS_TRUE(false); 996 } 997 //Since there are no MIO Components/Nodes, we end here 998 //No need to call RemoveDataSource. Just call cleanup. 999 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 1000 RunIfNotReady(); 1001 break; 1002 } 1003 1004 iState = PVAE_CMD_REMOVE_DATA_SOURCE; 1005 RunIfNotReady(); 1006 } 1007 else 1008 { 1009 if (PVAE_CMD_CREATE == iCurrentResetState) 1010 { 1011 //Reset in create state will return error. 1012 PVPATB_TEST_IS_TRUE(true); 1013 iState = PVAE_CMD_CLEANUPANDCOMPLETE; 1014 RunIfNotReady(); 1015 } 1016 else 1017 { 1018 // Reset failed 1019 PVPATB_TEST_IS_TRUE(false); 1020 OSCL_ASSERT("ERROR -- Response failure for CMD_RESET"); 1021 iObserver->CompleteTest(*iTestCase); 1022 } 1023 } 1024 } 1025 break; 1026 1027 case PVAE_CMD_REMOVE_DATA_SOURCE: 1028 { 1029 if (aResponse.GetCmdStatus() == PVMFSuccess) 1030 { 1031 if (EngineCmdComplete()) 1032 { 1033 iOutputFileName = NULL; 1034 iMIOComponent.DeleteInputNode(); 1035 if (iMediaInputType == PVMF_MIME_AVIFF) 1036 { 1037 PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser); 1038 PVAviFile::DeleteAviFileParser(fileparser); 1039 fileparser = NULL; 1040 iFileParser = NULL; 1041 } 1042 if (iMediaInputType == PVMF_MIME_WAVFF) 1043 { 1044 PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser); 1045 delete(fileparser); 1046 fileparser = NULL; 1047 iFileParser = NULL; 1048 } 1049 1050 iFileParser = NULL; 1051 iState = PVAE_CMD_CLOSE; 1052 RunIfNotReady(); 1053 1054 } 1055 else 1056 { 1057 return; //wait for completion of all RemoveDataSource calls. 1058 } 1059 } 1060 else 1061 { 1062 // RemoveDataSource failed 1063 PVPATB_TEST_IS_TRUE(false); 1064 iObserver->CompleteTest(*iTestCase); 1065 } 1066 } 1067 break; 1068 1069 case PVAE_CMD_CLOSE: 1070 { 1071 if (aResponse.GetCmdStatus() == PVMFSuccess) 1072 { 1073 PVPATB_TEST_IS_TRUE(true); 1074 } 1075 else 1076 { 1077 PVPATB_TEST_IS_TRUE(false); 1078 } 1079 iObserver->CompleteTest(*iTestCase); 1080 } 1081 break; 1082 1083 default: 1084 { 1085 // Testing error if this is reached 1086 PVPATB_TEST_IS_TRUE(false); 1087 iObserver->CompleteTest(*iTestCase); 1088 } 1089 break; 1090 } //end switch 1091 } 1092 1093