mmmw_plat/telephony_multimedia_service_api/tsrc/TmsAudioServicesTestClass/inc/TMSAudioServicesTestClass.h
changeset 0 71ca22bcf22a
child 3 4f62049db6ac
child 12 5a06f39ad45b
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: Telephony Multimedia Service - STIF TEST
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef __TMSAUDIOSERVICESTESTCLASS_H
       
    19 #define __TMSAUDIOSERVICESTESTCLASS_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <StifLogger.h>
       
    23 #include <TestScripterInternal.h>
       
    24 #include <StifTestModule.h>
       
    25 
       
    26 #include <e32svr.h>
       
    27 #include <e32base.h>
       
    28 #include <e32cons.h>
       
    29 #include <tms.h>
       
    30 #include <TmsFactory.h>
       
    31 #include <TmsCall.h>
       
    32 #include <TmsStream.h>
       
    33 #include <TmsFormat.h>
       
    34 #include <TmsClientSink.h>
       
    35 #include <TmsClientSource.h>
       
    36 #include <TmsClientSourceObsrvr.h>
       
    37 #include <TmsClientSinkObsrvr.h>
       
    38 #include <TmsVolumeEffect.h>
       
    39 #include <TmSGlobalVolEffect.h>
       
    40 #include <TmsGainEffect.h>
       
    41 #include <TmSGlobalGainEffect.h>
       
    42 #include <TmsEffectObsrvr.h>
       
    43 #include <TmsStreamObsrvr.h>
       
    44 #include <TmsBuffer.h>
       
    45 #include <TmsGlobalRouting.h>
       
    46 #include <TmsGlobalRoutingObsrvr.h>
       
    47 #include <TMSG711Format.h>
       
    48 #include <TMSG729Format.h>
       
    49 #include <TMSiLBCFormat.h>
       
    50 #include <TMSPCMFormat.h>
       
    51 #include <TMSAMRFormat.h>
       
    52 
       
    53 #include "TimeoutController.h"
       
    54 
       
    55 using namespace TMS;
       
    56 
       
    57 // CONSTANTS
       
    58 const TInt KErrBadTestParameter = -1000; // Error on configuration file
       
    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 = 2000;
       
    65 const TInt KMediumTimeout = 10000;
       
    66 const TInt KLongTimeout = 100000;
       
    67 
       
    68 #ifdef __JITTER_BUFFER_TEST__
       
    69 const TUint KDefaultSampleRateInkHz = 8; // for sequence number calculation
       
    70 const TUint KMaxSeqNumber = 0xFFFF; //65535
       
    71 #endif //__JITTER_BUFFER_TEST__
       
    72 
       
    73 _LIT( KMsgBadTestParameters, "[Error] No valid test case parameters");
       
    74 
       
    75 // General
       
    76 _LIT( KTagG711, "G711");
       
    77 _LIT( KTagG729, "G729");
       
    78 _LIT( KTagILBC, "iLBC");
       
    79 _LIT( KTagAMRNB, "AMR-NB");
       
    80 _LIT( KTagPCM16, "PCM16");
       
    81 
       
    82 _LIT( KTagUplink, "Uplink");
       
    83 _LIT( KTagDnlink, "Dnlink");
       
    84 _LIT( KTagFile, "File");
       
    85 _LIT( KTagRFile, "RFile");
       
    86 _LIT( KTagProfile, "Profile");
       
    87 _LIT( KTagDesL, "DesL");
       
    88 _LIT( KTagMin, "MIN");
       
    89 _LIT( KTagMax, "MAX");
       
    90 _LIT( KTagULaw, "uLaw");
       
    91 _LIT( KTagALaw, "aLaw");
       
    92 _LIT( KTag20ms, "20ms");
       
    93 _LIT( KTag30ms, "30ms");
       
    94 _LIT( KTagFile1, "File1");
       
    95 _LIT( KTagFile2, "File2");
       
    96 
       
    97 _LIT( KTagNone, "None");
       
    98 _LIT( KTagHandset, "Handset");
       
    99 _LIT( KTagLoudspeaker, "Loudspeaker");
       
   100 _LIT( KTagWiredAccessory, "WiredAccessory");
       
   101 _LIT( KTagAccessory, "Accessory");
       
   102 _LIT( KTagTTY, "TTY");
       
   103 _LIT( KTagPublic, "Public");
       
   104 _LIT( KTagPrivate, "Private");
       
   105 
       
   106 // MACROS
       
   107 //#define ?macro ?macro_def
       
   108 // Logging path
       
   109 #ifdef __WINSCW__
       
   110 _LIT( KTmsAudioServicesTestClassLogPath, "\\logs\\testframework\\" );
       
   111 _LIT16(KTestFile1, "\\testing\\data\\alarm 1.aac");
       
   112 _LIT16(KTestFile2, "\\testing\\data\\alarm.aac");
       
   113 _LIT16(KTestFile3, "\\testing\\data\\test_8khz.wav");
       
   114 #else
       
   115 _LIT( KTmsAudioServicesTestClassLogPath, "c:\\testing\\Log\\" );
       
   116 _LIT16(KTestFile1, "c:\\testing\\data\\alarm 1.aac");
       
   117 _LIT16(KTestFile2, "c:\\testing\\data\\alarm.aac");
       
   118 _LIT16(KTestFile3, "c:\\testing\\data\\test_8khz.wav");
       
   119 #endif
       
   120 
       
   121 // Log file
       
   122 _LIT( KTmsAudioServicesTestClassLogFile, "CTmsAudioServicesTestClass.txt" );
       
   123 _LIT8(KMimetypeAAC, "audio/aac");
       
   124 _LIT8(KMimetypeWAV, "audio/wav");
       
   125 const TUint KTonesBufSize = 6;
       
   126 const TUint KMimeStringSize = 32;
       
   127 
       
   128 // FORWARD DECLARATIONS
       
   129 class CTmsAudioServicesTestClass;
       
   130 class CTmsDataBuffer;
       
   131 #ifdef __JITTER_BUFFER_TEST__
       
   132 class CTmsJBDataBuffer;
       
   133 #endif //__JITTER_BUFFER_TEST__
       
   134 
       
   135 // CLASS DECLARATION
       
   136 
       
   137 /**
       
   138  *  CRadioUtilityTestClass test class for STIF Test Framework TestScripter.
       
   139  *  ?other_description_lines
       
   140  *
       
   141  *  @lib ?library
       
   142  *  @since Series60_3_2
       
   143  */
       
   144 NONSHARABLE_CLASS(CTmsAudioServicesTestClass) :
       
   145     public CScriptBase,
       
   146     public MTimeoutObserver,
       
   147     public TMSStreamObserver,
       
   148     public TMSClientSourceObserver,
       
   149     public TMSClientSinkObserver,
       
   150     public TMSEffectObserver,
       
   151     public TMSGlobalRoutingObserver
       
   152     {
       
   153     enum StreamState
       
   154         {
       
   155         UNINITIALIZED = 0,
       
   156         INITIALIZED,
       
   157         PAUSED,
       
   158         STARTED,
       
   159         };
       
   160 
       
   161 public: // Constructors and destructor
       
   162 
       
   163     /**
       
   164      * Two-phased constructor.
       
   165      */
       
   166     static CTmsAudioServicesTestClass* NewL(CTestModuleIf& aTestModuleIf);
       
   167 
       
   168     /**
       
   169      * Destructor.
       
   170      */
       
   171     virtual ~CTmsAudioServicesTestClass();
       
   172 
       
   173     enum TTmsExpectedEvent
       
   174         {
       
   175         EOpenDownlinkComplete,
       
   176         EOpenUplinkComplete,
       
   177         EDownlinkClosed,
       
   178         EUplinkClosed,
       
   179         EOpenCompleteDNL,
       
   180         EOpenCompleteUPL,
       
   181         EStreamPaused,
       
   182         EStreamStarted,
       
   183         EOpenComplete,
       
   184         EPlaybackComplete,
       
   185         EEmptyBuffer,
       
   186         EFillBuffer,
       
   187         EOutputChanged,
       
   188         ESetOutputComplete,
       
   189         };
       
   190 
       
   191 public:
       
   192     // Functions from base classes
       
   193 
       
   194     /**
       
   195      * From CScriptBase Runs a script line.
       
   196      * @since ?Series60_version
       
   197      * @param aItem Script line containing method name and parameters
       
   198      * @return Symbian OS error code
       
   199      */
       
   200     virtual TInt RunMethodL(CStifItemParser& aItem);
       
   201 
       
   202     // From MTimeoutObserver
       
   203 
       
   204     /**
       
   205      * @since ?Series60_version
       
   206      * @param none
       
   207      * Review if all the expected events have ocurred once the time is over
       
   208      */
       
   209     void HandleTimeout(TInt error);
       
   210 
       
   211     //From TMSStreamObserver
       
   212     void TMSStreamEvent(TMSStream* stream, TMSSignalEvent event);
       
   213 
       
   214     //From TMSClientSourceObserver
       
   215     void FillBuffer(TMSBuffer& buffer);
       
   216     void BufferProcessed(TMSBuffer* buffer, gint reason);
       
   217 
       
   218     //From TMSClientSinkObserver
       
   219     void ProcessBuffer(TMSBuffer* buffer);
       
   220 
       
   221     //From TMSClientSinkObserver starts
       
   222     void EffectsEvent(TMSEffect* tmseffect, TMSSignalEvent event);
       
   223 
       
   224     // from TMSGlobalRoutingObserver
       
   225     void GlobalRoutingEvent(TMSGlobalRouting* /*routing*/,
       
   226             TMSSignalEvent event, TMSAudioOutput output);
       
   227 
       
   228 private:
       
   229 
       
   230     /**
       
   231      * C++ default constructor.
       
   232      */
       
   233     CTmsAudioServicesTestClass(CTestModuleIf& aTestModuleIf);
       
   234 
       
   235     /**
       
   236      * By default Symbian 2nd phase constructor is private.
       
   237      */
       
   238     void ConstructL();
       
   239 
       
   240     // Prohibit copy constructor if not deriving from CBase.
       
   241     // ?classname( const ?classname& );
       
   242     // Prohibit assigment operator if not deriving from CBase.
       
   243     // ?classname& operator=( const ?classname& );
       
   244 
       
   245     /**
       
   246      * Frees all resources allocated from test methods.
       
   247      * @since ?Series60_version
       
   248      */
       
   249     void Delete();
       
   250 
       
   251     /**
       
   252      * Set an event as expected and set default timeout
       
   253      * @since ?Series60_version
       
   254      */
       
   255     void AddExpectedEvent(TTmsExpectedEvent event, TInt ms);
       
   256 
       
   257     /**
       
   258      * Unset an event as expected
       
   259      * @since ?Series60_version
       
   260      */
       
   261     TBool RemoveExpectedEvent(TTmsExpectedEvent event);
       
   262 
       
   263     /**
       
   264      * @since ?Series60_version
       
   265      * @param none
       
   266      * Removes all expected events
       
   267      */
       
   268     void RemoveAllExpectedEvents();
       
   269 
       
   270     /**
       
   271      * Verify that the event was expected, removes it from the list
       
   272      * Signal the TestScripter with the returned error code
       
   273      * @since ?Series60_version
       
   274      */
       
   275     void ProcessEvent(TTmsExpectedEvent aEvent, TInt aError);
       
   276 
       
   277     /**
       
   278      * Maps a event with a descriptor with its name
       
   279      * @since ?Series60_version
       
   280      */
       
   281     TPtrC EventName(TInt aKey);
       
   282 
       
   283     /**
       
   284      * Sets a timeout different since the default
       
   285      * @since Series60_3_2
       
   286      * @param aItem Script line containing parameters.
       
   287      * @return Symbian OS error code.
       
   288      */
       
   289     TInt SetTimeout(CStifItemParser& aItem);
       
   290 
       
   291     /**
       
   292      *
       
   293      * @since Series60_3_2
       
   294      * @param aItem Script line containing parameters.
       
   295      * @return Symbian OS error code.
       
   296      */
       
   297     TInt SetExpectedEvents(CStifItemParser& aItem);
       
   298 
       
   299     /**
       
   300      *
       
   301      * @since Series60_3_2
       
   302      * @param aItem Script line containing parameters.
       
   303      * @return Symbian OS error code.
       
   304      */
       
   305     TInt SetAllowedPanic(CStifItemParser& aItem);
       
   306 
       
   307     /**
       
   308      * Connect to the default client to the server
       
   309      * @since ?Series60_version
       
   310      * @param aItem Script line containing parameters.
       
   311      * @return Symbian OS error code.
       
   312      */
       
   313 
       
   314     TInt ExampleL(CStifItemParser& aItem);
       
   315 
       
   316     TInt CreateTmsFactory(CStifItemParser& aItem);
       
   317     TInt CreateCall(CStifItemParser& aItem);
       
   318     TInt CreateFormat(CStifItemParser& aItem);
       
   319     TInt CreateGlobalRouting(CStifItemParser& aItem);
       
   320 
       
   321     TInt CreateBuffer(CStifItemParser& aItem);
       
   322     TInt CreateEffect(CStifItemParser& aItem);
       
   323     TInt CreateSource(CStifItemParser& aItem);
       
   324     TInt CreateSink(CStifItemParser& aItem);
       
   325     TInt DeleteSource(CStifItemParser& aItem);
       
   326     TInt DeleteSink(CStifItemParser& aItem);
       
   327     TInt GetSourceType(CStifItemParser& aItem);
       
   328     TInt GetSinkType(CStifItemParser& aItem);
       
   329     TInt GetEffectType(CStifItemParser& aItem);
       
   330     TInt CreateDownlinkStream(CStifItemParser& aItem);
       
   331     TInt GetDownlinkVersion(CStifItemParser& aItem);
       
   332     TInt CreateUplinkStream(CStifItemParser& aItem);
       
   333     TInt GetUplinkVersion(CStifItemParser& aItem);
       
   334     TInt GetSupportedFormats(CStifItemParser& aItem);
       
   335     TInt IsCallTypeSupported(CStifItemParser& aItem);
       
   336     //  TInt GetSupportedUplinkFormats( CStifItemParser& aItem );
       
   337     TInt SetDownlinkFormat(CStifItemParser& aItem);
       
   338     TInt SetUplinkFormat(CStifItemParser& aItem);
       
   339     TInt ReSetDownlinkFormat(CStifItemParser& aItem);
       
   340     TInt ReSetUplinkFormat(CStifItemParser& aItem);
       
   341     TInt OpenDownlink(CStifItemParser& aItem);
       
   342     TInt OpenUplink(CStifItemParser& aItem);
       
   343 
       
   344     TInt Start(CStifItemParser& aItem);
       
   345     TInt Pause(CStifItemParser& aItem);
       
   346     TInt Stop(CStifItemParser& aItem);
       
   347     TInt Close(CStifItemParser& aItem);
       
   348     TInt Gain(CStifItemParser& aItem);
       
   349     TInt Volume(CStifItemParser& aItem);
       
   350 
       
   351     TInt GetBufferType(CStifItemParser& aItem);
       
   352 
       
   353     //  TInt GetSupportedBitrates( CStifItemParser& aItem );
       
   354 
       
   355     TInt GetBitRateList(CStifItemParser& aItem);
       
   356     TInt SetBitrates(CStifItemParser& aItem);
       
   357     TInt GetBitrates(CStifItemParser& aItem);
       
   358     TInt GetType(CStifItemParser& aItem);
       
   359     TInt GetVAD(CStifItemParser& aItem);
       
   360     TInt ToggleVAD(CStifItemParser& aItem);
       
   361 
       
   362     TInt GetMode(CStifItemParser& aItem);
       
   363     TInt SetMode(CStifItemParser& aItem);
       
   364     TInt GetCNG(CStifItemParser& aItem);
       
   365     TInt ToggleCNG(CStifItemParser& aItem);
       
   366     TInt GetPLC(CStifItemParser& aItem);
       
   367     TInt TogglePLC(CStifItemParser& aItem);
       
   368 
       
   369     void DoLoopback();
       
   370     void DisplayFormat(TMSFormatType aFormat);
       
   371     void GetSupportedBitrates(RArray<TUint>& aBrArr);
       
   372     void DisplayDevice(TMSAudioOutput device);
       
   373 
       
   374     TInt ConfigEncAudDevice(CStifItemParser& aItem);
       
   375 
       
   376     TInt AddClientSrcToDnlStream(CStifItemParser& aItem);
       
   377     TInt AddMicSrcToUplStream(CStifItemParser& aItem);
       
   378     TInt AddModemSrcToDnlStream(CStifItemParser& aItem);
       
   379     TInt RemoveClientSrcFromDnlStream(CStifItemParser& aItem);
       
   380     TInt RemoveMicSrcFromUplStream(CStifItemParser& aItem);
       
   381     TInt RemoveModemSrcFromDnlStream(CStifItemParser& aItem);
       
   382     TInt AddSourceObserver(CStifItemParser& aItem);
       
   383     TInt RemoveSourceObserver(CStifItemParser& aItem);
       
   384 
       
   385     TInt AddClientSinkToUplStream(CStifItemParser& aItem);
       
   386     TInt AddModemSinkToUplStream(CStifItemParser& aItem);
       
   387     TInt AddSpkrSinkToDnlStream(CStifItemParser& aItem);
       
   388     TInt RemoveClientSinkFromUplStream(CStifItemParser& aItem);
       
   389     TInt RemoveModemSinkFromUplStream(CStifItemParser& aItem);
       
   390     TInt RemoveSpkrSinkFromDnlStream(CStifItemParser& aItem);
       
   391     TInt AddSinkObserver(CStifItemParser& aItem);
       
   392     TInt RemoveSinkObserver(CStifItemParser& aItem);
       
   393 
       
   394     gint CreateVolumeEffect();
       
   395     gint CreateVolumeGlobleEffect();
       
   396     TInt AddVolumeEffectToStream(CStifItemParser& aItem);
       
   397     TInt AddGlobleVolumeEffectToStream(CStifItemParser& aItem);
       
   398     TInt RemoveGlobleVolumeEffectToStream(CStifItemParser& aItem);
       
   399     gint CreateGainEffect();
       
   400     gint CreateGlobleGainEffect();
       
   401     TInt AddGainEffectToStream(CStifItemParser& aItem);
       
   402     TInt AddGlobleGainEffectToStream(CStifItemParser& aItem);
       
   403     TInt RemoveGlobleGainEffectToStream(CStifItemParser& aItem);
       
   404     TInt GetStreamType(CStifItemParser& aItem);
       
   405     TInt GetStreamState(CStifItemParser& aItem);
       
   406 
       
   407     TInt SetOutput(CStifItemParser& aItem);
       
   408     TInt GetOutput(CStifItemParser& aItem);
       
   409     TInt GetPreviousOutput(CStifItemParser& aItem);
       
   410     TInt GetAvailableOutputs(CStifItemParser& aItem);
       
   411     TInt AddGlobalRoutingObserver(CStifItemParser& aItem);
       
   412     TInt DeleteGlobalRoutingObserver(CStifItemParser& aItem);
       
   413 
       
   414 private:
       
   415     // Data
       
   416 
       
   417     // reference to TestModuleIf
       
   418     CTestModuleIf& iTestModuleIf;
       
   419 
       
   420     // Dn/Uplink
       
   421     TMSFactory* iFactory;
       
   422     TMSStream* iTmsDnlink;
       
   423     TMSCall* iTmsCall;
       
   424     TMSStream* iTmsUplink;
       
   425     TMSAudioOutput device;
       
   426 
       
   427     // Codec format APIs
       
   428     TMSBuffer* iTmsBuffer;
       
   429     TMSFormat* iTmsFormat;
       
   430     TMSFormat* iTmsFormatUp;
       
   431     TMSFormat* iTmsFormatDn;
       
   432     TMSEffect* iTmsEffect;
       
   433     TMSSource *iTmsClientSource;
       
   434     TMSSource *iTmsModemSource;
       
   435     TMSSource *iTmsMicSource;
       
   436     TMSSink *iTmsClientSink;
       
   437     TMSSink *iTmsModemSink;
       
   438     TMSSink *iTmsSpkrSink;
       
   439     TMSEffect* iTmsUplinkEffect;
       
   440     TMSEffect* iTmsDnlinkEffect;
       
   441     TMSEffect* iGlobalVol;
       
   442     TMSEffect* iGlobalGain;
       
   443     TMSGlobalRouting* iTmsGlobalRouting;
       
   444 
       
   445     // For internal app state control
       
   446     StreamState iDnLinkStatus;
       
   447     StreamState iUpLinkStatus;
       
   448     TMSFormatType iDnLinkCodec;
       
   449     TMSFormatType iUpLinkCodec;
       
   450 
       
   451     FormatVector iCodec;
       
   452     BitRateVector iBitratesVector;
       
   453     OutputVector iAvailableoutputs;
       
   454 
       
   455     // For storing codec configuration locally
       
   456     TBool iPlc;
       
   457     TBool iCng;
       
   458     TBool iVad;
       
   459     //  TBool iFrameMode;
       
   460     //  TBool iFrameModeReqEC;
       
   461     //  TBool iSpkr;
       
   462     guint iMaxGain;
       
   463     guint iGain;
       
   464     guint iMaxVolume;
       
   465     guint iVolume;
       
   466     TUint currentBitrate;
       
   467     //  RArray<TUint> iBitratesArray;
       
   468 
       
   469     // For streaming buffer control
       
   470     TMSBuffer* iPlayBuf;
       
   471     TMSBuffer* iRecBuf;
       
   472     // TPtr8               iPlayBufPtr;
       
   473     // TPtr8               iRecBufPtr;
       
   474 
       
   475     TBool iPlayBufReady;
       
   476     TBool iRecBufReady;
       
   477 
       
   478     // Active object with a timer to timeout the test case
       
   479     CSimpleTimeout * iTimeoutController;
       
   480 
       
   481     // Indicates if the test case use a normal exit reason
       
   482     TBool iNormalExitReason;
       
   483 
       
   484     // List of expected events
       
   485     RArray<TTmsExpectedEvent> iExpectedEvents;
       
   486 
       
   487     // List of notification event (by the callback)
       
   488     RArray<TTmsExpectedEvent> iOcurredEvents;
       
   489 
       
   490     CActiveSchedulerWait* iActive;
       
   491 
       
   492     };
       
   493 
       
   494 #endif //__TMSAUDIOSERVICESTESTCLASS_H
       
   495 
       
   496 // End of File