gst_plugins_symbian/tsrc/gstreamertestmodule/inc/GStreamerTestClass.h
changeset 2 5505e8908944
child 8 4a7fac7dd34a
child 29 567bb019e3e3
equal deleted inserted replaced
1:4c282e7dd6d3 2:5505e8908944
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
       
     3 *
       
     4 * This library is free software; you can redistribute it and/or
       
     5 * modify it under the terms of the GNU Lesser General Public
       
     6 * License as published by the Free Software Foundation; either
       
     7 * version 2 of the License, or (at your option) any later version.
       
     8 *
       
     9 * This library is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    12 * Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public
       
    15 * License along with this library; if not, write to the
       
    16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    17 * Boston, MA 02111-1307, USA.
       
    18 *
       
    19 * Description:
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 
       
    25 #ifndef CGStreamerTestClass_H
       
    26 #define CGStreamerTestClass_H
       
    27 
       
    28 //  INCLUDES
       
    29 #include <StifLogger.h>
       
    30 #include <TestScripterInternal.h>
       
    31 #include <StifTestModule.h>
       
    32 
       
    33 #include <e32svr.h>
       
    34 #include <e32base.h>
       
    35 #include <e32cons.h>
       
    36 #include <gst/gst.h>
       
    37 
       
    38 #include "TimeoutController.h"
       
    39 #include "gstg711encoderinterface.h"
       
    40 #include "gstspeechencoderconfig.h"
       
    41 #include "gsterrorconcealmentinterface.h"
       
    42 #include "gstg711decoderinterface.h"
       
    43 #include "gstilbcdecoderinterface.h"
       
    44 #include "gstilbcencoderinterface.h"
       
    45 #include "gstg729encoderinterface.h"
       
    46 #include "gstg729decoderinterface.h"
       
    47 
       
    48 
       
    49 //global variables
       
    50 /*static GstElement *iPipeline;
       
    51 static GMainLoop *iLoop;
       
    52 static GstElement *iConverter;
       
    53 static GstElement *iResampler;
       
    54 static GstElement *iSink;*/
       
    55 
       
    56 // CONSTANTS
       
    57 const TInt KErrBadTestParameter= -1000;         // Error on configuration file
       
    58 
       
    59 const TInt KErrEventPending =-2000;             // Timeout and not callback 
       
    60 const TInt KErrCallbackErrorCode = -2001;       // Callback return error code
       
    61 const TInt KErrUnexpectedValue =-2002;          // Unexpected value at setting    
       
    62 const TInt KErrTimeoutController = -2007;		// Unexpected notification
       
    63 
       
    64 const TInt KShortTimeout = 1000;
       
    65 const TInt KMediumTimeout = 4000;
       
    66 const TInt KLongTimeout = 100000;
       
    67 
       
    68 
       
    69 _LIT( KMsgBadTestParameters, "[Error] No valid test case parameters");
       
    70 
       
    71 // General
       
    72 _LIT( KTagLocation, "location");
       
    73 
       
    74 // Common Properties
       
    75 _LIT( KTagRateProperty,"rate");
       
    76 _LIT( KTagChannelsProperty,"channels");
       
    77 _LIT( KTagLeftBalanceProperty,"leftbalance");
       
    78 
       
    79 
       
    80 // Sink Properties
       
    81 _LIT( KTagVolumeProperty,"volume");
       
    82 _LIT( KTagMaxVolumeProperty,"maxvolume");
       
    83 _LIT( KTagSamplesPlayedProperty,"samplesplayed");
       
    84 _LIT( KTagRightBalanceProperty,"rightbalance");
       
    85 _LIT( KTagVolumeRampProperty,"volumeramp");
       
    86 _LIT( KTagPriorityProperty,"priority");
       
    87 _LIT( KTagPereferenceProperty,"preference");
       
    88 _LIT( KTagFourCCProperty,"fourcc");
       
    89 _LIT( KTagMimeTypeProperty,"mimetype");
       
    90 
       
    91 // Source Properties
       
    92 _LIT( KTagGainProperty,"gain");
       
    93 _LIT( KTagMaxGainProperty,"maxgain");
       
    94 _LIT( KTagSamplesRecordedProperty,"samplesrecorded");
       
    95 
       
    96 
       
    97 
       
    98 // MACROS
       
    99 //#define ?macro ?macro_def
       
   100 // Logging path
       
   101 #ifdef __WINSCW__
       
   102 _LIT( KGStreamerTestClassLogPath, "\\logs\\testframework\\" ); 
       
   103 #else
       
   104 _LIT( KGStreamerTestClassLogPath, "e:\\testing\\Log\\" );
       
   105 #endif
       
   106 
       
   107 // Log file
       
   108 _LIT( KGStreamerTestClassLogFile, "GStreamerTestClass.txt" ); 
       
   109 
       
   110 
       
   111 // FORWARD DECLARATIONS
       
   112 class CGStreamerTestClass;
       
   113 //typedef struct _GstObjects GstObjects;
       
   114 class CGlibEventHandler: public CActive
       
   115 {
       
   116     
       
   117 public:
       
   118     static CGlibEventHandler* NewL();
       
   119     ~CGlibEventHandler();
       
   120     
       
   121     void RunL();
       
   122     void DoCancel();
       
   123     void Start();
       
   124     void Stop();
       
   125 private:
       
   126     CGlibEventHandler();
       
   127     void ConstructL();  
       
   128     
       
   129     RTimer iTimer;
       
   130 };
       
   131 
       
   132 
       
   133 class CGstObjects : public CBase
       
   134     {
       
   135 public:
       
   136 
       
   137     static CGstObjects* NewL(void* aParent);    
       
   138     virtual ~CGstObjects();
       
   139 private:
       
   140     void ConstructL();
       
   141     CGstObjects(void* aParent);
       
   142     
       
   143 public :
       
   144     
       
   145     GstElement *iPipeline;
       
   146     GMainLoop *iLoop;
       
   147     GstElement *iConverter;
       
   148     GstElement *iResampler;
       
   149     GstElement *iSink;        
       
   150     GstElement *iSource;
       
   151     GstElement *iWavparse;
       
   152 
       
   153     GstElement *iDecoder;
       
   154     GstElement *iFakesink;
       
   155     GstElement *iFilesink;
       
   156     GstElement *iEncoder;
       
   157     GstElement *iFilter;
       
   158     GstElement *iWavenc;
       
   159     GstBus* iBus;
       
   160     GstCaps* iCaps;
       
   161     GstG711EncoderIntfc *iG711EncoderIntfc;
       
   162     GstG729EncoderIntfc *iG729EncoderIntfc;
       
   163     GstIlbcEncoderIntfc *iIlbcEncoderIntfc;
       
   164     GstSpeechEncoderConfigIntfc *iSpeechEncoderIntfc;
       
   165     GstErrorConcealmentIntfc *iErrconcealmentIntfc;
       
   166     GstG711DecoderIntfc *iG711DecoderIntfc;
       
   167     GstG729DecoderIntfc *iG729DecoderIntfc;
       
   168     GstIlbcDecoderIntfc *iIlbcDecoderIntfc;  
       
   169     FILE* fp;
       
   170     CGlibEventHandler* iCGlibEventHandler;
       
   171     void *iParent;
       
   172     };
       
   173 
       
   174 // CLASS DECLARATION
       
   175 
       
   176 /**
       
   177 *  CGStreamerTestClass test class for STIF Test Framework TestScripter.
       
   178 *  ?other_description_lines
       
   179 *
       
   180 *  @lib ?library
       
   181 *  @since Series60_3_2
       
   182 */
       
   183 NONSHARABLE_CLASS(CGStreamerTestClass) : public CScriptBase, 
       
   184 											public MTimeoutObserver
       
   185     {
       
   186     public:  // Constructors and destructor
       
   187 
       
   188         /**
       
   189         * Two-phased constructor.
       
   190         */
       
   191         static CGStreamerTestClass* NewL( CTestModuleIf& aTestModuleIf );
       
   192 
       
   193         /**
       
   194         * Destructor.
       
   195         */
       
   196         virtual ~CGStreamerTestClass();
       
   197 
       
   198      
       
   199 		enum TGSTExpectedEvent
       
   200             {
       
   201             EEOSReceived
       
   202             };
       
   203 
       
   204 		enum TGStreamerElements
       
   205 		    {
       
   206 		    EFILESOURCE = 1,
       
   207 		    EFILESINK,
       
   208 		    EFAKESOURCE,
       
   209 		    EFAKESINK,
       
   210 		    EWAVPARSE,		    
       
   211 		    EMP3DECODER,
       
   212 		    EWAVEENCODER,
       
   213 		    ERESAMPLER,
       
   214 		    ECONVERTER,
       
   215 		    EDEVSOUNDSRC,
       
   216 		    EDEVSOUNDSINK
       
   217 		    };
       
   218 		
       
   219       enum TElementCustomInterfaces
       
   220             {
       
   221             EG711ENCODER = 1,
       
   222             EG711DECODER,
       
   223             EG729ENCODER,
       
   224             EG729DECODER,
       
   225             EILBCENCODER,
       
   226             EILBCDECODER,
       
   227             ESPEECHENCODER,          
       
   228             EERRORCONCEALMENT
       
   229             };
       
   230 
       
   231       enum TG711DecCustomIntfcProp
       
   232           {
       
   233           EG711SetDecoderMode = 1,
       
   234           EG711SetCng,
       
   235           EG711GetCng,
       
   236           EG711SetPlc
       
   237           };
       
   238 
       
   239       enum TILBCDecCustomIntfcProp
       
   240           {
       
   241           EIlbcSetDecoderMode = 1,
       
   242           EIlbcSetCng,
       
   243           EIlbcGetCng,
       
   244           };   
       
   245       
       
   246       enum TG729DecCustomIntfcProp
       
   247           {
       
   248           EG729BadLsfNextBuffer = 1
       
   249           };
       
   250       
       
   251       enum TG711EncCustomIntfcProp
       
   252           {
       
   253           EG711SetEncoderMode = 1,
       
   254           EG711SetVadMode,
       
   255           EG711GetVadMode          
       
   256           };
       
   257 
       
   258       enum TILBCEncCustomIntfcProp
       
   259           {
       
   260           EIlbcSetEncoderMode = 1,
       
   261           EIlbcSetVadMode,
       
   262           EIlbcGetVadMode          
       
   263           };
       
   264       
       
   265       enum TG729EncCustomIntfcProp
       
   266           {
       
   267           EG729SetVadMode = 1,
       
   268           EG729GetVadMode          
       
   269           };
       
   270       
       
   271       enum TSpEncCustomIntfcProp
       
   272           {
       
   273           ESPENGetSupportedBitrates = 1,
       
   274           ESPENSetBitrate,
       
   275           ESPENGetBitrate,
       
   276           ESPENSetVadMode,
       
   277           ESPENGetVadMode       
       
   278           };
       
   279       
       
   280       enum TErrorConcealCustomIntfcProp
       
   281           {
       
   282           EECConcealErrorForNextBuffer = 1,
       
   283           EECSetFrameMode,
       
   284           EECFrameModeRqrdForEC         
       
   285           };    
       
   286       
       
   287     public: // New functions
       
   288 
       
   289         /**
       
   290         * ?member_description.
       
   291         * @since ?Series60_version
       
   292         * @param ?arg1 ?description
       
   293         * @return ?description
       
   294         */
       
   295         //?type ?member_function( ?type ?arg1 );
       
   296 
       
   297     public: // Functions from base classes
       
   298 
       
   299         /**
       
   300         * From CScriptBase Runs a script line.
       
   301         * @since ?Series60_version
       
   302         * @param aItem Script line containing method name and parameters
       
   303         * @return Symbian OS error code
       
   304         */
       
   305         virtual TInt RunMethodL( CStifItemParser& aItem );
       
   306 
       
   307 
       
   308  	
       
   309 	    // From MTimeoutObserver
       
   310 
       
   311 	    /**
       
   312 	    * @since ?Series60_version
       
   313 	    * @param none
       
   314 	    * Review if all the expected events have ocurred once the time is over
       
   315 	    */
       
   316 	    void HandleTimeout(TInt error);
       
   317 
       
   318         /**
       
   319         * Verify that the event was expected, removes it from the list
       
   320         * Signal the TestScripter with the returned error code
       
   321         * @since ?Series60_version
       
   322         */
       
   323         void ProcessEvent(TGSTExpectedEvent aEvent, TInt aError);
       
   324 
       
   325 
       
   326     protected:  // New functions
       
   327 
       
   328         /**
       
   329         * ?member_description.
       
   330         * @since ?Series60_version
       
   331         * @param ?arg1 ?description
       
   332         * @return ?description
       
   333         */
       
   334         //?type ?member_function( ?type ?arg1 );
       
   335 
       
   336     protected:  // Functions from base classes
       
   337 
       
   338         /**
       
   339         * From ?base_class ?member_description
       
   340         */
       
   341         //?type ?member_function();
       
   342 
       
   343     private:
       
   344 
       
   345         /**
       
   346         * C++ default constructor.
       
   347         */
       
   348         CGStreamerTestClass( CTestModuleIf& aTestModuleIf );
       
   349 
       
   350         /**
       
   351         * By default Symbian 2nd phase constructor is private.
       
   352         */
       
   353         void ConstructL();
       
   354 
       
   355         // Prohibit copy constructor if not deriving from CBase.
       
   356         // ?classname( const ?classname& );
       
   357         // Prohibit assigment operator if not deriving from CBase.
       
   358         // ?classname& operator=( const ?classname& );
       
   359 
       
   360         /**
       
   361         * Frees all resources allocated from test methods.
       
   362         * @since ?Series60_version
       
   363         */
       
   364         void Delete();
       
   365 
       
   366         /**
       
   367         * Test methods are listed below. 
       
   368         */
       
   369 
       
   370         /**
       
   371         * Example test method.
       
   372         * @since ?Series60_version
       
   373         * @param aItem Script line containing parameters.
       
   374         * @return Symbian OS error code.
       
   375         */
       
   376 
       
   377 	    /**
       
   378 	    * Set an event as expected and set default timeout
       
   379 	    * @since ?Series60_version
       
   380 	    */
       
   381 	    void AddExpectedEvent(TGSTExpectedEvent event, TInt ms);
       
   382 
       
   383 
       
   384 	    /**
       
   385 	    * Unset an event as expected
       
   386 	    * @since ?Series60_version
       
   387 	    */
       
   388 	    TBool RemoveExpectedEvent(TGSTExpectedEvent event);
       
   389 
       
   390 
       
   391 	    /**
       
   392 	    * @since ?Series60_version
       
   393 	    * @param none
       
   394 	    * Removes all expected events
       
   395 	    */
       
   396 	    void RemoveAllExpectedEvents();
       
   397 
       
   398 
       
   399 
       
   400 	    /**
       
   401 	    * Maps a event with a descriptor with its name
       
   402 	    * @since ?Series60_version
       
   403 	    */
       
   404 	    TPtrC EventName( TInt aKey );
       
   405 
       
   406 	    /*
       
   407 	    * Test methods are listed below.
       
   408 	    */
       
   409 
       
   410 	    /**
       
   411 	    * Sets a timeout different since the default
       
   412 	    * @since Series60_3_2
       
   413 	    * @param aItem Script line containing parameters.
       
   414 	    * @return Symbian OS error code.
       
   415 	    */
       
   416 	    TInt SetTimeout( CStifItemParser& aItem );
       
   417 
       
   418 	    /**
       
   419 	    *
       
   420 	    * @since Series60_3_2
       
   421 	    * @param aItem Script line containing parameters.
       
   422 	    * @return Symbian OS error code.
       
   423 	    */
       
   424 	    TInt SetExpectedEvents( CStifItemParser& aItem );
       
   425 
       
   426 	    /**
       
   427 	    *
       
   428 	    * @since Series60_3_2
       
   429 	    * @param aItem Script line containing parameters.
       
   430 	    * @return Symbian OS error code.
       
   431 	    */
       
   432 	    TInt SetAllowedPanic( CStifItemParser& aItem );
       
   433 	    
       
   434 	    /**
       
   435 	    * Connect to the default client to the server
       
   436 	    * @since ?Series60_version
       
   437 	    * @param aItem Script line containing parameters.
       
   438 	    * @return Symbian OS error code.
       
   439 	    */
       
   440 
       
   441 		TInt ExampleL( CStifItemParser& aItem );
       
   442 			
       
   443 		TInt InitGStreamer( CStifItemParser& aItem );
       
   444 		TInt CreatePipeLine( CStifItemParser& aItem );
       
   445 		TInt CreateElement( CStifItemParser& aItem );
       
   446 		TInt SetElementProperties( CStifItemParser& aItem );
       
   447 		TInt GetElementProperties( CStifItemParser& aItem );
       
   448 		TInt AddElementToPipeline( CStifItemParser& aItem );
       
   449 		TInt SetPipelineState( CStifItemParser& aItem );
       
   450 		TInt InitPipeLine( CStifItemParser& aItem );
       
   451 		TInt LinkElementsInPipeline( CStifItemParser& aItem );
       
   452 		TInt GetElementsCustomIntfc( CStifItemParser& aItem );
       
   453 		TInt CustomIntfcProp( CStifItemParser& aItem );
       
   454 		
       
   455 		TInt SetCapsInPipeLine( CStifItemParser& aItem );
       
   456 		
       
   457 		TInt SetMainLoopRun( CStifItemParser& aItem );
       
   458 		TInt GetConfigureData();
       
   459 		TInt SetConfigureData();
       
   460 
       
   461 
       
   462     
       
   463     public:     // Data
       
   464         // ?one_line_short_description_of_data
       
   465         //?data_declaration;
       
   466 
       
   467     protected:  // Data
       
   468         // ?one_line_short_description_of_data
       
   469         //?data_declaration;
       
   470 
       
   471     private:    // Data
       
   472         
       
   473     	// reference to TestModuleIf
       
   474     	CTestModuleIf& iTestModuleIf;
       
   475    	
       
   476     	// Active object with a timer to timeout the test case
       
   477     	CSimpleTimeout * iTimeoutController;
       
   478 
       
   479     	// Indicates if the test case use a normal exit reason
       
   480     	TBool iNormalExitReason;
       
   481 
       
   482     	// List of expected events
       
   483     	RArray<TGSTExpectedEvent> iExpectedEvents;
       
   484 
       
   485     	// List of notification event (by the callback)
       
   486     	RArray<TGSTExpectedEvent> iOcurredEvents;
       
   487     	
       
   488 
       
   489     	/*GstElement *iSource;
       
   490     	GstElement *iWavparse;
       
   491 
       
   492     	GstElement *iDecoder;
       
   493     	GstElement *iFakesink;
       
   494     	GstElement *iFilesink;
       
   495     	GstElement *iEncoder;
       
   496     	GstElement *iFilter;
       
   497     	GstElement *iWavenc;
       
   498     	GstBus* iBus;
       
   499     	GstCaps* iCaps;
       
   500     	GstG711EncoderIntfc *iG711EncoderIntfc;
       
   501         GstG729EncoderIntfc *iG729EncoderIntfc;
       
   502         GstIlbcEncoderIntfc *iIlbcEncoderIntfc;
       
   503     	GstSpeechEncoderConfigIntfc *iSpeechEncoderIntfc;
       
   504     	GstErrorConcealmentIntfc *iErrconcealmentIntfc;
       
   505     	GstG711DecoderIntfc *iG711DecoderIntfc;
       
   506         GstG729DecoderIntfc *iG729DecoderIntfc;
       
   507         GstIlbcDecoderIntfc *iIlbcDecoderIntfc;*/
       
   508         
       
   509         CGstObjects* iObjects;
       
   510     	
       
   511     };
       
   512 
       
   513 #endif      // CGStreamerTestClass_H
       
   514 
       
   515 // End of File