qtms/tsrc/qttmstestapp/inc/ctmstestengine.h
changeset 62 b276843a15ba
equal deleted inserted replaced
58:c76ea6caa649 62:b276843a15ba
       
     1 /*
       
     2  * Copyright (c) 2010 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 - TestApp
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef CTMSTESTENGINE_H
       
    19 #define CTMSTESTENGINE_H
       
    20 
       
    21 //#define __PLAY_WAV_FROM_FILE__
       
    22 //#define __RECORD_WAV_TO_FILE__
       
    23 
       
    24 // INCLUDES
       
    25 #include <QTextEdit>
       
    26 #include <QObject>
       
    27 #include <e32base.h>
       
    28 #include <tmsfactory.h>
       
    29 #include <tmscall.h>
       
    30 #include <tmsstream.h>
       
    31 #include <tmsstreamobsrvr.h>
       
    32 #include <tmsformat.h>
       
    33 #include <tmsclientsinkobsrvr.h>
       
    34 #include <tmsclientsourceobsrvr.h>
       
    35 #include <tmseffectobsrvr.h>
       
    36 #include <tmsglobalroutingobsrvr.h>
       
    37 #include <tmsdtmf.h>
       
    38 #include <tmsdtmfobsrvr.h>
       
    39 #include <tmsringtone.h>
       
    40 #include <tmsringtoneobsrvr.h>
       
    41 #include <tmsinbandtone.h>
       
    42 #include <tmsinbandtoneobsrvr.h>
       
    43 #include <tmsbuffer.h>
       
    44 #include "mtmstestengine.h"
       
    45 
       
    46 using namespace TMS;
       
    47 
       
    48 // CLASS DECLARATION
       
    49 /**
       
    50  *  CTmsTestEngine application engine class.
       
    51  */
       
    52 class CTmsTestEngine : public CBase,
       
    53                        public TMSStreamObserver,
       
    54                        public TMSClientSourceObserver,
       
    55                        public TMSClientSinkObserver,
       
    56                        public TMSEffectObserver,
       
    57                        public TMSGlobalRoutingObserver,
       
    58                        public TMSRingToneObserver,
       
    59                        public TMSDTMFObserver,
       
    60                        public TMSInbandToneObserver,
       
    61                        public MTmsTestEngine
       
    62     {
       
    63 public:
       
    64     enum TAppState
       
    65         {
       
    66         ENotReady = 0,
       
    67         EReady,
       
    68         EStreaming
       
    69         };
       
    70 
       
    71     /**
       
    72      * NewL()
       
    73      *
       
    74      * Create new CTmsTestEngine object
       
    75      * return a pointer to the created instance of CTmsTestEngine
       
    76      * @param aView a Pointer to CTmsTestView.
       
    77      */
       
    78     static CTmsTestEngine* NewL(QTextEdit* statusDisplay);
       
    79 
       
    80     /**
       
    81      * NewLC()
       
    82      *
       
    83      */
       
    84     static CTmsTestEngine* NewLC(QTextEdit* statusDisplay);
       
    85 
       
    86     /**
       
    87      * Destructor
       
    88      *
       
    89      */
       
    90     ~CTmsTestEngine();
       
    91 
       
    92     void GetSupportedDownlinkFormats(TBool aDisplayCodecs = EFalse);
       
    93     void GetSupportedUplinkFormats(TBool aDisplayCodecs = EFalse);
       
    94     void SetDownlinkFormat(TMSFormatType aCodecFormat);
       
    95     void OpenDownlink();
       
    96     void StartDownlink();
       
    97     void StopDownlink();
       
    98     void CloseDownlink();
       
    99     void GetMaxVolume();
       
   100     void GetVolume();
       
   101     void SetVolume(guint aVolume);
       
   102     void MuteSpeaker();
       
   103     void SetMaxVolume();
       
   104     void VolumeUp();
       
   105     void VolumeDn();
       
   106 
       
   107     void SetUplinkFormat(TMSFormatType aCodecFormat);
       
   108     void OpenUplink();
       
   109     void StartUplink();
       
   110     void StopUplink();
       
   111     void CloseUplink();
       
   112     void GetMaxGain();
       
   113     void GetGain();
       
   114     void SetMaxGain();
       
   115     void MuteMic();
       
   116 
       
   117     void GetSupportedBitrates();
       
   118     gint GetSupportedBitrates(BitRateVector& aBrArr);
       
   119     void SelectMinBitrate();
       
   120     void SelectMaxBitrate();
       
   121     void SetBitrate(TUint aBitrate);
       
   122     void GetBitrate();
       
   123     void GetBitrate(TUint& aBitrate);
       
   124     void ToggleVad();
       
   125     void GetVad();
       
   126     void ToggleCng();
       
   127     void GetCng();
       
   128     void TogglePlc();
       
   129     void GetPlc();
       
   130     void SetDnLinkG711ALAW();
       
   131     void SetDnLinkG711uLAW();
       
   132     void SetDnLinkILBC20MS();
       
   133     void SetDnLinkILBC30MS();
       
   134     void SetUpLinkG711ALAW();
       
   135     void SetUpLinkG711uLAW();
       
   136     void SetUpLinkILBC20MS();
       
   137     void SetUpLinkILBC30MS();
       
   138     void GetDnLinkG711Mode();
       
   139     void GetDnLinkILBCMode();
       
   140     void GetUpLinkG711Mode();
       
   141     void GetUpLinkILBCMode();
       
   142 
       
   143     void SetOutputDevice(TMSAudioOutput device);
       
   144     void SetHandset();
       
   145     void SetLoudSpeaker();
       
   146     void GetAudioDevice();
       
   147     void GetAvailableOutput();
       
   148     void DoLoopback();
       
   149     void OneTouchLoopback();
       
   150     void EndCall();
       
   151 
       
   152     void InitDTMFTonePlayerDnlink();
       
   153     void InitDTMFTonePlayerUplink();
       
   154     void DTMFTonePlayDnlink();
       
   155     void DTMFTonePlayUplink();
       
   156     void CloseDTMFPlayerDnlink();
       
   157     void CloseDTMFPlayerUplink();
       
   158 
       
   159     gint CreateRingTonePlayer();
       
   160     void InitRingTonePlayerFromProfiles();
       
   161     void InitRingTonePlayerFromFile();
       
   162     void InitRingToneVideoPlayer();
       
   163     void InitRingToneSequencePlayer();
       
   164     void InitRingToneWithTTS();
       
   165     void InitRingToneBeepOnce();
       
   166     void InitRingToneSilent();
       
   167     void InitRingToneUnsecureVoIP();
       
   168     void PlayRingTone();
       
   169     void StopRingTone();
       
   170     void MuteRingTone();
       
   171     void PauseVideoRingTone();
       
   172     void CloseRingTonePlayer();
       
   173     void DeinitRingTonePlayer();
       
   174 
       
   175     void SetCallType(TMSCallType calltype);
       
   176 
       
   177     void CreateInbandTonePlayer();
       
   178     void StartInbandTone(TMSInbandToneType inbandtonetype);
       
   179     void StopInbandTone();
       
   180 
       
   181     gint CreateFactory();
       
   182     gint CreateCall(TMSCallType calltype);
       
   183     gint CreateUplink();
       
   184     gint CreateDownlink();
       
   185     gint CreateClientSource();
       
   186     gint CreateModemSource();
       
   187     gint AddClientSourceToStream();
       
   188     gint AddModemSourceToStream();
       
   189     gint CreateClientSink();
       
   190     gint CreateModemSink();
       
   191     gint AddClientSinkToStream();
       
   192     gint AddModemSinkToStream();
       
   193     gint CreateMicSource();
       
   194     gint AddMicSourceToStream();
       
   195     gint CreateSpeakerSink();
       
   196     gint AddSpeakerSinkToStream();
       
   197 
       
   198     gint CreateVolumeEffect();
       
   199     gint AddVolumeEffectToStream();
       
   200     gint CreateGainEffect();
       
   201     gint CreateGlobalRouting();
       
   202     gint AddGainEffectToStream();
       
   203 
       
   204     void CreateGlobalVol();
       
   205     void CreateGlobalGain();
       
   206     void GetGlobalVol();
       
   207     void GetGlobalMaxVol();
       
   208     void SetGlobalVol();
       
   209     void GetGlobalGain();
       
   210     void GetGlobalMaxGain();
       
   211     void SetGlobalGain();
       
   212 
       
   213     //From TMSClientSourceObserver
       
   214     void FillBuffer(TMSBuffer& buffer);
       
   215     void BufferProcessed(const TMSBuffer* buffer, gint reason);
       
   216 
       
   217     //From TMSClientSinkObserver
       
   218     void ProcessBuffer(const TMSBuffer* buffer);
       
   219 
       
   220     //From TMSStreamObserver
       
   221     void TMSStreamEvent(const TMSStream& stream, TMSSignalEvent event);
       
   222 
       
   223     //From TMSClientSinkObserver
       
   224     void EffectsEvent(const TMSEffect& tmseffect, TMSSignalEvent event);
       
   225 
       
   226     //From TMSGlobalRoutingObserver
       
   227     void GlobalRoutingEvent(const TMSGlobalRouting& routing,
       
   228             TMSSignalEvent event, TMSAudioOutput output);
       
   229 
       
   230     //From TMSRingToneObserver
       
   231     void RingtoneEvent(const TMSRingTone& rt, TMSSignalEvent event);
       
   232 
       
   233     //From TMSDTMFObserver
       
   234     void DTMFEvent(const TMSDTMF& dtmf, TMSSignalEvent event);
       
   235 
       
   236     //From TMSInbandToneObserver
       
   237     void InbandToneEvent(const TMSInbandTone& inbandtone, TMSSignalEvent event);
       
   238 
       
   239 private:
       
   240 
       
   241     void ConstructL(QTextEdit* statusDisplay);
       
   242     CTmsTestEngine();
       
   243 
       
   244     void ConfigureDecoder();
       
   245     void ConfigureEncoder();
       
   246 
       
   247     void DisplayFormat(TMSFormatType aFormat);
       
   248     void DisplayDevice(TMSAudioOutput device);
       
   249     void DisplayText(const QString& str, const gint num = 0);
       
   250 
       
   251 #ifdef __RECORD_WAV_TO_FILE__
       
   252     void WriteToFile(const guint8* str, const guint len);
       
   253 #endif //__RECORD_WAV_TO_FILE__
       
   254 
       
   255 private:
       
   256 
       
   257     // For text printing to the display
       
   258     QTextEdit* iStatusDisplay;
       
   259 
       
   260     // Dn/Uplink, DTMF, Ring tone APIs
       
   261     TMSFactory*       iFactory;
       
   262     TMSCall*          iTmsCall;
       
   263     TMSCallType       iCallType;
       
   264     TMSStream*        iTmsDnlink;
       
   265     TMSStream*        iTmsUplink;
       
   266     TMSSource*        iTmsClientSource;
       
   267     TMSSource*        iTmsMicSource;
       
   268     TMSSource*        iTmsModemSource;
       
   269     TMSSink*          iTmsClientSink;
       
   270     TMSSink*          iTmsSpeakerSink;
       
   271     TMSSink*          iTmsModemSink;
       
   272     TMSDTMF*          iDTMFTonePlayerDn;
       
   273     TMSDTMF*          iDTMFTonePlayerUp;
       
   274     TMSEffect*        iTmsUplinkEffect;
       
   275     TMSEffect*        iTmsDnlinkEffect;
       
   276     TMSEffect*        iGlobalVol;
       
   277     TMSEffect*        iGlobalGain;
       
   278     TMSGlobalRouting* iTmsGlobalRouting;
       
   279     TMSRingTone*      iTmsRingTonePlayer;
       
   280     TMSInbandTone*    iInbandTonePlayer;
       
   281 
       
   282     // Codec format APIs
       
   283     TMSFormat* iDecFormatIntfc;
       
   284     TMSFormat* iEncFormatIntfc;
       
   285 
       
   286     // For internal app state control
       
   287     TAppState iDnLinkStatus;
       
   288     TAppState iUpLinkStatus;
       
   289     TMSFormatType iDnLinkCodec;
       
   290     TMSFormatType iUpLinkCodec;
       
   291     TBool iOneTouchLoopback;
       
   292     TInt iHasDTMFObserver;
       
   293 
       
   294     // For storing codec configuration locally
       
   295     TBool iPlc;
       
   296     TBool iCng;
       
   297     TBool iVad;
       
   298     TBool iSpkr;
       
   299     guint iMaxGain;
       
   300     guint iMaxVolume;
       
   301     guint iVolume;
       
   302     TUint iBitrate;
       
   303     BitRateVector iBitratesVector;
       
   304     OutputVector iAvailableoutputs;
       
   305 
       
   306     // For streaming buffer control
       
   307     TBool iPlayBufReady;
       
   308     TBool iRecBufReady;
       
   309     TInt iPlayBufMaxLen;
       
   310     TMSBuffer* iPlayBuf;
       
   311     TMSBuffer* iRecBuf;
       
   312     TUint iSeqNum;
       
   313     TUint iSeqNumIncrement;
       
   314     gint iSizeCopy;
       
   315     guint8* iDesCopy;
       
   316 
       
   317     TMS::FormatVector iUplCodecs;
       
   318     TMS::FormatVector iDnlCodecs;
       
   319     GString* iRTStr;
       
   320     GString* iTTSStr;
       
   321 
       
   322 #ifdef __WINSCW__
       
   323     TInt iBufIndex;
       
   324 #endif //__WINSCW__
       
   325 
       
   326 #ifdef __PLAY_WAV_FROM_FILE__
       
   327     RFile iFile;
       
   328     TInt iFileLen;
       
   329     TInt iReadSize;
       
   330     TInt iReadPos;
       
   331     TBool iEOF;
       
   332     RFs iFs;
       
   333     HBufC8* iBuf;
       
   334 #endif
       
   335 
       
   336 #ifdef __RECORD_WAV_TO_FILE__
       
   337     RFile iFile;
       
   338     TInt iWriteLen;
       
   339     TInt iReadPos;
       
   340     RFs iFs;
       
   341     HBufC8* iWriteBuf;
       
   342 #endif //__RECORD_WAV_TO_FILE__
       
   343     };
       
   344 
       
   345 #endif //CTMSTESTENGINE_H
       
   346 
       
   347 // End of file