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_TESTSET7_H_INCLUDED
     19 #define TEST_PV_AUTHOR_ENGINE_TESTSET7_H_INCLUDED
     20 
     21 #ifndef TEST_PV_MEDIAINPUT_AUTHOR_ENGINE_H
     22 #include "test_pv_mediainput_author_engine.h"
     23 #endif
     24 
     25 #define PVPATB_TEST_IS_TRUE( condition ) (iTestCase->test_is_true_stub( (condition), (#condition), __FILE__, __LINE__ ))
     26 
     27 class pv_mediainput_async_test_reset: public pvauthor_async_test_base
     28 {
     29     public:
     30         pv_mediainput_async_test_reset(PVAuthorAsyncTestParam aTestParam, PVMediaInputTestParam aMediaParam, bool aPauseResumeEnable, PVAECmdType aResetState)
     31                 : pvauthor_async_test_base(aTestParam)
     32                 , iOutputFileName(NULL)
     33                 , iInputFileName(NULL)
     34                 , iComposerMimeType(aMediaParam.iComposerInfo)
     35                 , iAudioEncoderMimeType(aMediaParam.iAudioEncInfo)
     36                 , iVideoEncoderMimeType(aMediaParam.iVideoEncInfo)
     37                 , iMediaInputType(aMediaParam.iInputFormat)
     38                 , iAuthor(NULL)
     39                 , iComposer(NULL)
     40                 , iFileParser(NULL)
     41                 , iComposerConfig(NULL)
     42                 , iAudioEncoderConfig(NULL)
     43                 , iVideoEncoderConfig(NULL)
     44                 , iPendingCmds(0)
     45                 , iPauseResumeEnable(aPauseResumeEnable)
     46                 , iRemoveDataSourceDone(0)
     47                 , iAddAudioMediaTrack(false)
     48                 , iAddVideoMediaTrack(false)
     49                 , iCurrentResetState(aResetState)
     50 
     51 
     52         {
     53             iLogger = PVLogger::GetLoggerObject("pv_mediainput_async_test_reset");
     54 
     55             iTestDuration = KTestDuration * 1000 * 1000;
     56 
     57             if (oscl_strlen(aMediaParam.iIPFileInfo.get_cstr()) != 0)
     58             {
     59                 oscl_wchar output2[ARRAY_SIZE];
     60                 oscl_UTF8ToUnicode(aMediaParam.iIPFileInfo.get_cstr(), oscl_strlen(aMediaParam.iIPFileInfo.get_cstr()), output2, ARRAY_SIZE);
     61                 iInputFileName.set(output2, oscl_strlen(output2));
     62 
     63             }
     64 
     65             if (oscl_strlen(aMediaParam.iOPFileInfo.get_cstr()) != 0)
     66             {
     67                 oscl_wchar output1[ARRAY_SIZE];
     68                 oscl_UTF8ToUnicode(aMediaParam.iOPFileInfo.get_cstr(), oscl_strlen(aMediaParam.iOPFileInfo.get_cstr()), output1, ARRAY_SIZE);
     69                 iOutputFileName.set(output1, oscl_strlen(output1));
     70             }
     71 
     72 
     73             if (PVAE_CMD_CREATE == iCurrentResetState)
     74             {
     75                 iNextResetState = PVAE_CMD_OPEN;
     76             }
     77             else if (PVAE_CMD_OPEN == iCurrentResetState)
     78             {
     79                 iNextResetState = PVAE_CMD_ADD_DATA_SOURCE;
     80             }
     81             else if (PVAE_CMD_ADD_DATA_SOURCE == iCurrentResetState)
     82             {
     83                 iNextResetState = PVAE_CMD_SELECT_COMPOSER;
     84             }
     85             else if (PVAE_CMD_SELECT_COMPOSER == iCurrentResetState)
     86             {
     87                 iNextResetState = PVAE_CMD_ADD_MEDIA_TRACK;
     88             }
     89             else if (PVAE_CMD_ADD_MEDIA_TRACK == iCurrentResetState)
     90             {
     91                 iNextResetState = PVAE_CMD_INIT;
     92             }
     93             else if (PVAE_CMD_INIT == iCurrentResetState)
     94             {
     95                 iNextResetState = PVAE_CMD_START;
     96             }
     97             else if (PVAE_CMD_START == iCurrentResetState)
     98             {
     99                 if (iPauseResumeEnable)
    100                 {
    101                     iNextResetState = PVAE_CMD_PAUSE;
    102                 }
    103                 else
    104                 {
    105                     iNextResetState = PVAE_CMD_RECORDING;
    106                 }
    107             }
    108             else if ((PVAE_CMD_PAUSE == iCurrentResetState) || (PVAE_CMD_RECORDING == iCurrentResetState))
    109             {
    110                 iNextResetState = PVAE_CMD_STOP;
    111             }
    112 
    113 
    114         }
    115 
    116         ~pv_mediainput_async_test_reset()
    117         {
    118             Cleanup();
    119         }
    120 
    121         void Run();
    122         void StartTest();
    123 
    124         // Author engine observer functions
    125         void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
    126         void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
    127         void CommandCompleted(const PVCmdResponse& aResponse);
    128 
    129         PVAECmdType iState;
    130         // Test output
    131         OSCL_wHeapString<OsclMemAllocator> iOutputFileName;
    132         OSCL_wHeapString<OsclMemAllocator> iInputFileName;
    133 
    134         OSCL_HeapString<OsclMemAllocator> iComposerMimeType;
    135         OSCL_HeapString<OsclMemAllocator> iAudioEncoderMimeType;
    136         OSCL_HeapString<OsclMemAllocator> iVideoEncoderMimeType;
    137 
    138         //test input type
    139         PVMFFormatType  iMediaInputType;
    140 
    141         PVAECmdType GetNextResetState()
    142         {
    143             return iNextResetState;
    144         }
    145 
    146     private:
    147         // Methods to create test input nodes and add to author engine
    148         bool CreateTestInputs();
    149         bool AddDataSource();
    150 
    151         // Methods to configure composers
    152         bool ConfigComposer();
    153         bool ConfigOutputFile();
    154         bool ConfigMp43gpComposer();
    155 
    156         // Methods to add media tracks
    157         bool AddMediaTrack();
    158 
    159         // Methods to configure encoders
    160         bool ConfigureVideoEncoder();
    161         bool ConfigureAudioEncoder();
    162 
    163         void ResetAuthorConfig();
    164 
    165         void Cleanup();
    166 
    167         void AddEngineCommand()
    168         {
    169             iPendingCmds++;
    170         }
    171 
    172         bool EngineCmdComplete()
    173         {
    174             if (iPendingCmds > 0)
    175             {
    176                 --iPendingCmds;
    177             }
    178 
    179             if (iPendingCmds == 0)
    180             {
    181                 return true;
    182             }
    183 
    184             return false;
    185         }
    186 
    187         bool IsEngineCmdPending()
    188         {
    189             if (iPendingCmds > 0)
    190                 return true;
    191             else
    192                 return false;
    193         }
    194 
    195         // Author engine related variables
    196         PVAuthorEngineInterface* iAuthor;
    197         OsclAny*                 iComposer;
    198         OsclAny*                 iFileParser;
    199         PVInterface*             iComposerConfig;
    200         PVInterface*             iAudioEncoderConfig;
    201         PVInterface*             iVideoEncoderConfig;
    202         PVMIOControlComp         iMIOComponent;
    203         uint32                   iPendingCmds;
    204         PVLogger*                iLogger;
    205         bool                     iPauseResumeEnable;
    206         uint                     iRemoveDataSourceDone;
    207         uint32                   iTestDuration;
    208         bool                     iAddAudioMediaTrack;
    209         bool                     iAddVideoMediaTrack;
    210         PVAECmdType              iNextResetState;
    211         PVAECmdType              iCurrentResetState;
    212         Oscl_FileServer          iFileServer;
    213 };
    214 
    215 #endif
    216