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