Home | History | Annotate | Download | only in src
      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_TESTSET5_H_INCLUDED
     19 #include "test_pv_author_engine_testset5.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 #ifndef PVMI_KVP_H_INCLUDED
     43 #include "pvmi_kvp.h"
     44 #endif
     45 void pv_mediainput_async_test_opencomposestop::StartTest()
     46 {
     47     AddToScheduler();
     48     iState = PVAE_CMD_CREATE;
     49     RunIfNotReady();
     50 }
     51 
     52 
     53 /*@todo add error handling here */
     54 ////////////////////////////////////////////////////////////////////////////
     55 void pv_mediainput_async_test_opencomposestop::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
     56 {
     57     OSCL_UNUSED_ARG(aEvent);
     58     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "pv_mediainput_async_test_opencomposestop::HandleErrorEvent"));
     59     iState = PVAE_CMD_RESET;
     60     Cancel();//added to cancel previous running AO
     61     RunIfNotReady();
     62 }
     63 
     64 ////////////////////////////////////////////////////////////////////////////
     65 void pv_mediainput_async_test_opencomposestop::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
     66 {
     67     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
     68                     (0, "pv_mediainput_async_test_opencomposestop::HandleInformationalEvent"));
     69 
     70     OsclAny* eventData = NULL;
     71     switch (aEvent.GetEventType())
     72     {
     73         case PVMF_COMPOSER_MAXFILESIZE_REACHED:
     74         case PVMF_COMPOSER_MAXDURATION_REACHED:
     75             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
     76                             (0, "pv_mediainput_async_test_opencomposestop::HandleNodeInformationalEvent: Max file size reached"));
     77             iState = PVAE_CMD_RESET;
     78 
     79             Cancel();
     80             PVPATB_TEST_IS_TRUE(true);
     81             RunIfNotReady();
     82 
     83             fprintf(iFile, "Recording finished, Closing file please wait *******\n");
     84             break;
     85 
     86         case PVMF_COMPOSER_DURATION_PROGRESS:
     87             aEvent.GetEventData(eventData);
     88             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
     89                             (0, "pv_mediainput_async_test_opencomposestop::HandleNodeInformationalEvent: Duration progress: %d ms",
     90                              (int32)eventData));
     91             fprintf(iStdOut, "Duration: %d ms\n", (int32)eventData);
     92             break;
     93 
     94         case PVMF_COMPOSER_FILESIZE_PROGRESS:
     95             aEvent.GetEventData(eventData);
     96             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
     97                             (0, "pv_mediainput_async_test_opencomposestop::HandleNodeInformationalEvent: File size progress: %d bytes",
     98                              (int32)eventData));
     99             fprintf(iStdOut, "File size: %d bytes\n", (int32)eventData);
    100             break;
    101 
    102         case PVMF_COMPOSER_EOS_REACHED:
    103             //Engine already stopped at EOS so send reset command.
    104             iState = PVAE_CMD_RESET;
    105             //cancel recording timeout scheduled for timer object.
    106             Cancel();
    107             RunIfNotReady();
    108 
    109             fprintf(iFile, "Recording finished, Closing file please wait *******\n");
    110 
    111             break;
    112 
    113         default:
    114             break;
    115     }
    116 }
    117 
    118 ////////////////////////////////////////////////////////////////////////////
    119 bool pv_mediainput_async_test_opencomposestop::CreateTestInputs()
    120 {
    121     int32 status = 0;
    122     int32 error = 0;
    123     iFileParser = NULL;
    124 
    125     iFileServer.Connect();
    126 
    127     if (iMediaInputType == PVMF_MIME_AVIFF)
    128     {
    129 
    130         OSCL_TRY(error, iFileParser = PVAviFile::CreateAviFileParser(iInputFileName, error, &iFileServer););
    131 
    132         if (error || (NULL == iFileParser))
    133         {
    134             if (iFileParser)
    135             {
    136                 goto ERROR_CODE;
    137             }
    138             else
    139             {
    140                 return false;
    141             }
    142         }
    143 
    144         //set recording duration to TEST_TIMEOUT_FACTOR times the file duration in order to time out
    145         //if EOS is not received by this time.
    146         iTestDuration = (TEST_TIMEOUT_FACTOR * ((PVAviFile*)iFileParser)->GetFileDuration());
    147 
    148         if (iTestDuration > KAuthoringSessionUnit)
    149         {
    150             //if test duration, in microsec, is too large, the uint32
    151             //variable will rollover. Hence the test run is divided
    152             //in small sessions of KAuthoringSessionUnit duration
    153             iAuthoringCount = iTestDuration / KAuthoringSessionUnit;
    154             iTestDuration = KAuthoringSessionUnit * 1000 * 1000; //in microsec
    155         }
    156         else
    157         {
    158             iTestDuration = iTestDuration * 1000 * 1000;
    159         }
    160         uint32 numStreams = ((PVAviFile*)iFileParser)->GetNumStreams();
    161 
    162         iAddAudioMediaTrack = false;
    163         iAddVideoMediaTrack = false;
    164 
    165         for (uint32 ii = 0; ii < numStreams; ii++)
    166         {
    167             if (oscl_strstr(((PVAviFile*)iFileParser)->GetStreamMimeType(ii).get_cstr(), "audio"))
    168             {
    169                 iAddAudioMediaTrack = true;
    170             }
    171 
    172             if (oscl_strstr(((PVAviFile*)iFileParser)->GetStreamMimeType(ii).get_cstr(), "video"))
    173             {
    174                 iAddVideoMediaTrack = true;
    175             }
    176 
    177         }
    178 
    179     }
    180     else if (iMediaInputType == PVMF_MIME_WAVFF)
    181     {
    182         OSCL_TRY(error, iFileParser = OSCL_NEW(PV_Wav_Parser, ()););
    183         if (error || (NULL == iFileParser))
    184         {
    185             return false;
    186         }
    187         if (((PV_Wav_Parser*)iFileParser)->InitWavParser(iInputFileName, &iFileServer) != PVWAVPARSER_OK)
    188         {
    189 
    190             goto ERROR_CODE;
    191         }
    192 
    193         iAddAudioMediaTrack = true;
    194         iAddVideoMediaTrack = false;
    195 
    196         PVWAVFileInfo fileInfo;
    197 
    198         ((PV_Wav_Parser*)iFileParser)->RetrieveFileInfo(fileInfo);
    199 
    200         //set recording duration to TEST_TIMEOUT_FACTOR times the file duration in order to time out
    201         //if EOS is not received by this time.
    202         iTestDuration = (TEST_TIMEOUT_FACTOR * ((fileInfo.NumSamples * fileInfo.BytesPerSample) / fileInfo.SampleRate)) ; // in sec
    203 
    204         if (iTestDuration > KAuthoringSessionUnit)
    205         {
    206             //if test duration, in microsec, is too large, the uint32
    207             //variable will rollover. Hence the test run is divided
    208             //in small sessions of KAuthoringSessionUnit duration
    209             iAuthoringCount = iTestDuration / KAuthoringSessionUnit;
    210             iTestDuration = KAuthoringSessionUnit * 1000 * 1000; //in microsec
    211         }
    212         else
    213         {
    214             iTestDuration = iTestDuration * 1000 * 1000;
    215         }
    216 
    217     }
    218 
    219     {
    220 
    221         PVMIOControlComp MIOComp(iMediaInputType, (OsclAny*)iFileParser, iLoopTime);
    222 
    223         if (iLoopTime)
    224         {
    225 
    226             iTestDuration = TEST_TIMEOUT_FACTOR * iLoopTime ; //timeout duration in microsec
    227             if (iTestDuration > KAuthoringSessionUnit)
    228             {
    229                 //if test duration, in microsec, is too large, the uint32
    230                 //variable will rollover. Hence the test run is divided
    231                 //in small sessions of KAuthoringSessionUnit duration
    232                 iAuthoringCount = iTestDuration / KAuthoringSessionUnit;
    233                 iTestDuration = KAuthoringSessionUnit * 1000 * 1000; //in microsec
    234             }
    235             else
    236             {
    237                 iTestDuration = iTestDuration * 1000 * 1000;
    238             }
    239 
    240         }
    241 
    242         status = MIOComp.CreateMIOInputNode(iRealTimeAuthoring, iMediaInputType, iInputFileName);
    243         if (status != PVMFSuccess)
    244         {
    245             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
    246                             (0, "pv_mediainput_async_test_opencomposestop::CreateTestInputs: Error - CreateMIOInputNode failed"));
    247 
    248             goto ERROR_CODE;
    249 
    250         }
    251 
    252         iMIOComponent = MIOComp;
    253         if (!AddDataSource())
    254         {
    255 
    256             //delete any MIO Comp created.
    257             MIOComp.DeleteInputNode();
    258             goto ERROR_CODE;
    259 
    260         }
    261 
    262         return true;
    263 
    264     }
    265 
    266 
    267 ERROR_CODE:
    268     {
    269         //remove file parser
    270         if (iMediaInputType == PVMF_MIME_AVIFF)
    271         {
    272             PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
    273             PVAviFile::DeleteAviFileParser(fileparser);
    274             fileparser = NULL;
    275             iFileParser = NULL;
    276         }
    277         else if (iMediaInputType == PVMF_MIME_WAVFF)
    278         {
    279             PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
    280             delete(fileparser);
    281             fileparser = NULL;
    282             iFileParser = NULL;
    283         }
    284 
    285         return false;
    286     }
    287 
    288 
    289 }
    290 
    291 ////////////////////////////////////////////////////////////////////////////
    292 bool pv_mediainput_async_test_opencomposestop::AddDataSource()
    293 {
    294     int32 err = 0;
    295     uint32 noOfNodes = iMIOComponent.iMIONode.size();
    296 
    297     OSCL_TRY(err,
    298              for (uint32 ii = 0; ii < noOfNodes; ii++)
    299 {
    300     AddEngineCommand();
    301 
    302         iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor);
    303     }
    304             );
    305 
    306     if (err != OSCL_ERR_NONE)
    307     {
    308         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
    309                         (0, "pvauthor_async_test_miscellaneous::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
    310 
    311         iMIOComponent.DeleteInputNode();
    312         return false;
    313     }
    314 
    315     return true;
    316 }
    317 
    318 ////////////////////////////////////////////////////////////////////////////
    319 bool pv_mediainput_async_test_opencomposestop::ConfigComposer()
    320 {
    321     if (!ConfigOutputFile())
    322     {
    323         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
    324                         (0, "pv_mediainput_async_test_opencomposestop::ConfigComposer: Error - ConfigOutputFile failed"));
    325 
    326         return false;
    327     }
    328 
    329     if ((oscl_strstr(iComposerMimeType.get_str(), "mp4")) || (oscl_strstr(iComposerMimeType.get_str(), "3gp")))
    330     {
    331         if (!ConfigMp43gpComposer())
    332         {
    333             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
    334                             (0, "pv_mediainput_async_test_opencomposestop::ConfigComposer: Error - ConfigMp43gpComposer failed"));
    335 
    336             return false;
    337         }
    338     }
    339     return true;
    340 }
    341 
    342 ////////////////////////////////////////////////////////////////////////////
    343 bool pv_mediainput_async_test_opencomposestop::ConfigOutputFile()
    344 {
    345 
    346     PvmfFileOutputNodeConfigInterface* clipConfig = OSCL_STATIC_CAST(PvmfFileOutputNodeConfigInterface*, iComposerConfig);
    347     if (!clipConfig)
    348     {
    349         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
    350                         (0, "pv_mediainput_async_test_opencomposestop::ConfigAmrComposer: Error - Invalid iComposerConfig"));
    351 
    352         return false;
    353     }
    354 
    355     if (!iUseExtrnFileDesc)
    356     {
    357         if (clipConfig->SetOutputFileName(iOutputFileName) != PVMFSuccess)
    358         {
    359             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
    360                             (0, "pv_mediainput_async_test_opencomposestop::ConfigAmrComposer: Error - SetOutputFileName failed"));
    361 
    362             return false;
    363         }
    364     }
    365     else
    366     {
    367         char* fname[ARRAY_SIZE];
    368         oscl_UnicodeToUTF8(iOutputFileName.get_str(), iOutputFileName.get_size(), (char*)fname, ARRAY_SIZE);
    369 
    370         FILE *fp = fopen((char*)fname, "w+b");
    371         if (fp)
    372         {
    373             iFileHandle = OSCL_NEW(OsclFileHandle, (fp));
    374             if (clipConfig->SetOutputFileDescriptor(iFileHandle) != PVMFSuccess)
    375             {
    376                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
    377                                 (0, "pv_mediainput_async_test_opencomposestop::ConfigAmrComposer: Error - SetOutputFileName failed"));
    378 
    379                 return false;
    380             }
    381         }
    382 
    383     }
    384     return true;
    385 }
    386 
    387 ////////////////////////////////////////////////////////////////////////////
    388 bool pv_mediainput_async_test_opencomposestop::ConfigMp43gpComposer()
    389 {
    390 
    391     PVMp4FFCNClipConfigInterface* clipConfig;
    392     clipConfig = OSCL_STATIC_CAST(PVMp4FFCNClipConfigInterface*, iComposerConfig);
    393     if (!clipConfig)
    394     {
    395         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
    396                         (0, "pv_mediainput_async_test_opencomposestop::ConfigMp43gpComposer: Error - iComposerConfig==NULL"));
    397 
    398         return false;
    399     }
    400     PvmfAssetInfo3GPPLocationStruct aLocation_info;
    401 
    402     OSCL_wHeapString<OsclMemAllocator> versionString = _STRLIT("Latest Version");
    403     OSCL_wHeapString<OsclMemAllocator> titleString = _STRLIT("This is the test title");
    404     OSCL_wHeapString<OsclMemAllocator> authorString = _STRLIT("Unknown");
    405     OSCL_wHeapString<OsclMemAllocator> copyrightString = _STRLIT("PV Copyright");
    406     OSCL_wHeapString<OsclMemAllocator> descriptionString = _STRLIT("New Song");
    407     OSCL_wHeapString<OsclMemAllocator> ratingString = _STRLIT("Five");
    408     OSCL_wHeapString<OsclMemAllocator> performerString = _STRLIT("Performer");
    409     OSCL_wHeapString<OsclMemAllocator> genreString = _STRLIT("Rock");
    410     OSCL_wHeapString<OsclMemAllocator> classificationInfoString = _STRLIT("Rock Music");
    411     OSCL_wHeapString<OsclMemAllocator> keyWordInfoString1 = _STRLIT("One");
    412     OSCL_wHeapString<OsclMemAllocator> keyWordInfoString2 = _STRLIT("Two");
    413     OSCL_wHeapString<OsclMemAllocator> keyWordInfoString3 = _STRLIT("Three");
    414     OSCL_wHeapString<OsclMemAllocator> location_name = _STRLIT("PV");
    415     OSCL_wHeapString<OsclMemAllocator> astronomical_body = _STRLIT("PV");
    416     OSCL_wHeapString<OsclMemAllocator> additional_notes = _STRLIT("PV");
    417     OSCL_wHeapString<OsclMemAllocator> iAlbumTitle = _STRLIT("albumtitle");
    418     uint16 iRecordingYear = 2008;
    419 
    420     OSCL_HeapString<OsclMemAllocator> lang_code = "eng";
    421 
    422     aLocation_info._location_name = NULL;
    423     uint32 size = location_name.get_size();
    424     aLocation_info._location_name = (oscl_wchar *)oscl_malloc(sizeof(oscl_wchar) * size + 10);
    425     oscl_strncpy(aLocation_info._location_name, location_name.get_cstr(), size);
    426     aLocation_info._location_name[size+1] = 0;
    427 
    428     size = astronomical_body.get_size();
    429     aLocation_info._astronomical_body = NULL;
    430     aLocation_info._astronomical_body = (oscl_wchar *)oscl_malloc(sizeof(oscl_wchar) * size + 10);
    431     oscl_strncpy(aLocation_info._astronomical_body, astronomical_body.get_cstr(), size);
    432     aLocation_info._astronomical_body[size+1] = 0;
    433 
    434 
    435     size = additional_notes.get_size();
    436     aLocation_info._additional_notes = NULL;
    437     aLocation_info._additional_notes = (oscl_wchar *)oscl_malloc(sizeof(oscl_wchar) * size + 10);
    438     oscl_strncpy(aLocation_info._additional_notes, additional_notes.get_cstr(), size);
    439     aLocation_info._additional_notes[size+1] = 0;
    440 
    441     aLocation_info._role = 2;
    442     aLocation_info._longitude = 0;
    443     aLocation_info._latitude = 0;
    444     aLocation_info._altitude = 0;
    445     aLocation_info.Lang_code = lang_code;
    446 
    447 
    448     uint32 classificationEntity = 0;
    449     uint16 classificationTable = 0;
    450 
    451     clipConfig->SetOutputFileName(iOutputFileName);
    452     clipConfig->SetPresentationTimescale(1000);
    453     clipConfig->SetVersion(versionString, lang_code);
    454     clipConfig->SetTitle(titleString, lang_code);
    455     clipConfig->SetAuthor(authorString, lang_code);
    456     clipConfig->SetCopyright(copyrightString, lang_code);
    457     clipConfig->SetDescription(descriptionString, lang_code);
    458     clipConfig->SetRating(ratingString, lang_code);
    459     clipConfig->SetPerformer(performerString, lang_code);
    460     clipConfig->SetGenre(genreString, lang_code);
    461     clipConfig->SetClassification(classificationInfoString, classificationEntity, classificationTable, lang_code);
    462     clipConfig->SetKeyWord(keyWordInfoString1, lang_code);
    463     clipConfig->SetKeyWord(keyWordInfoString2, lang_code);
    464     clipConfig->SetKeyWord(keyWordInfoString3, lang_code);
    465 
    466 
    467     clipConfig->SetLocationInfo(aLocation_info);
    468 
    469 
    470     clipConfig->SetAlbumInfo(iAlbumTitle, lang_code);
    471 
    472 
    473     clipConfig->SetRecordingYear(iRecordingYear);
    474 
    475     if (iTestCaseNum == K3GPPDownloadModeTest || iTestCaseNum == K3GPPDownloadModeLongetivityTest)
    476     {
    477         clipConfig->SetAuthoringMode(PVMP4FFCN_3GPP_DOWNLOAD_MODE);
    478     }
    479     else if (iTestCaseNum == K3GPPProgressiveDownloadModeTest || iTestCaseNum == K3GPPProgressiveDownloadModeLongetivityTest)
    480     {
    481         clipConfig->SetAuthoringMode(PVMP4FFCN_3GPP_PROGRESSIVE_DOWNLOAD_MODE);
    482     }
    483     else if (iTestCaseNum == KMovieFragmentModeTest || iTestCaseNum == KMovieFragmentModeLongetivityTest)
    484     {
    485         clipConfig->SetAuthoringMode(PVMP4FFCN_MOVIE_FRAGMENT_MODE);
    486     }
    487 
    488 
    489 
    490 
    491     if (aLocation_info._location_name != NULL)
    492         OSCL_FREE(aLocation_info._location_name);
    493 
    494     if (aLocation_info._astronomical_body != NULL)
    495         OSCL_FREE(aLocation_info._astronomical_body);
    496 
    497     if (aLocation_info._additional_notes != NULL)
    498         OSCL_FREE(aLocation_info._additional_notes);
    499 
    500 
    501     return true;
    502 }
    503 
    504 ////////////////////////////////////////////////////////////////////////////
    505 bool pv_mediainput_async_test_opencomposestop::AddMediaTrack()
    506 {
    507     PVMIOControlComp MIOComp;
    508 
    509     if (iAddAudioMediaTrack)
    510     {
    511         if (iMediaInputType == PVMF_MIME_AVIFF)
    512         {
    513             Oscl_Vector<uint32, OsclMemAllocator> audioStrNum;
    514 
    515             audioStrNum = (iMIOComponent.iPVAviFile)->GetAudioStreamCountList();
    516 
    517             if (audioStrNum.size() == 0)
    518             {
    519                 return false;
    520             }
    521 
    522             iAuthor->AddMediaTrack(*(iMIOComponent.iMIONode[audioStrNum[0]]), iAudioEncoderMimeType,
    523                                    iComposer, iAudioEncoderConfig, (OsclAny*)iAuthor);
    524 
    525             AddEngineCommand();
    526 
    527         }
    528         else if (iMediaInputType == PVMF_MIME_WAVFF)
    529         {
    530             PVWAVFileInfo wavFileInfo;
    531             (iMIOComponent.iPVWavFile)->RetrieveFileInfo(wavFileInfo);
    532 
    533 
    534             iAuthor->AddMediaTrack(*(iMIOComponent.iMIONode[0]), iAudioEncoderMimeType,
    535                                    iComposer, iAudioEncoderConfig, (OsclAny*)iAuthor);
    536 
    537             AddEngineCommand();
    538 
    539 
    540         }
    541 
    542 
    543     }
    544 
    545     if (iAddVideoMediaTrack)
    546     {
    547         if (iMediaInputType == PVMF_MIME_AVIFF)
    548         {
    549             Oscl_Vector<uint32, OsclMemAllocator> vidStrNum;
    550             vidStrNum = (iMIOComponent.iPVAviFile)->GetVideoStreamCountList();
    551 
    552             if (vidStrNum.size() == 0)
    553             {
    554                 return false;
    555             }
    556 
    557             iAuthor->AddMediaTrack(*(iMIOComponent.iMIONode[vidStrNum[0]]), iVideoEncoderMimeType,
    558                                    iComposer, iVideoEncoderConfig, (OsclAny*)iAuthor);
    559 
    560             AddEngineCommand();
    561 
    562         }
    563         else if (iMediaInputType == PVMF_MIME_WAVFF)
    564         {
    565             return false;
    566         }
    567 
    568     }
    569 
    570     return true;
    571 }
    572 
    573 ////////////////////////////////////////////////////////////////////////////
    574 bool pv_mediainput_async_test_opencomposestop::ConfigureVideoEncoder()
    575 {
    576 
    577     PVMp4H263EncExtensionInterface* config;
    578     config = OSCL_STATIC_CAST(PVMp4H263EncExtensionInterface*, iVideoEncoderConfig);
    579     if (!config)
    580     {
    581         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
    582                         (0, "pv_mediainput_async_test_opencomposestop::ConfigureVideoEncoder: No configuration needed"));
    583 
    584         return true;
    585     }
    586 
    587     uint32 width = 0;
    588     uint32 height = 0;
    589     OsclFloat frameRate = 0.0;
    590     uint32 frameInterval = 0;
    591 
    592     if (iMediaInputType == PVMF_MIME_AVIFF)
    593     {
    594         Oscl_Vector<uint32, OsclMemAllocator> vidStrNum =
    595             (iMIOComponent.iPVAviFile)->GetVideoStreamCountList();
    596 
    597         width = (iMIOComponent.iPVAviFile)->GetWidth(vidStrNum[0]);
    598         bool orient = false;
    599         height = (iMIOComponent.iPVAviFile)->GetHeight(orient, vidStrNum[0]);
    600         frameRate = (iMIOComponent.iPVAviFile)->GetFrameRate(vidStrNum[0]);
    601         frameInterval = (iMIOComponent.iPVAviFile)->GetFrameDuration();
    602     }
    603 
    604     //setting the width and height
    605     config->SetOutputFrameSize(0, width , height);
    606 
    607     //setting video bitrate
    608     if (0 == iVideoBitrate)
    609     {
    610         config->SetOutputBitRate(0, KVideoBitrate);
    611     }
    612     else
    613     {
    614         config->SetOutputBitRate(0, iVideoBitrate);//values from config file
    615     }
    616 
    617     config->SetOutputFrameRate(0, frameRate);
    618     config->SetNumLayers(KNumLayers);
    619     config->SetIFrameInterval(KVideoIFrameInterval);
    620     config->SetSceneDetection(true);
    621 
    622     return true;
    623 }
    624 
    625 bool pv_mediainput_async_test_opencomposestop::ConfigureAudioEncoder()
    626 {
    627 
    628     PVAudioEncExtensionInterface* config;
    629     config = OSCL_STATIC_CAST(PVAudioEncExtensionInterface*, iAudioEncoderConfig);
    630     if (!config)
    631     {
    632         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
    633                         (0, "pv_mediainput_async_test_opencomposestop::Encoder: No configuration needed"));
    634 
    635         return true;
    636     }
    637 
    638     if (!PVAETestNodeConfig::ConfigureAudioEncoder(iAudioEncoderConfig, iAudioEncoderMimeType, iAudioBitrate))
    639     {
    640         return false;
    641     }
    642     return true;
    643 }
    644 ////////////////////////////////////////////////////////////////////////////
    645 void pv_mediainput_async_test_opencomposestop::ResetAuthorConfig()
    646 {
    647     if (iComposerConfig)
    648     {
    649         iComposerConfig->removeRef();
    650         iComposerConfig = NULL;
    651     }
    652     if (iAudioEncoderConfig)
    653     {
    654         iAudioEncoderConfig->removeRef();
    655         iAudioEncoderConfig = NULL;
    656     }
    657     if (iVideoEncoderConfig)
    658     {
    659         iVideoEncoderConfig->removeRef();
    660         iVideoEncoderConfig = NULL;
    661     }
    662 }
    663 
    664 ////////////////////////////////////////////////////////////////////////////
    665 void pv_mediainput_async_test_opencomposestop::Cleanup()
    666 {
    667     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "pv_mediainput_async_test_opencomposestop::Cleanup"));
    668 
    669     iComposer = NULL;
    670 
    671     ResetAuthorConfig();
    672     if (iAuthor)
    673     {
    674         PVAuthorEngineFactory::DeleteAuthor(iAuthor);
    675         iAuthor = NULL;
    676     }
    677 
    678 //  iMIOComponent.DeleteInputNode();
    679     iOutputFileName = NULL;
    680     iFileServer.Close();
    681     if (iFileHandle)
    682     {
    683         OSCL_DELETE(iFileHandle);
    684         iFileHandle = NULL;
    685     }
    686 }
    687 
    688 
    689 ////////////////////////////////////////////////////////////////////////////
    690 void pv_mediainput_async_test_opencomposestop::Run()
    691 {
    692     if (IsEngineCmdPending())
    693     {
    694         return;
    695     }
    696 
    697     switch (iState)
    698     {
    699         case PVAE_CMD_CREATE:
    700         {
    701             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
    702                             (0, "******pv_mediainput_async_test_opencomposestop::iTestCaseNum:%d******", iTestCaseNum));
    703             fprintf(iFile, "Creating Author Engine \n");
    704 
    705             iAuthor = PVAuthorEngineFactory::CreateAuthor(this, this, this);
    706             if (!iAuthor)
    707             {
    708                 PVPATB_TEST_IS_TRUE(false);
    709                 iState = PVAE_CMD_CLEANUPANDCOMPLETE;
    710                 RunIfNotReady();
    711 
    712             }
    713             else
    714             {
    715                 iState = PVAE_CMD_OPEN;
    716                 RunIfNotReady();
    717             }
    718         }
    719         break;
    720 
    721         case PVAE_CMD_OPEN:
    722         {
    723             fprintf(iFile, "Opening Author Engine\n");
    724             iAuthor->Open((OsclAny*)iAuthor);
    725         }
    726         break;
    727 
    728         case PVAE_CMD_ADD_DATA_SOURCE:
    729         {
    730             fprintf(iFile, "Add Data Source\n");
    731             bool aStatus = CreateTestInputs();
    732             if (aStatus == 0) //Failed while creating test input
    733             {
    734                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
    735                                 (0, "pv_mediainput_async_test_opencomposestop::CreateTestInputs: Error - failed"));
    736 
    737                 PVPATB_TEST_IS_TRUE(false);
    738 
    739                 iState = PVAE_CMD_CLEANUPANDCOMPLETE;
    740 
    741                 RunIfNotReady();
    742             }
    743 
    744         }
    745         break;
    746 
    747         case PVAE_CMD_SELECT_COMPOSER:
    748         {
    749             fprintf(iFile, "Select Composer\n");
    750             iAuthor->SelectComposer(iComposerMimeType, iComposerConfig,
    751                                     (OsclAny*)iAuthor);
    752         }
    753         break;
    754 
    755         case PVAE_CMD_QUERY_INTERFACE:
    756 
    757             fprintf(iFile, "Query Interface\n");
    758 
    759             if (!QueryComposerOutputInterface())
    760             {
    761                 iState = PVAE_CMD_ADD_MEDIA_TRACK;
    762                 RunIfNotReady();
    763             }
    764             break;
    765 
    766         case PVAE_CMD_ADD_MEDIA_TRACK:
    767         {
    768             fprintf(iFile, "Add Media Track\n");
    769             if (!AddMediaTrack())
    770             {
    771                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
    772                                 (0, "pv_mediainput_async_test_opencomposestop::AddMediaTrack Error - No track added"));
    773                 PVPATB_TEST_IS_TRUE(false);
    774                 iState = PVAE_CMD_REMOVE_DATA_SOURCE;
    775                 RunIfNotReady();
    776             }
    777         }
    778         break;
    779 
    780         case PVAE_CMD_INIT:
    781         {
    782             fprintf(iFile, "Initializing  Author Engine\n");
    783             iAuthor->Init((OsclAny*)iAuthor);
    784         }
    785         break;
    786 
    787         case PVAE_CMD_START:
    788         {
    789             fprintf(iFile, "Starting Author Engine\n");
    790             iAuthor->Start();
    791         }
    792         break;
    793 
    794         case PVAE_CMD_STOP:
    795         {
    796             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
    797                             (0, "pv_mediainput_async_test_opencomposestop::Run: Command Stop"));
    798 
    799             fprintf(iFile, "Error: Recording timeout, stop engine please wait *******\n");
    800             iAuthor->Stop((OsclAny*)iAuthor);
    801 
    802             //flag error as no EOS was found and recording timedout
    803             PVPATB_TEST_IS_TRUE(false);
    804 
    805         }
    806         break;
    807 
    808         case PVAE_CMD_RESET:
    809         {
    810             ResetAuthorConfig();
    811             if (iAuthor->GetPVAuthorState() != PVAE_STATE_IDLE)
    812             {
    813                 iAuthor->Reset((OsclAny*)iAuthor);
    814             }
    815         }
    816         break;
    817 
    818         case PVAE_CMD_REMOVE_DATA_SOURCE:
    819         {
    820             for (uint32 ii = 0; ii < iMIOComponent.iMIONode.size(); ii++)
    821             {
    822                 iAuthor->RemoveDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor);
    823                 AddEngineCommand();
    824             }
    825         }
    826         break;
    827 
    828         case PVAE_CMD_CLOSE:
    829         {
    830             iAuthor->Close((OsclAny*)iAuthor);
    831         }
    832         break;
    833 
    834         case PVAE_CMD_PAUSE:
    835         {
    836             fprintf(iFile, "Pause Initiated ********\n");
    837             iAuthor->Pause((OsclAny*)iAuthor);
    838         }
    839         break;
    840 
    841         case PVAE_CMD_RESUME:
    842         {
    843             fprintf(iFile, "Resume Athoring *******\n");
    844             iAuthor->Resume((OsclAny*)iAuthor);
    845         }
    846         break;
    847 
    848         case PVAE_CMD_QUERY_INTERFACE2:
    849             fprintf(iFile, "Query Interface2\n");
    850             iAuthor->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (PVInterface*&)iAuthorCapConfigIF, (OsclAny*)iAuthor);
    851             break;
    852         case PVAE_CMD_CAPCONFIG_ASYNC:
    853         {
    854             fprintf(iFile, "Cap Config ASync\n");
    855             CapConfigAsync();
    856 
    857         }
    858         break;
    859 
    860         case PVAE_CMD_CAPCONFIG_SYNC:
    861             // set configuration MIME strings Synchronously
    862         {
    863             fprintf(iFile, "Cap Config Sync\n");
    864 
    865             if (!CapConfigSync()) //CapConfig failed
    866             {
    867                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
    868                                 (0, "pv_mediainput_async_test_opencomposestop::Run: Error - CapConfigSync failed"));
    869                 PVPATB_TEST_IS_TRUE(false);
    870                 iState = PVAE_CMD_CLEANUPANDCOMPLETE;
    871                 RunIfNotReady();
    872             }
    873             else
    874             {
    875                 iState = PVAE_CMD_START;
    876                 RunIfNotReady();
    877             }
    878         }
    879         break;
    880 
    881         case PVAE_CMD_CLEANUPANDCOMPLETE:
    882         {
    883             Cleanup();
    884             iObserver->CompleteTest(*iTestCase);
    885         }
    886         break;
    887 
    888         case PVAE_CMD_ADD_DATA_SINK:
    889         case PVAE_CMD_REMOVE_DATA_SINK:
    890             break;
    891 
    892         case PVAE_CMD_RECORDING:
    893         {
    894             fprintf(iFile, "Recording Please Wait*******\n");
    895             if (!iAuthoringCount)
    896             {
    897                 iState = PVAE_CMD_STOP;
    898                 RunIfNotReady(iTestDuration);
    899             }
    900             else
    901             {
    902                 iState = PVAE_CMD_RECORDING;
    903                 RunIfNotReady(iTestDuration);
    904                 iAuthoringCount--;
    905             }
    906         }
    907         break;
    908 
    909         default:
    910             break;
    911     } //end switch
    912 }
    913 
    914 ////////////////////////////////////////////////////////////////////////////
    915 void pv_mediainput_async_test_opencomposestop::CommandCompleted(const PVCmdResponse& aResponse)
    916 {
    917     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
    918                     (0, "pv_mediainput_async_test_opencomposestop::CommandCompleted iState:%d", iState));
    919 
    920 
    921     if (aResponse.GetCmdStatus() != PVMFSuccess)
    922     {
    923         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
    924                         (0, "pv_mediainput_async_test_opencomposestop::CommandCompleted iState:%d FAILED", iState));
    925     }
    926 
    927     switch (iState)
    928     {
    929         case PVAE_CMD_OPEN:
    930         {
    931             if (aResponse.GetCmdStatus() == PVMFSuccess)
    932             {
    933                 iState = PVAE_CMD_ADD_DATA_SOURCE;
    934                 RunIfNotReady();
    935             }
    936             else
    937             {
    938                 // Open failed
    939                 PVPATB_TEST_IS_TRUE(false);
    940                 iState = PVAE_CMD_RESET;
    941                 RunIfNotReady();
    942             }
    943         }
    944         break;
    945 
    946         case PVAE_CMD_ADD_DATA_SOURCE:
    947         {
    948             if (EngineCmdComplete())
    949             {
    950                 iState = PVAE_CMD_SELECT_COMPOSER;
    951             }
    952 
    953             if (aResponse.GetCmdStatus() == PVMFSuccess)
    954             {
    955                 RunIfNotReady();
    956             }
    957             else
    958             {
    959                 // AddDataSource failed
    960                 PVPATB_TEST_IS_TRUE(false);
    961                 iState = PVAE_CMD_RESET;
    962                 RunIfNotReady();
    963             }
    964         }
    965         break;
    966 
    967         case PVAE_CMD_SELECT_COMPOSER:
    968         {
    969             if (aResponse.GetCmdStatus() == PVMFSuccess)
    970             {
    971                 iComposer = aResponse.GetResponseData();
    972                 if (!ConfigComposer())
    973                 {
    974                     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
    975                                     (0, "pv_mediainput_async_test_opencomposestop::CommandCompleted: Error - ConfigComposer failed"));
    976 
    977                     PVPATB_TEST_IS_TRUE(false);
    978                     iState = PVAE_CMD_RESET;
    979                     RunIfNotReady();
    980                     return;
    981                 }
    982                 else
    983                 {
    984                     iState = PVAE_CMD_QUERY_INTERFACE;
    985                     RunIfNotReady();
    986                 }
    987             }
    988             else
    989             {
    990                 // SelectComposer failed
    991                 PVPATB_TEST_IS_TRUE(false);
    992                 iState = PVAE_CMD_RESET;
    993                 RunIfNotReady();
    994             }
    995 
    996         }
    997         break;
    998         case PVAE_CMD_QUERY_INTERFACE:
    999         {
   1000             if (aResponse.GetCmdStatus() == PVMFSuccess)
   1001             {
   1002                 ConfigComposerOutput();
   1003                 iState = PVAE_CMD_ADD_MEDIA_TRACK;
   1004                 RunIfNotReady();
   1005             }
   1006             else
   1007             {
   1008                 // QueryInterface failed
   1009                 PVPATB_TEST_IS_TRUE(false);
   1010                 iState = PVAE_CMD_RESET;
   1011                 RunIfNotReady();
   1012             }
   1013         }
   1014         break;
   1015         case PVAE_CMD_ADD_MEDIA_TRACK:
   1016         {
   1017             if (EngineCmdComplete())
   1018             {
   1019                 if (iAddVideoMediaTrack)
   1020                 {
   1021                     ConfigureVideoEncoder();
   1022                 }
   1023 
   1024                 if (iAddAudioMediaTrack)
   1025                 {
   1026                     ConfigureAudioEncoder();
   1027                 }
   1028 
   1029                 iState = PVAE_CMD_QUERY_INTERFACE2;
   1030             }
   1031 
   1032             if (aResponse.GetCmdStatus() == PVMFSuccess)
   1033             {
   1034                 RunIfNotReady();
   1035             }
   1036             else
   1037             {
   1038                 // AddMediaTrack failed
   1039                 PVPATB_TEST_IS_TRUE(false);
   1040                 iState = PVAE_CMD_RESET;
   1041                 RunIfNotReady();
   1042             }
   1043         }
   1044         break;
   1045         case PVAE_CMD_QUERY_INTERFACE2:
   1046             if (aResponse.GetCmdStatus() == PVMFSuccess)
   1047             {
   1048                 iState = PVAE_CMD_INIT;
   1049                 RunIfNotReady();
   1050             }
   1051             else
   1052             {
   1053                 // QueryInterface2 failed
   1054                 PVPATB_TEST_IS_TRUE(false);
   1055                 iState = PVAE_CMD_RESET;
   1056                 RunIfNotReady();
   1057             }
   1058             break;
   1059 
   1060         case PVAE_CMD_INIT:
   1061         {
   1062             if (aResponse.GetCmdStatus() == PVMFSuccess)
   1063             {
   1064                 if (iTestCaseNum == CapConfigTest)
   1065                 {
   1066                     iState = PVAE_CMD_CAPCONFIG_ASYNC;
   1067                 }
   1068                 else
   1069                 {
   1070                     iState = PVAE_CMD_START;
   1071                 }
   1072                 RunIfNotReady();
   1073             }
   1074             else
   1075             {
   1076                 // Init failed
   1077                 PVPATB_TEST_IS_TRUE(false);
   1078                 iState = PVAE_CMD_RESET;
   1079                 RunIfNotReady();
   1080             }
   1081         }
   1082         break;
   1083         case PVAE_CMD_CAPCONFIG_ASYNC:
   1084         {
   1085 
   1086             if (aResponse.GetCmdStatus() != PVMFSuccess)
   1087             {
   1088                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
   1089                                 (0, "pv_mediainput_async_test_opencomposestop::Run: Error - CapConfigAsync failed"));
   1090                 PVPATB_TEST_IS_TRUE(false);
   1091                 iState = PVAE_CMD_CLEANUPANDCOMPLETE;
   1092                 RunIfNotReady();
   1093             }
   1094             else
   1095             {
   1096                 PVPATB_TEST_IS_TRUE(true);
   1097                 iState = PVAE_CMD_START;
   1098                 RunIfNotReady();
   1099             }
   1100         }
   1101         break;
   1102 
   1103         case PVAE_CMD_START:
   1104         {
   1105             if (aResponse.GetCmdStatus() == PVMFSuccess)
   1106             {
   1107                 if (iPauseResumeEnable)
   1108                 {
   1109                     iState = PVAE_CMD_PAUSE;
   1110                     RunIfNotReady(KPauseDuration); //Pause after 5 sec
   1111                 }
   1112                 else
   1113                 {
   1114                     iState = PVAE_CMD_RECORDING;
   1115                     RunIfNotReady();
   1116                 }
   1117             }
   1118             else
   1119             {
   1120                 // Start failed
   1121                 PVPATB_TEST_IS_TRUE(false);
   1122                 iState = PVAE_CMD_RESET;
   1123                 RunIfNotReady();
   1124             }
   1125         }
   1126         break;
   1127 
   1128         case PVAE_CMD_PAUSE:
   1129         {
   1130             if (aResponse.GetCmdStatus() == PVMFSuccess)
   1131             {
   1132                 fprintf(iFile, "PAUSED: Resume after 10 seconds*******\n");
   1133                 iState = PVAE_CMD_RESUME;
   1134                 /* Stay paused for 10 seconds */
   1135                 RunIfNotReady(10*1000*1000);
   1136             }
   1137             else
   1138             {
   1139                 //Pause failed
   1140                 PVPATB_TEST_IS_TRUE(false);
   1141                 iState = PVAE_CMD_RESET;
   1142                 RunIfNotReady();
   1143             }
   1144         }
   1145         break;
   1146 
   1147         case PVAE_CMD_RESUME:
   1148         {
   1149             if (aResponse.GetCmdStatus() == PVMFSuccess)
   1150             {
   1151                 iState = PVAE_CMD_RECORDING;
   1152 
   1153                 //Start Authoring again
   1154                 RunIfNotReady();
   1155             }
   1156             else
   1157             {
   1158                 //Resume failed
   1159                 PVPATB_TEST_IS_TRUE(false);
   1160                 iState = PVAE_CMD_RESET;
   1161                 RunIfNotReady();
   1162             }
   1163         }
   1164         break;
   1165 
   1166         case PVAE_CMD_STOP:
   1167         {
   1168             if (aResponse.GetCmdStatus() == PVMFSuccess)
   1169             {
   1170                 iOutputFileName = NULL;
   1171                 iState = PVAE_CMD_RESET;
   1172                 RunIfNotReady();
   1173             }
   1174             else
   1175             {
   1176                 // Stop failed
   1177                 PVPATB_TEST_IS_TRUE(false);
   1178                 iState = PVAE_CMD_RESET;
   1179                 RunIfNotReady();
   1180             }
   1181         }
   1182         break;
   1183 
   1184         case PVAE_CMD_RESET:
   1185         {
   1186             if (aResponse.GetCmdStatus() == PVMFSuccess)
   1187             {
   1188                 if ((iMIOComponent.iMediaInput.size() == 0) || (iMIOComponent.iMIONode.size() == 0))
   1189                 {
   1190                     if (aResponse.GetCmdStatus() == PVMFSuccess)
   1191                     {
   1192                         PVPATB_TEST_IS_TRUE(true);
   1193                     }
   1194                     else
   1195                     {
   1196                         PVPATB_TEST_IS_TRUE(false);
   1197                     }
   1198                     //Since there are no MIO Components/Nodes, we end here
   1199                     //No need to call RemoveDataSource
   1200                     iObserver->CompleteTest(*iTestCase);
   1201                     break;
   1202                 }
   1203 
   1204                 iState = PVAE_CMD_REMOVE_DATA_SOURCE;
   1205                 RunIfNotReady();
   1206             }
   1207             else
   1208             {
   1209                 // Reset failed
   1210                 PVPATB_TEST_IS_TRUE(false);
   1211                 OSCL_ASSERT("ERROR -- Response failure for CMD_RESET");
   1212                 iObserver->CompleteTest(*iTestCase);
   1213             }
   1214         }
   1215         break;
   1216 
   1217         case PVAE_CMD_REMOVE_DATA_SOURCE:
   1218         {
   1219             if (aResponse.GetCmdStatus() == PVMFSuccess)
   1220             {
   1221                 if (EngineCmdComplete())
   1222                 {
   1223                     iOutputFileName = NULL;
   1224                     iMIOComponent.DeleteInputNode();
   1225                     if (iMediaInputType == PVMF_MIME_AVIFF)
   1226                     {
   1227                         PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
   1228                         PVAviFile::DeleteAviFileParser(fileparser);
   1229                         fileparser = NULL;
   1230                         iFileParser = NULL;
   1231                     }
   1232                     else if (iMediaInputType == PVMF_MIME_WAVFF)
   1233                     {
   1234                         PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
   1235                         delete(fileparser);
   1236                         fileparser = NULL;
   1237                         iFileParser = NULL;
   1238                     }
   1239 
   1240                     iFileParser = NULL;
   1241                     iState = PVAE_CMD_CLOSE;
   1242                     RunIfNotReady();
   1243 
   1244                 }
   1245                 else
   1246                 {
   1247                     return; //wait for completion of all RemoveDataSource calls.
   1248                 }
   1249             }
   1250             else
   1251             {
   1252                 // RemoveDataSource failed
   1253                 PVPATB_TEST_IS_TRUE(false);
   1254                 iObserver->CompleteTest(*iTestCase);
   1255             }
   1256         }
   1257         break;
   1258 
   1259         case PVAE_CMD_CLOSE:
   1260         {
   1261             if (aResponse.GetCmdStatus() == PVMFSuccess)
   1262             {
   1263                 PVPATB_TEST_IS_TRUE(true);
   1264             }
   1265             else
   1266             {
   1267                 PVPATB_TEST_IS_TRUE(false);
   1268             }
   1269             iObserver->CompleteTest(*iTestCase);
   1270         }
   1271         break;
   1272 
   1273         default:
   1274         {
   1275             // Testing error if this is reached
   1276             PVPATB_TEST_IS_TRUE(false);
   1277             iObserver->CompleteTest(*iTestCase);
   1278         }
   1279         break;
   1280     }  //end switch
   1281 }
   1282 
   1283 bool pv_mediainput_async_test_opencomposestop::ConfigComposerOutput()
   1284 {
   1285     PvmfComposerSizeAndDurationInterface* config =
   1286         OSCL_REINTERPRET_CAST(PvmfComposerSizeAndDurationInterface*, iOutputSizeAndDurationConfig);
   1287     if (!config)
   1288     {
   1289         return false;
   1290     }
   1291     bool enabled = false;
   1292     uint32 configData = 0;
   1293     switch (iTestCaseNum)
   1294     {
   1295         case KMaxFileSizeTest:
   1296         case KMaxFileSizeLongetivityTest:
   1297         {
   1298             if (config->SetMaxFileSize(true, KMaxFileSize) != PVMFSuccess)
   1299             {
   1300                 return false;
   1301             }
   1302             config->GetMaxFileSizeConfig(enabled, configData);
   1303             if (!enabled || configData != KMaxFileSize)
   1304             {
   1305                 return false;
   1306             }
   1307         }
   1308         break;
   1309 
   1310         case PVMediaInput_Open_Compose_Stop_Test:
   1311         case PVMediaInput_Open_Compose_Stop_Test_UsingExternalFileHandle:
   1312         {
   1313             if (config->SetFileSizeProgressReport(true, KFileSizeProgressFreq) != PVMFSuccess)
   1314             {
   1315                 return false;
   1316             }
   1317             config->GetFileSizeProgressReportConfig(enabled, configData);
   1318             if (!enabled || configData != KFileSizeProgressFreq)
   1319             {
   1320                 return false;
   1321             }
   1322             if (config->SetDurationProgressReport(true, KDurationProgressFreq) != PVMFSuccess)
   1323             {
   1324                 return false;
   1325             }
   1326             config->GetDurationProgressReportConfig(enabled, configData);
   1327             if (!enabled || configData != KDurationProgressFreq)
   1328             {
   1329                 return false;
   1330             }
   1331         }
   1332         break;
   1333 
   1334         default:
   1335             break;
   1336     }
   1337 
   1338     return true;
   1339 }
   1340 
   1341 ////////////////////////////////////////////////////////////////////////////
   1342 bool pv_mediainput_async_test_opencomposestop::QueryComposerOutputInterface()
   1343 {
   1344     switch (iTestCaseNum)
   1345     {
   1346         case PVMediaInput_Open_Compose_Stop_Test:
   1347         case PVMediaInput_Open_Compose_Stop_Test_UsingExternalFileHandle:
   1348         case KMaxFileSizeTest:
   1349         {
   1350             //iPendingCmds.push_back(PVAE_CMD_QUERY_INTERFACE);
   1351             iAuthor->QueryInterface(PvmfComposerSizeAndDurationUuid,
   1352                                     iOutputSizeAndDurationConfig, (OsclAny*)iAuthor);
   1353             return true;
   1354         }
   1355         break;
   1356         default:
   1357             return false;
   1358     }
   1359 
   1360     return false;
   1361 }
   1362 
   1363 ////////////////////////////////////////////////////////////////////////////
   1364 // function for setting configuration MIME strings Asynchronously
   1365 
   1366 bool pv_mediainput_async_test_opencomposestop::CapConfigAsync()
   1367 {
   1368     if (iTestCaseNum == CapConfigTest)
   1369     {
   1370         // Set the observer
   1371         iAuthorCapConfigIF->setObserver(this);
   1372 
   1373         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/author/productinfo/dummyprod1;valtype=int32");
   1374         iKVPSetAsync.key = iKeyStringSetAsync.get_str();
   1375         iKVPSetAsync.value.int32_value = 2;
   1376 
   1377         // set the parameter
   1378         iErrorKVP = NULL;
   1379         iAuthorCapConfigIF->setParametersAsync(NULL, &iKVPSetAsync, 1, iErrorKVP);
   1380 
   1381         return true;
   1382     }
   1383     else
   1384     {
   1385         return false;
   1386     }
   1387 }
   1388 
   1389 ////////////////////////////////////////////////////////////////////////////
   1390 // function for setting configuration MIME strings Synchronously
   1391 
   1392 bool pv_mediainput_async_test_opencomposestop::CapConfigSync()
   1393 {
   1394     if (iTestCaseNum == CapConfigTest)
   1395     {
   1396         // set the mime strings here
   1397         // capabilty and configuration feature implemented here
   1398         // set the config parameters using MIME strings here
   1399 
   1400         // set the KVP array
   1401         PvmiKvp paramkvp1;
   1402         // set cache size for composer node
   1403         //  PVMI_FILEIO_PV_CACHE_SIZE (MACRO defined in "pvmi_fileio_kvp.h")
   1404         OSCL_StackString<64> paramkey1(_STRLIT_CHAR(PVMI_FILEIO_PV_CACHE_SIZE));
   1405         paramkey1 += _STRLIT_CHAR(";valtype=uint32");
   1406         // set KVP values
   1407         // for composer node
   1408         paramkvp1.key = paramkey1.get_str();
   1409         paramkvp1.value.uint32_value = 1024;
   1410 
   1411         iErrorKVP = NULL;
   1412 
   1413         // verifyParametersSync will give Failure for test cases not using MP4 composer("fileio") node so commented
   1414         // Verify the new settings
   1415         //if (iAuthorCapConfigIF->verifyParametersSync(NULL, &paramkvp1, 1) == PVMFSuccess)
   1416         {
   1417             // set the parameter
   1418             iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
   1419             if (iErrorKVP == NULL)
   1420             {
   1421                 // Check by calling get
   1422                 PvmiKvp* retparam = NULL;
   1423                 int retnumparam = 0;
   1424                 paramkey1 += _STRLIT_CHAR(";attr=cur");
   1425                 // pass the string
   1426                 // retrieve a MIME string back
   1427                 iAuthorCapConfigIF->getParametersSync(NULL, paramkey1.get_str(), retparam, retnumparam, NULL);
   1428 
   1429                 if ((retparam != NULL) && (retnumparam == 1))
   1430                 {
   1431                     // release the parameters
   1432                     if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
   1433                     {
   1434                         return false;
   1435                     }
   1436                 }
   1437             }
   1438         }
   1439         /*
   1440         else
   1441         {
   1442             return false;
   1443         }*/
   1444 
   1445         //MIME for file output node
   1446         // set here any parameter here
   1447         OSCL_StackString<64> paramkey2(_STRLIT_CHAR("x-pvmf/file/output/parameter1;valtype=uint32"));
   1448 
   1449         // for file output node
   1450         paramkvp1.key = paramkey2.get_str();
   1451         paramkvp1.value.int32_value = 144;
   1452 
   1453         // set the value in node using SetParameterSync f(n) here
   1454         iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
   1455 
   1456         // MIME for media io node
   1457         // set parameters here
   1458         OSCL_StackString<64> paramkey3(_STRLIT_CHAR("x-pvmf/media-io/parameter1;valtype=uint32"));
   1459 
   1460         // for media io node
   1461         paramkvp1.key = paramkey3.get_str();
   1462         paramkvp1.value.int32_value = 144;
   1463 
   1464         // set the value in node using SetParameterSync f(n) here
   1465         iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
   1466 
   1467         if (iErrorKVP == NULL)
   1468         {
   1469             // Check by calling get
   1470             PvmiKvp* retparam = NULL;
   1471             int retnumparam = 0;
   1472             paramkey3 += _STRLIT_CHAR(";attr=cur");
   1473             // pass the string
   1474             // retrieve a MIME string back
   1475             iAuthorCapConfigIF->getParametersSync(NULL, paramkey3.get_str(), retparam, retnumparam, NULL);
   1476             if ((retparam != NULL) && (retnumparam == 1))
   1477             {
   1478                 // release the parameters
   1479                 if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
   1480                 {
   1481                     return false;
   1482                 }
   1483             }
   1484         }
   1485 
   1486         // MIME for amr encoder
   1487         // set the parameter here
   1488 
   1489         // MIME string here "x-pvmf/encoder/audio/sampling_rate;valtype=uint32"
   1490         OSCL_StackString<64> paramkey4(_STRLIT_CHAR(MOUT_AUDIO_SAMPLING_RATE_KEY));
   1491         // MOUT_AUDIO_SAMPLING_RATE_KEY (MACRO defined in "pvmi_kvp.h")
   1492         // for amr encoder node
   1493         paramkvp1.key = paramkey4.get_str();
   1494         paramkvp1.value.int32_value = 8000;
   1495 
   1496         // set the value in node using SetParameterSync f(n) here
   1497         iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
   1498 
   1499         if (iErrorKVP == NULL)
   1500         {
   1501             // Check by calling get
   1502             PvmiKvp* retparam = NULL;
   1503             int retnumparam = 0;
   1504             paramkey1 += _STRLIT_CHAR(";attr=cur");
   1505             // pass the string
   1506             // retrieve a MIME string back
   1507             iAuthorCapConfigIF->getParametersSync(NULL, paramkey4.get_str(), retparam, retnumparam, NULL);
   1508             if ((retparam != NULL) && (retnumparam == 1))
   1509             {
   1510                 // release the parameters
   1511                 if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
   1512                 {
   1513                     return false;
   1514                 }
   1515             }
   1516         }
   1517 
   1518 
   1519         // MIME for video encoder
   1520         // set the parameter frame width in the node (use combinations for width n height default is 176 by 144)
   1521 
   1522         // MIME string here "x-pvmf/video/render/output_width;valtype=uint32"
   1523         OSCL_StackString<64> paramkey5(_STRLIT_CHAR(MOUT_VIDEO_OUTPUT_WIDTH_KEY));
   1524         // MACRO "MOUT_VIDEO_OUTPUT_WIDTH_KEY" been defined in "pvmi_kvp.h"
   1525         // for video encoder node
   1526         paramkvp1.key = paramkey5.get_str();
   1527         paramkvp1.value.uint32_value = 128;
   1528         // set the value in node using SetParameterSync f(n) here
   1529         iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
   1530 
   1531         if (iErrorKVP == NULL)
   1532         {
   1533             // Check by calling get
   1534             PvmiKvp* retparam = NULL;
   1535             int retnumparam = 0;
   1536             paramkey1 += _STRLIT_CHAR(";attr=cur");
   1537             // pass the string
   1538             // retrieve a MIME string back
   1539             iAuthorCapConfigIF->getParametersSync(NULL, paramkey5.get_str(), retparam, retnumparam, NULL);
   1540             if ((retparam != NULL) && (retnumparam == 1))
   1541             {
   1542                 // release the parameters
   1543                 if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
   1544                 {
   1545                     return false;
   1546                 }
   1547             }
   1548         }
   1549 
   1550         // MIME for AVC Encoder
   1551         // set the parameter encoding mode
   1552 
   1553         // MIME string here "x-pvmf/avc/encoder/encoding_mode;valtype=uint32"
   1554         OSCL_StackString<64> paramkey6(_STRLIT_CHAR(PVMF_AVC_ENCODER_ENCODINGMODE_KEY));
   1555         // MACRO "PVMF_AVC_ENCODER_ENCODINGMODE_KEY" been defined in "pvmi_kvp.h"
   1556         // for AVC Encoder node
   1557         paramkvp1.key = paramkey6.get_str();
   1558         paramkvp1.value.uint32_value = 3;//EAVCEI_ENCMODE_TWOWAY;
   1559         // set the value in node using SetParameterSync f(n) here
   1560         iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
   1561 
   1562         if (iErrorKVP == NULL)
   1563         {
   1564             // Check by calling get
   1565             PvmiKvp* retparam = NULL;
   1566             int retnumparam = 0;
   1567             paramkey1 += _STRLIT_CHAR(";attr=cur");
   1568             // pass the string
   1569             // retrieve a MIME string back
   1570             iAuthorCapConfigIF->getParametersSync(NULL, paramkey6.get_str(), retparam, retnumparam, NULL);
   1571             if ((retparam != NULL) && (retnumparam == 1))
   1572             {
   1573                 // release the parameters
   1574                 if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
   1575                 {
   1576                     return false;
   1577                 }
   1578             }
   1579         }
   1580 
   1581         return true;
   1582     }
   1583     else
   1584     {
   1585         return true;
   1586     }
   1587 
   1588 }
   1589 
   1590 void pv_mediainput_async_test_opencomposestop::SignalEvent(int32 aReq_Id)
   1591 {
   1592     if (aReq_Id == 0) //For PVAE_CMD_CAPCONFIG_SET_PARAMETERS
   1593     {
   1594         if (iErrorKVP != NULL)
   1595         {
   1596             // There was an error in setParameterAsync()
   1597             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
   1598                             (0, "pv_mediainput_async_test_opencomposestop::SignalEvent: setParametersAsync failed"));
   1599             PVPATB_TEST_IS_TRUE(false);
   1600             iObserver->CompleteTest(*iTestCase);
   1601         }
   1602         else
   1603         {
   1604             iState = PVAE_CMD_CAPCONFIG_SYNC;
   1605             RunIfNotReady();
   1606         }
   1607     }
   1608 }
   1609 
   1610