qtms/tsrc/qttmstestapp/src/ctmstestengine.cpp
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 // INCLUDES
       
    19 #include <e32base.h>
       
    20 #include <eikenv.h>
       
    21 #include <gstring.h>
       
    22 #include <tmsclientsink.h>
       
    23 #include <tmsclientsource.h>
       
    24 #include <tmspcmformat.h>
       
    25 #include <tmsamrformat.h>
       
    26 #include <tmsilbcformat.h>
       
    27 #include <tmsg711format.h>
       
    28 #include <tmsg729format.h>
       
    29 #include <tmsvolumeeffect.h>
       
    30 #include <tmsgaineffect.h>
       
    31 #include <tmsglobalvoleffect.h>
       
    32 #include <tmsglobalgaineffect.h>
       
    33 #include <tmsglobalrouting.h>
       
    34 #include <tmsver.h>
       
    35 #include "ctmstestengine.h"
       
    36 
       
    37 #ifdef _DEBUG
       
    38 #include "e32debug.h"
       
    39 #define DEBPRN0(str)       RDebug::Print(str, this)
       
    40 #define DEBPRN1(str, val1) RDebug::Print(str, this, val1)
       
    41 #else
       
    42 #define DEBPRN0(str)
       
    43 #define DEBPRN1(str, val1)
       
    44 #endif //_DEBUG
       
    45 
       
    46 //#define __PROFILING_ENABLED__
       
    47 
       
    48 #ifdef __PROFILING_ENABLED__
       
    49 #include "perfutility.h"
       
    50 #endif //__PROFILING_ENABLED__
       
    51 
       
    52 //#define __TEST_CODE_COVERAGE__
       
    53 
       
    54 // CONSTANTS
       
    55 _LIT8(KRTBeepSequence, "\x00\x11\x0A\x0A\x08\x73\x0A\x40\x28\x0A\xF7\
       
    56 \x05\xFC\x40\x64\x0A\x08\x40\x32\x0A\xF7\x06\x0B");
       
    57 _LIT16(KTextToSpeak, "THE PHONE IS RINGING");
       
    58 _LIT16(KTestFile1, "C:\\Data\\Sounds\\Digital\\NokiaTest.aac");
       
    59 
       
    60 #ifdef __RECORD_WAV_TO_FILE__
       
    61 _LIT(KFileName, "c:\\data\\tmsrec.amr");
       
    62 const TUint KFileBufLen = 4096;
       
    63 const TInt KAMRNBHeaderLen = 6;
       
    64 const TUint8 KAMRNBHeader[KAMRNBHeaderLen] = {0x23,0x21,0x41,0x4d,0x52,0x0a};
       
    65 #endif
       
    66 
       
    67 // ----------------------------------------------------------------------------
       
    68 // CTmsTestEngine::CTmsTestEngine()
       
    69 // constructor
       
    70 // ----------------------------------------------------------------------------
       
    71 //
       
    72 CTmsTestEngine::CTmsTestEngine()
       
    73     {
       
    74     // Disable GLib slice allocators; will take care of memory leaks
       
    75     // caused by g_string_free().
       
    76     g_setenv("G_SLICE", "always-malloc", 1);
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // CTmsTestEngine::~CTmsTestEngine
       
    81 // destructor
       
    82 // ----------------------------------------------------------------------------
       
    83 //
       
    84 CTmsTestEngine::~CTmsTestEngine()
       
    85     {
       
    86     EndCall();
       
    87     CloseRingTonePlayer();
       
    88 
       
    89     if (iFactory && iGlobalVol)
       
    90         {
       
    91         static_cast<TMSGlobalVolEffect*> (iGlobalVol)->RemoveObserver(*this);
       
    92         iFactory->DeleteEffect(iGlobalVol);
       
    93         }
       
    94     if (iFactory && iGlobalGain)
       
    95         {
       
    96         static_cast<TMSGlobalGainEffect*> (iGlobalGain)->RemoveObserver(*this);
       
    97         iFactory->DeleteEffect(iGlobalGain);
       
    98         }
       
    99     if (iFactory && iTmsGlobalRouting)
       
   100         {
       
   101         iTmsGlobalRouting->RemoveObserver(*this);
       
   102         iFactory->DeleteGlobalRouting(iTmsGlobalRouting);
       
   103         }
       
   104     if (iFactory && iInbandTonePlayer)
       
   105         {
       
   106         iInbandTonePlayer->RemoveObserver(*this);
       
   107         iFactory->DeleteInbandTonePlayer(iInbandTonePlayer);
       
   108         }
       
   109 
       
   110     delete iFactory;
       
   111 
       
   112 #ifdef __PLAY_WAV_FROM_FILE__
       
   113     iFile.Close();
       
   114     iFs.Close();
       
   115     delete iBuf;
       
   116 #endif
       
   117 #ifdef __RECORD_WAV_TO_FILE__
       
   118     iFile.Close();
       
   119     iFs.Close();
       
   120     delete iWriteBuf;
       
   121 #endif
       
   122     }
       
   123 
       
   124 // ----------------------------------------------------------------------------
       
   125 // CTmsTestEngine::NewL
       
   126 // Symbian constructor.
       
   127 // ----------------------------------------------------------------------------
       
   128 //
       
   129 CTmsTestEngine* CTmsTestEngine::NewL(QTextEdit* statusDisplay)
       
   130     {
       
   131     CTmsTestEngine* self(NULL);
       
   132     self=CTmsTestEngine::NewLC(statusDisplay);
       
   133     return self;
       
   134     }
       
   135 
       
   136 // ----------------------------------------------------------------------------
       
   137 // CTmsTestEngine::NewL
       
   138 // Symbian constructor with self pointer pushed into the cleanup stack.
       
   139 // ----------------------------------------------------------------------------
       
   140 //
       
   141 CTmsTestEngine* CTmsTestEngine::NewLC(QTextEdit* statusDisplay)
       
   142     {
       
   143     CTmsTestEngine* self = new (ELeave) CTmsTestEngine;
       
   144     //CleanupStack::PushL(self);
       
   145     self->ConstructL(statusDisplay);
       
   146     return self;
       
   147     }
       
   148 
       
   149 // ----------------------------------------------------------------------------
       
   150 // CTmsTestEngine::NewL
       
   151 // Standard Symbian 2nd phase constructor
       
   152 // ----------------------------------------------------------------------------
       
   153 //
       
   154 void CTmsTestEngine::ConstructL(QTextEdit* statusDisplay)
       
   155     {
       
   156     DEBPRN0(_L("CTmsTestEngine[0x%x]::ConstructL :>"));
       
   157     iStatusDisplay = statusDisplay;
       
   158 
       
   159 #ifdef __PLAY_WAV_FROM_FILE__
       
   160     iReadSize = KFileBufLen;
       
   161     TInt err = iFs.Connect();
       
   162     if (err == TMS_RESULT_SUCCESS)
       
   163         {
       
   164         err = iFile.Open(iFs, KTestFile1, EFileShareAny | EFileRead);
       
   165         }
       
   166     if (err == TMS_RESULT_SUCCESS)
       
   167         {
       
   168         iFile.Size(iFileLen);
       
   169         }
       
   170     iBuf = HBufC8::NewL(iReadSize);
       
   171 #endif
       
   172 
       
   173 #ifdef __RECORD_WAV_TO_FILE__
       
   174     TInt err = iFs.Connect();
       
   175     if (err == TMS_RESULT_SUCCESS)
       
   176         {
       
   177         err = iFile.Replace(iFs, KFileName, EFileWrite);
       
   178 #ifndef __WINSCW__
       
   179         if (err == KErrNone)
       
   180             {
       
   181             // Prefix file with AMR-NB header
       
   182             TBuf8<KAMRNBHeaderLen> buf;
       
   183             buf.Append(KAMRNBHeader, 6);
       
   184             iFile.Write(buf, KAMRNBHeaderLen);
       
   185             }
       
   186 #endif //__WINSCW__
       
   187         }
       
   188     iWriteLen = KFileBufLen;
       
   189     iWriteBuf = HBufC8::NewL(iWriteLen);
       
   190 #endif //__RECORD_WAV_TO_FILE__
       
   191 
       
   192     CreateFactory();
       
   193     CreateGlobalRouting();
       
   194     CreateGlobalVol();
       
   195     CreateGlobalGain();
       
   196     CreateRingTonePlayer();
       
   197 
       
   198     DEBPRN0(_L("CTmsTestEngine[0x%x]::ConstructL :<"));
       
   199     }
       
   200 
       
   201 gint CTmsTestEngine::CreateFactory()
       
   202     {
       
   203     gint status(TMS_RESULT_SUCCESS);
       
   204     TMSVer v(10,0,0);
       
   205     status = TMSFactory::CreateFactory(iFactory, v);
       
   206 
       
   207     if (status != TMS_RESULT_SUCCESS || !iFactory)
       
   208         {
       
   209         DisplayText("Tms create factory failed ", status);
       
   210         }
       
   211     else
       
   212         {
       
   213 #ifdef __TEST_CODE_COVERAGE__
       
   214         TMSBuffer* tmsbuffer(NULL);
       
   215         TMSBufferType buftype(TMS_BUFFER_MEMORY);
       
   216         guint size(100);
       
   217         iFactory->CreateBuffer(TMS_BUFFER_MEMORY, size, tmsbuffer);
       
   218         if (tmsbuffer)
       
   219             {
       
   220             tmsbuffer->GetType(buftype);
       
   221             tmsbuffer->GetDataSize(size);
       
   222             tmsbuffer->SetDataSize(size);
       
   223             guint8* pbuf(NULL);
       
   224             tmsbuffer->GetDataPtr(pbuf);
       
   225             guint64 ts(0);
       
   226             tmsbuffer->GetTimeStamp(ts);
       
   227             tmsbuffer->SetTimeStamp(ts);
       
   228             iFactory->DeleteBuffer(tmsbuffer);
       
   229             }
       
   230 #endif //__TEST_CODE_COVERAGE__
       
   231 
       
   232         DisplayText("Tms factory created");
       
   233         }
       
   234     return status;
       
   235     }
       
   236 
       
   237 gint CTmsTestEngine::CreateCall(TMSCallType calltype)
       
   238     {
       
   239     gint status(TMS_RESULT_SUCCESS);
       
   240     if (iFactory && !iTmsCall)
       
   241         {
       
   242         status = iFactory->CreateCall(calltype, iTmsCall, 0);
       
   243         if (status == TMS_RESULT_SUCCESS)
       
   244             {
       
   245 #ifdef __TEST_CODE_COVERAGE__
       
   246             guint ctxid;
       
   247             iTmsCall->GetCallContextId(ctxid);
       
   248 #endif //__TEST_CODE_COVERAGE__
       
   249             DisplayText("Tms call created");
       
   250             }
       
   251         else
       
   252             {
       
   253             DisplayText("Tms call create failed ", status);
       
   254             }
       
   255         }
       
   256     return status;
       
   257     }
       
   258 
       
   259 gint CTmsTestEngine::CreateUplink()
       
   260     {
       
   261     gint status(TMS_RESULT_SUCCESS);
       
   262 
       
   263     if (iTmsCall)
       
   264         {
       
   265         status = iTmsCall->CreateStream(TMS_STREAM_UPLINK, iTmsUplink);
       
   266         if (status == TMS_RESULT_SUCCESS)
       
   267             {
       
   268 #ifdef __TEST_CODE_COVERAGE__
       
   269             guint ctxid;
       
   270             iTmsCall->GetCallContextId(ctxid);
       
   271 #endif //__TEST_CODE_COVERAGE__
       
   272             DisplayText("TMS uplink created");
       
   273             }
       
   274         else
       
   275             {
       
   276             DisplayText("TMS uplink failed ", status);
       
   277             }
       
   278         }
       
   279     return status;
       
   280     }
       
   281 
       
   282 gint CTmsTestEngine::CreateDownlink()
       
   283     {
       
   284     gint status(TMS_RESULT_SUCCESS);
       
   285 
       
   286     if (iTmsCall)
       
   287         {
       
   288         status = iTmsCall->CreateStream(TMS_STREAM_DOWNLINK, iTmsDnlink);
       
   289         if (status == TMS_RESULT_SUCCESS)
       
   290             {
       
   291             DisplayText("TMS downlink created");
       
   292             }
       
   293         else
       
   294             {
       
   295             DisplayText("TMS downlink failed ", status);
       
   296             }
       
   297         }
       
   298     return status;
       
   299     }
       
   300 
       
   301 gint CTmsTestEngine::CreateClientSource()
       
   302     {
       
   303     gint status(TMS_RESULT_SUCCESS);
       
   304 
       
   305     if (iFactory && !iTmsClientSource)
       
   306         {
       
   307         status = iFactory->CreateSource(TMS_SOURCE_CLIENT, iTmsClientSource);
       
   308         if (status == TMS_RESULT_SUCCESS)
       
   309             {
       
   310             DisplayText("TMS clientsource created");
       
   311             }
       
   312         else
       
   313             {
       
   314             DisplayText("TMS clientsource failed ", status);
       
   315             }
       
   316         }
       
   317     return status;
       
   318     }
       
   319 
       
   320 gint CTmsTestEngine::CreateModemSource()
       
   321     {
       
   322     gint status(TMS_RESULT_SUCCESS);
       
   323 
       
   324     if (iFactory && !iTmsModemSource)
       
   325         {
       
   326         status = iFactory->CreateSource(TMS_SOURCE_MODEM, iTmsModemSource);
       
   327         if (status == TMS_RESULT_SUCCESS)
       
   328             {
       
   329 #ifdef __TEST_CODE_COVERAGE__
       
   330             TMSSourceType st;
       
   331             iTmsModemSource->GetType(st);
       
   332 #endif //__TEST_CODE_COVERAGE__
       
   333             DisplayText("TMS modemsource created");
       
   334             }
       
   335         else
       
   336             {
       
   337             DisplayText("TMS modemsource failed ", status);
       
   338             }
       
   339         }
       
   340     return status;
       
   341     }
       
   342 
       
   343 gint CTmsTestEngine::AddClientSourceToStream()
       
   344     {
       
   345     gint status(TMS_RESULT_SUCCESS);
       
   346     if (iTmsDnlink && iTmsClientSource)
       
   347         {
       
   348         static_cast<TMSClientSource*> (iTmsClientSource)->AddObserver(*this,
       
   349                 NULL);
       
   350         status = iTmsDnlink->AddSource(iTmsClientSource);
       
   351 
       
   352 #ifdef __TEST_CODE_COVERAGE__
       
   353         TMSSourceType st;
       
   354         static_cast<TMSClientSource*> (iTmsClientSource)->GetType(st);
       
   355         gboolean enqueue(false);
       
   356         static_cast<TMSClientSource*> (iTmsClientSource)->GetEnqueueMode(enqueue);
       
   357         static_cast<TMSClientSource*> (iTmsClientSource)->SetEnqueueMode(FALSE);
       
   358         static_cast<TMSClientSource*> (iTmsClientSource)->Flush();
       
   359 #endif //__TEST_CODE_COVERAGE__
       
   360         }
       
   361     return status;
       
   362     }
       
   363 
       
   364 gint CTmsTestEngine::AddModemSourceToStream()
       
   365     {
       
   366     gint status(TMS_RESULT_SUCCESS);
       
   367     if (iTmsDnlink && iTmsModemSource)
       
   368         {
       
   369         status = iTmsDnlink->AddSource(iTmsModemSource);
       
   370         }
       
   371     return status;
       
   372     }
       
   373 
       
   374 gint CTmsTestEngine::CreateClientSink()
       
   375     {
       
   376     gint status(TMS_RESULT_SUCCESS);
       
   377 
       
   378     if (iFactory && !iTmsClientSink)
       
   379         {
       
   380         status = iFactory->CreateSink(TMS_SINK_CLIENT, iTmsClientSink);
       
   381         if (status == TMS_RESULT_SUCCESS)
       
   382             {
       
   383             DisplayText("TMS client sink created");
       
   384             }
       
   385         else
       
   386             {
       
   387             DisplayText("TMS client sink failed ", status);
       
   388             }
       
   389         }
       
   390     return status;
       
   391     }
       
   392 
       
   393 gint CTmsTestEngine::CreateModemSink()
       
   394     {
       
   395     gint status(TMS_RESULT_SUCCESS);
       
   396 
       
   397     if (iFactory && !iTmsModemSink)
       
   398         {
       
   399         status = iFactory->CreateSink(TMS_SINK_MODEM, iTmsModemSink);
       
   400         if (status == TMS_RESULT_SUCCESS)
       
   401             {
       
   402 #ifdef __TEST_CODE_COVERAGE__
       
   403             TMSSinkType st;
       
   404             iTmsModemSink->GetType(st);
       
   405 #endif  //__TEST_CODE_COVERAGE__
       
   406             DisplayText("TMS modem sink created");
       
   407             }
       
   408         else
       
   409             {
       
   410             DisplayText("TMS modem sink failed ", status);
       
   411             }
       
   412         }
       
   413     return status;
       
   414     }
       
   415 
       
   416 gint CTmsTestEngine::AddClientSinkToStream()
       
   417     {
       
   418     gint status(TMS_RESULT_SUCCESS);
       
   419 
       
   420     if (iTmsUplink && iTmsClientSink)
       
   421         {
       
   422         status = static_cast<TMSClientSink*> (iTmsClientSink)->AddObserver(
       
   423                 *this, NULL);
       
   424         status |= iTmsUplink->AddSink(iTmsClientSink);
       
   425         }
       
   426     return status;
       
   427     }
       
   428 
       
   429 gint CTmsTestEngine::AddModemSinkToStream()
       
   430     {
       
   431     gint status(TMS_RESULT_SUCCESS);
       
   432 
       
   433     if (iTmsUplink && iTmsModemSink)
       
   434         {
       
   435         status = iTmsUplink->AddSink(iTmsModemSink);
       
   436         }
       
   437     return status;
       
   438     }
       
   439 
       
   440 gint CTmsTestEngine::CreateMicSource()
       
   441     {
       
   442     gint status(TMS_RESULT_SUCCESS);
       
   443 
       
   444     if (iFactory && !iTmsMicSource)
       
   445         {
       
   446         status = iFactory->CreateSource(TMS_SOURCE_MIC, iTmsMicSource);
       
   447         if (status == TMS_RESULT_SUCCESS)
       
   448             {
       
   449             DisplayText("TMS mic source created");
       
   450             }
       
   451         else
       
   452             {
       
   453             DisplayText("TMS mic source failed ", status);
       
   454             }
       
   455         }
       
   456     return status;
       
   457     }
       
   458 
       
   459 gint CTmsTestEngine::AddMicSourceToStream()
       
   460     {
       
   461     gint status(TMS_RESULT_SUCCESS);
       
   462     if (iTmsUplink && iTmsMicSource)
       
   463         {
       
   464         status = iTmsUplink->AddSource(iTmsMicSource);
       
   465         }
       
   466     return status;
       
   467     }
       
   468 
       
   469 gint CTmsTestEngine::CreateSpeakerSink()
       
   470     {
       
   471     gint status(TMS_RESULT_SUCCESS);
       
   472 
       
   473     if (iFactory && !iTmsSpeakerSink)
       
   474         {
       
   475         status = iFactory->CreateSink(TMS_SINK_SPEAKER, iTmsSpeakerSink);
       
   476         if (status == TMS_RESULT_SUCCESS)
       
   477             {
       
   478             DisplayText("TMS speaker sink created");
       
   479             }
       
   480         else
       
   481             {
       
   482             DisplayText("TMS speaker sink failed ", status);
       
   483             }
       
   484         }
       
   485     return status;
       
   486     }
       
   487 
       
   488 gint CTmsTestEngine::AddSpeakerSinkToStream()
       
   489     {
       
   490     gint status(TMS_RESULT_SUCCESS);
       
   491     if (iTmsDnlink && iTmsSpeakerSink)
       
   492         {
       
   493         status = iTmsDnlink->AddSink(iTmsSpeakerSink);
       
   494         }
       
   495     return status;
       
   496     }
       
   497 
       
   498 // ----------------------------------------------------------------------------
       
   499 // CTmsTestEngine::SetCallType
       
   500 //
       
   501 // ----------------------------------------------------------------------------
       
   502 //
       
   503 void CTmsTestEngine::SetCallType(TMSCallType calltype)
       
   504     {
       
   505     gint status(KErrNotFound);
       
   506 
       
   507 #ifdef __PROFILING_ENABLED__
       
   508     TAG_CALLBACK_TIME_PROFILING_START;
       
   509 #endif //__PROFILING_ENABLED__
       
   510 
       
   511     if (iFactory)
       
   512         {
       
   513         iCallType = calltype;
       
   514 
       
   515         if (!iTmsCall)
       
   516             {
       
   517             gboolean issupported(FALSE);
       
   518             iFactory->IsCallTypeSupported(iCallType, issupported);
       
   519             if (issupported)
       
   520                 {
       
   521                 status = iFactory->CreateCall(iCallType, iTmsCall);
       
   522                 }
       
   523             else
       
   524                 {
       
   525                 status = KErrNotSupported;
       
   526                 }
       
   527             }
       
   528 
       
   529         iCallType = iTmsCall->GetCallType();
       
   530 
       
   531         if (status == TMS_RESULT_SUCCESS)
       
   532             {
       
   533             DisplayText("Tms call created");
       
   534             }
       
   535         else
       
   536             {
       
   537             DisplayText("Tms call creation failed ", status);
       
   538             }
       
   539         }
       
   540     if (status == TMS_RESULT_SUCCESS)
       
   541         {
       
   542         status = CreateUplink();
       
   543         }
       
   544     if (status == TMS_RESULT_SUCCESS)
       
   545         {
       
   546         status = CreateDownlink();
       
   547         }
       
   548     if (iCallType == TMS_CALL_IP)
       
   549         {
       
   550         if (status == TMS_RESULT_SUCCESS)
       
   551             {
       
   552             status = CreateMicSource();
       
   553             status |= AddMicSourceToStream();
       
   554             status |= CreateClientSink();
       
   555             status |= AddClientSinkToStream();
       
   556             }
       
   557 
       
   558         if (status == TMS_RESULT_SUCCESS)
       
   559             {
       
   560             status |= CreateClientSource();
       
   561             status |= AddClientSourceToStream();
       
   562             status |= CreateSpeakerSink();
       
   563             status |= AddSpeakerSinkToStream();
       
   564             }
       
   565         }
       
   566     else if (iCallType == TMS_CALL_CS)
       
   567         {
       
   568         if (status == TMS_RESULT_SUCCESS)
       
   569             {
       
   570             status = CreateMicSource();
       
   571             status |= AddMicSourceToStream();
       
   572             status |= CreateModemSink();
       
   573             status |= AddModemSinkToStream();
       
   574             }
       
   575         if (status == TMS_RESULT_SUCCESS)
       
   576             {
       
   577             status = CreateModemSource();
       
   578             status |= AddModemSourceToStream();
       
   579             status |= CreateSpeakerSink();
       
   580             status |= AddSpeakerSinkToStream();
       
   581             }
       
   582         }
       
   583 
       
   584     if (status == TMS_RESULT_SUCCESS)
       
   585         {
       
   586         status = CreateVolumeEffect();
       
   587         status |= AddVolumeEffectToStream();
       
   588         status |= CreateGainEffect();
       
   589         status |= AddGainEffectToStream();
       
   590         }
       
   591 
       
   592     //NOTE: CS does not call SetDownlinkFormat/SetUplinkFormat
       
   593     //so it is OK to open downlink and uplink at this point.
       
   594     if (status == TMS_RESULT_SUCCESS && iCallType == TMS_CALL_CS)
       
   595         {
       
   596         // To avoid asyc calback racing situation, it may be safer to
       
   597         // start second stream after receiving TMS_STREAM_INITIALIZED event.
       
   598         // But for now, let's try opening both at the same time.
       
   599         OpenDownlink();
       
   600         OpenUplink();
       
   601         }
       
   602     }
       
   603 
       
   604 // ----------------------------------------------------------------------------
       
   605 // CTmsTestEngine::GetSupportedDownlinkFormats
       
   606 //
       
   607 // ----------------------------------------------------------------------------
       
   608 //
       
   609 void CTmsTestEngine::GetSupportedDownlinkFormats(TBool aDisplayList)
       
   610     {
       
   611     gint status(TMS_RESULT_SUCCESS);
       
   612 
       
   613     if (iFactory)
       
   614         {
       
   615         status = iFactory->GetSupportedFormats(TMS_STREAM_DOWNLINK, iDnlCodecs);
       
   616 
       
   617         if (status != TMS_RESULT_SUCCESS)
       
   618             {
       
   619             DisplayText("DNL Codecs retrieve error: ", status);
       
   620             }
       
   621 
       
   622         if (iDnlCodecs.size() > 0 && aDisplayList)
       
   623             {
       
   624             DisplayText("Supported DNL codecs");
       
   625             std::vector<TMSFormat*>::iterator itDnlCodecs = iDnlCodecs.begin();
       
   626             TMSFormatType fmttype;
       
   627             for (; itDnlCodecs < iDnlCodecs.end(); itDnlCodecs++)
       
   628                 {
       
   629                 (*itDnlCodecs)->GetType(fmttype);
       
   630                 DisplayFormat(fmttype);
       
   631                 }
       
   632             gint size = iDnlCodecs.size();
       
   633             for (gint i = 0; i < size; i++)
       
   634                 {
       
   635                 itDnlCodecs = iDnlCodecs.begin();
       
   636                 iFactory->DeleteFormat(*itDnlCodecs);
       
   637                 iDnlCodecs.erase(itDnlCodecs);
       
   638                 }
       
   639             }
       
   640         }
       
   641     }
       
   642 
       
   643 // ----------------------------------------------------------------------------
       
   644 // CTmsTestEngine::GetSupportedUplinkFormats
       
   645 //
       
   646 // ----------------------------------------------------------------------------
       
   647 //
       
   648 void CTmsTestEngine::GetSupportedUplinkFormats(TBool aDisplayList)
       
   649     {
       
   650     gint status(TMS_RESULT_SUCCESS);
       
   651 
       
   652     if (iFactory)
       
   653         {
       
   654         status = iFactory->GetSupportedFormats(TMS_STREAM_UPLINK, iUplCodecs);
       
   655         if (status != TMS_RESULT_SUCCESS)
       
   656             {
       
   657             DisplayText("UPL Codecs retrieve error: ", status);
       
   658             }
       
   659 
       
   660         if (iUplCodecs.size() > 0 && aDisplayList)
       
   661             {
       
   662             DisplayText("Supported UPL codecs");
       
   663             std::vector<TMSFormat*>::iterator codecs = iUplCodecs.begin();
       
   664             TMSFormatType fmttype;
       
   665             for (; codecs < iUplCodecs.end(); codecs++)
       
   666                 {
       
   667                 (*codecs)->GetType(fmttype);
       
   668                 DisplayFormat(fmttype);
       
   669                 }
       
   670             gint size = iUplCodecs.size();
       
   671             for (gint i = 0; i < size; i++)
       
   672                 {
       
   673                 codecs = iUplCodecs.begin();
       
   674                 iFactory->DeleteFormat(*codecs);
       
   675                 iUplCodecs.erase(codecs);
       
   676                 }
       
   677             }
       
   678         }
       
   679     }
       
   680 
       
   681 // ----------------------------------------------------------------------------
       
   682 // CTmsTestEngine::DisplayFormat
       
   683 //
       
   684 // ----------------------------------------------------------------------------
       
   685 //
       
   686 void CTmsTestEngine::DisplayFormat(TMSFormatType aFormat)
       
   687     {
       
   688     switch (aFormat)
       
   689         {
       
   690         case TMS_FORMAT_AMR:
       
   691             DisplayText("AMR-NB");
       
   692             break;
       
   693         case TMS_FORMAT_G711:
       
   694             DisplayText("G.711");
       
   695             break;
       
   696         case TMS_FORMAT_G729:
       
   697             DisplayText("G.729");
       
   698             break;
       
   699         case TMS_FORMAT_ILBC:
       
   700             DisplayText("iLBC");
       
   701             break;
       
   702         case TMS_FORMAT_PCM:
       
   703             DisplayText("PCM-16");
       
   704             break;
       
   705         default:
       
   706             break;
       
   707         }
       
   708     }
       
   709 
       
   710 // ----------------------------------------------------------------------------
       
   711 // CTmsTestEngine::SetDownlinkFormat()
       
   712 //
       
   713 // ----------------------------------------------------------------------------
       
   714 //
       
   715 void CTmsTestEngine::SetDownlinkFormat(TMSFormatType aCodecFormat)
       
   716     {
       
   717     gint status(TMS_RESULT_SUCCESS);
       
   718 
       
   719     if (!iTmsCall)
       
   720         {
       
   721         SetCallType(TMS_CALL_IP);
       
   722         }
       
   723     if (iFactory && iDecFormatIntfc)
       
   724         {
       
   725         iFactory->DeleteFormat(iDecFormatIntfc);
       
   726         }
       
   727 
       
   728     iDnLinkCodec = aCodecFormat;
       
   729 
       
   730     if (iFactory && iTmsDnlink)
       
   731         {
       
   732         status = iFactory->CreateFormat(iDnLinkCodec, iDecFormatIntfc);
       
   733         status |= iTmsDnlink->SetFormat(iDecFormatIntfc);
       
   734         }
       
   735 
       
   736 #ifdef __TEST_CODE_COVERAGE__
       
   737     TMSFormatType ft;
       
   738 #endif //__TEST_CODE_COVERAGE__
       
   739 
       
   740     switch (iDnLinkCodec)
       
   741         {
       
   742         case TMS_FORMAT_G711:
       
   743             {
       
   744 #ifdef __TEST_CODE_COVERAGE__
       
   745             status = iDecFormatIntfc->GetType(ft);
       
   746             if (ft != TMS_FORMAT_G711)
       
   747                 {
       
   748                 status = KErrArgument;
       
   749                 }
       
   750 #endif //__TEST_CODE_COVERAGE__
       
   751             DisplayText("G.711 DNL Codec Set");
       
   752             break;
       
   753             }
       
   754         case TMS_FORMAT_G729:
       
   755             {
       
   756 #ifdef __TEST_CODE_COVERAGE__
       
   757             status = iDecFormatIntfc->GetType(ft);
       
   758             if (ft != TMS_FORMAT_G729)
       
   759                 {
       
   760                 status = KErrArgument;
       
   761                 }
       
   762 #endif //__TEST_CODE_COVERAGE__
       
   763             DisplayText("G.729 DNL Codec Set");
       
   764             break;
       
   765             }
       
   766         case TMS_FORMAT_ILBC:
       
   767             {
       
   768 #ifdef __TEST_CODE_COVERAGE__
       
   769             status = iDecFormatIntfc->GetType(ft);
       
   770             if (ft != TMS_FORMAT_ILBC)
       
   771                 {
       
   772                 status = KErrArgument;
       
   773                 }
       
   774 #endif //__TEST_CODE_COVERAGE__
       
   775             DisplayText("iLBC DNL Codec Set");
       
   776             break;
       
   777             }
       
   778         case TMS_FORMAT_AMR:
       
   779             {
       
   780 #ifdef __TEST_CODE_COVERAGE__
       
   781             status = iDecFormatIntfc->GetType(ft);
       
   782             if (ft != TMS_FORMAT_AMR)
       
   783                 {
       
   784                 status = KErrArgument;
       
   785                 }
       
   786 #endif //__TEST_CODE_COVERAGE__
       
   787             DisplayText("AMR-NB DNL Codec Set");
       
   788             break;
       
   789             }
       
   790         case TMS_FORMAT_PCM:
       
   791             {
       
   792 #ifdef __TEST_CODE_COVERAGE__
       
   793             status = iDecFormatIntfc->GetType(ft);
       
   794             if (ft != TMS_FORMAT_PCM)
       
   795                 {
       
   796                 status = KErrArgument;
       
   797                 }
       
   798 #endif //__TEST_CODE_COVERAGE__
       
   799             DisplayText("PCM-16 DNL Codec Set");
       
   800             break;
       
   801             }
       
   802         default:
       
   803             {
       
   804             status = KErrNotSupported;
       
   805             }
       
   806         }
       
   807 
       
   808     if (status == TMS_RESULT_SUCCESS)
       
   809         {
       
   810         OpenDownlink(); //Initialize DNL
       
   811         }
       
   812     }
       
   813 
       
   814 // ----------------------------------------------------------------------------
       
   815 // CTmsTestEngine::OpenDownlink()
       
   816 //
       
   817 // ----------------------------------------------------------------------------
       
   818 //
       
   819 void CTmsTestEngine::OpenDownlink()
       
   820     {
       
   821     gint status(TMS_RESULT_SUCCESS);
       
   822 
       
   823     if (iTmsDnlink)
       
   824         {
       
   825         iTmsDnlink->AddObserver(*this, NULL);
       
   826         status = iTmsDnlink->Init();
       
   827         if (status != TMS_RESULT_SUCCESS)
       
   828             {
       
   829             DisplayText("DNL init error ", status);
       
   830             }
       
   831         }
       
   832     }
       
   833 
       
   834 // ----------------------------------------------------------------------------
       
   835 // CTmsTestEngine::StartDownlink()
       
   836 //
       
   837 // ----------------------------------------------------------------------------
       
   838 //
       
   839 void CTmsTestEngine::StartDownlink()
       
   840     {
       
   841     if (iDnLinkStatus == EReady)
       
   842         {
       
   843 #ifdef __TEST_CODE_COVERAGE__
       
   844         ConfigureDecoder();
       
   845         gint id = iTmsDnlink->GetStreamId();
       
   846 #endif //__TEST_CODE_COVERAGE__
       
   847 
       
   848         iTmsDnlink->Start(2); //retry for ~2 sec
       
   849         iDnLinkStatus = EStreaming;
       
   850 #ifdef __WINSCW__
       
   851         iBufIndex = 0;
       
   852 #endif //__WINSCW__
       
   853         }
       
   854     else
       
   855         {
       
   856         DisplayText("DNL not ready");
       
   857         }
       
   858     }
       
   859 
       
   860 // ----------------------------------------------------------------------------
       
   861 // CTmsTestEngine::StopDownlink()
       
   862 //
       
   863 // ----------------------------------------------------------------------------
       
   864 //
       
   865 void CTmsTestEngine::StopDownlink()
       
   866     {
       
   867     if (iDnLinkStatus == EStreaming)
       
   868         {
       
   869 #ifdef __TEST_CODE_COVERAGE__
       
   870         iTmsDnlink->Pause();
       
   871         iTmsDnlink->GetState();
       
   872 #endif //__TEST_CODE_COVERAGE__
       
   873 
       
   874         iTmsDnlink->Stop();
       
   875         iDnLinkStatus = EReady;
       
   876         iOneTouchLoopback = EFalse;
       
   877         DisplayText("DNL stopped");
       
   878         }
       
   879     }
       
   880 
       
   881 // ----------------------------------------------------------------------------
       
   882 // CTmsTestEngine::CloseDownlink()
       
   883 //
       
   884 // ----------------------------------------------------------------------------
       
   885 //
       
   886 void CTmsTestEngine::CloseDownlink()
       
   887     {
       
   888     if (iTmsDnlink && iDnLinkStatus != ENotReady)
       
   889         {
       
   890         if (iTmsDnlinkEffect)
       
   891             {
       
   892             iTmsDnlink->RemoveEffect(iTmsDnlinkEffect);
       
   893             }
       
   894         if (iTmsClientSource)
       
   895             {
       
   896             iTmsDnlink->RemoveSource(iTmsClientSource);
       
   897             }
       
   898         if (iTmsModemSource)
       
   899             {
       
   900             iTmsDnlink->RemoveSource(iTmsModemSource);
       
   901             }
       
   902         if (iTmsSpeakerSink)
       
   903             {
       
   904             iTmsDnlink->RemoveSink(iTmsSpeakerSink);
       
   905             }
       
   906         iTmsDnlink->Deinit();
       
   907         iDnLinkStatus = ENotReady;
       
   908         }
       
   909     iPlayBufReady = EFalse;
       
   910     iOneTouchLoopback = EFalse;
       
   911     }
       
   912 
       
   913 gint CTmsTestEngine::CreateVolumeEffect()
       
   914     {
       
   915     gint status(TMS_RESULT_SUCCESS);
       
   916 
       
   917     if (iFactory && iTmsDnlink && !iTmsDnlinkEffect)
       
   918         {
       
   919         status = iFactory->CreateEffect(TMS_EFFECT_VOLUME, iTmsDnlinkEffect);
       
   920         if (status == TMS_RESULT_SUCCESS)
       
   921             {
       
   922             static_cast<TMSVolumeEffect*> (iTmsDnlinkEffect)->AddObserver(
       
   923                     *this, NULL);
       
   924             }
       
   925         }
       
   926     return status;
       
   927     }
       
   928 
       
   929 gint CTmsTestEngine::AddVolumeEffectToStream()
       
   930     {
       
   931     gint status(TMS_RESULT_SUCCESS);
       
   932 
       
   933     if (iTmsDnlink && iTmsDnlinkEffect)
       
   934         {
       
   935         status = iTmsDnlink->AddEffect(iTmsDnlinkEffect);
       
   936         }
       
   937     return status;
       
   938     }
       
   939 
       
   940 gint CTmsTestEngine::CreateGainEffect()
       
   941     {
       
   942     gint status(TMS_RESULT_SUCCESS);
       
   943 
       
   944     if (iFactory && iTmsUplink && !iTmsUplinkEffect)
       
   945         {
       
   946         status = iFactory->CreateEffect(TMS_EFFECT_GAIN, iTmsUplinkEffect);
       
   947         if (status == TMS_RESULT_SUCCESS)
       
   948             {
       
   949             static_cast<TMSGainEffect*> (iTmsUplinkEffect)->AddObserver(*this,
       
   950                     NULL);
       
   951             }
       
   952         }
       
   953     return status;
       
   954     }
       
   955 
       
   956 gint CTmsTestEngine::CreateGlobalRouting()
       
   957     {
       
   958     gint status(TMS_RESULT_SUCCESS);
       
   959 
       
   960     if (iFactory)
       
   961         {
       
   962         status = iFactory->CreateGlobalRouting(iTmsGlobalRouting);
       
   963         if (status == TMS_RESULT_SUCCESS)
       
   964             {
       
   965             DisplayText("TMS routing created");
       
   966             iTmsGlobalRouting->AddObserver(*this, NULL);
       
   967             }
       
   968         else
       
   969             {
       
   970             DisplayText("Global routing failed: ", status);
       
   971             }
       
   972         }
       
   973     return status;
       
   974     }
       
   975 
       
   976 gint CTmsTestEngine::AddGainEffectToStream()
       
   977     {
       
   978     gint status(TMS_RESULT_SUCCESS);
       
   979 
       
   980     if (iTmsUplink && iTmsUplinkEffect)
       
   981         {
       
   982         status = iTmsUplink->AddEffect(iTmsUplinkEffect);
       
   983         }
       
   984     return status;
       
   985     }
       
   986 
       
   987 gint CTmsTestEngine::CreateRingTonePlayer()
       
   988     {
       
   989     gint status(TMS_RESULT_SUCCESS);
       
   990 
       
   991     if (iFactory)
       
   992         {
       
   993         status = iFactory->CreateRingTonePlayer(iTmsRingTonePlayer);
       
   994 
       
   995         if (iTmsRingTonePlayer && status == TMS_RESULT_SUCCESS)
       
   996             {
       
   997             iTmsRingTonePlayer->AddObserver(*this, NULL);
       
   998             DisplayText("RingTone Player created");
       
   999             }
       
  1000         else
       
  1001             {
       
  1002             DisplayText("RT create failed: ", status);
       
  1003             }
       
  1004         }
       
  1005     return status;
       
  1006     }
       
  1007 
       
  1008 // ----------------------------------------------------------------------------
       
  1009 // CTmsTestEngine::ConfigureDecoder()
       
  1010 //
       
  1011 // ----------------------------------------------------------------------------
       
  1012 //
       
  1013 void CTmsTestEngine::ConfigureDecoder()
       
  1014     {
       
  1015     // NOTE: These calls can ONLY be made when codec is in a STOPPED state.
       
  1016 
       
  1017     switch (iDnLinkCodec)
       
  1018         {
       
  1019         case TMS_FORMAT_G711:
       
  1020             {
       
  1021             gboolean cng(TRUE);
       
  1022             static_cast<TMSG711Format*> (iDecFormatIntfc)->SetCNG(cng);
       
  1023             static_cast<TMSG711Format*> (iDecFormatIntfc)->GetCNG(cng);
       
  1024             gboolean plc(FALSE);
       
  1025             static_cast<TMSG711Format*> (iDecFormatIntfc)->SetPlc(plc);
       
  1026             static_cast<TMSG711Format*> (iDecFormatIntfc)->GetPlc(plc);
       
  1027             TMSG711CodecMode mode(TMS_G711_CODEC_MODE_ALAW);
       
  1028             static_cast<TMSG711Format*> (iDecFormatIntfc)->SetMode(mode);
       
  1029             static_cast<TMSG711Format*> (iDecFormatIntfc)->GetMode(mode);
       
  1030             break;
       
  1031             }
       
  1032         case TMS_FORMAT_ILBC:
       
  1033             {
       
  1034             gboolean cng(TRUE);
       
  1035             static_cast<TMSILBCFormat*> (iDecFormatIntfc)->SetCNG(cng);
       
  1036             static_cast<TMSILBCFormat*> (iDecFormatIntfc)->GetCNG(cng);
       
  1037             TMSILBCCodecMode mode(TMS_ILBC_CODEC_MODE_20MS_FRAME);
       
  1038             static_cast<TMSILBCFormat*> (iDecFormatIntfc)->SetMode(mode);
       
  1039             static_cast<TMSILBCFormat*> (iDecFormatIntfc)->GetMode(mode);
       
  1040             break;
       
  1041             }
       
  1042         case TMS_FORMAT_G729:
       
  1043         case TMS_FORMAT_AMR:
       
  1044         case TMS_FORMAT_PCM:
       
  1045         default:
       
  1046             {
       
  1047             break;
       
  1048             }
       
  1049         }
       
  1050     }
       
  1051 
       
  1052 // ----------------------------------------------------------------------------
       
  1053 // CTmsTestEngine::GetMaxVolume()
       
  1054 //
       
  1055 // ----------------------------------------------------------------------------
       
  1056 //
       
  1057 void CTmsTestEngine::GetMaxVolume()
       
  1058     {
       
  1059     if (iTmsDnlinkEffect)
       
  1060         {
       
  1061         static_cast<TMSVolumeEffect*> (iTmsDnlinkEffect)->GetMaxLevel(
       
  1062                 iMaxVolume);
       
  1063         }
       
  1064     DisplayText("Max Volume: ", iMaxVolume);
       
  1065     }
       
  1066 
       
  1067 // ----------------------------------------------------------------------------
       
  1068 // CTmsTestEngine::GetVolume
       
  1069 //
       
  1070 // ----------------------------------------------------------------------------
       
  1071 //
       
  1072 void CTmsTestEngine::GetVolume()
       
  1073     {
       
  1074     if (iTmsDnlinkEffect)
       
  1075         {
       
  1076         static_cast<TMSVolumeEffect*> (iTmsDnlinkEffect)->GetLevel(iVolume);
       
  1077         }
       
  1078     DisplayText("Volume ", iVolume);
       
  1079     }
       
  1080 
       
  1081 // ----------------------------------------------------------------------------
       
  1082 // CTmsTestEngine::MuteSpeaker()
       
  1083 //
       
  1084 // ----------------------------------------------------------------------------
       
  1085 //
       
  1086 void CTmsTestEngine::MuteSpeaker()
       
  1087     {
       
  1088     SetVolume(0);
       
  1089     }
       
  1090 
       
  1091 // ----------------------------------------------------------------------------
       
  1092 // CTmsTestEngine::SetMaxVolume
       
  1093 //
       
  1094 // ----------------------------------------------------------------------------
       
  1095 //
       
  1096 void CTmsTestEngine::SetMaxVolume()
       
  1097     {
       
  1098     SetVolume(iMaxVolume);
       
  1099     }
       
  1100 
       
  1101 // ----------------------------------------------------------------------------
       
  1102 // CTmsTestEngine::SetVolume
       
  1103 //
       
  1104 // ----------------------------------------------------------------------------
       
  1105 //
       
  1106 void CTmsTestEngine::SetVolume(guint aVolume)
       
  1107     {
       
  1108     iVolume = aVolume;
       
  1109 
       
  1110     if (iTmsDnlinkEffect)
       
  1111         {
       
  1112         static_cast<TMSVolumeEffect*> (iTmsDnlinkEffect)->SetLevel(aVolume);
       
  1113         }
       
  1114     else
       
  1115         {
       
  1116         DisplayText("Create Dnlink VolumeEffect first");
       
  1117         }
       
  1118     }
       
  1119 
       
  1120 // ----------------------------------------------------------------------------
       
  1121 // CTmsTestEngine::VolumeUp()
       
  1122 //
       
  1123 // ----------------------------------------------------------------------------
       
  1124 //
       
  1125 void CTmsTestEngine::VolumeUp()
       
  1126     {
       
  1127     if ((iDnLinkStatus == EReady || iDnLinkStatus == EStreaming)
       
  1128             && iTmsDnlinkEffect)
       
  1129         {
       
  1130         if (iVolume < iMaxVolume)
       
  1131             {
       
  1132             static_cast<TMSVolumeEffect*> (iTmsDnlinkEffect)->SetLevel(
       
  1133                     ++iVolume);
       
  1134             }
       
  1135         }
       
  1136     else
       
  1137         {
       
  1138         DisplayText("Create DNL first");
       
  1139         }
       
  1140     }
       
  1141 
       
  1142 // ----------------------------------------------------------------------------
       
  1143 // CTmsTestEngine::VolumeDn()
       
  1144 //
       
  1145 // ----------------------------------------------------------------------------
       
  1146 //
       
  1147 void CTmsTestEngine::VolumeDn()
       
  1148     {
       
  1149     if ((iDnLinkStatus == EReady || iDnLinkStatus == EStreaming)
       
  1150             && iTmsDnlinkEffect)
       
  1151         {
       
  1152         if (iVolume > 0)
       
  1153             {
       
  1154             static_cast<TMSVolumeEffect*> (iTmsDnlinkEffect)->SetLevel(
       
  1155                     --iVolume);
       
  1156             }
       
  1157         }
       
  1158     else
       
  1159         {
       
  1160         DisplayText("Open DNL first");
       
  1161         }
       
  1162     }
       
  1163 
       
  1164 // ----------------------------------------------------------------------------
       
  1165 // CTmsTestEngine::OpenUplink()
       
  1166 //
       
  1167 // ----------------------------------------------------------------------------
       
  1168 //
       
  1169 void CTmsTestEngine::OpenUplink()
       
  1170     {
       
  1171     gint status = TMS_RESULT_SUCCESS;
       
  1172 
       
  1173     if (iTmsUplink)
       
  1174         {
       
  1175         iTmsUplink->AddObserver(*this, NULL);
       
  1176         status = iTmsUplink->Init(); //retry for ~3 sec
       
  1177         if (status != TMS_RESULT_SUCCESS)
       
  1178             {
       
  1179             DisplayText("UPL init error: ", status);
       
  1180             }
       
  1181         }
       
  1182     }
       
  1183 
       
  1184 // ----------------------------------------------------------------------------
       
  1185 // CTmsTestEngine::StartUplink()
       
  1186 //
       
  1187 // ----------------------------------------------------------------------------
       
  1188 //
       
  1189 void CTmsTestEngine::StartUplink()
       
  1190     {
       
  1191     if (iUpLinkStatus == EReady)
       
  1192         {
       
  1193 #ifdef __TEST_CODE_COVERAGE__
       
  1194         ConfigureEncoder();
       
  1195         ToggleVad();
       
  1196         GetVad();
       
  1197         GetSupportedBitrates();
       
  1198         SelectMaxBitrate();
       
  1199         GetBitrate();
       
  1200         gint id = iTmsUplink->GetStreamId();
       
  1201 #endif //__TEST_CODE_COVERAGE__
       
  1202 
       
  1203         iTmsUplink->Start(4); //retry for ~4 sec
       
  1204         iUpLinkStatus = EStreaming;
       
  1205         }
       
  1206     else
       
  1207         {
       
  1208         DisplayText("UPL not ready");
       
  1209         }
       
  1210     }
       
  1211 
       
  1212 // ----------------------------------------------------------------------------
       
  1213 // CTmsTestEngine::StopUplink()
       
  1214 //
       
  1215 // ----------------------------------------------------------------------------
       
  1216 //
       
  1217 void CTmsTestEngine::StopUplink()
       
  1218     {
       
  1219     if (iUpLinkStatus == EStreaming)
       
  1220         {
       
  1221         iTmsUplink->Stop();
       
  1222         iUpLinkStatus = EReady;
       
  1223         iOneTouchLoopback = EFalse;
       
  1224         DisplayText("UPL stopped");
       
  1225         }
       
  1226     }
       
  1227 
       
  1228 // ----------------------------------------------------------------------------
       
  1229 // CTmsTestEngine::CloseUplink()
       
  1230 //
       
  1231 // ----------------------------------------------------------------------------
       
  1232 //
       
  1233 void CTmsTestEngine::CloseUplink()
       
  1234     {
       
  1235     iRecBufReady = EFalse;
       
  1236     iOneTouchLoopback = EFalse;
       
  1237 
       
  1238     if (iTmsUplink && iUpLinkStatus != ENotReady)
       
  1239         {
       
  1240         if (iTmsUplinkEffect)
       
  1241             {
       
  1242             iTmsUplink->RemoveEffect(iTmsUplinkEffect);
       
  1243             }
       
  1244         if (iTmsMicSource)
       
  1245             {
       
  1246             iTmsUplink->RemoveSource(iTmsMicSource);
       
  1247             }
       
  1248         if (iTmsClientSink)
       
  1249             {
       
  1250             iTmsUplink->RemoveSink(iTmsClientSink);
       
  1251             }
       
  1252         if (iTmsModemSink)
       
  1253             {
       
  1254             iTmsUplink->RemoveSink(iTmsModemSink);
       
  1255             }
       
  1256         iTmsUplink->Deinit();
       
  1257         iUpLinkStatus = ENotReady;
       
  1258         }
       
  1259     }
       
  1260 
       
  1261 // ----------------------------------------------------------------------------
       
  1262 // CTmsTestEngine::SetUplinkFormat()
       
  1263 //
       
  1264 // ----------------------------------------------------------------------------
       
  1265 //
       
  1266 void CTmsTestEngine::SetUplinkFormat(TMSFormatType aCodecFormat)
       
  1267     {
       
  1268     gint status(TMS_RESULT_SUCCESS);
       
  1269 
       
  1270     if (!iTmsCall)
       
  1271         {
       
  1272         SetCallType(TMS_CALL_IP);
       
  1273         }
       
  1274     if (iFactory && iEncFormatIntfc)
       
  1275         {
       
  1276         iFactory->DeleteFormat(iEncFormatIntfc);
       
  1277         }
       
  1278 
       
  1279     iUpLinkCodec = aCodecFormat;
       
  1280 
       
  1281     if (iFactory && iTmsUplink)
       
  1282         {
       
  1283         status = iFactory->CreateFormat(iUpLinkCodec, iEncFormatIntfc);
       
  1284         status |= iTmsUplink->SetFormat(iEncFormatIntfc);
       
  1285         }
       
  1286 
       
  1287 #ifdef __TEST_CODE_COVERAGE__
       
  1288     TMSFormatType ft;
       
  1289 #endif //__TEST_CODE_COVERAGE__
       
  1290 
       
  1291     switch (iUpLinkCodec)
       
  1292         {
       
  1293         case TMS_FORMAT_G711:
       
  1294             {
       
  1295 #ifdef __TEST_CODE_COVERAGE__
       
  1296             status = iEncFormatIntfc->GetType(ft);
       
  1297             if (ft != TMS_FORMAT_G711)
       
  1298                 {
       
  1299                 status = KErrArgument;
       
  1300                 }
       
  1301 #endif //__TEST_CODE_COVERAGE__
       
  1302             DisplayText("G.711 UPL Codec Set");
       
  1303             break;
       
  1304             }
       
  1305         case TMS_FORMAT_G729:
       
  1306             {
       
  1307 #ifdef __TEST_CODE_COVERAGE__
       
  1308             status = iEncFormatIntfc->GetType(ft);
       
  1309             if (ft != TMS_FORMAT_G729)
       
  1310                 {
       
  1311                 status = KErrArgument;
       
  1312                 }
       
  1313 #endif //__TEST_CODE_COVERAGE__
       
  1314             DisplayText("G.729 UPL Codec Set");
       
  1315             break;
       
  1316             }
       
  1317         case TMS_FORMAT_ILBC:
       
  1318             {
       
  1319 #ifdef __TEST_CODE_COVERAGE__
       
  1320             status = iEncFormatIntfc->GetType(ft);
       
  1321             if (ft != TMS_FORMAT_ILBC)
       
  1322                 {
       
  1323                 status = KErrArgument;
       
  1324                 }
       
  1325 #endif //__TEST_CODE_COVERAGE__
       
  1326             DisplayText("iLBC UPL Codec Set");
       
  1327             break;
       
  1328             }
       
  1329         case TMS_FORMAT_AMR:
       
  1330             {
       
  1331 #ifdef __TEST_CODE_COVERAGE__
       
  1332             status = iEncFormatIntfc->GetType(ft);
       
  1333             if (ft != TMS_FORMAT_AMR)
       
  1334                 {
       
  1335                 status = KErrArgument;
       
  1336                 }
       
  1337 #endif //__TEST_CODE_COVERAGE__
       
  1338             DisplayText("AMR-NB UPL Codec Set");
       
  1339             break;
       
  1340             }
       
  1341         case TMS_FORMAT_PCM:
       
  1342             {
       
  1343 #ifdef __TEST_CODE_COVERAGE__
       
  1344             status = iEncFormatIntfc->GetType(ft);
       
  1345             if (ft != TMS_FORMAT_PCM)
       
  1346                 {
       
  1347                 status = KErrArgument;
       
  1348                 }
       
  1349 #endif //__TEST_CODE_COVERAGE__
       
  1350             DisplayText("PCM-16 UPL Codec Set");
       
  1351             break;
       
  1352             }
       
  1353         default:
       
  1354             {
       
  1355             status = KErrNotSupported;
       
  1356             }
       
  1357         }
       
  1358 
       
  1359     if (status == TMS_RESULT_SUCCESS)
       
  1360         {
       
  1361         OpenUplink(); //Initialize UPL
       
  1362         }
       
  1363     }
       
  1364 
       
  1365 // ----------------------------------------------------------------------------
       
  1366 // CTmsTestEngine::ConfigureEncoder()
       
  1367 //
       
  1368 // ----------------------------------------------------------------------------
       
  1369 //
       
  1370 void CTmsTestEngine::ConfigureEncoder()
       
  1371     {
       
  1372     // Any of these calls can ONLY be made when encoder is in a STOPPED state.
       
  1373 
       
  1374     switch (iUpLinkCodec)
       
  1375         {
       
  1376         case TMS_FORMAT_G711:
       
  1377             {
       
  1378             TMSG711CodecMode mode(TMS_G711_CODEC_MODE_ALAW);
       
  1379             static_cast<TMSG711Format*> (iEncFormatIntfc)->SetMode(mode);
       
  1380             static_cast<TMSG711Format*> (iEncFormatIntfc)->GetMode(mode);
       
  1381             break;
       
  1382             }
       
  1383         case TMS_FORMAT_ILBC:
       
  1384             {
       
  1385             TMSILBCCodecMode mode(TMS_ILBC_CODEC_MODE_20MS_FRAME);
       
  1386             static_cast<TMSILBCFormat*> (iEncFormatIntfc)->SetMode(mode);
       
  1387             static_cast<TMSILBCFormat*> (iEncFormatIntfc)->GetMode(mode);
       
  1388             break;
       
  1389             }
       
  1390         case TMS_FORMAT_G729:
       
  1391         case TMS_FORMAT_AMR:
       
  1392         case TMS_FORMAT_PCM:
       
  1393         default:
       
  1394             {
       
  1395             break;
       
  1396             }
       
  1397         }
       
  1398     }
       
  1399 
       
  1400 // ----------------------------------------------------------------------------
       
  1401 // CTmsTestEngine::GetMaxGain()
       
  1402 //
       
  1403 // ----------------------------------------------------------------------------
       
  1404 //
       
  1405 void CTmsTestEngine::GetMaxGain()
       
  1406     {
       
  1407     if (iTmsUplinkEffect)
       
  1408         {
       
  1409         static_cast<TMSGainEffect*> (iTmsUplinkEffect)->GetMaxLevel(iMaxGain);
       
  1410         DisplayText("MaxGain: ", iMaxGain);
       
  1411         }
       
  1412     }
       
  1413 
       
  1414 // ----------------------------------------------------------------------------
       
  1415 // CTmsTestEngine::GetGain()
       
  1416 //
       
  1417 // ----------------------------------------------------------------------------
       
  1418 //
       
  1419 void CTmsTestEngine::GetGain()
       
  1420     {
       
  1421     guint gain;
       
  1422     if (iTmsUplinkEffect)
       
  1423         {
       
  1424         static_cast<TMSGainEffect*> (iTmsUplinkEffect)->GetLevel(gain);
       
  1425         DisplayText("Gain: ", gain);
       
  1426         }
       
  1427     }
       
  1428 
       
  1429 // ----------------------------------------------------------------------------
       
  1430 // CTmsTestEngine::SetMaxGain()
       
  1431 //
       
  1432 // ----------------------------------------------------------------------------
       
  1433 //
       
  1434 void CTmsTestEngine::SetMaxGain()
       
  1435     {
       
  1436     static_cast<TMSGainEffect*> (iTmsUplinkEffect)->SetLevel(iMaxGain);
       
  1437     }
       
  1438 
       
  1439 // ----------------------------------------------------------------------------
       
  1440 // CTmsTestEngine::MuteMic()
       
  1441 //
       
  1442 // ----------------------------------------------------------------------------
       
  1443 //
       
  1444 void CTmsTestEngine::MuteMic()
       
  1445     {
       
  1446     static_cast<TMSGainEffect*> (iTmsUplinkEffect)->SetLevel(0);
       
  1447     }
       
  1448 
       
  1449 // ----------------------------------------------------------------------------
       
  1450 // CTmsTestEngine::GetSupportedBitrates
       
  1451 //
       
  1452 // ----------------------------------------------------------------------------
       
  1453 //
       
  1454 void CTmsTestEngine::GetSupportedBitrates()
       
  1455     {
       
  1456     TInt status = GetSupportedBitrates(iBitratesVector);
       
  1457 
       
  1458     if (status == TMS_RESULT_SUCCESS)
       
  1459         {
       
  1460         std::vector<guint>::iterator itBitrates = iBitratesVector.begin();
       
  1461         for (; itBitrates < iBitratesVector.end(); itBitrates++)
       
  1462             {
       
  1463             DisplayText("BR ", *itBitrates);
       
  1464             }
       
  1465         }
       
  1466     else
       
  1467         {
       
  1468         DisplayText("BR Error: ", status);
       
  1469         }
       
  1470     }
       
  1471 
       
  1472 // ----------------------------------------------------------------------------
       
  1473 // CTmsTestEngine::GetSupportedBitrates
       
  1474 //
       
  1475 // ----------------------------------------------------------------------------
       
  1476 //
       
  1477 TInt CTmsTestEngine::GetSupportedBitrates(BitRateVector& aBrArr)
       
  1478     {
       
  1479     TInt status = KErrNotFound;
       
  1480 
       
  1481     switch (iUpLinkCodec)
       
  1482         {
       
  1483         case TMS_FORMAT_G711:
       
  1484             status = static_cast<TMSG711Format*>
       
  1485                     (iEncFormatIntfc)->GetSupportedBitRates(aBrArr);
       
  1486             break;
       
  1487         case TMS_FORMAT_G729:
       
  1488             status = static_cast<TMSG729Format*>
       
  1489                     (iEncFormatIntfc)->GetSupportedBitRates(aBrArr);
       
  1490             break;
       
  1491         case TMS_FORMAT_ILBC:
       
  1492             status = static_cast<TMSILBCFormat*>
       
  1493                     (iEncFormatIntfc)->GetSupportedBitRates(aBrArr);
       
  1494             break;
       
  1495         case TMS_FORMAT_AMR:
       
  1496             status = static_cast<TMSAMRFormat*>
       
  1497                     (iEncFormatIntfc)->GetSupportedBitRates(aBrArr);
       
  1498             break;
       
  1499         case TMS_FORMAT_PCM:
       
  1500         default:
       
  1501             status = KErrNotSupported;
       
  1502             break;
       
  1503         }
       
  1504     return status;
       
  1505     }
       
  1506 
       
  1507 // ----------------------------------------------------------------------------
       
  1508 // CTmsTestEngine::SelectMinBitrate
       
  1509 //
       
  1510 // ----------------------------------------------------------------------------
       
  1511 //
       
  1512 void CTmsTestEngine::SelectMinBitrate()
       
  1513     {
       
  1514     if (iBitratesVector.size() > 0)
       
  1515         {
       
  1516         std::vector<guint>::iterator bitrate = iBitratesVector.begin();
       
  1517         iBitrate = *bitrate;
       
  1518         SetBitrate(iBitrate);
       
  1519         DisplayText("BR set: ", iBitrate);
       
  1520         }
       
  1521     }
       
  1522 
       
  1523 // ----------------------------------------------------------------------------
       
  1524 // CTmsTestEngine::SelectMaxBitrate
       
  1525 //
       
  1526 // ----------------------------------------------------------------------------
       
  1527 //
       
  1528 void CTmsTestEngine::SelectMaxBitrate()
       
  1529     {
       
  1530     if (iBitratesVector.size() > 0)
       
  1531         {
       
  1532         iBitrate = iBitratesVector.back();
       
  1533         SetBitrate(iBitrate);
       
  1534         DisplayText("BR set: ", iBitrate);
       
  1535         }
       
  1536     }
       
  1537 
       
  1538 // ----------------------------------------------------------------------------
       
  1539 // CTmsTestEngine::SetBitrate
       
  1540 //
       
  1541 // ----------------------------------------------------------------------------
       
  1542 //
       
  1543 void CTmsTestEngine::SetBitrate(TUint aBitrate)
       
  1544     {
       
  1545     switch (iUpLinkCodec)
       
  1546         {
       
  1547         case TMS_FORMAT_G711:
       
  1548             static_cast<TMSG711Format*> (iEncFormatIntfc)->SetBitRate(aBitrate);
       
  1549             DisplayText("Set BR: ", iBitrate);
       
  1550             break;
       
  1551         case TMS_FORMAT_G729:
       
  1552             static_cast<TMSG729Format*> (iEncFormatIntfc)->SetBitRate(aBitrate);
       
  1553             DisplayText("Set BR: ", iBitrate);
       
  1554             break;
       
  1555         case TMS_FORMAT_ILBC:
       
  1556             static_cast<TMSILBCFormat*> (iEncFormatIntfc)->SetBitRate(aBitrate);
       
  1557             DisplayText("Set BR: ", iBitrate);
       
  1558             break;
       
  1559         case TMS_FORMAT_AMR:
       
  1560             static_cast<TMSAMRFormat*> (iEncFormatIntfc)->SetBitRate(aBitrate);
       
  1561             DisplayText("Set BR: ", iBitrate);
       
  1562             break;
       
  1563         case TMS_FORMAT_PCM:
       
  1564         default:
       
  1565             break;
       
  1566         }
       
  1567     }
       
  1568 
       
  1569 // ----------------------------------------------------------------------------
       
  1570 // CTmsTestEngine::GetBitrate
       
  1571 //
       
  1572 // ----------------------------------------------------------------------------
       
  1573 //
       
  1574 void CTmsTestEngine::GetBitrate()
       
  1575     {
       
  1576     if (iUpLinkCodec != TMS_FORMAT_PCM)
       
  1577         {
       
  1578         GetBitrate(iBitrate);
       
  1579         DisplayText("Current BR: ", iBitrate);
       
  1580         }
       
  1581     }
       
  1582 
       
  1583 // ----------------------------------------------------------------------------
       
  1584 // CTmsTestEngine::GetBitrate
       
  1585 //
       
  1586 // ----------------------------------------------------------------------------
       
  1587 //
       
  1588 void CTmsTestEngine::GetBitrate(TUint& aBitrate)
       
  1589     {
       
  1590     switch (iUpLinkCodec)
       
  1591         {
       
  1592         case TMS_FORMAT_G711:
       
  1593             static_cast<TMSG711Format*> (iEncFormatIntfc)->GetBitRate(aBitrate);
       
  1594             break;
       
  1595         case TMS_FORMAT_G729:
       
  1596             static_cast<TMSG729Format*> (iEncFormatIntfc)->GetBitRate(aBitrate);
       
  1597             break;
       
  1598         case TMS_FORMAT_ILBC:
       
  1599             static_cast<TMSILBCFormat*> (iEncFormatIntfc)->GetBitRate(aBitrate);
       
  1600             break;
       
  1601         case TMS_FORMAT_AMR:
       
  1602             static_cast<TMSAMRFormat*> (iEncFormatIntfc)->GetBitRate(aBitrate);
       
  1603             break;
       
  1604         case TMS_FORMAT_PCM:
       
  1605         default:
       
  1606             break;
       
  1607         }
       
  1608     }
       
  1609 
       
  1610 // ----------------------------------------------------------------------------
       
  1611 // CTmsTestEngine::ToggleVad
       
  1612 //
       
  1613 // ----------------------------------------------------------------------------
       
  1614 //
       
  1615 void CTmsTestEngine::ToggleVad()
       
  1616     {
       
  1617     iVad = (iVad) ? EFalse : ETrue;
       
  1618 
       
  1619     switch (iUpLinkCodec)
       
  1620         {
       
  1621         case TMS_FORMAT_G711:
       
  1622             static_cast<TMSG711Format*> (iEncFormatIntfc)->SetVADMode(iVad);
       
  1623             DisplayText("Set VAD: ", iVad);
       
  1624             break;
       
  1625         case TMS_FORMAT_G729:
       
  1626             static_cast<TMSG729Format*> (iEncFormatIntfc)->SetVADMode(iVad);
       
  1627             DisplayText("Set VAD: ", iVad);
       
  1628             break;
       
  1629         case TMS_FORMAT_ILBC:
       
  1630             static_cast<TMSILBCFormat*> (iEncFormatIntfc)->SetVADMode(iVad);
       
  1631             DisplayText("Set VAD: ", iVad);
       
  1632             break;
       
  1633         case TMS_FORMAT_AMR:
       
  1634             //static_cast<TMSAMRFormat*> (iEncFormatIntfc)->SetVADMode(iVad);
       
  1635             //DisplayText("Set VAD: ", iVad);
       
  1636             break;
       
  1637         case TMS_FORMAT_PCM:
       
  1638         default:
       
  1639             break;
       
  1640         }
       
  1641     }
       
  1642 
       
  1643 // ----------------------------------------------------------------------------
       
  1644 // CTmsTestEngine::GetVad
       
  1645 //
       
  1646 // ----------------------------------------------------------------------------
       
  1647 //
       
  1648 void CTmsTestEngine::GetVad()
       
  1649     {
       
  1650     switch (iUpLinkCodec)
       
  1651         {
       
  1652         case TMS_FORMAT_G711:
       
  1653             static_cast<TMSG711Format*> (iEncFormatIntfc)->GetVADMode(iVad);
       
  1654             DisplayText("Current VAD: ", iVad);
       
  1655             break;
       
  1656         case TMS_FORMAT_G729:
       
  1657             static_cast<TMSG729Format*> (iEncFormatIntfc)->GetVADMode(iVad);
       
  1658             DisplayText("Current VAD: ", iVad);
       
  1659             break;
       
  1660         case TMS_FORMAT_ILBC:
       
  1661             static_cast<TMSILBCFormat*> (iEncFormatIntfc)->GetVADMode(iVad);
       
  1662             DisplayText("Current VAD: ", iVad);
       
  1663             break;
       
  1664         case TMS_FORMAT_AMR:
       
  1665             //static_cast<TMSAMRFormat*> (iEncFormatIntfc)->GetVADMode(iVad);
       
  1666             //DisplayText("Current VAD: ", iVad);
       
  1667             break;
       
  1668         case TMS_FORMAT_PCM:
       
  1669         default:
       
  1670             break;
       
  1671         }
       
  1672     }
       
  1673 
       
  1674 // ----------------------------------------------------------------------------
       
  1675 // CTmsTestEngine::ToggleCng
       
  1676 //
       
  1677 // ----------------------------------------------------------------------------
       
  1678 //
       
  1679 void CTmsTestEngine::ToggleCng()
       
  1680     {
       
  1681     iCng = (iCng) ? EFalse : ETrue;
       
  1682 
       
  1683     switch (iDnLinkCodec)
       
  1684         {
       
  1685         case TMS_FORMAT_G711:
       
  1686             static_cast<TMSG711Format*> (iDecFormatIntfc)->SetCNG(iCng);
       
  1687             DisplayText("Set CNG ", iCng);
       
  1688             break;
       
  1689         case TMS_FORMAT_ILBC:
       
  1690             static_cast<TMSILBCFormat*> (iDecFormatIntfc)->SetCNG(iCng);
       
  1691             DisplayText("Set CNG ", iCng);
       
  1692             break;
       
  1693         default:
       
  1694             break;
       
  1695         }
       
  1696     }
       
  1697 
       
  1698 // ----------------------------------------------------------------------------
       
  1699 // CTmsTestEngine::GetCng
       
  1700 //
       
  1701 // ----------------------------------------------------------------------------
       
  1702 //
       
  1703 void CTmsTestEngine::GetCng()
       
  1704     {
       
  1705     switch (iDnLinkCodec)
       
  1706         {
       
  1707         case TMS_FORMAT_G711:
       
  1708             static_cast<TMSG711Format*> (iDecFormatIntfc)->GetCNG(iCng);
       
  1709             DisplayText("Current CNG ", iCng);
       
  1710             break;
       
  1711         case TMS_FORMAT_ILBC:
       
  1712             static_cast<TMSILBCFormat*> (iDecFormatIntfc)->GetCNG(iCng);
       
  1713             DisplayText("Current CNG ", iCng);
       
  1714             break;
       
  1715         default:
       
  1716             break;
       
  1717         }
       
  1718     }
       
  1719 
       
  1720 // ----------------------------------------------------------------------------
       
  1721 // CTmsTestEngine::TogglePlc
       
  1722 //
       
  1723 // ----------------------------------------------------------------------------
       
  1724 //
       
  1725 void CTmsTestEngine::TogglePlc()
       
  1726     {
       
  1727     iPlc = (iPlc) ? EFalse : ETrue;
       
  1728     if (iDnLinkCodec == TMS_FORMAT_G711)
       
  1729         {
       
  1730         static_cast<TMSG711Format*> (iDecFormatIntfc)->SetPlc(ETrue);
       
  1731         DisplayText("Set PLC ", iPlc);
       
  1732         }
       
  1733     }
       
  1734 
       
  1735 // ----------------------------------------------------------------------------
       
  1736 // CTmsTestEngine::GetPlc
       
  1737 //
       
  1738 // ----------------------------------------------------------------------------
       
  1739 //
       
  1740 void CTmsTestEngine::GetPlc()
       
  1741     {
       
  1742     if (iDnLinkCodec == TMS_FORMAT_G711)
       
  1743         {
       
  1744         static_cast<TMSG711Format*> (iDecFormatIntfc)->GetPlc(iPlc);
       
  1745         DisplayText("Current PLC ", iPlc);
       
  1746         }
       
  1747     }
       
  1748 
       
  1749 // ----------------------------------------------------------------------------
       
  1750 // CTmsTestEngine::SetDnLinkG711ALAW
       
  1751 //
       
  1752 // ----------------------------------------------------------------------------
       
  1753 //
       
  1754 void CTmsTestEngine::SetDnLinkG711ALAW()
       
  1755     {
       
  1756     if (iDnLinkCodec == TMS_FORMAT_G711)
       
  1757         {
       
  1758         static_cast<TMSG711Format*> (iDecFormatIntfc)->SetMode(
       
  1759                 TMS_G711_CODEC_MODE_ALAW);
       
  1760         DisplayText("DNL G.711 Mode Set: [aLaw]");
       
  1761         }
       
  1762     }
       
  1763 
       
  1764 // ----------------------------------------------------------------------------
       
  1765 // CTmsTestEngine::SetDnLinkG711uLAW
       
  1766 //
       
  1767 // ----------------------------------------------------------------------------
       
  1768 //
       
  1769 void CTmsTestEngine::SetDnLinkG711uLAW()
       
  1770     {
       
  1771     if (iDnLinkCodec == TMS_FORMAT_G711)
       
  1772         {
       
  1773         static_cast<TMSG711Format*> (iDecFormatIntfc)->SetMode(
       
  1774                 TMS_G711_CODEC_MODE_MULAW);
       
  1775         DisplayText("DNL G.711 Mode Set: [uLaw]");
       
  1776         }
       
  1777     }
       
  1778 
       
  1779 // ----------------------------------------------------------------------------
       
  1780 // CTmsTestEngine::GetDnLinkG711Mode
       
  1781 //
       
  1782 // ----------------------------------------------------------------------------
       
  1783 //
       
  1784 void CTmsTestEngine::GetDnLinkG711Mode()
       
  1785     {
       
  1786     if (iDnLinkCodec == TMS_FORMAT_G711)
       
  1787         {
       
  1788         TMSG711CodecMode mode;
       
  1789         TInt status = static_cast<TMSG711Format*> (iDecFormatIntfc)->GetMode(
       
  1790                 mode);
       
  1791 
       
  1792         if (status == TMS_RESULT_SUCCESS)
       
  1793             {
       
  1794             if (mode == TMS_G711_CODEC_MODE_MULAW)
       
  1795                 {
       
  1796                 DisplayText("DNL G711 Mode: [uLaw]");
       
  1797                 }
       
  1798             else
       
  1799                 {
       
  1800                 DisplayText("DNL G711 Mode: [aLaw]");
       
  1801                 }
       
  1802             }
       
  1803         else
       
  1804             {
       
  1805             DisplayText("DNL G711 GetMode Error: ", status);
       
  1806             }
       
  1807         }
       
  1808     }
       
  1809 
       
  1810 // ----------------------------------------------------------------------------
       
  1811 // CTmsTestEngine::SetDnLinkILBC20MS
       
  1812 //
       
  1813 // ----------------------------------------------------------------------------
       
  1814 //
       
  1815 void CTmsTestEngine::SetDnLinkILBC20MS()
       
  1816     {
       
  1817     if (iDnLinkCodec == TMS_FORMAT_ILBC)
       
  1818         {
       
  1819         static_cast<TMSILBCFormat*> (iDecFormatIntfc)->SetMode(
       
  1820                 TMS_ILBC_CODEC_MODE_20MS_FRAME);
       
  1821         DisplayText("DNL iLBC Mode Set: [20ms]");
       
  1822         }
       
  1823     }
       
  1824 
       
  1825 // ----------------------------------------------------------------------------
       
  1826 // CTmsTestEngine::SetDnLinkILBC30MS
       
  1827 //
       
  1828 // ----------------------------------------------------------------------------
       
  1829 //
       
  1830 void CTmsTestEngine::SetDnLinkILBC30MS()
       
  1831     {
       
  1832     if (iDnLinkCodec == TMS_FORMAT_ILBC)
       
  1833         {
       
  1834         static_cast<TMSILBCFormat*> (iDecFormatIntfc)->SetMode(
       
  1835                 TMS_ILBC_CODEC_MODE_30MS_FRAME);
       
  1836         DisplayText("DNL iLBC Mode Set: [30ms]");
       
  1837         }
       
  1838     }
       
  1839 
       
  1840 // ----------------------------------------------------------------------------
       
  1841 // CTmsTestEngine::GetDnLinkILBCMode
       
  1842 //
       
  1843 // ----------------------------------------------------------------------------
       
  1844 //
       
  1845 void CTmsTestEngine::GetDnLinkILBCMode()
       
  1846     {
       
  1847     if (iDnLinkCodec == TMS_FORMAT_ILBC)
       
  1848         {
       
  1849         TMSILBCCodecMode mode;
       
  1850         gint status = static_cast<TMSILBCFormat*> (iDecFormatIntfc)->GetMode(
       
  1851                 mode);
       
  1852 
       
  1853         if (status == TMS_RESULT_SUCCESS)
       
  1854             {
       
  1855             if (mode == TMS_ILBC_CODEC_MODE_30MS_FRAME)
       
  1856                 {
       
  1857                 DisplayText("DNL iLBC Mode: [30ms]");
       
  1858                 }
       
  1859             else if (mode == TMS_ILBC_CODEC_MODE_20MS_FRAME)
       
  1860                 {
       
  1861                 DisplayText("DNL iLBC Mode: [20ms]");
       
  1862                 }
       
  1863             }
       
  1864         else
       
  1865             {
       
  1866             DisplayText("DNL iLBC GetMode Error: ", status);
       
  1867             }
       
  1868         }
       
  1869     }
       
  1870 
       
  1871 // ----------------------------------------------------------------------------
       
  1872 // CTmsTestEngine::SetUpLinkG711ALAW
       
  1873 //
       
  1874 // ----------------------------------------------------------------------------
       
  1875 //
       
  1876 void CTmsTestEngine::SetUpLinkG711ALAW()
       
  1877     {
       
  1878     if (iUpLinkCodec == TMS_FORMAT_G711)
       
  1879         {
       
  1880         static_cast<TMSG711Format*> (iEncFormatIntfc)->SetMode(
       
  1881                 TMS_G711_CODEC_MODE_ALAW);
       
  1882         DisplayText("UPL G.711 Mode Set: [aLaw]");
       
  1883         }
       
  1884     }
       
  1885 
       
  1886 // ----------------------------------------------------------------------------
       
  1887 // CTmsTestEngine::SetUpLinkG711uLAW
       
  1888 //
       
  1889 // ----------------------------------------------------------------------------
       
  1890 //
       
  1891 void CTmsTestEngine::SetUpLinkG711uLAW()
       
  1892     {
       
  1893 
       
  1894     if (iUpLinkCodec == TMS_FORMAT_G711)
       
  1895         {
       
  1896         static_cast<TMSG711Format*> (iEncFormatIntfc)->SetMode(
       
  1897                 TMS_G711_CODEC_MODE_MULAW);
       
  1898         DisplayText("UPL G.711 Mode Set: [uLaw]");
       
  1899         }
       
  1900     }
       
  1901 
       
  1902 // ----------------------------------------------------------------------------
       
  1903 // CTmsTestEngine::GetUpLinkG711Mode
       
  1904 //
       
  1905 // ----------------------------------------------------------------------------
       
  1906 //
       
  1907 void CTmsTestEngine::GetUpLinkG711Mode()
       
  1908     {
       
  1909     gint status(TMS_RESULT_SUCCESS);
       
  1910     if (iUpLinkCodec == TMS_FORMAT_G711)
       
  1911         {
       
  1912         TMSG711CodecMode mode;
       
  1913         status = static_cast<TMSG711Format*> (iEncFormatIntfc)->GetMode(mode);
       
  1914 
       
  1915         if (status == TMS_RESULT_SUCCESS)
       
  1916             {
       
  1917             if (mode == TMS_G711_CODEC_MODE_MULAW)
       
  1918                 {
       
  1919                 DisplayText("UPL G.711 Mode: [uLaw]");
       
  1920                 }
       
  1921             else if (mode == TMS_G711_CODEC_MODE_ALAW)
       
  1922                 {
       
  1923                 DisplayText("UPL G.711 Mode: [aLaw]");
       
  1924                 }
       
  1925             }
       
  1926         else
       
  1927             {
       
  1928             DisplayText("UPL G.711 GetMode Error: ", status);
       
  1929             }
       
  1930         }
       
  1931     }
       
  1932 
       
  1933 // ----------------------------------------------------------------------------
       
  1934 // CTmsTestEngine::SetUpLinkILBC20MS
       
  1935 //
       
  1936 // ----------------------------------------------------------------------------
       
  1937 //
       
  1938 void CTmsTestEngine::SetUpLinkILBC20MS()
       
  1939     {
       
  1940     if (iUpLinkCodec == TMS_FORMAT_ILBC)
       
  1941         {
       
  1942         static_cast<TMSILBCFormat*> (iEncFormatIntfc)->SetMode(
       
  1943                 TMS_ILBC_CODEC_MODE_20MS_FRAME);
       
  1944         DisplayText("UPL iLBC Mode Set: [20ms]");
       
  1945         }
       
  1946     }
       
  1947 
       
  1948 // ----------------------------------------------------------------------------
       
  1949 // CTmsTestEngine::SetUpLinkILBC30MS
       
  1950 //
       
  1951 // ----------------------------------------------------------------------------
       
  1952 //
       
  1953 void CTmsTestEngine::SetUpLinkILBC30MS()
       
  1954     {
       
  1955     if (iUpLinkCodec == TMS_FORMAT_ILBC)
       
  1956         {
       
  1957         static_cast<TMSILBCFormat*> (iEncFormatIntfc)->SetMode(
       
  1958                 TMS_ILBC_CODEC_MODE_30MS_FRAME);
       
  1959         DisplayText("UPL iLBC Mode Set: [30ms]");
       
  1960         }
       
  1961     }
       
  1962 
       
  1963 // ----------------------------------------------------------------------------
       
  1964 // CTmsTestEngine::GetUpLinkILBCMode
       
  1965 //
       
  1966 // ----------------------------------------------------------------------------
       
  1967 //
       
  1968 void CTmsTestEngine::GetUpLinkILBCMode()
       
  1969     {
       
  1970     gint status(TMS_RESULT_SUCCESS);
       
  1971     if (iUpLinkCodec == TMS_FORMAT_ILBC)
       
  1972         {
       
  1973         TMSILBCCodecMode mode;
       
  1974         status = static_cast<TMSILBCFormat*> (iEncFormatIntfc)->GetMode(mode);
       
  1975 
       
  1976         if (status == TMS_RESULT_SUCCESS)
       
  1977             {
       
  1978             if (mode == TMS_ILBC_CODEC_MODE_30MS_FRAME)
       
  1979                 {
       
  1980                 DisplayText("UPL iLBC Mode: [30ms]");
       
  1981                 }
       
  1982             else if (mode == TMS_ILBC_CODEC_MODE_20MS_FRAME)
       
  1983                 {
       
  1984                 DisplayText("UPL iLBC Mode: [20ms]");
       
  1985                 }
       
  1986             }
       
  1987         else
       
  1988             {
       
  1989             DisplayText("UPL iLBC GetMode Error: ", status);
       
  1990             }
       
  1991         }
       
  1992     }
       
  1993 
       
  1994 // ----------------------------------------------------------------------------
       
  1995 // CTmsTestEngine::CreateGlobalVol
       
  1996 //
       
  1997 // ----------------------------------------------------------------------------
       
  1998 //
       
  1999 void CTmsTestEngine::CreateGlobalVol()
       
  2000     {
       
  2001     gint status(TMS_RESULT_SUCCESS);
       
  2002 
       
  2003     if (iFactory && !iGlobalVol)
       
  2004         {
       
  2005         status = iFactory->CreateEffect(TMS_EFFECT_GLOBAL_VOL, iGlobalVol);
       
  2006 
       
  2007         if (status == TMS_RESULT_SUCCESS)
       
  2008             {
       
  2009             DisplayText("Global Vol Created");
       
  2010             static_cast<TMSGlobalVolEffect*> (iGlobalVol)->AddObserver(*this,
       
  2011                     NULL);
       
  2012             }
       
  2013         else
       
  2014             {
       
  2015             DisplayText("Global Vol failed: ", status);
       
  2016             }
       
  2017         }
       
  2018     }
       
  2019 
       
  2020 // ----------------------------------------------------------------------------
       
  2021 // CTmsTestEngine::CreateGlobalGain
       
  2022 //
       
  2023 // ----------------------------------------------------------------------------
       
  2024 //
       
  2025 void CTmsTestEngine::CreateGlobalGain()
       
  2026     {
       
  2027     gint status(TMS_RESULT_SUCCESS);
       
  2028 
       
  2029     if (iFactory && !iGlobalGain)
       
  2030         {
       
  2031         status = iFactory->CreateEffect(TMS_EFFECT_GLOBAL_GAIN, iGlobalGain);
       
  2032 
       
  2033         if (status == TMS_RESULT_SUCCESS)
       
  2034             {
       
  2035             DisplayText("Global Gain Created");
       
  2036             static_cast<TMSGlobalGainEffect*> (iGlobalGain)->AddObserver(*this,
       
  2037                     NULL);
       
  2038             }
       
  2039         else
       
  2040             {
       
  2041             DisplayText("Global Gain failed: ", status);
       
  2042             }
       
  2043         }
       
  2044     }
       
  2045 
       
  2046 // ----------------------------------------------------------------------------
       
  2047 // CTmsTestEngine::GetGlobalVol
       
  2048 //
       
  2049 // ----------------------------------------------------------------------------
       
  2050 //
       
  2051 void CTmsTestEngine::GetGlobalVol()
       
  2052     {
       
  2053     if (iGlobalVol)
       
  2054         {
       
  2055         TUint level(0);
       
  2056         static_cast<TMSGlobalVolEffect*> (iGlobalVol)->GetLevel(level);
       
  2057         DisplayText("Global Vol: ", level);
       
  2058         }
       
  2059     }
       
  2060 
       
  2061 // ----------------------------------------------------------------------------
       
  2062 // CTmsTestEngine::GetGlobalMaxVol
       
  2063 //
       
  2064 // ----------------------------------------------------------------------------
       
  2065 //
       
  2066 void CTmsTestEngine::GetGlobalMaxVol()
       
  2067     {
       
  2068     if (iGlobalVol)
       
  2069         {
       
  2070         TUint level(0);
       
  2071         static_cast<TMSGlobalVolEffect*> (iGlobalVol)->GetMaxLevel(level);
       
  2072         DisplayText("Global Max Vol: ", level);
       
  2073         }
       
  2074     }
       
  2075 
       
  2076 // ----------------------------------------------------------------------------
       
  2077 // CTmsTestEngine::SetGlobalVol
       
  2078 //
       
  2079 // ----------------------------------------------------------------------------
       
  2080 //
       
  2081 void CTmsTestEngine::SetGlobalVol()
       
  2082     {
       
  2083     TUint level(0);
       
  2084     if (iGlobalVol)
       
  2085         {
       
  2086         static_cast<TMSGlobalVolEffect*> (iGlobalVol)->GetMaxLevel(level);
       
  2087         static_cast<TMSGlobalVolEffect*> (iGlobalVol)->SetLevel(level);
       
  2088         }
       
  2089     }
       
  2090 
       
  2091 // ----------------------------------------------------------------------------
       
  2092 // CTmsTestEngine::GetGlobalGain
       
  2093 //
       
  2094 // ----------------------------------------------------------------------------
       
  2095 //
       
  2096 void CTmsTestEngine::GetGlobalGain()
       
  2097     {
       
  2098     if (iGlobalGain)
       
  2099         {
       
  2100         TUint level(0);
       
  2101         static_cast<TMSGlobalGainEffect*> (iGlobalGain)->GetLevel(level);
       
  2102         DisplayText("Global Gain: ", level);
       
  2103         }
       
  2104     }
       
  2105 
       
  2106 // ----------------------------------------------------------------------------
       
  2107 // CTmsTestEngine::GetGlobalMaxGain
       
  2108 //
       
  2109 // ----------------------------------------------------------------------------
       
  2110 //
       
  2111 void CTmsTestEngine::GetGlobalMaxGain()
       
  2112     {
       
  2113     if (iGlobalGain)
       
  2114         {
       
  2115         TUint level(0);
       
  2116         static_cast<TMSGlobalGainEffect*> (iGlobalGain)->GetMaxLevel(level);
       
  2117         DisplayText("Global Max gain: ", level);
       
  2118         }
       
  2119     }
       
  2120 
       
  2121 // ----------------------------------------------------------------------------
       
  2122 // CTmsTestEngine::SetGlobalGain
       
  2123 //
       
  2124 // ----------------------------------------------------------------------------
       
  2125 //
       
  2126 void CTmsTestEngine::SetGlobalGain()
       
  2127     {
       
  2128     TUint level(0);
       
  2129     if (iGlobalGain)
       
  2130         {
       
  2131         static_cast<TMSGlobalGainEffect*> (iGlobalGain)->GetMaxLevel(level);
       
  2132         static_cast<TMSGlobalGainEffect*> (iGlobalGain)->SetLevel(level);
       
  2133         }
       
  2134     }
       
  2135 
       
  2136 // ----------------------------------------------------------------------------
       
  2137 // CTmsTestEngine::SetOutputDevice
       
  2138 //
       
  2139 // ----------------------------------------------------------------------------
       
  2140 //
       
  2141 void CTmsTestEngine::SetOutputDevice(TMSAudioOutput device)
       
  2142     {
       
  2143     gint status(TMS_RESULT_SUCCESS);
       
  2144 
       
  2145     if (iTmsGlobalRouting)
       
  2146         {
       
  2147         switch (device)
       
  2148             {
       
  2149             case TMS_AUDIO_OUTPUT_NONE:
       
  2150                 status = iTmsGlobalRouting->SetOutput(TMS_AUDIO_OUTPUT_NONE);
       
  2151                 DisplayText("Routing none");
       
  2152                 break;
       
  2153             case TMS_AUDIO_OUTPUT_PUBLIC:
       
  2154                 status = iTmsGlobalRouting->SetOutput(TMS_AUDIO_OUTPUT_PUBLIC);
       
  2155                 DisplayText("Routing public");
       
  2156                 break;
       
  2157             case TMS_AUDIO_OUTPUT_PRIVATE:
       
  2158                 status = iTmsGlobalRouting->SetOutput(TMS_AUDIO_OUTPUT_PRIVATE);
       
  2159                 DisplayText("Routing private");
       
  2160                 break;
       
  2161             case TMS_AUDIO_OUTPUT_HANDSET:
       
  2162                 status = iTmsGlobalRouting->SetOutput(TMS_AUDIO_OUTPUT_HANDSET);
       
  2163                 DisplayText("Routing to handset");
       
  2164                 break;
       
  2165             case TMS_AUDIO_OUTPUT_LOUDSPEAKER:
       
  2166                 status = iTmsGlobalRouting->SetOutput(
       
  2167                         TMS_AUDIO_OUTPUT_LOUDSPEAKER);
       
  2168                 DisplayText("Routing to Loudspeaker");
       
  2169                 break;
       
  2170             case TMS_AUDIO_OUTPUT_WIRED_ACCESSORY:
       
  2171                 status = iTmsGlobalRouting->SetOutput(
       
  2172                         TMS_AUDIO_OUTPUT_WIRED_ACCESSORY);
       
  2173                 DisplayText("Routing to Wired accessory");
       
  2174                 break;
       
  2175             case TMS_AUDIO_OUTPUT_ACCESSORY:
       
  2176                 status = iTmsGlobalRouting->SetOutput(
       
  2177                         TMS_AUDIO_OUTPUT_ACCESSORY);
       
  2178                 DisplayText("Routing to BT accessory");
       
  2179                 break;
       
  2180             case TMS_AUDIO_OUTPUT_ETTY:
       
  2181                 status = iTmsGlobalRouting->SetOutput(TMS_AUDIO_OUTPUT_ETTY);
       
  2182                 DisplayText("Routing to TTY");
       
  2183                 break;
       
  2184             default: // ENoPreference
       
  2185                 DisplayText("Default Device Routing");
       
  2186                 break;
       
  2187             }
       
  2188         }
       
  2189     if (status != TMS_RESULT_SUCCESS)
       
  2190         {
       
  2191         DisplayText("Routing failed: ", status);
       
  2192         }
       
  2193     }
       
  2194 
       
  2195 // ----------------------------------------------------------------------------
       
  2196 // CTmsTestEngine::SetHandset
       
  2197 //
       
  2198 // ----------------------------------------------------------------------------
       
  2199 //
       
  2200 void CTmsTestEngine::SetHandset()
       
  2201     {
       
  2202     gint status(TMS_RESULT_SUCCESS);
       
  2203 
       
  2204     if (iTmsGlobalRouting)
       
  2205         {
       
  2206         status = iTmsGlobalRouting->SetOutput(TMS_AUDIO_OUTPUT_HANDSET);
       
  2207 
       
  2208         if (status != TMS_RESULT_SUCCESS)
       
  2209             {
       
  2210             DisplayText("SetHandSet failed: ", status);
       
  2211             }
       
  2212         else
       
  2213             {
       
  2214             DisplayText("SetHandSet");
       
  2215             }
       
  2216         }
       
  2217     }
       
  2218 
       
  2219 // ----------------------------------------------------------------------------
       
  2220 // CTmsTestEngine::SetLoudSpeaker
       
  2221 //
       
  2222 // ----------------------------------------------------------------------------
       
  2223 //
       
  2224 void CTmsTestEngine::SetLoudSpeaker()
       
  2225     {
       
  2226     gint status(TMS_RESULT_SUCCESS);
       
  2227 
       
  2228     if (iTmsGlobalRouting)
       
  2229         {
       
  2230         status = iTmsGlobalRouting->SetOutput(TMS_AUDIO_OUTPUT_LOUDSPEAKER);
       
  2231 
       
  2232         if (status != TMS_RESULT_SUCCESS)
       
  2233             {
       
  2234             DisplayText("SetLoudSpeaker failed: ", status);
       
  2235             }
       
  2236         else
       
  2237             {
       
  2238             DisplayText("SetLoudSpeaker");
       
  2239             }
       
  2240         }
       
  2241     }
       
  2242 
       
  2243 // ----------------------------------------------------------------------------
       
  2244 // CTmsTestEngine::GetAudioDevice
       
  2245 //
       
  2246 // ----------------------------------------------------------------------------
       
  2247 //
       
  2248 void CTmsTestEngine::GetAudioDevice()
       
  2249     {
       
  2250     TMSAudioOutput device;
       
  2251 
       
  2252     if (iTmsGlobalRouting)
       
  2253         {
       
  2254         iTmsGlobalRouting->GetOutput(device);
       
  2255 #ifdef __TEST_CODE_COVERAGE__
       
  2256         TMSAudioOutput prevdevice;
       
  2257         iTmsGlobalRouting->GetPreviousOutput(prevdevice);
       
  2258 #endif //__TEST_CODE_COVERAGE__
       
  2259 
       
  2260         switch (device)
       
  2261             {
       
  2262             case TMS_AUDIO_OUTPUT_NONE:
       
  2263                 DisplayText("Routing none");
       
  2264                 break;
       
  2265             case TMS_AUDIO_OUTPUT_PUBLIC:
       
  2266                 DisplayText("Routing public");
       
  2267                 break;
       
  2268             case TMS_AUDIO_OUTPUT_PRIVATE:
       
  2269                 DisplayText("Routing private");
       
  2270                 break;
       
  2271             case TMS_AUDIO_OUTPUT_HANDSET:
       
  2272                 DisplayText("Routing to handset");
       
  2273                 break;
       
  2274             case TMS_AUDIO_OUTPUT_LOUDSPEAKER:
       
  2275                 DisplayText("Routing to Loudspeaker");
       
  2276                 break;
       
  2277             case TMS_AUDIO_OUTPUT_WIRED_ACCESSORY:
       
  2278                 DisplayText("Routing to Wired accessory");
       
  2279                 break;
       
  2280             case TMS_AUDIO_OUTPUT_ACCESSORY:
       
  2281                 DisplayText("Routing to BT accessory");
       
  2282                 break;
       
  2283             case TMS_AUDIO_OUTPUT_ETTY:
       
  2284                 DisplayText("Routing to TTY");
       
  2285                 break;
       
  2286             default: // ENoPreference
       
  2287                 DisplayText("Default Device Routing");
       
  2288                 break;
       
  2289             }
       
  2290         }
       
  2291     }
       
  2292 
       
  2293 // ----------------------------------------------------------------------------
       
  2294 // CTmsTestEngine::GetAvailableOutput
       
  2295 //
       
  2296 // ----------------------------------------------------------------------------
       
  2297 //
       
  2298 void CTmsTestEngine::GetAvailableOutput()
       
  2299     {
       
  2300     TInt status(TMS_RESULT_SUCCESS);
       
  2301 
       
  2302     if (iTmsGlobalRouting)
       
  2303         {
       
  2304         status = iTmsGlobalRouting->GetAvailableOutputs(iAvailableoutputs);
       
  2305 
       
  2306         if (status == TMS_RESULT_SUCCESS)
       
  2307             {
       
  2308             DisplayText("Available outputs: ", iAvailableoutputs.size());
       
  2309             std::vector<guint>::iterator outputs = iAvailableoutputs.begin();
       
  2310             for (; outputs < iAvailableoutputs.end(); outputs++)
       
  2311                 {
       
  2312                 DisplayDevice(*outputs);
       
  2313                 }
       
  2314             }
       
  2315         else
       
  2316             {
       
  2317             DisplayText("Available output error: ", status);
       
  2318             }
       
  2319         }
       
  2320     }
       
  2321 
       
  2322 // ----------------------------------------------------------------------------
       
  2323 // CTmsTestEngine::DisplayDevice
       
  2324 //
       
  2325 // ----------------------------------------------------------------------------
       
  2326 //
       
  2327 void CTmsTestEngine::DisplayDevice(TMSAudioOutput device)
       
  2328     {
       
  2329     switch (device)
       
  2330         {
       
  2331         case TMS_AUDIO_OUTPUT_NONE:
       
  2332             DisplayText("none");
       
  2333             break;
       
  2334         case TMS_AUDIO_OUTPUT_PUBLIC:
       
  2335             DisplayText("Public");
       
  2336             break;
       
  2337         case TMS_AUDIO_OUTPUT_PRIVATE:
       
  2338             DisplayText("Private");
       
  2339             break;
       
  2340         case TMS_AUDIO_OUTPUT_HANDSET:
       
  2341             DisplayText("Handset");
       
  2342             break;
       
  2343         case TMS_AUDIO_OUTPUT_LOUDSPEAKER:
       
  2344             DisplayText("Loudspeaker");
       
  2345             break;
       
  2346         case TMS_AUDIO_OUTPUT_WIRED_ACCESSORY:
       
  2347             DisplayText("Wired accessory");
       
  2348             break;
       
  2349         case TMS_AUDIO_OUTPUT_ACCESSORY:
       
  2350             DisplayText("Accessory");
       
  2351             break;
       
  2352         case TMS_AUDIO_OUTPUT_ETTY:
       
  2353             DisplayText("TTY");
       
  2354             break;
       
  2355         default:
       
  2356             break;
       
  2357         }
       
  2358     }
       
  2359 
       
  2360 // ----------------------------------------------------------------------------
       
  2361 // CTmsTestEngine::InitDTMFTonePlayerDnlink
       
  2362 //
       
  2363 // ----------------------------------------------------------------------------
       
  2364 //
       
  2365 void CTmsTestEngine::InitDTMFTonePlayerDnlink()
       
  2366     {
       
  2367     gint status(TMS_RESULT_SUCCESS);
       
  2368     if (iFactory)
       
  2369         {
       
  2370         status = iFactory->CreateDTMF(TMS_STREAM_DOWNLINK, iDTMFTonePlayerDn);
       
  2371         }
       
  2372     if (iDTMFTonePlayerDn && status == TMS_RESULT_SUCCESS)
       
  2373         {
       
  2374         // Note: It is sufficient to register only 1 DTMF observer per client.
       
  2375         // Since callbacks from UPL and DNL DTMF players are handled by the
       
  2376         // same client, and callback mechanism doesn't distinguish between
       
  2377         // UPL and DNL DTMF event, registering same client twice will result
       
  2378         // in duplicated callbacks.
       
  2379         if (iHasDTMFObserver == 0)
       
  2380             {
       
  2381             status = iDTMFTonePlayerDn->AddObserver(*this, NULL);
       
  2382             iHasDTMFObserver++;
       
  2383             }
       
  2384         }
       
  2385     if (status == TMS_RESULT_SUCCESS)
       
  2386         {
       
  2387         DisplayText("DTMF Downlink OK");
       
  2388         }
       
  2389     else
       
  2390         {
       
  2391         DisplayText("DTMF Downlink failed:", status);
       
  2392         }
       
  2393     }
       
  2394 
       
  2395 // ----------------------------------------------------------------------------
       
  2396 // CTmsTestEngine::InitDTMFTonePlayerUplink
       
  2397 //
       
  2398 // ----------------------------------------------------------------------------
       
  2399 //
       
  2400 void CTmsTestEngine::InitDTMFTonePlayerUplink()
       
  2401     {
       
  2402     gint status(TMS_RESULT_SUCCESS);
       
  2403     if (iFactory)
       
  2404         {
       
  2405         status = iFactory->CreateDTMF(TMS_STREAM_UPLINK, iDTMFTonePlayerUp);
       
  2406         }
       
  2407     if (iDTMFTonePlayerUp && status == TMS_RESULT_SUCCESS)
       
  2408         {
       
  2409         // Note: It is sufficient to register only 1 DTMF observer per client.
       
  2410         // Since callbacks from UPL and DNL DTMF players are handled by the
       
  2411         // same client, and callback mechanism doesn't distinguish between
       
  2412         // UPL and DNL DTMF event, registering same client twice will result
       
  2413         // in duplicated callbacks.
       
  2414         if (iHasDTMFObserver == 0)
       
  2415             {
       
  2416             status = iDTMFTonePlayerUp->AddObserver(*this, NULL);
       
  2417             iHasDTMFObserver++;
       
  2418             }
       
  2419         }
       
  2420     if (status == TMS_RESULT_SUCCESS)
       
  2421         {
       
  2422         DisplayText("DTMF Uplink OK");
       
  2423         }
       
  2424     else
       
  2425         {
       
  2426         DisplayText("DTMF Uplink failed: ", status);
       
  2427         }
       
  2428     }
       
  2429 
       
  2430 // ----------------------------------------------------------------------------
       
  2431 // CTmsTestEngine::DTMFTonePlayDnlink
       
  2432 //
       
  2433 // ----------------------------------------------------------------------------
       
  2434 //
       
  2435 void CTmsTestEngine::DTMFTonePlayDnlink()
       
  2436     {
       
  2437     GString* dtmfstring;
       
  2438     gint status(TMS_RESULT_SUCCESS);
       
  2439     if (iDTMFTonePlayerDn)
       
  2440         {
       
  2441         dtmfstring = g_string_new("4723");
       
  2442         status = iDTMFTonePlayerDn->SetTone(dtmfstring);
       
  2443         if (status == TMS_RESULT_SUCCESS)
       
  2444             {
       
  2445             status = iDTMFTonePlayerDn->Start();
       
  2446             if (status != TMS_RESULT_SUCCESS)
       
  2447                 {
       
  2448                 DisplayText("DTMF downlink start failed: ", status);
       
  2449                 }
       
  2450             }
       
  2451         else
       
  2452             {
       
  2453             DisplayText("DTMF downlink settone failed: ", status);
       
  2454             }
       
  2455         g_string_free(dtmfstring, TRUE);
       
  2456         }
       
  2457     else
       
  2458         {
       
  2459         DisplayText("Downlink not ready");
       
  2460         }
       
  2461     }
       
  2462 
       
  2463 // ----------------------------------------------------------------------------
       
  2464 // CTmsTestEngine::DTMFTonePlayUplink
       
  2465 //
       
  2466 // ----------------------------------------------------------------------------
       
  2467 //
       
  2468 void CTmsTestEngine::DTMFTonePlayUplink()
       
  2469     {
       
  2470     GString* dtmfstring;
       
  2471     gint status(TMS_RESULT_SUCCESS);
       
  2472     // Note: uplink must be in the streaming state (disable for testing)
       
  2473     if (iDTMFTonePlayerUp && iUpLinkStatus == EStreaming)
       
  2474         {
       
  2475         dtmfstring = g_string_new("4567890*#123");
       
  2476         //dtmfstring = g_string_append_c(dtmfstring, '4');
       
  2477         status = iDTMFTonePlayerUp->SetTone(dtmfstring);
       
  2478         if (status == TMS_RESULT_SUCCESS)
       
  2479             {
       
  2480 #ifdef __TEST_CODE_COVERAGE__
       
  2481             // CS call only
       
  2482             iDTMFTonePlayerUp->ContinueDTMFStringSending(TRUE);
       
  2483 #endif //__TEST_CODE_COVERAGE__
       
  2484 
       
  2485             status = iDTMFTonePlayerUp->Start();
       
  2486 
       
  2487             if (status != TMS_RESULT_SUCCESS)
       
  2488                 {
       
  2489                 DisplayText("DTMF uplink start failed: ", status);
       
  2490                 }
       
  2491             }
       
  2492         else
       
  2493             {
       
  2494             DisplayText("DTMF uplink settone failed: ", status);
       
  2495             }
       
  2496         g_string_free(dtmfstring, TRUE);
       
  2497         }
       
  2498     else
       
  2499         {
       
  2500         DisplayText("Uplink not ready");
       
  2501         }
       
  2502     }
       
  2503 
       
  2504 // ----------------------------------------------------------------------------
       
  2505 // CTmsTestEngine::CloseDTMFPlayerDnlink
       
  2506 //
       
  2507 // ----------------------------------------------------------------------------
       
  2508 //
       
  2509 void CTmsTestEngine::CloseDTMFPlayerDnlink()
       
  2510     {
       
  2511     if (iFactory && iDTMFTonePlayerDn)
       
  2512         {
       
  2513         iDTMFTonePlayerDn->Stop();
       
  2514         iDTMFTonePlayerDn->RemoveObserver(*this);
       
  2515         iHasDTMFObserver--;
       
  2516         iFactory->DeleteDTMF(iDTMFTonePlayerDn);
       
  2517         }
       
  2518     }
       
  2519 
       
  2520 // ----------------------------------------------------------------------------
       
  2521 // CTmsTestEngine::CloseDTMFPlayerUplink
       
  2522 //
       
  2523 // ----------------------------------------------------------------------------
       
  2524 //
       
  2525 void CTmsTestEngine::CloseDTMFPlayerUplink()
       
  2526     {
       
  2527     if (iFactory && iDTMFTonePlayerUp)
       
  2528         {
       
  2529         iDTMFTonePlayerUp->Stop();
       
  2530         iDTMFTonePlayerUp->RemoveObserver(*this);
       
  2531         iHasDTMFObserver--;
       
  2532         iFactory->DeleteDTMF(iDTMFTonePlayerUp);
       
  2533         }
       
  2534     }
       
  2535 
       
  2536 // ----------------------------------------------------------------------------
       
  2537 // CTmsTestEngine::InitRingTonePlayerFromProfiles
       
  2538 //
       
  2539 // ----------------------------------------------------------------------------
       
  2540 //
       
  2541 void CTmsTestEngine::InitRingTonePlayerFromProfiles()
       
  2542     {
       
  2543     if (iTmsRingTonePlayer)
       
  2544         {
       
  2545         gint status = iTmsRingTonePlayer->Init(TMS_RINGTONE_DEFAULT);
       
  2546         DisplayText("RT Init Profile: ", status);
       
  2547         }
       
  2548     }
       
  2549 
       
  2550 // ----------------------------------------------------------------------------
       
  2551 // CTmsTestEngine::InitRingTonePlayerFromFile
       
  2552 //
       
  2553 // ----------------------------------------------------------------------------
       
  2554 //
       
  2555 void CTmsTestEngine::InitRingTonePlayerFromFile()
       
  2556     {
       
  2557     if (iTmsRingTonePlayer)
       
  2558         {
       
  2559         TBuf<sizeof(KTestFile1)> buf(KTestFile1);
       
  2560         iRTStr = g_string_new_len((gchar*) buf.Ptr(), buf.Length() * 2);
       
  2561         gint status = iTmsRingTonePlayer->Init(TMS_RINGTONE_FILE, iRTStr);
       
  2562         DisplayText("RT Init File: ", status);
       
  2563         g_string_free(iRTStr, TRUE);
       
  2564         iRTStr = NULL;
       
  2565         }
       
  2566     }
       
  2567 
       
  2568 // ----------------------------------------------------------------------------
       
  2569 // CTmsTestEngine::InitRingToneVideoPlayer
       
  2570 //
       
  2571 // ----------------------------------------------------------------------------
       
  2572 //
       
  2573 void CTmsTestEngine::InitRingToneVideoPlayer()
       
  2574     {
       
  2575     }
       
  2576 
       
  2577 // ----------------------------------------------------------------------------
       
  2578 // CTmsTestEngine::InitRingToneSequencePlayer
       
  2579 // Creates sequence player to play custom sequence in descriptor format
       
  2580 // ----------------------------------------------------------------------------
       
  2581 //
       
  2582 void CTmsTestEngine::InitRingToneSequencePlayer()
       
  2583     {
       
  2584     if (iTmsRingTonePlayer)
       
  2585         {
       
  2586         TBuf8<sizeof(KRTBeepSequence)> buf(KRTBeepSequence);
       
  2587         iRTStr = g_string_new_len((gchar*) buf.Ptr(), buf.Length());
       
  2588         gint status = iTmsRingTonePlayer->Init(TMS_RINGTONE_SEQUENCE, iRTStr);
       
  2589         DisplayText("RT Init Sequence:", status);
       
  2590         g_string_free(iRTStr, TRUE);
       
  2591         }
       
  2592     }
       
  2593 
       
  2594 // ----------------------------------------------------------------------------
       
  2595 // CTmsTestEngine::InitRingToneBeepOnce
       
  2596 // Creates sequence player to play single beep
       
  2597 // ----------------------------------------------------------------------------
       
  2598 //
       
  2599 void CTmsTestEngine::InitRingToneBeepOnce()
       
  2600     {
       
  2601     if (iTmsRingTonePlayer)
       
  2602         {
       
  2603         gint status = iTmsRingTonePlayer->Init(TMS_RINGTONE_BEEP_ONCE);
       
  2604         DisplayText("RT Init BeepOnce: ", status);
       
  2605         }
       
  2606     }
       
  2607 
       
  2608 // ----------------------------------------------------------------------------
       
  2609 // CTmsTestEngine::InitRingToneSilent
       
  2610 // Creates sequence player to play silent tone
       
  2611 // ----------------------------------------------------------------------------
       
  2612 //
       
  2613 void CTmsTestEngine::InitRingToneSilent()
       
  2614     {
       
  2615     if (iTmsRingTonePlayer)
       
  2616         {
       
  2617         gint status = iTmsRingTonePlayer->Init(TMS_RINGTONE_SILENT);
       
  2618         DisplayText("RT Init Silent: ", status);
       
  2619         }
       
  2620     }
       
  2621 
       
  2622 // ----------------------------------------------------------------------------
       
  2623 // CTmsTestEngine::InitRingToneUnsecureVoIP
       
  2624 // Creates sequence player to play tone for unsecured VoIP call.
       
  2625 // ----------------------------------------------------------------------------
       
  2626 //
       
  2627 void CTmsTestEngine::InitRingToneUnsecureVoIP()
       
  2628     {
       
  2629     if (iTmsRingTonePlayer)
       
  2630         {
       
  2631         gint status = iTmsRingTonePlayer->Init(TMS_RINGTONE_UNSECURE_VOIP);
       
  2632         DisplayText("RT Init UnsecVoIP: ", status);
       
  2633         }
       
  2634     }
       
  2635 
       
  2636 // ----------------------------------------------------------------------------
       
  2637 // CTmsTestEngine::InitRingToneWithTTS
       
  2638 // Creates sequence player to play default RT with Text-To-Speech
       
  2639 // ----------------------------------------------------------------------------
       
  2640 //
       
  2641 void CTmsTestEngine::InitRingToneWithTTS()
       
  2642     {
       
  2643     if (iTmsRingTonePlayer)
       
  2644         {
       
  2645         TBuf<sizeof(KTextToSpeak)> buf(KTextToSpeak);
       
  2646         iTTSStr = g_string_new_len((gchar*) buf.Ptr(), buf.Length() * 2);
       
  2647         gint status = iTmsRingTonePlayer->Init(TMS_RINGTONE_DEFAULT, NULL,
       
  2648                 iTTSStr);
       
  2649         DisplayText("RT Init TTS:", status);
       
  2650         g_string_free(iTTSStr, TRUE);
       
  2651         }
       
  2652     iTTSStr = NULL;
       
  2653     }
       
  2654 
       
  2655 // ----------------------------------------------------------------------------
       
  2656 // CTmsTestEngine::PlayRingTone
       
  2657 //
       
  2658 // ----------------------------------------------------------------------------
       
  2659 //
       
  2660 void CTmsTestEngine::PlayRingTone()
       
  2661     {
       
  2662     if (iTmsRingTonePlayer)
       
  2663         {
       
  2664         iTmsRingTonePlayer->Play();
       
  2665         }
       
  2666     }
       
  2667 
       
  2668 // ----------------------------------------------------------------------------
       
  2669 // CTmsTestEngine::StopRingTone
       
  2670 //
       
  2671 // ----------------------------------------------------------------------------
       
  2672 //
       
  2673 void CTmsTestEngine::StopRingTone()
       
  2674     {
       
  2675     if (iTmsRingTonePlayer)
       
  2676         {
       
  2677         iTmsRingTonePlayer->Stop();
       
  2678         }
       
  2679     }
       
  2680 
       
  2681 // ----------------------------------------------------------------------------
       
  2682 // CTmsTestEngine::MuteRingTone
       
  2683 //
       
  2684 // ----------------------------------------------------------------------------
       
  2685 //
       
  2686 void CTmsTestEngine::MuteRingTone()
       
  2687     {
       
  2688     if (iTmsRingTonePlayer)
       
  2689         {
       
  2690         iTmsRingTonePlayer->Mute();
       
  2691         }
       
  2692     }
       
  2693 
       
  2694 // ----------------------------------------------------------------------------
       
  2695 // CTmsTestEngine::PauseVideoRingTone
       
  2696 // Pause audio for video RT only
       
  2697 // ----------------------------------------------------------------------------
       
  2698 //
       
  2699 void CTmsTestEngine::PauseVideoRingTone()
       
  2700     {
       
  2701     if (iTmsRingTonePlayer)
       
  2702         {
       
  2703         iTmsRingTonePlayer->Pause();
       
  2704         }
       
  2705     }
       
  2706 
       
  2707 // ----------------------------------------------------------------------------
       
  2708 // CTmsTestEngine::DeinitRingTonePlayer
       
  2709 //
       
  2710 // ----------------------------------------------------------------------------
       
  2711 //
       
  2712 void CTmsTestEngine::DeinitRingTonePlayer()
       
  2713     {
       
  2714     if (iTmsRingTonePlayer)
       
  2715         {
       
  2716         iTmsRingTonePlayer->Deinit();
       
  2717         }
       
  2718     }
       
  2719 
       
  2720 // ----------------------------------------------------------------------------
       
  2721 // CTmsTestEngine::CloseRingTonePlayer
       
  2722 //
       
  2723 // ----------------------------------------------------------------------------
       
  2724 //
       
  2725 void CTmsTestEngine::CloseRingTonePlayer()
       
  2726     {
       
  2727     if (iFactory && iTmsRingTonePlayer)
       
  2728         {
       
  2729         DeinitRingTonePlayer();
       
  2730         iTmsRingTonePlayer->RemoveObserver(*this);
       
  2731         iFactory->DeleteRingTonePlayer(iTmsRingTonePlayer);
       
  2732         DisplayText("RT Player Closed");
       
  2733         }
       
  2734     }
       
  2735 
       
  2736 // ----------------------------------------------------------------------------
       
  2737 // CTmsTestEngine::CreateInbandTonePlayer
       
  2738 //
       
  2739 // ----------------------------------------------------------------------------
       
  2740 //
       
  2741 void CTmsTestEngine::CreateInbandTonePlayer()
       
  2742     {
       
  2743     gint status(TMS_RESULT_SUCCESS);
       
  2744     if (iFactory && !iInbandTonePlayer)
       
  2745         {
       
  2746         status = iFactory->CreateInbandTonePlayer(iInbandTonePlayer);
       
  2747         if (iInbandTonePlayer && status == TMS_RESULT_SUCCESS)
       
  2748             {
       
  2749             iInbandTonePlayer->AddObserver(*this, NULL);
       
  2750             DisplayText("Inband Tone Player created");
       
  2751             }
       
  2752         else
       
  2753             {
       
  2754             DisplayText("Inband Tone Player failed: ", status);
       
  2755             }
       
  2756         }
       
  2757     }
       
  2758 
       
  2759 // ----------------------------------------------------------------------------
       
  2760 // CTmsTestEngine::StartInbandTone
       
  2761 //
       
  2762 // ----------------------------------------------------------------------------
       
  2763 //
       
  2764 void CTmsTestEngine::StartInbandTone(TMSInbandToneType inbandtone)
       
  2765     {
       
  2766     gint status(TMS_RESULT_SUCCESS);
       
  2767     CreateInbandTonePlayer();
       
  2768     if (iFactory && iInbandTonePlayer)
       
  2769         {
       
  2770         status = iInbandTonePlayer->Start(inbandtone);
       
  2771         if (status == TMS_RESULT_SUCCESS)
       
  2772             {
       
  2773             DisplayText("Inband Tone Player Start");
       
  2774             }
       
  2775         else
       
  2776             {
       
  2777             DisplayText("Inband tone failed: ", status);
       
  2778             }
       
  2779         }
       
  2780     }
       
  2781 
       
  2782 // ----------------------------------------------------------------------------
       
  2783 // CTmsTestEngine::StopInbandTone
       
  2784 //
       
  2785 // ----------------------------------------------------------------------------
       
  2786 //
       
  2787 void CTmsTestEngine::StopInbandTone()
       
  2788     {
       
  2789     gint status(TMS_RESULT_SUCCESS);
       
  2790     if (iFactory && iInbandTonePlayer)
       
  2791         {
       
  2792         status = iInbandTonePlayer->Stop();
       
  2793         if (status == TMS_RESULT_SUCCESS)
       
  2794             {
       
  2795             DisplayText("Inband Tone Player Stop");
       
  2796             }
       
  2797         else
       
  2798             {
       
  2799             DisplayText("Inband tone failed: ", status);
       
  2800             }
       
  2801         }
       
  2802     }
       
  2803 
       
  2804 // ----------------------------------------------------------------------------
       
  2805 // CTmsTestEngine::OneTouchLoopback
       
  2806 //
       
  2807 // ----------------------------------------------------------------------------
       
  2808 //
       
  2809 void CTmsTestEngine::OneTouchLoopback()
       
  2810     {
       
  2811     iOneTouchLoopback = ETrue;
       
  2812 
       
  2813     // Change between CS and IP call type for testing.
       
  2814     //SetCallType(TMS_CALL_CS); //will activate streams
       
  2815     SetCallType(TMS_CALL_IP);
       
  2816 
       
  2817     if (iTmsCall->GetCallType() == TMS_CALL_IP)
       
  2818         {
       
  2819 #ifdef __WINSCW__
       
  2820         SetDownlinkFormat(TMS_FORMAT_PCM);
       
  2821         SetUplinkFormat(TMS_FORMAT_PCM);
       
  2822 #else  //__WINSCW__
       
  2823         SetDownlinkFormat(TMS_FORMAT_AMR);
       
  2824         SetUplinkFormat(TMS_FORMAT_AMR);
       
  2825 #endif //__WINSCW__
       
  2826         }
       
  2827     }
       
  2828 
       
  2829 // ----------------------------------------------------------------------------
       
  2830 // CTmsTestEngine::DoLoopback
       
  2831 //
       
  2832 // ----------------------------------------------------------------------------
       
  2833 //
       
  2834 void CTmsTestEngine::DoLoopback()
       
  2835     {
       
  2836     if (iPlayBufReady && iRecBufReady)
       
  2837         {
       
  2838         guint8* srcptr(NULL);
       
  2839         guint8* desptr(NULL);
       
  2840         guint srcsize(0);
       
  2841         guint dessize(0);
       
  2842 
       
  2843         iPlayBuf->GetDataPtr(desptr);
       
  2844         iPlayBuf->GetDataSize(dessize);
       
  2845         iRecBuf->GetDataPtr(srcptr);
       
  2846         iRecBuf->GetDataSize(srcsize);
       
  2847 
       
  2848 #ifdef __WINSCW__
       
  2849         // This is the case when the size of the play buffer is larger than
       
  2850         // the size of the recorded buffer. In WINS, DirectX views partially
       
  2851         // filled buffers as an EOS and throws (-10). So, we will collect
       
  2852         // multiple buffers here.
       
  2853         Mem::Copy(desptr + iBufIndex, srcptr, srcsize);
       
  2854         iBufIndex += srcsize;
       
  2855         if (iBufIndex >= dessize)
       
  2856             {
       
  2857             iPlayBuf->SetDataSize(dessize);
       
  2858             static_cast<TMSClientSource*> (iTmsClientSource)->BufferFilled(
       
  2859                     *iPlayBuf);
       
  2860             iPlayBufReady = EFalse; // buf filled, ready for next FillBuffer
       
  2861             iBufIndex = 0;
       
  2862             }
       
  2863 #else //__WINSCW__
       
  2864         Mem::Copy(desptr, srcptr, srcsize);
       
  2865         iPlayBuf->SetDataSize(srcsize);
       
  2866         static_cast<TMSClientSource*> (iTmsClientSource)->BufferFilled(
       
  2867                 *iPlayBuf);
       
  2868         iPlayBufReady = EFalse; // buf filled, ready for FillBuffer
       
  2869 #endif //__WINSCW__
       
  2870         iRecBufReady = EFalse; // buf consumed, ready for next EmptyBuffer
       
  2871         }
       
  2872     }
       
  2873 
       
  2874 // ----------------------------------------------------------------------------
       
  2875 // CTmsTestEngine::EndCall
       
  2876 //
       
  2877 // ----------------------------------------------------------------------------
       
  2878 //
       
  2879 void CTmsTestEngine::EndCall()
       
  2880     {
       
  2881     StopUplink();
       
  2882     StopDownlink();
       
  2883     CloseUplink();
       
  2884     CloseDownlink();
       
  2885     CloseDTMFPlayerUplink();
       
  2886     CloseDTMFPlayerDnlink();
       
  2887 
       
  2888     if (iTmsUplink && iTmsCall)
       
  2889         {
       
  2890         iTmsCall->DeleteStream(iTmsUplink);
       
  2891         }
       
  2892     if (iTmsDnlink && iTmsCall)
       
  2893         {
       
  2894         iTmsCall->DeleteStream(iTmsDnlink);
       
  2895         }
       
  2896     if (iFactory && iTmsCall)
       
  2897         {
       
  2898         iFactory->DeleteCall(iTmsCall);
       
  2899         }
       
  2900     if (iFactory && iTmsClientSource)
       
  2901         {
       
  2902         if (iCallType == TMS_CALL_IP)
       
  2903             {
       
  2904             static_cast<TMSClientSource*> (iTmsClientSource)->RemoveObserver(
       
  2905                     *this);
       
  2906             }
       
  2907         iFactory->DeleteSource(iTmsClientSource);
       
  2908         }
       
  2909     if (iFactory && iTmsMicSource)
       
  2910         {
       
  2911         iFactory->DeleteSource(iTmsMicSource);
       
  2912         }
       
  2913     if (iFactory && iTmsModemSource)
       
  2914         {
       
  2915         iFactory->DeleteSource(iTmsModemSource);
       
  2916         }
       
  2917     if (iFactory && iTmsClientSink)
       
  2918         {
       
  2919         if (iCallType == TMS_CALL_IP)
       
  2920             {
       
  2921             static_cast<TMSClientSink*> (iTmsClientSink)->RemoveObserver(*this);
       
  2922             }
       
  2923         iFactory->DeleteSink(iTmsClientSink);
       
  2924         }
       
  2925     if (iFactory && iTmsSpeakerSink)
       
  2926         {
       
  2927         iFactory->DeleteSink(iTmsSpeakerSink);
       
  2928         }
       
  2929     if (iFactory && iTmsModemSink)
       
  2930         {
       
  2931         iFactory->DeleteSink(iTmsModemSink);
       
  2932         }
       
  2933     if (iFactory && iTmsDnlinkEffect)
       
  2934         {
       
  2935         static_cast<TMSVolumeEffect*> (iTmsDnlinkEffect)->RemoveObserver(*this);
       
  2936         iFactory->DeleteEffect(iTmsDnlinkEffect);
       
  2937         }
       
  2938     if (iFactory && iTmsUplinkEffect)
       
  2939         {
       
  2940         static_cast<TMSGainEffect*> (iTmsUplinkEffect)->RemoveObserver(*this);
       
  2941         iFactory->DeleteEffect(iTmsUplinkEffect);
       
  2942         }
       
  2943     if (iFactory && iEncFormatIntfc)
       
  2944         {
       
  2945         iFactory->DeleteFormat(iEncFormatIntfc);
       
  2946         }
       
  2947     if (iFactory && iDecFormatIntfc)
       
  2948         {
       
  2949         iFactory->DeleteFormat(iDecFormatIntfc);
       
  2950         }
       
  2951     if (iFactory && iDTMFTonePlayerDn)
       
  2952         {
       
  2953         iFactory->DeleteDTMF(iDTMFTonePlayerDn);
       
  2954         }
       
  2955     if (iFactory && iDTMFTonePlayerUp)
       
  2956         {
       
  2957         iFactory->DeleteDTMF(iDTMFTonePlayerUp);
       
  2958         }
       
  2959     }
       
  2960 
       
  2961 #ifdef __RECORD_WAV_TO_FILE__
       
  2962 void CTmsTestEngine::WriteToFile(const guint8* str, const guint len)
       
  2963     {
       
  2964     TPtrC8 ptr(str, len);
       
  2965     TPtr8 p = iWriteBuf->Des();
       
  2966     p.Copy(ptr);
       
  2967     iFile.Write(p);
       
  2968     }
       
  2969 #endif //__RECORD_WAV_TO_FILE__
       
  2970 
       
  2971 // CALLBACKS
       
  2972 
       
  2973 void CTmsTestEngine::TMSStreamEvent(const TMSStream& stream,
       
  2974         TMSSignalEvent event)
       
  2975     {
       
  2976     switch (const_cast<TMSStream&> (stream).GetStreamType())
       
  2977         {
       
  2978         case TMS_STREAM_UPLINK:
       
  2979             {
       
  2980             switch (event.type)
       
  2981                 {
       
  2982                 case TMS_EVENT_STREAM_STATE_CHANGED:
       
  2983                     {
       
  2984                     switch (event.curr_state)
       
  2985                         {
       
  2986                         case TMS_STREAM_INITIALIZED:
       
  2987                             {
       
  2988 #ifdef __PROFILING_ENABLED__
       
  2989                             TAG_CALLBACK_TIME_PROFILING_END;
       
  2990                             PRINT_CALLBACK_TIME_LATENCY;
       
  2991 #endif //__PROFILING_ENABLED__
       
  2992                             iUpLinkStatus = EReady;
       
  2993                             DisplayText("Uplink initialized ");
       
  2994                             if (iOneTouchLoopback)
       
  2995                                 {
       
  2996                                 StartUplink();
       
  2997                                 }
       
  2998                             break;
       
  2999                             }
       
  3000                         case TMS_STREAM_UNINITIALIZED:
       
  3001                             iTmsUplink->RemoveObserver(*this);
       
  3002                             DisplayText("Uplink uninitialized");
       
  3003                             break;
       
  3004                         case TMS_STREAM_PAUSED:
       
  3005                             DisplayText("Uplink paused");
       
  3006                             break;
       
  3007                         case TMS_STREAM_STARTED:
       
  3008                             DisplayText("Uplink started");
       
  3009                             break;
       
  3010                         default:
       
  3011                             break;
       
  3012                         }
       
  3013                     break;
       
  3014                     }
       
  3015                 case TMS_EVENT_STREAM_STATE_CHANGE_ERROR:
       
  3016                     DisplayText("Uplink Error ", event.reason);
       
  3017                     break;
       
  3018                 default:
       
  3019                     break;
       
  3020                 }
       
  3021             break;
       
  3022             }
       
  3023         case TMS_STREAM_DOWNLINK:
       
  3024             {
       
  3025             switch (event.type)
       
  3026                 {
       
  3027                 case TMS_EVENT_STREAM_STATE_CHANGED:
       
  3028                     {
       
  3029                     switch (event.curr_state)
       
  3030                         {
       
  3031                         case TMS_STREAM_INITIALIZED:
       
  3032                             {
       
  3033 #ifdef __PROFILING_ENABLED__
       
  3034                             TAG_CALLBACK_TIME_PROFILING_END;
       
  3035                             PRINT_CALLBACK_TIME_LATENCY;
       
  3036                             TAG_CALLBACK_TIME_PROFILING_START;
       
  3037 #endif //__PROFILING_ENABLED__
       
  3038                             GetMaxVolume();
       
  3039                             SetVolume(iMaxVolume / 2);
       
  3040                             iDnLinkStatus = EReady;
       
  3041                             DisplayText("Downlink initialized");
       
  3042                             if (iOneTouchLoopback)
       
  3043                                 {
       
  3044 #ifndef __WINSCW__
       
  3045                                 // No audio mixing in WINS - do not start
       
  3046                                 StartDownlink();
       
  3047 #endif //__WINSCW__
       
  3048                                 }
       
  3049                             break;
       
  3050                             }
       
  3051                         case TMS_STREAM_UNINITIALIZED:
       
  3052                             iTmsDnlink->RemoveObserver(*this);
       
  3053                             DisplayText("Downlink uninitialized");
       
  3054                             break;
       
  3055                         case TMS_STREAM_PAUSED:
       
  3056                             DisplayText("Downlink paused");
       
  3057                             break;
       
  3058                         case TMS_STREAM_STARTED:
       
  3059                             DisplayText("Downlink started");
       
  3060                             break;
       
  3061                         default:
       
  3062                             break;
       
  3063                         }
       
  3064                     break;
       
  3065                     }
       
  3066                 case TMS_EVENT_STREAM_STATE_CHANGE_ERROR:
       
  3067                     DisplayText("Downlink Error ", event.reason);
       
  3068                     break;
       
  3069                 default:
       
  3070                     break;
       
  3071                 }
       
  3072             break;
       
  3073             }
       
  3074         default:
       
  3075             break;
       
  3076         }
       
  3077     }
       
  3078 
       
  3079 //From TMSClientSourceObserver
       
  3080 void CTmsTestEngine::FillBuffer(TMSBuffer& buffer)
       
  3081     {
       
  3082     iPlayBufReady = ETrue;
       
  3083     iPlayBuf = &buffer;
       
  3084 
       
  3085 #ifdef __PLAY_WAV_FROM_FILE__
       
  3086     guint8* gptr(NULL);
       
  3087     iPlayBuf->GetDataPtr(gptr);
       
  3088     guint gsize;
       
  3089     iPlayBuf->GetDataSize(gsize);
       
  3090     if (!iBuf)
       
  3091         {
       
  3092         iBuf = HBufC8::NewL(gsize);
       
  3093         }
       
  3094     TPtr8 p = iBuf->Des();
       
  3095 
       
  3096     if ((iReadPos + gsize) > iFileLen)
       
  3097         {
       
  3098         gsize = iFileLen - iReadPos;
       
  3099         iEOF = ETrue;
       
  3100         }
       
  3101 
       
  3102     iFile.Read(iReadPos, p, gsize);
       
  3103     //  DEBPRN1(_L("CVoIPTestEngine[0x%x]::FillBuffer [%d]"), iReadPos);
       
  3104 
       
  3105     if (!iEOF)
       
  3106         {
       
  3107         iReadPos += gsize;
       
  3108         }
       
  3109     else
       
  3110         {
       
  3111         // start over from the beginning
       
  3112         iReadPos = 0;
       
  3113         iEOF = EFalse;
       
  3114         }
       
  3115 
       
  3116     Mem::Copy(gptr, (TUint8*) iBuf->Ptr(), iBuf->Size());
       
  3117     iPlayBuf->SetDataSize(iBuf->Size());
       
  3118     static_cast<TMSClientSource*> (iTmsClientSource)->BufferFilled(*iPlayBuf);
       
  3119     User::After(TTimeIntervalMicroSeconds32(100000)); //clears choppy audio
       
  3120 
       
  3121     iPlayBufReady = EFalse; // buf filled, ready for FillBuffer
       
  3122     iRecBufReady = EFalse; // buf consumed, ready for EmptyBuffer
       
  3123 
       
  3124 #else //__PLAY_WAV_FROM_FILE__
       
  3125     if (iDnLinkStatus == EStreaming)
       
  3126         {
       
  3127         DoLoopback();
       
  3128         }
       
  3129 #endif //__PLAY_WAV_FROM_FILE__
       
  3130     }
       
  3131 
       
  3132 //From TMSClientSourceObserver
       
  3133 void CTmsTestEngine::BufferProcessed(const TMSBuffer* /*buffer*/,
       
  3134         gint /*reason*/)
       
  3135     {
       
  3136     }
       
  3137 
       
  3138 // From TMSClientSinkObserver
       
  3139 void CTmsTestEngine::ProcessBuffer(const TMSBuffer* buffer)
       
  3140     {
       
  3141     iRecBufReady = ETrue;
       
  3142     iRecBuf = const_cast<TMSBuffer*> (buffer);
       
  3143 
       
  3144     if (iUpLinkStatus == EStreaming)
       
  3145         {
       
  3146         // Process recorded buffer here.
       
  3147 
       
  3148 #ifdef __RECORD_WAV_TO_FILE__
       
  3149         guint8* p(NULL);
       
  3150         guint len(0);
       
  3151         iRecBuf->GetDataPtr(p);
       
  3152         iRecBuf->GetDataSize(len);
       
  3153         WriteToFile(p, len);
       
  3154 #endif //__RECORD_WAV_TO_FILE__
       
  3155 
       
  3156         DoLoopback();
       
  3157         static_cast<TMSClientSink*> (iTmsClientSink)->BufferProcessed(iRecBuf);
       
  3158         }
       
  3159     }
       
  3160 
       
  3161 // From TMSEffectObserver
       
  3162 void CTmsTestEngine::EffectsEvent(const TMSEffect& tmseffect,
       
  3163         TMSSignalEvent event)
       
  3164     {
       
  3165     gint reason = event.reason;
       
  3166 
       
  3167     if (reason == TMS_RESULT_SUCCESS)
       
  3168         {
       
  3169         TMSEffectType effecttype;
       
  3170         const_cast<TMSEffect&> (tmseffect).GetType(effecttype);
       
  3171         switch (effecttype)
       
  3172             {
       
  3173             case TMS_EFFECT_GLOBAL_VOL:
       
  3174                 {
       
  3175                 switch (event.type)
       
  3176                     {
       
  3177                     case TMS_EVENT_EFFECT_VOL_CHANGED:
       
  3178                         DisplayText("Global vol effect change");
       
  3179                         TMSVolumeEventChangeData* vd;
       
  3180                         vd = static_cast<TMSVolumeEventChangeData*>
       
  3181                                 (event.event_data);
       
  3182                         DisplayText("Volume level: ", vd->level);
       
  3183                         DisplayText("Output device: ", vd->output);
       
  3184                         break;
       
  3185                     default:
       
  3186                         break;
       
  3187                     }
       
  3188                 }
       
  3189                 break;
       
  3190             case TMS_EFFECT_GLOBAL_GAIN:
       
  3191                 {
       
  3192                 switch (event.type)
       
  3193                     {
       
  3194                     case TMS_EVENT_EFFECT_GAIN_CHANGED:
       
  3195                         DisplayText("Global gain effect change");
       
  3196                         break;
       
  3197                     default:
       
  3198                         break;
       
  3199                     }
       
  3200                 }
       
  3201                 break;
       
  3202             case TMS_EFFECT_VOLUME:
       
  3203                 {
       
  3204                 switch (event.type)
       
  3205                     {
       
  3206                     case TMS_EVENT_EFFECT_VOL_CHANGED:
       
  3207                         DisplayText("Stream vol effect change");
       
  3208                         break;
       
  3209                     default:
       
  3210                         break;
       
  3211                     }
       
  3212                 }
       
  3213                 break;
       
  3214             case TMS_EFFECT_GAIN:
       
  3215                 {
       
  3216                 switch (event.type)
       
  3217                     {
       
  3218                     case TMS_EVENT_EFFECT_GAIN_CHANGED:
       
  3219                         DisplayText("Stream gain effect change");
       
  3220                         break;
       
  3221                     default:
       
  3222                         break;
       
  3223                     }
       
  3224                 }
       
  3225                 break;
       
  3226             default:
       
  3227                 break;
       
  3228             }
       
  3229         }
       
  3230     else
       
  3231         {
       
  3232         DisplayText("Effect failed: ", reason);
       
  3233         }
       
  3234     }
       
  3235 
       
  3236 // From TMSGlobalRoutingObserver
       
  3237 void CTmsTestEngine::GlobalRoutingEvent(const TMSGlobalRouting& /*routing*/,
       
  3238         TMSSignalEvent event, TMSAudioOutput output)
       
  3239     {
       
  3240     gint reason = event.reason;
       
  3241 
       
  3242     if (reason == TMS_RESULT_SUCCESS)
       
  3243         {
       
  3244         switch (event.type)
       
  3245             {
       
  3246             case TMS_EVENT_ROUTING_AVAIL_OUTPUTS_CHANGED:
       
  3247                 DisplayText("Available outputs changed");
       
  3248                 break;
       
  3249             case TMS_EVENT_ROUTING_OUTPUT_CHANGED:
       
  3250                 DisplayText("output changed");
       
  3251                 break;
       
  3252             case TMS_EVENT_ROUTING_SET_OUTPUT_COMPLETE:
       
  3253                 DisplayText("set output complete");
       
  3254                 break;
       
  3255             default:
       
  3256                 break;
       
  3257             }
       
  3258         DisplayDevice(output);
       
  3259         }
       
  3260     else
       
  3261         {
       
  3262         DisplayText("Routing failed", reason);
       
  3263         }
       
  3264     }
       
  3265 
       
  3266 // From TMSRingToneObserver
       
  3267 void CTmsTestEngine::RingtoneEvent(const TMSRingTone& /*rt*/,
       
  3268         TMSSignalEvent event)
       
  3269     {
       
  3270     gint reason = event.reason;
       
  3271 
       
  3272     if (reason == TMS_RESULT_SUCCESS)
       
  3273         {
       
  3274         switch (event.type)
       
  3275             {
       
  3276             case TMS_EVENT_RINGTONE_OPEN_COMPLETE:
       
  3277                 DisplayText("RT Open Complete");
       
  3278                 break;
       
  3279             case TMS_EVENT_RINGTONE_PLAY_COMPLETE:
       
  3280                 DisplayText("RT Play Complete");
       
  3281                 break;
       
  3282             case TMS_EVENT_RINGTONE_DEINIT_COMPLETE:
       
  3283                 DisplayText("RT Deinit Complete");
       
  3284                 break;
       
  3285             default:
       
  3286                 break;
       
  3287             }
       
  3288         }
       
  3289     else
       
  3290         {
       
  3291         DisplayText("Ringtone failed", reason);
       
  3292         }
       
  3293     }
       
  3294 
       
  3295 // From TMSDTMFObserver
       
  3296 void CTmsTestEngine::DTMFEvent(const TMSDTMF& /*dtmf*/, TMSSignalEvent event)
       
  3297     {
       
  3298     gint reason = event.reason;
       
  3299 
       
  3300     if (reason == TMS_RESULT_SUCCESS)
       
  3301         {
       
  3302         switch (event.type)
       
  3303             {
       
  3304             case TMS_EVENT_DTMF_TONE_STARTED:
       
  3305                 DisplayText("DTMF Started");
       
  3306                 break;
       
  3307             case TMS_EVENT_DTMF_TONE_STOPPED:
       
  3308                 DisplayText("DTMF Stopped");
       
  3309                 break;
       
  3310             default:
       
  3311                 break;
       
  3312             }
       
  3313         }
       
  3314     else
       
  3315         {
       
  3316         DisplayText("DTMF failed", reason);
       
  3317         }
       
  3318     }
       
  3319 
       
  3320 // From TMSInbandToneObserver
       
  3321 void CTmsTestEngine::InbandToneEvent(const TMSInbandTone& /*inbandtone*/,
       
  3322         TMSSignalEvent event)
       
  3323     {
       
  3324     gint reason = event.reason;
       
  3325 
       
  3326     if (reason != TMS_RESULT_SUCCESS)
       
  3327         {
       
  3328         switch (event.type)
       
  3329             {
       
  3330             case TMS_EVENT_INBAND_TONE_STARTED:
       
  3331                 DisplayText("Inband Tone Started");
       
  3332                 break;
       
  3333             case TMS_EVENT_INBAND_TONE_STOPPED:
       
  3334                 DisplayText("Inband Tone Stopped");
       
  3335                 break;
       
  3336             default:
       
  3337                 break;
       
  3338             }
       
  3339         }
       
  3340     else
       
  3341         {
       
  3342         DisplayText("Inband tone failed", reason);
       
  3343         }
       
  3344     }
       
  3345 
       
  3346 // ----------------------------------------------------------------------------
       
  3347 // CTmsTestEngine::DisplayText
       
  3348 // Print text with status code.
       
  3349 // ----------------------------------------------------------------------------
       
  3350 //
       
  3351 void CTmsTestEngine::DisplayText(const QString& str, const gint num)
       
  3352     {
       
  3353     if (num != 0)
       
  3354         {
       
  3355         iStatusDisplay->append(str + " " + QString::number(num));
       
  3356         }
       
  3357     else
       
  3358         {
       
  3359         iStatusDisplay->append(str);
       
  3360         }
       
  3361     }
       
  3362 
       
  3363 // End of file