multimediacommscontroller/tsrc/componenttests/src/test_interface.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006 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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 #include "test_interface.h"
       
    23 #include "mmcccodecinformation.h"
       
    24 #include "mccteststubs.h"
       
    25 #include "mmccinterface.h"
       
    26 #include "testdefinitions.hrh"
       
    27 
       
    28 // ======== MEMBER FUNCTIONS =================================================
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // CTestInterfaceInterface::CTestInterfaceInterface
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CTestInterface::CTestInterface( CConsoleBase& aConsole,
       
    37     const TMccNetSettings& aSettings, CMccInterface& aIF, CMccInterfaceStub& aIFStub )
       
    38     :
       
    39     iConsole( aConsole ), iNetsettings( aSettings ), iInterface( aIF ),
       
    40     iIfStub( aIFStub )
       
    41     {
       
    42     }
       
    43     
       
    44 // ---------------------------------------------------------------------------
       
    45 // CTestInterface::ConstructL
       
    46 // Symbian 2nd phase constructor can leave.
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 void CTestInterface::ConstructL()
       
    50     {
       
    51     }
       
    52     
       
    53 // ---------------------------------------------------------------------------
       
    54 // CTestInterface::NewL
       
    55 // Static constructor.
       
    56 // ---------------------------------------------------------------------------
       
    57 //   
       
    58 CTestInterface* CTestInterface::NewL( CConsoleBase& aConsole,
       
    59     const TMccNetSettings& aSettings, CMccInterface& aIF, CMccInterfaceStub& aIFStub )
       
    60     {
       
    61     CTestInterface* self 
       
    62         = new ( ELeave ) CTestInterface( aConsole, aSettings, aIF, aIFStub );
       
    63 
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop( self );
       
    67     return self;
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CTestInterface::~CTestInterface
       
    72 // Destructor.
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CTestInterface::~CTestInterface()
       
    76     {
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CTestInterface::DoRunInterfaceTestsL
       
    81 // 
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 void CTestInterface::DoRunInterfaceTestsL()
       
    85     {
       
    86     iConsole.ClearScreen();
       
    87     iConsole.Printf( _L("\n*** INTERFACE TESTS ***\n") );
       
    88     
       
    89     TInt err( KErrNone );
       
    90     iConsole.Printf( _L("GET CAPABILITIES\n") );
       
    91     RDebug::Print( _L("Mcc_COM_TEST_START: TestGetCapabilitiesL") );
       
    92     __UHEAP_MARK;
       
    93     TRAP( err, TestGetCapabilitiesL() );
       
    94     __UHEAP_MARKEND;
       
    95     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestGetCapabilitiesL, ERR: %d"), err );
       
    96     
       
    97     
       
    98     iConsole.Printf( _L("CREATE SINGLE SESSION\n") );
       
    99     RDebug::Print( _L("Mcc_COM_TEST_START: TestSingleSessionCreationL") );
       
   100     __UHEAP_MARK;
       
   101     TRAP( err, TestSingleSessionCreationL() );
       
   102     __UHEAP_MARKEND;
       
   103     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSingleSessionCreationL, ERR: %d"), err );
       
   104 
       
   105 
       
   106     iConsole.Printf( _L("CREATE SINGLE LINK\n") );
       
   107     RDebug::Print( _L("Mcc_COM_TEST_START: TestSingleLinkCreationL") );
       
   108     __UHEAP_MARK;
       
   109     TRAP( err, TestSingleLinkCreationL() );
       
   110     __UHEAP_MARKEND;
       
   111     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSingleLinkCreationL, ERR: %d"), err );
       
   112 
       
   113 
       
   114     iConsole.Printf( _L("CREATE SINGLE STREAM\n") );
       
   115     RDebug::Print( _L("Mcc_COM_TEST_START: TestSingleStreamCreationL") );
       
   116     //__UHEAP_MARK;
       
   117     TRAP( err, TestSingleStreamCreationL() );
       
   118     //__UHEAP_MARKEND;
       
   119     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSingleStreamCreationL, ERR: %d"), err );
       
   120 
       
   121     
       
   122     iConsole.Printf( _L("PREPARE SINGLE STREAM\n") );
       
   123     RDebug::Print( _L("Mcc_COM_TEST_START: TestSingleStreamPreparingL") );
       
   124     __UHEAP_MARK;
       
   125     iConsole.Printf( _L("Audio uplink\n") );
       
   126     TRAP( err, TestSingleStreamPreparingL( KMccLinkGeneral, KMccAudioUplinkStream,
       
   127         KUidMmfAudioInput, KMccRtpSinkUid, KAMRSdpName ) );
       
   128     __UHEAP_MARKEND;
       
   129     
       
   130     
       
   131     iConsole.Printf( _L("Audio downlink\n") );
       
   132     __UHEAP_MARK;
       
   133     TRAP( err, TestSingleStreamPreparingL( KMccLinkGeneral, KMccAudioDownlinkStream,
       
   134         KMccRtpSourceUid, KUidMmfAudioOutput, KAMRSdpName ) );
       
   135     __UHEAP_MARKEND;
       
   136     //TestSingleStreamPreparingL( KPCMUSdpName );
       
   137     //TestSingleStreamPreparingL( KPCMASdpName );
       
   138     //TestSingleStreamPreparingL( KILBCSdpName );
       
   139     //TestSingleStreamPreparingL( KG729SdpName );
       
   140     __UHEAP_MARK;
       
   141     iConsole.Printf( _L("Invalid source/sink 1\n") );
       
   142     // INVALID SOUCE/SINK, SHOULD NOT PASS TEST
       
   143     TRAP( err, TestSingleStreamPreparingL( KMccLinkGeneral, KMccAudioUplinkStream,
       
   144         KMccRtpSourceUid, KUidMmfAudioOutput, KAMRSdpName ) );
       
   145     __UHEAP_MARKEND;
       
   146     __UHEAP_MARK;
       
   147     iConsole.Printf( _L("Invalid source/sink 2\n") );
       
   148     // INVALID SOUCE/SINK, SHOULD NOT PASS TEST
       
   149     TRAP( err, TestSingleStreamPreparingL( KMccLinkGeneral, KMccAudioDownlinkStream,
       
   150         KUidMmfAudioInput, KMccRtpSinkUid, KAMRSdpName ) );
       
   151     __UHEAP_MARKEND;
       
   152     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSingleStreamPreparingL, ERR: %d"), err );
       
   153 
       
   154 
       
   155     iConsole.Printf( _L("PLAY SINGLE STREAM\n") );
       
   156     iConsole.Printf( _L("Audio uplink\n") );
       
   157     RDebug::Print( _L("Mcc_COM_TEST_START: TestSingleStreamPlayingL") );
       
   158     __UHEAP_MARK;
       
   159     TRAP( err, TestSingleStreamPlayingL( KMccLinkGeneral, KMccAudioUplinkStream,
       
   160         KUidMmfAudioInput, KMccRtpSinkUid, KAMRSdpName ) );
       
   161     __UHEAP_MARKEND;
       
   162     __UHEAP_MARK;
       
   163     iConsole.Printf( _L("Audio downlink\n") );
       
   164     TRAP( err, TestSingleStreamPlayingL( KMccLinkGeneral, KMccAudioDownlinkStream,
       
   165         KMccRtpSourceUid, KUidMmfAudioOutput, KAMRSdpName ) );
       
   166     __UHEAP_MARKEND;
       
   167     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSingleStreamPlayingL, ERR: %d"), err );
       
   168     
       
   169 
       
   170     iConsole.Printf( _L("PAUSE SINGLE STREAM\n") );
       
   171     RDebug::Print( _L("Mcc_COM_TEST_START: TestSingleStreamPausingL") );
       
   172     __UHEAP_MARK;
       
   173     iConsole.Printf( _L("Audio uplink\n") );
       
   174     TRAP( err, TestSingleStreamPausingL( KMccLinkGeneral, KMccAudioUplinkStream,
       
   175         KUidMmfAudioInput, KMccRtpSinkUid, KAMRSdpName ) );
       
   176     __UHEAP_MARKEND;
       
   177     __UHEAP_MARK;
       
   178     iConsole.Printf( _L("Audio downlink\n") );
       
   179     TRAP( err, TestSingleStreamPausingL( KMccLinkGeneral, KMccAudioDownlinkStream,
       
   180         KMccRtpSourceUid, KUidMmfAudioOutput, KAMRSdpName ) );
       
   181     __UHEAP_MARKEND;
       
   182     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSingleStreamPausingL, ERR: %d"), err );
       
   183     
       
   184     iConsole.Printf( _L("MUTE AUDIO\n") );
       
   185     RDebug::Print( _L("Mcc_COM_TEST_START: TestAudioMuteL") );
       
   186     //__UHEAP_MARK;
       
   187     TRAP( err, TestAudioMuteL() );
       
   188     //__UHEAP_MARKEND;
       
   189     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestAudioMuteL, ERR: %d"), err );
       
   190     
       
   191     iConsole.Printf( _L("SET CODEC\n") );
       
   192     RDebug::Print( _L("Mcc_COM_TEST_START: TestSetCodecL") );
       
   193     __UHEAP_MARK;
       
   194     TRAP( err, TestSetCodecL() );
       
   195     __UHEAP_MARKEND;
       
   196     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSetCodecL, ERR: %d"), err );
       
   197     
       
   198 
       
   199     iConsole.Printf( _L("GET CODEC\n") );
       
   200     RDebug::Print( _L("Mcc_COM_TEST_START: TestGetCodecL") );
       
   201     //__UHEAP_MARK;
       
   202     TRAP( err, TestGetCodecL() );
       
   203     //__UHEAP_MARKEND;
       
   204     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestGetCodecL, ERR: %d"), err );
       
   205 
       
   206 
       
   207     iConsole.Printf( _L("GET SSRC\n") );
       
   208     RDebug::Print( _L("Mcc_COM_TEST_START: TestGetSSRCL") );
       
   209     __UHEAP_MARK;
       
   210     TRAP( err, TestGetSSRCL() );
       
   211     __UHEAP_MARKEND;
       
   212     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestGetSSRCL, ERR: %d"), err );
       
   213 
       
   214     
       
   215     iConsole.Printf( _L("INACTIVITY TIMER\n") );
       
   216     RDebug::Print( _L("Mcc_COM_TEST_START: TestInactivityTimerL") );
       
   217     __UHEAP_MARK;
       
   218     TRAP( err, TestInactivityTimerL() );
       
   219     __UHEAP_MARKEND;
       
   220     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestInactivityTimerL, ERR: %d"), err );
       
   221     
       
   222     
       
   223     iConsole.Printf( _L("FAST SHUTDOWNS\n") );
       
   224     RDebug::Print( _L("Mcc_COM_TEST_START: TestFastShutdownsL") );
       
   225     //__UHEAP_MARK;
       
   226     TRAP( err, TestFastShutdownsL() );
       
   227     //__UHEAP_MARKEND;
       
   228     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestFastShutdownsL, ERR: %d"), err );
       
   229     
       
   230     
       
   231     iConsole.Printf( _L("CREATE MULTI STREAM/LINK/SESSION\n") );
       
   232     RDebug::Print( _L("Mcc_COM_TEST_START: TestMultiStreamLinkSessionL") );
       
   233     //__UHEAP_MARK;
       
   234     TRAP( err, TestMultiStreamLinkSessionL() );
       
   235     //__UHEAP_MARKEND;
       
   236     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestMultiStreamLinkSessionL, ERR: %d"), err );
       
   237     
       
   238     
       
   239     iConsole.Printf( _L("MULTI STREAM PREPARE\n") );
       
   240     RDebug::Print( _L("Mcc_COM_TEST_START: TestMultiStreamPreparingL") );
       
   241     //__UHEAP_MARK;
       
   242     TRAP( err, TestMultiStreamPreparingL() );
       
   243     //__UHEAP_MARKEND;
       
   244     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestMultiStreamPreparingL, ERR: %d"), err );
       
   245     
       
   246 
       
   247     iConsole.Printf( _L("RESOURCE REUSE\n") );
       
   248     RDebug::Print( _L("Mcc_COM_TEST_START: TestResourceReuseL") );
       
   249     //__UHEAP_MARK;
       
   250     TRAP( err, TestResourceReuseL() );
       
   251     //__UHEAP_MARKEND;
       
   252     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestResourceReuseL, ERR: %d"), err );
       
   253     
       
   254 #ifndef __WINSCW__
       
   255     iConsole.Printf( _L("BASIC AUDIO STREAMING\n") );
       
   256     RDebug::Print( _L("Mcc_COM_TEST_START: TestAudioStreamingL") );
       
   257     //__UHEAP_MARK;
       
   258 
       
   259     TRAP( err, TestAudioStreamingL( KAMRSdpName ) );
       
   260     RDebug::Print( _L("AMR: %d"), err );
       
   261 
       
   262     TRAP( err, TestAudioStreamingL( KILBCSdpName ) );
       
   263     RDebug::Print( _L("iLBC: %d"), err );
       
   264     TRAP( err, TestAudioStreamingL( KPCMUSdpName ) );
       
   265     RDebug::Print( _L("PCMU: %d"), err );
       
   266     TRAP( err, TestAudioStreamingL( KPCMASdpName ) );
       
   267     RDebug::Print( _L("PCMA: %d"), err );
       
   268     TRAP( err, TestAudioStreamingL( KG729SdpName ) );
       
   269     RDebug::Print( _L("G729: %d"), err );
       
   270 
       
   271     //__UHEAP_MARKEND;
       
   272     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestAudioStreamingL, ERR: %d"), err );
       
   273     
       
   274     iConsole.Printf( _L("UP/DOWNLINK PAUSE\n") );
       
   275     RDebug::Print( _L("Mcc_COM_TEST_START: TestMultiStreamPausingL") );
       
   276     //__UHEAP_MARK;
       
   277     TRAP( err, TestMultiStreamPausingL() );
       
   278     //__UHEAP_MARKEND;
       
   279     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestMultiStreamPausingL, ERR: %d"), err );
       
   280 
       
   281     
       
   282     iConsole.Printf( _L("AMR-NB FEC\n") );
       
   283     RDebug::Print( _L("Mcc_COM_TEST_START: TestAmrFecL") );
       
   284     //__UHEAP_MARK;
       
   285     TRAP( err, TestAmrFecL() );
       
   286     //__UHEAP_MARKEND;
       
   287     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestAmrFecL, ERR: %d"), err );
       
   288 
       
   289     
       
   290     iConsole.Printf( _L("2198 REDUNDANCY\n") );
       
   291     RDebug::Print( _L("Mcc_COM_TEST_START: TestRedundancyL") );
       
   292     //__UHEAP_MARK;
       
   293     
       
   294     TRAP( err, TestRedundancyL( KAMRSdpName ) );
       
   295     RDebug::Print( _L("AMR RED: %d"), err );
       
   296 
       
   297     TRAP( err, TestRedundancyL( KPCMASdpName ) );
       
   298     RDebug::Print( _L("PCMU RED: %d"), err );
       
   299     
       
   300     TRAP( err, TestRedundancyL( KPCMUSdpName ) );
       
   301     RDebug::Print( _L("PCMU RED: %d"), err );
       
   302     
       
   303     TRAP( err, TestRedundancyL( KILBCSdpName ) );
       
   304     RDebug::Print( _L("iLBC RED: %d"), err );
       
   305     
       
   306     TRAP( err, TestRedundancyL( KG729SdpName ) );
       
   307     RDebug::Print( _L("G729: %d"), err );
       
   308     
       
   309     //__UHEAP_MARKEND;
       
   310     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestRedundancyL, ERR: %d"), err );
       
   311     
       
   312     iConsole.Printf( _L("AUDIO ROUTING\n") );
       
   313     RDebug::Print( _L("Mcc_COM_TEST_START: TestAudioRoutingL") );
       
   314     //__UHEAP_MARK;
       
   315     //TRAP( err, TestAudioRoutingL() );
       
   316     //__UHEAP_MARKEND;
       
   317     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestAudioRoutingL, ERR: %d"), err );
       
   318     
       
   319 #endif
       
   320     }
       
   321     
       
   322 // ---------------------------------------------------------------------------
       
   323 // CTestInterface::TestGetCapabilitiesL
       
   324 // ---------------------------------------------------------------------------
       
   325 //
       
   326 void CTestInterface::TestGetCapabilitiesL() const
       
   327     {
       
   328     RDebug::Print( _L("CTestInterface::TestGetCapabilitiesL") );
       
   329 
       
   330     RPointerArray<CMccCodecInformation> codecArray;
       
   331     CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray );
       
   332     User::LeaveIfError( iInterface.GetCapabilities( codecArray ) );
       
   333     
       
   334     if ( 0 == codecArray.Count() )
       
   335         {
       
   336         RDebug::Print( _L("CTestInterface::TestGetCapabilitiesL - KErrUnknown") );
       
   337         User::Leave( KErrUnknown );
       
   338         }
       
   339     
       
   340     CleanupStack::PopAndDestroy( &codecArray );
       
   341     }
       
   342     
       
   343 // ---------------------------------------------------------------------------
       
   344 // CTestInterface::TestSingleSessionCreationL
       
   345 // Test explicit/implicit session creation and destruction.
       
   346 // ---------------------------------------------------------------------------
       
   347 //
       
   348 void CTestInterface::TestSingleSessionCreationL()
       
   349     {
       
   350     RDebug::Print( _L("CTestInterface::TestSingleSessionCreationL") );
       
   351 
       
   352     TUint32 sessionId1;
       
   353     User::LeaveIfError( iInterface.CreateSession( sessionId1 ) );
       
   354     User::LeaveIfError( iInterface.CloseSession( sessionId1 ) );
       
   355     
       
   356     TUint32 sessionId2;
       
   357     User::LeaveIfError( iInterface.CreateSession( sessionId2 ) );
       
   358     if ( KErrNone == iInterface.CloseSession( 0 ) )
       
   359         {
       
   360         RDebug::Print( _L("CTestInterface::TestSingleSessionCreationL - KErrUnknown") );
       
   361         User::Leave( KErrUnknown );
       
   362         }
       
   363     
       
   364     User::LeaveIfError( iInterface.CloseSession( sessionId2 ) );
       
   365     }
       
   366 
       
   367 
       
   368 // ---------------------------------------------------------------------------
       
   369 // CTestInterface::TestSingleLinkCreationL
       
   370 // 
       
   371 // ---------------------------------------------------------------------------
       
   372 //
       
   373 void CTestInterface::TestSingleLinkCreationL()
       
   374     {
       
   375     RDebug::Print( _L("CTestInterface::TestSingleLinkCreationL") );
       
   376     
       
   377     TUint32 sessionId;
       
   378     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
   379     
       
   380     RDebug::Print( _L("CTestInterface::TestSingleLinkCreationL KMccLinkGeneral") );
       
   381     TUint32 linkId1;
       
   382     User::LeaveIfError(
       
   383         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId1,
       
   384             iNetsettings ) );
       
   385     iIfStub.WaitForEvent( sessionId, linkId1, 0, KMccLinkCreated );
       
   386     
       
   387     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId1 ) );
       
   388     
       
   389     RDebug::Print( _L( "CTestInterface::TestSingleLinkCreationL KMccLinkLocal" ) );
       
   390     TUint32 linkId2;
       
   391     User::LeaveIfError(
       
   392         iInterface.CreateLink( sessionId, KMccLinkLocal, linkId2,
       
   393             iNetsettings ) );
       
   394     
       
   395     iIfStub.WaitForEvent( sessionId, linkId2, 0, KMccLinkCreated );
       
   396     
       
   397     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId2 ) );
       
   398 
       
   399     TInt err
       
   400         = iInterface.CreateLink( sessionId + 10, KMccLinkLocal, linkId2, iNetsettings );
       
   401     
       
   402     if ( KErrNotFound != err )
       
   403         {
       
   404         User::Leave( KErrTotalLossOfPrecision );
       
   405         }
       
   406     
       
   407     TUint32 linkId3;
       
   408     User::LeaveIfError(
       
   409         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId3,
       
   410             iNetsettings ) );
       
   411     iIfStub.WaitForEvent( sessionId, linkId3, 0, KMccLinkCreated );
       
   412     
       
   413     if ( KErrNone == iInterface.CloseLink( 0, 0 ) )
       
   414         {
       
   415         RDebug::Print( _L("CTestInterface::TestSingleLinkCreationL - KErrUnknown 1") );
       
   416         User::Leave( KErrUnknown );
       
   417         }
       
   418     
       
   419     if ( KErrNone == iInterface.CloseLink( sessionId, 0 ) )
       
   420         {
       
   421         RDebug::Print( _L("CTestInterface::TestSingleLinkCreationL - KErrUnknown 2") );
       
   422         User::Leave( KErrUnknown );
       
   423         }
       
   424     
       
   425     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId3 ) );
       
   426     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
   427     }
       
   428     
       
   429 // ---------------------------------------------------------------------------
       
   430 // CTestInterface::TestSingleStreamCreationL
       
   431 // ---------------------------------------------------------------------------
       
   432 //
       
   433 void CTestInterface::TestSingleStreamCreationL()
       
   434     {
       
   435     TUint32 sessionId;
       
   436     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
   437     
       
   438     RDebug::Print( _L( "CTestInterface::TestSingleStreamCreationL KMccLinkGeneral" ) );
       
   439     TUint32 linkId;
       
   440     User::LeaveIfError(
       
   441         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId,
       
   442             iNetsettings ) );
       
   443     
       
   444     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
   445 
       
   446     // AUDIO UPLINK STREAM CREATION
       
   447     RDebug::Print( _L("CTestInterface::TestSingleStreamCreationL ADD RSC AUDIO UL") );
       
   448     TUint32 rtpSinkId;
       
   449     TUint32 audioSourceId;
       
   450     User::LeaveIfError(
       
   451         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, rtpSinkId ) );
       
   452     User::LeaveIfError(
       
   453         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, audioSourceId ) );
       
   454     
       
   455     RDebug::Print( _L("CTestInterface::TestSingleStreamCreationL CREATE AUDIO UL") );
       
   456     TUint32 streamId1;
       
   457     CMccCodecInformation* codec
       
   458         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
   459     CleanupStack::PushL( codec );
       
   460     
       
   461     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId1, 
       
   462         KMccAudioUplinkStream, *codec ) );
       
   463     
       
   464     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId1 ) );
       
   465     iInterface.RemoveDataSource( sessionId, linkId, streamId1, audioSourceId );
       
   466     iInterface.RemoveDataSink( sessionId, linkId, streamId1, rtpSinkId );
       
   467     
       
   468     // AUDIO DOWNLINK STREAM CREATION
       
   469     RDebug::Print( _L("CTestInterface::TestSingleStreamCreationL ADD RSC AUDIO DL") );
       
   470     TUint32 audioSinkId;
       
   471     TUint32 rtpSourceId;
       
   472     User::LeaveIfError(
       
   473         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, audioSinkId ) );
       
   474     User::LeaveIfError(
       
   475         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, rtpSourceId ) );
       
   476     
       
   477     RDebug::Print( _L("CTestInterface::TestSingleStreamCreationL CREATE AUDIO DL") );
       
   478     TUint32 streamId2;
       
   479     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId2, 
       
   480         KMccAudioDownlinkStream, *codec ) );
       
   481     
       
   482     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId2 ) );
       
   483     iInterface.RemoveDataSink( sessionId, linkId, streamId2, audioSinkId );
       
   484     iInterface.RemoveDataSource( sessionId, linkId, streamId2, rtpSourceId );
       
   485     
       
   486     // AUDIO LOCAL STREAM CREATION
       
   487     
       
   488     // AUDIO DOWNLINK STANDBY STREAM CREATION
       
   489     
       
   490     // VIDEO UPLINK STREAM CREATION
       
   491     
       
   492     // VIDEO DOWNLINK STREAM CREATION
       
   493     
       
   494     // VIDEO LOCAL STREAM CREATION
       
   495     
       
   496     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
   497     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
   498     CleanupStack::PopAndDestroy( codec );
       
   499     }
       
   500 
       
   501 
       
   502 // ---------------------------------------------------------------------------
       
   503 // CTestInterface::TestSingleStreamPreparingL
       
   504 // ---------------------------------------------------------------------------
       
   505 //
       
   506 void CTestInterface::TestSingleStreamPreparingL( TInt aLinkType,
       
   507     TInt aStreamType, TUid aDataSource, TUid aDataSink, const TDesC8& aCodec )
       
   508     {
       
   509     TUint32 sessionId;
       
   510     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
   511     TUint32 linkId;
       
   512     User::LeaveIfError(
       
   513         iInterface.CreateLink( sessionId, aLinkType, linkId, iNetsettings ) );
       
   514     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
   515     
       
   516     // STREAM PREPARING, IMPLICIT ENDPOINT PREPARE
       
   517     RDebug::Print( _L( "CTestInterface::TestSingleStreamPreparingL AUDIO UL, CODEC: %S" ), &aCodec );
       
   518     TUint32 dataSinkId1;
       
   519     TUint32 dataSourceId1;
       
   520     User::LeaveIfError(
       
   521         iInterface.AddDataSink( aDataSink, KNullDesC8, dataSinkId1 ) );
       
   522     User::LeaveIfError(
       
   523         iInterface.AddDataSource( aDataSource, KNullDesC8, dataSourceId1 ) );
       
   524     
       
   525     TUint32 streamId1;
       
   526     CMccCodecInformation* codec
       
   527         = FetchCodecByMimeSubtypeNameL( iInterface, aCodec );
       
   528     CleanupStack::PushL( codec );
       
   529     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId1, 
       
   530         aStreamType, *codec ) );
       
   531     
       
   532     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, streamId1 ) );
       
   533     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPrepared );
       
   534     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPrepared );
       
   535     
       
   536     User::LeaveIfError( iInterface.SetRemoteAddress( sessionId, linkId, 
       
   537         iNetsettings.iRemoteAddress, iNetsettings.iRemoteRtcpPort ) );
       
   538     
       
   539     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, streamId1 ) );
       
   540     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStopped );
       
   541     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStopped );
       
   542 
       
   543     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId1 ) );
       
   544     iInterface.RemoveDataSink( sessionId, linkId, streamId1, dataSinkId1 );
       
   545     iInterface.RemoveDataSource( sessionId, linkId, streamId1, dataSourceId1 );
       
   546 
       
   547     // STREAM PREPARING, EXPLICIT ENDPOINT PREPARE
       
   548     TUint32 streamId2;
       
   549     TUint32 dataSinkId2;
       
   550     TUint32 dataSourceId2;
       
   551     User::LeaveIfError(
       
   552         iInterface.AddDataSink( aDataSink, KNullDesC8, dataSinkId2 ) );
       
   553     User::LeaveIfError(
       
   554         iInterface.AddDataSource( aDataSource, KNullDesC8, dataSourceId2 ) );
       
   555     
       
   556     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId2, 
       
   557         aStreamType, *codec ) );
       
   558     
       
   559     // Network resources must be prepared first
       
   560     TUint32 prepareId1 = ( KMccRtpSinkUid == aDataSink ) ? dataSinkId2 : dataSourceId2;
       
   561     TUint32 prepareId2 = ( prepareId1 == dataSinkId2 ) ? dataSourceId2 : dataSinkId2;
       
   562     User::LeaveIfError( 
       
   563         iInterface.PrepareStream( sessionId, linkId, streamId2, prepareId1 ) );
       
   564     iIfStub.WaitForEvent( sessionId, linkId, streamId2, prepareId1, KMccStreamPrepared );
       
   565     
       
   566     User::LeaveIfError( 
       
   567         iInterface.PrepareStream( sessionId, linkId, streamId2, prepareId2 ) );
       
   568     iIfStub.WaitForEvent( sessionId, linkId, streamId2, prepareId2, KMccStreamPrepared );
       
   569     
       
   570     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId2 ) );
       
   571     iInterface.RemoveDataSink( sessionId, linkId, streamId2, dataSinkId2 );
       
   572     iInterface.RemoveDataSource( sessionId, linkId, streamId2, dataSourceId2 );
       
   573     
       
   574     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
   575     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
   576     CleanupStack::PopAndDestroy( codec );
       
   577     }
       
   578     
       
   579 
       
   580 // ---------------------------------------------------------------------------
       
   581 // CTestInterface::TestSingleStreamPlayingL
       
   582 // ---------------------------------------------------------------------------
       
   583 //
       
   584 void CTestInterface::TestSingleStreamPlayingL( TInt aLinkType,
       
   585     TInt aStreamType, TUid aDataSource, TUid aDataSink, const TDesC8& aCodec )
       
   586     {
       
   587     TUint32 sessionId;
       
   588     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
   589     TUint32 linkId;
       
   590     User::LeaveIfError(
       
   591         iInterface.CreateLink( sessionId, aLinkType, linkId, iNetsettings ) );
       
   592     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
   593             
       
   594     RDebug::Print( _L("CTestInterface::TestSingleStreamPlayingL: %S"), &aCodec );
       
   595     TUint32 dataSinkId1;
       
   596     TUint32 dataSourceId1;
       
   597     User::LeaveIfError(
       
   598         iInterface.AddDataSink( aDataSink, KNullDesC8, dataSinkId1 ) );
       
   599     User::LeaveIfError(
       
   600         iInterface.AddDataSource( aDataSource, KNullDesC8, dataSourceId1 ) );
       
   601     
       
   602     TUint32 streamId1;
       
   603     CMccCodecInformation* codec
       
   604         = FetchCodecByMimeSubtypeNameL( iInterface, aCodec );
       
   605     CleanupStack::PushL( codec );
       
   606     
       
   607     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId1, 
       
   608         aStreamType, *codec ) );
       
   609     
       
   610     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, streamId1 ) );
       
   611     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPrepared );
       
   612     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPrepared );
       
   613 
       
   614     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, streamId1 ) );
       
   615     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStarted );
       
   616     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStarted );
       
   617     
       
   618     iConsole.Printf( _L( "Press a key to stop (1/4)\n" ) );
       
   619     iConsole.Getch();
       
   620     
       
   621     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, streamId1 ) );
       
   622     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStopped );
       
   623     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStopped );
       
   624 
       
   625     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId1 ) );
       
   626     iInterface.RemoveDataSink( sessionId, linkId, streamId1, dataSinkId1 );
       
   627     iInterface.RemoveDataSource( sessionId, linkId, streamId1, dataSourceId1 );
       
   628     // STREAM DESTRUCTION FROM PLAYING STATE
       
   629 /*
       
   630     TUint32 dataSinkId2;
       
   631     TUint32 dataSourceId2;
       
   632     User::LeaveIfError(
       
   633         iInterface.AddDataSink( aDataSink, KNullDesC8, dataSinkId2 ) );
       
   634     User::LeaveIfError(
       
   635         iInterface.AddDataSource( aDataSource, KNullDesC8, dataSourceId2 ) );
       
   636     
       
   637     TUint32 streamId2;
       
   638     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId2, 
       
   639         aStreamType, *codec ) );
       
   640     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, streamId2 ) );
       
   641     iIfStub.WaitForEvent( sessionId, linkId, streamId2, KMccStreamPrepared );
       
   642     iIfStub.WaitForEvent( sessionId, linkId, streamId2, KMccStreamPrepared );
       
   643     
       
   644     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, streamId2 ) );
       
   645     iIfStub.WaitForEvent( sessionId, linkId, streamId2, KMccStreamStarted );
       
   646     iIfStub.WaitForEvent( sessionId, linkId, streamId2, KMccStreamStarted );
       
   647     
       
   648     iConsole.Printf( _L( "Press a key to stop (2/4)\n" ) );
       
   649     iConsole.Getch();
       
   650     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId2 ) );
       
   651 */
       
   652 
       
   653     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
   654     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
   655     CleanupStack::PopAndDestroy( codec );
       
   656     }
       
   657     
       
   658 // ---------------------------------------------------------------------------
       
   659 // CTestInterface::TestSingleStreamPausingL
       
   660 // ---------------------------------------------------------------------------
       
   661 //
       
   662 void CTestInterface::TestSingleStreamPausingL( TInt aLinkType,
       
   663     TInt aStreamType, TUid aDataSource, TUid aDataSink, const TDesC8& aCodec )
       
   664     {
       
   665     TUint32 sessionId;
       
   666     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
   667     TUint32 linkId;
       
   668     User::LeaveIfError(
       
   669         iInterface.CreateLink( sessionId, aLinkType, linkId, iNetsettings ) );
       
   670     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
   671         
       
   672     RDebug::Print( _L("CTestInterface::TestSingleStreamPausingL: %S"), &aCodec );
       
   673     TUint32 dataSinkId1;
       
   674     TUint32 dataSourceId1;
       
   675     User::LeaveIfError(
       
   676         iInterface.AddDataSink( aDataSink, KNullDesC8, dataSinkId1 ) );
       
   677     User::LeaveIfError(
       
   678         iInterface.AddDataSource( aDataSource, KNullDesC8, dataSourceId1 ) );
       
   679     
       
   680     TUint32 streamId1;
       
   681     CMccCodecInformation* codec
       
   682         = FetchCodecByMimeSubtypeNameL( iInterface, aCodec );
       
   683     CleanupStack::PushL( codec );
       
   684     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId1, 
       
   685         aStreamType, *codec ) );
       
   686     
       
   687     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, streamId1 ) );
       
   688     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPrepared );
       
   689     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPrepared );
       
   690     
       
   691     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, streamId1 ) );
       
   692     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStarted );
       
   693     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStarted );
       
   694 
       
   695     iConsole.Printf( _L( "Press a key to pause\n" ) );
       
   696     iConsole.Getch();
       
   697     User::LeaveIfError( iInterface.PauseStream( sessionId, linkId, streamId1 ) );
       
   698     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPaused );
       
   699     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPaused );
       
   700 
       
   701     iConsole.Printf( _L( "Press a key to resume\n" ) );
       
   702     iConsole.Getch();
       
   703     User::LeaveIfError( iInterface.ResumeStream( sessionId, linkId, streamId1 ) );
       
   704     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamResumed );
       
   705     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamResumed );
       
   706 
       
   707     iConsole.Printf( _L( "Press a key to stop\n" ) );
       
   708     iConsole.Getch();
       
   709     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, streamId1 ) );
       
   710     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStopped );
       
   711     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStopped );
       
   712 
       
   713     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId1 ) );
       
   714     iInterface.RemoveDataSink( sessionId, linkId, streamId1, dataSinkId1 );
       
   715     iInterface.RemoveDataSource( sessionId, linkId, streamId1, dataSourceId1 );
       
   716     
       
   717     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
   718     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
   719     CleanupStack::PopAndDestroy( codec );
       
   720     }
       
   721 
       
   722 // ---------------------------------------------------------------------------
       
   723 // CTestInterface::TestAudioMuteL
       
   724 // ---------------------------------------------------------------------------
       
   725 //
       
   726 void CTestInterface::TestAudioMuteL()
       
   727     {
       
   728     TUint32 sessionId;
       
   729     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
   730         
       
   731     // Create link
       
   732     TUint32 linkId;
       
   733     User::LeaveIfError( iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId, iNetsettings ) );
       
   734     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
   735         
       
   736     User::LeaveIfError( iInterface.SetRemoteAddress( sessionId, linkId, iNetsettings.iRemoteAddress ) );
       
   737     
       
   738     CMccCodecInformation* codec
       
   739         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
   740     CleanupStack::PushL( codec );
       
   741     
       
   742     // Create upstream
       
   743     TUint32 upStream;
       
   744     TUint32 dataSinkId1;
       
   745     TUint32 dataSourceId1;
       
   746     User::LeaveIfError( iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId1 ) );
       
   747     User::LeaveIfError( iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId1 ) );
       
   748     codec->SetPriorityPreference( KAudioPrefVoipAudioUplink );
       
   749     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, upStream, 
       
   750         KMccAudioUplinkStream, *codec ) );
       
   751 
       
   752     // Create downstream
       
   753     TUint32 downStream;
       
   754     TUint32 dataSinkId2;
       
   755     TUint32 dataSourceId2;
       
   756     User::LeaveIfError( iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, dataSinkId2 ) );
       
   757     User::LeaveIfError( iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, dataSourceId2 ) );
       
   758     codec->SetPriorityPreference( KAudioPrefVoipAudioDownlink );
       
   759     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, downStream,
       
   760         KMccAudioDownlinkStream, *codec ) );
       
   761     
       
   762     // Prepare and start up and downstream       
       
   763     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, upStream ) );
       
   764     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPrepared );
       
   765     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPrepared );
       
   766     
       
   767     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, upStream ) );
       
   768     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStarted );
       
   769     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStarted );
       
   770         
       
   771     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, downStream ) );
       
   772     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPrepared );
       
   773     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPrepared );
       
   774     
       
   775     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, downStream ) );
       
   776     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStarted );
       
   777     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStarted );
       
   778         
       
   779     // Pause upstream
       
   780     iConsole.Printf( _L( "Press a key to mute audio\n" ) );
       
   781     iConsole.Getch();
       
   782     User::LeaveIfError( iInterface.PauseStream( sessionId, linkId, upStream ) );
       
   783     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPaused );
       
   784     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPaused );
       
   785     
       
   786     // Resume upstream
       
   787     iConsole.Printf( _L( "Press a key to unmute audio\n" ) );
       
   788     iConsole.Getch();
       
   789     User::LeaveIfError( iInterface.ResumeStream( sessionId, linkId, upStream ) );
       
   790     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamResumed );
       
   791     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamResumed );
       
   792     
       
   793     iConsole.Printf( _L( "Press a key to stop\n" ) );
       
   794     iConsole.Getch();
       
   795     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, upStream ) );
       
   796     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStopped );
       
   797     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStopped );
       
   798     
       
   799     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, downStream ) );
       
   800     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStopped );
       
   801     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStopped );
       
   802         
       
   803     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, upStream ) );
       
   804     iInterface.RemoveDataSink( sessionId, linkId, upStream, dataSinkId1 );
       
   805     iInterface.RemoveDataSource( sessionId, linkId, upStream, dataSourceId1 );
       
   806     
       
   807     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, downStream ) );
       
   808     iInterface.RemoveDataSink( sessionId, linkId, downStream, dataSinkId2 );
       
   809     iInterface.RemoveDataSource( sessionId, linkId, downStream, dataSourceId2 );
       
   810     
       
   811     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
   812     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
   813     CleanupStack::PopAndDestroy( codec );
       
   814     }
       
   815 
       
   816 // ---------------------------------------------------------------------------
       
   817 // CTestInterface::TestSetCodecL
       
   818 // ---------------------------------------------------------------------------
       
   819 //
       
   820 void CTestInterface::TestSetCodecL()
       
   821     {
       
   822     TUint32 sessionId;
       
   823     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
   824     TUint32 linkId;
       
   825     User::LeaveIfError(
       
   826         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId, iNetsettings ) );
       
   827     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
   828     
       
   829     TUint32 dataSinkId1;
       
   830     TUint32 dataSourceId1;
       
   831     User::LeaveIfError(
       
   832         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId1 ) );
       
   833     User::LeaveIfError(
       
   834         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId1 ) );
       
   835     
       
   836     TUint32 streamId1;
       
   837     CMccCodecInformation* codec
       
   838         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
   839     CleanupStack::PushL( codec );
       
   840     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId1, 
       
   841         KMccAudioUplinkStream, *codec ) );
       
   842     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, streamId1 ) );
       
   843     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPrepared );
       
   844     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPrepared );
       
   845     
       
   846     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, streamId1 ) );
       
   847     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStarted );
       
   848     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStarted );
       
   849     
       
   850     // CHANGING CODEC SHOULD CAUSE AN ERROR
       
   851     /*
       
   852     CMccCodecInformation* codec2
       
   853         = FetchCodecByMimeSubtypeNameL( iInterface, KPCMUSdpName );
       
   854     CleanupStack::PushL( codec2 );
       
   855     TInt err = iInterface.SetCodec( sessionId, linkId, streamId1, *codec2 );
       
   856     if ( KErrArgument != err )
       
   857         {
       
   858         User::Leave( KErrTotalLossOfPrecision );
       
   859         }
       
   860     */
       
   861     // TBD: TEST CHANGING OF CODEC PARAMETERS
       
   862     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, streamId1 ) );
       
   863     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStopped );
       
   864     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStopped );
       
   865     
       
   866     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId1 ) );
       
   867     iInterface.RemoveDataSink( sessionId, linkId, streamId1, dataSinkId1 );
       
   868     iInterface.RemoveDataSource( sessionId, linkId, streamId1, dataSourceId1 );
       
   869     
       
   870     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
   871     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
   872     //CleanupStack::PopAndDestroy( codec2 );
       
   873     CleanupStack::PopAndDestroy( codec );
       
   874     }
       
   875     
       
   876     
       
   877 // ---------------------------------------------------------------------------
       
   878 // CTestInterface::TestGetCodecL
       
   879 // ---------------------------------------------------------------------------
       
   880 //
       
   881 void CTestInterface::TestGetCodecL()
       
   882     {
       
   883     TUint32 sessionId;
       
   884     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
   885     TUint32 linkId;
       
   886     User::LeaveIfError(
       
   887         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId, iNetsettings ) );
       
   888     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
   889     
       
   890     TUint32 dataSinkId1;
       
   891     TUint32 dataSourceId1;
       
   892     User::LeaveIfError(
       
   893         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId1 ) );
       
   894     User::LeaveIfError(
       
   895         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId1 ) );
       
   896     
       
   897     TUint32 streamId;
       
   898     CMccCodecInformation* codec
       
   899         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
   900     CleanupStack::PushL( codec );
       
   901     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId, 
       
   902         KMccAudioUplinkStream, *codec ) );
       
   903     
       
   904     CMccCodecInformation* gotCodec 
       
   905         = iInterface.CodecL( sessionId, linkId, streamId );
       
   906     CleanupStack::PushL( gotCodec );
       
   907     
       
   908     if ( gotCodec && gotCodec->FourCC() != codec->FourCC() )
       
   909         {
       
   910         User::Leave( KErrTotalLossOfPrecision );
       
   911         }
       
   912     
       
   913     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId ) );
       
   914     iInterface.RemoveDataSink( sessionId, linkId, streamId, dataSinkId1 );
       
   915     iInterface.RemoveDataSource( sessionId, linkId, streamId, dataSourceId1 );
       
   916     
       
   917     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
   918     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
   919     CleanupStack::PopAndDestroy( gotCodec );
       
   920     CleanupStack::PopAndDestroy( codec );
       
   921     }
       
   922 
       
   923 
       
   924 // ---------------------------------------------------------------------------
       
   925 // CTestInterface::TestGetSSRCL
       
   926 // ---------------------------------------------------------------------------
       
   927 //
       
   928 void CTestInterface::TestGetSSRCL()
       
   929 	{
       
   930     TUint32 sessionId;
       
   931     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
   932     TUint32 linkId;
       
   933     User::LeaveIfError(
       
   934         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId, iNetsettings ) );
       
   935     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
   936     
       
   937     // UPLINK STREAM
       
   938     TUint32 dataSinkId1;
       
   939     TUint32 dataSourceId1;
       
   940     User::LeaveIfError(
       
   941         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId1 ) );
       
   942     User::LeaveIfError(
       
   943         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId1 ) );
       
   944     
       
   945     TUint32 streamId1;
       
   946     CMccCodecInformation* codec
       
   947         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
   948     CleanupStack::PushL( codec );
       
   949     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId1, 
       
   950         KMccAudioUplinkStream, *codec ) );
       
   951     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, streamId1 ) );
       
   952     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPrepared );
       
   953     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamPrepared );
       
   954 
       
   955     TUint32 ssrc( 0 );
       
   956     User::LeaveIfError(
       
   957         iInterface.GetSSRC( sessionId, linkId, streamId1, dataSinkId1, ssrc ) );
       
   958     if ( 0 == ssrc )
       
   959         {
       
   960         User::Leave( KErrTotalLossOfPrecision );
       
   961         }
       
   962     
       
   963     // DOWNLINK STREAM
       
   964     TUint32 dataSinkId2;
       
   965     TUint32 dataSourceId2;
       
   966     User::LeaveIfError(
       
   967         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId2 ) );
       
   968     User::LeaveIfError(
       
   969         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId2 ) );
       
   970 
       
   971     TUint32 streamId2;
       
   972     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId2, 
       
   973         KMccAudioUplinkStream, *codec ) );
       
   974     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, streamId2 ) );
       
   975     iIfStub.WaitForEvent( sessionId, linkId, streamId2, KMccStreamPrepared );
       
   976     iIfStub.WaitForEvent( sessionId, linkId, streamId2, KMccStreamPrepared );
       
   977         
       
   978     User::LeaveIfError(
       
   979         iInterface.GetSSRC ( sessionId, linkId, streamId2, dataSinkId1, ssrc ) );
       
   980     if ( 0 == ssrc )
       
   981         {
       
   982         User::Leave( KErrTotalLossOfPrecision );
       
   983         }
       
   984     
       
   985     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, streamId1 ) );
       
   986     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStopped );
       
   987     iIfStub.WaitForEvent( sessionId, linkId, streamId1, KMccStreamStopped );
       
   988     
       
   989     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, streamId2 ) );
       
   990     iIfStub.WaitForEvent( sessionId, linkId, streamId2, KMccStreamStopped );
       
   991     iIfStub.WaitForEvent( sessionId, linkId, streamId2, KMccStreamStopped );    
       
   992     
       
   993     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId1 ) );
       
   994     iInterface.RemoveDataSink( sessionId, linkId, streamId1, dataSinkId1 );
       
   995     iInterface.RemoveDataSource( sessionId, linkId, streamId1, dataSourceId1 );
       
   996     
       
   997     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId2 ) );
       
   998     iInterface.RemoveDataSink( sessionId, linkId, streamId2, dataSinkId1 );
       
   999     iInterface.RemoveDataSource( sessionId, linkId, streamId2, dataSourceId1 );
       
  1000     
       
  1001     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
  1002     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
  1003     CleanupStack::PopAndDestroy( codec );
       
  1004 	}
       
  1005 	
       
  1006    
       
  1007 // ---------------------------------------------------------------------------
       
  1008 // CTestInterface::TestInactivityTimerL
       
  1009 // ---------------------------------------------------------------------------
       
  1010 //
       
  1011 void CTestInterface::TestInactivityTimerL()
       
  1012     {
       
  1013     const TUint KLongInactivityTimeout( 1000 ); // 1 second
       
  1014 
       
  1015     TUint32 session;
       
  1016     User::LeaveIfError( iInterface.CreateSession( session ) );
       
  1017 
       
  1018     CMccCodecInformation* codec
       
  1019         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
  1020     CleanupStack::PushL( codec );
       
  1021     
       
  1022     TUint32 dataSinkId1;
       
  1023     TUint32 dataSourceId1;
       
  1024     
       
  1025     // Create downlink and stream
       
  1026     TUint32 linkId, downStream;
       
  1027     User::LeaveIfError( 
       
  1028         iInterface.CreateLink( session, KMccLinkGeneral, linkId, iNetsettings ) );
       
  1029     iIfStub.WaitForEvent( session, linkId, 0, KMccLinkCreated );
       
  1030     
       
  1031     User::LeaveIfError(
       
  1032         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, dataSinkId1 ) );
       
  1033     User::LeaveIfError(
       
  1034         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, dataSourceId1 ) );
       
  1035     User::LeaveIfError( iInterface.CreateStream( session, linkId, downStream,
       
  1036                                                  KMccAudioDownlinkStream, *codec ) );
       
  1037 
       
  1038     // Start, wait for inactivity event and stop timer
       
  1039     User::LeaveIfError( iInterface.StartInactivityTimer( session, linkId, downStream,
       
  1040                         KLongInactivityTimeout, dataSourceId1 ) );
       
  1041     iIfStub.WaitForEvent( session, linkId, downStream, KMccInactivityEvent );
       
  1042     
       
  1043     /*
       
  1044     // Timer is automatically stopped after sending inactivity event
       
  1045     User::LeaveIfError( iInterface.StopInactivityTimer( session, linkId, downStream,
       
  1046         dataSourceId1 ) );
       
  1047     */
       
  1048     
       
  1049     // TRY TO USE INVALID TIMEOUT TIME
       
  1050     TInt err = iInterface.StartInactivityTimer( session, linkId, downStream,
       
  1051         0, dataSourceId1 );
       
  1052     if ( KErrArgument != err )
       
  1053         {
       
  1054         RDebug::Print( _L("CTestInterface::TestInactivityTimerL ERR: %d" ),
       
  1055             err );
       
  1056         RDebug::Print( _L("Timer should not work with timeout 0") );
       
  1057         User::Leave( KErrTotalLossOfPrecision );
       
  1058         }
       
  1059     
       
  1060     User::LeaveIfError( iInterface.DeleteStream( session, linkId, downStream ) );
       
  1061     iInterface.RemoveDataSink( session, linkId, downStream, dataSinkId1 );
       
  1062     iInterface.RemoveDataSource( session, linkId, downStream, dataSourceId1 );
       
  1063                             
       
  1064     // TRY TO USE TIMER WITH UL-STREAM
       
  1065     TUint32 upStream;
       
  1066     TUint32 dataSinkId2;
       
  1067     TUint32 dataSourceId2;
       
  1068     User::LeaveIfError(
       
  1069         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId2 ) );
       
  1070     User::LeaveIfError(
       
  1071         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId2 ) );
       
  1072     User::LeaveIfError( iInterface.CreateStream( session, linkId, upStream,
       
  1073         KMccAudioUplinkStream, *codec ) );
       
  1074     
       
  1075     err = iInterface.StartInactivityTimer( session, linkId, upStream, dataSinkId2,
       
  1076         KLongInactivityTimeout );
       
  1077     if ( KErrNone == err )
       
  1078         {
       
  1079         RDebug::Print( _L("Timer should not work on ul-stream") );
       
  1080         User::Leave( KErrTotalLossOfPrecision );
       
  1081         }
       
  1082 
       
  1083     User::LeaveIfError( iInterface.DeleteStream( session, linkId, upStream ) );
       
  1084     iInterface.RemoveDataSink( session, linkId, upStream, dataSinkId2 );
       
  1085     iInterface.RemoveDataSource( session, linkId, upStream, dataSourceId2 );
       
  1086     
       
  1087     User::LeaveIfError( iInterface.CloseLink( session, linkId ) );
       
  1088     User::LeaveIfError( iInterface.CloseSession( session ) );
       
  1089     CleanupStack::PopAndDestroy( codec );
       
  1090     }
       
  1091 
       
  1092 
       
  1093 // ---------------------------------------------------------------------------
       
  1094 // CTestInterface::TestMultiStreamLinkSessionL
       
  1095 // Tests stream creation to multiple links and sessions.
       
  1096 // ---------------------------------------------------------------------------
       
  1097 //
       
  1098 void CTestInterface::TestMultiStreamLinkSessionL()
       
  1099     {
       
  1100     RArray<TUint32> sessIds;
       
  1101     CleanupClosePushL( sessIds );
       
  1102     RArray<TUint32> linkIds;
       
  1103     CleanupClosePushL( linkIds );
       
  1104     RArray<TUint32> strmIds;
       
  1105     CleanupClosePushL( strmIds );
       
  1106     RArray<TUint32> sourceIds;
       
  1107     CleanupClosePushL( sourceIds );
       
  1108     RArray<TUint32> sinkIds;
       
  1109     CleanupClosePushL( sinkIds );
       
  1110     
       
  1111     CMccCodecInformation* codec
       
  1112         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
  1113     CleanupStack::PushL( codec );
       
  1114     
       
  1115     for ( TInt sessCnt = 0; sessCnt < 3; sessCnt++ )
       
  1116         {
       
  1117         TUint32 sessId;
       
  1118         User::LeaveIfError( iInterface.CreateSession( sessId ) );
       
  1119         sessIds.Append( sessId );
       
  1120         
       
  1121         for ( TInt linkCnt = 0; linkCnt < 3; linkCnt++ )
       
  1122             {
       
  1123             TUint32 linkId;
       
  1124             User::LeaveIfError(
       
  1125                 iInterface.CreateLink( 
       
  1126                 sessIds[sessCnt], KMccLinkGeneral, linkId, iNetsettings ) );
       
  1127             
       
  1128             iIfStub.WaitForEvent( sessId, linkId, 0, KMccLinkCreated );
       
  1129             linkIds.Append( linkId );
       
  1130             
       
  1131             // UL-STREAM
       
  1132             TUint32 dataSinkId;
       
  1133             TUint32 dataSourceId;
       
  1134             User::LeaveIfError(
       
  1135                 iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId ) );
       
  1136             User::LeaveIfError(
       
  1137                 iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId ) );
       
  1138             sourceIds.Append( dataSourceId );
       
  1139             sinkIds.Append( dataSinkId );
       
  1140             
       
  1141             TUint32 ulStreamId;
       
  1142             User::LeaveIfError( 
       
  1143                 iInterface.CreateStream( sessIds[sessCnt], linkIds[sessCnt*3+linkCnt], ulStreamId, 
       
  1144                 KMccAudioUplinkStream, *codec ) );
       
  1145             strmIds.Append( ulStreamId );
       
  1146             
       
  1147             // DL-STREAM
       
  1148             User::LeaveIfError(
       
  1149                 iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, dataSinkId ) );
       
  1150             User::LeaveIfError( 
       
  1151                 iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, dataSourceId ) );
       
  1152             sourceIds.Append( dataSourceId );
       
  1153             sinkIds.Append( dataSinkId );
       
  1154             
       
  1155             TUint32 dlStreamId;
       
  1156             User::LeaveIfError( 
       
  1157                 iInterface.CreateStream( sessIds[sessCnt], linkIds[sessCnt*3+linkCnt], dlStreamId, 
       
  1158                 KMccAudioDownlinkStream, *codec ) );
       
  1159             strmIds.Append( dlStreamId );
       
  1160             }
       
  1161         }
       
  1162     
       
  1163     for ( TInt ind = 0; ind < sessIds.Count(); ind++ )
       
  1164         {
       
  1165         // FAST SHUTDOWN
       
  1166         User::LeaveIfError( iInterface.CloseSession( sessIds[ind] ) );
       
  1167         }
       
  1168     
       
  1169     // TBD: REMOVE DATASINK&SOURCE
       
  1170     CleanupStack::PopAndDestroy( codec );
       
  1171     CleanupStack::PopAndDestroy( &sinkIds );
       
  1172     CleanupStack::PopAndDestroy( &sourceIds );
       
  1173     CleanupStack::PopAndDestroy( &strmIds );
       
  1174     CleanupStack::PopAndDestroy( &linkIds );
       
  1175     CleanupStack::PopAndDestroy( &sessIds );
       
  1176     }
       
  1177     
       
  1178     
       
  1179 // ---------------------------------------------------------------------------
       
  1180 // CTestInterface::TestFastShutdownsL
       
  1181 // ---------------------------------------------------------------------------
       
  1182 //
       
  1183 void CTestInterface::TestFastShutdownsL()
       
  1184     {
       
  1185     RDebug::Print( _L("CTestInterface::TestFastShutdownsL") );
       
  1186     
       
  1187     TUint32 sessionId;
       
  1188     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
  1189     
       
  1190     TUint32 linkId1;
       
  1191     User::LeaveIfError(
       
  1192         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId1,
       
  1193             iNetsettings ) );
       
  1194     iIfStub.WaitForEvent( sessionId, linkId1, 0, KMccLinkCreated );
       
  1195     
       
  1196     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId1 ) );
       
  1197         
       
  1198     CMccCodecInformation* codec
       
  1199         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
  1200     CleanupStack::PushL( codec );
       
  1201     
       
  1202     // Add data sink and source
       
  1203     TUint32 endpointId1;
       
  1204     TUint32 endpointId2;
       
  1205     User::LeaveIfError(
       
  1206         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, endpointId1 ) );
       
  1207     User::LeaveIfError(
       
  1208         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, endpointId2 ) );
       
  1209     
       
  1210     // Create downlink and stream 1
       
  1211     TUint32 downLink1, downStream1;
       
  1212     User::LeaveIfError(
       
  1213         iInterface.CreateLink( sessionId, KMccLinkGeneral, downLink1, iNetsettings ) );
       
  1214     iIfStub.WaitForEvent( sessionId, downLink1, 0, KMccLinkCreated );
       
  1215     
       
  1216     User::LeaveIfError( iInterface.CreateStream( sessionId, downLink1, downStream1,
       
  1217         KMccAudioDownlinkStream, *codec ) );
       
  1218 
       
  1219     // Create uplink and stream 1
       
  1220     TUint32 upLink1, upStream1;
       
  1221     User::LeaveIfError( 
       
  1222         iInterface.CreateLink( sessionId, KMccLinkGeneral, upLink1, iNetsettings ) );
       
  1223     
       
  1224     User::LeaveIfError(
       
  1225         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, endpointId1 ) );
       
  1226     User::LeaveIfError(
       
  1227         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, endpointId2 ) );
       
  1228     User::LeaveIfError( iInterface.CreateStream( sessionId, upLink1, upStream1,
       
  1229                                                  KMccAudioUplinkStream, *codec ) );
       
  1230 
       
  1231     // Create downlink and stream 2
       
  1232     TUint32 downLink2, downStream2;
       
  1233     User::LeaveIfError( iInterface.CreateLink( sessionId, KMccLinkGeneral, downLink2, iNetsettings ) );
       
  1234     iIfStub.WaitForEvent( sessionId, downLink2, 0, KMccLinkCreated );
       
  1235     
       
  1236     User::LeaveIfError(
       
  1237         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, endpointId1 ) );
       
  1238     User::LeaveIfError(
       
  1239         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, endpointId2 ) );
       
  1240     User::LeaveIfError( iInterface.CreateStream( sessionId, downLink2, downStream2,
       
  1241                                                  KMccAudioDownlinkStream, *codec ) );
       
  1242 
       
  1243     // Create uplink and stream 2
       
  1244     TUint32 upLink2, upStream2;
       
  1245     User::LeaveIfError( iInterface.CreateLink( sessionId, KMccLinkGeneral, upLink2, iNetsettings ) );
       
  1246     iIfStub.WaitForEvent( sessionId, upLink2, 0, KMccLinkCreated );
       
  1247     
       
  1248     User::LeaveIfError(
       
  1249         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, endpointId1 ) );
       
  1250     User::LeaveIfError(
       
  1251         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, endpointId2 ) );
       
  1252     User::LeaveIfError( iInterface.CreateStream( sessionId, upLink2, upStream2,
       
  1253                                                  KMccAudioUplinkStream, *codec ) );
       
  1254 
       
  1255     User::LeaveIfError( iInterface.PrepareStream( sessionId, upLink1, upStream1 ) );
       
  1256     iIfStub.WaitForEvent( sessionId, upLink1, upStream1, KMccStreamPrepared );
       
  1257     iIfStub.WaitForEvent( sessionId, upLink1, upStream1, KMccStreamPrepared );
       
  1258     
       
  1259     User::LeaveIfError( iInterface.PrepareStream( sessionId, upLink2, upStream2 ) );
       
  1260     iIfStub.WaitForEvent( sessionId, upLink2, upStream2, KMccStreamPrepared );
       
  1261     iIfStub.WaitForEvent( sessionId, upLink2, upStream2, KMccStreamPrepared );
       
  1262     
       
  1263     User::LeaveIfError( iInterface.PrepareStream( sessionId, downLink1, downStream1 ) );
       
  1264     iIfStub.WaitForEvent( sessionId, downLink1, downStream1, KMccStreamPrepared );
       
  1265     iIfStub.WaitForEvent( sessionId, downLink1, downStream1, KMccStreamPrepared );
       
  1266     
       
  1267     User::LeaveIfError( iInterface.PrepareStream( sessionId, downLink2, downStream2 ) );
       
  1268     iIfStub.WaitForEvent( sessionId, downLink2, downStream2, KMccStreamPrepared );
       
  1269     iIfStub.WaitForEvent( sessionId, downLink2, downStream2, KMccStreamPrepared );
       
  1270     
       
  1271     User::LeaveIfError( iInterface.StartStream( sessionId, upLink1, upStream1 ) );
       
  1272     iIfStub.WaitForEvent( sessionId, upLink1, upStream1, KMccStreamStarted );
       
  1273     iIfStub.WaitForEvent( sessionId, upLink1, upStream1, KMccStreamStarted );
       
  1274     
       
  1275     iConsole.Printf( _L( "Press a key to stop\n" ) );
       
  1276     iConsole.Getch();
       
  1277     
       
  1278     // TBD: REMOVE DATASINK&SOURCE
       
  1279     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
  1280     CleanupStack::PopAndDestroy( codec );
       
  1281     }
       
  1282     
       
  1283 
       
  1284 // ---------------------------------------------------------------------------
       
  1285 // CTestInterface::TestResourceReuseL
       
  1286 // 
       
  1287 // ---------------------------------------------------------------------------
       
  1288 //
       
  1289 void CTestInterface::TestResourceReuseL()
       
  1290     {
       
  1291     TUint32 sessionId;
       
  1292     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
  1293     TUint32 linkId;
       
  1294     User::LeaveIfError(
       
  1295         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId, iNetsettings ) );
       
  1296     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
  1297     
       
  1298     TUint32 ulStreamId;
       
  1299     TUint32 rtpSinkId;
       
  1300     TUint32 micSourceId1;
       
  1301     User::LeaveIfError(
       
  1302         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, rtpSinkId ) );
       
  1303     User::LeaveIfError(
       
  1304         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, micSourceId1 ) );
       
  1305     
       
  1306     CMccCodecInformation* codec
       
  1307         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
  1308     CleanupStack::PushL( codec );
       
  1309     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, ulStreamId, 
       
  1310         KMccAudioUplinkStream, *codec ) );
       
  1311     
       
  1312     TUint32 dlStreamId;
       
  1313     TUint32 speakerSinkId1;
       
  1314     TUint32 rtpSourceId;
       
  1315     User::LeaveIfError(
       
  1316         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, speakerSinkId1 ) );
       
  1317     User::LeaveIfError(
       
  1318         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, rtpSourceId ) );
       
  1319     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, dlStreamId, 
       
  1320         KMccAudioUplinkStream, *codec ) );
       
  1321         
       
  1322     TUint32 ulStreamId2;
       
  1323     TUint32 micSourceId2;
       
  1324     User::LeaveIfError(
       
  1325         iInterface.Reuse( sessionId, linkId, ulStreamId, rtpSinkId ) );
       
  1326     User::LeaveIfError(
       
  1327         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, micSourceId2 ) );
       
  1328     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, ulStreamId2, 
       
  1329         KMccAudioUplinkStream, *codec ) );
       
  1330     
       
  1331     TUint32 dlStreamId2;
       
  1332     TUint32 speakerSinkId2;
       
  1333     User::LeaveIfError(
       
  1334         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, speakerSinkId2 ) );
       
  1335     User::LeaveIfError(
       
  1336         iInterface.Reuse( sessionId, linkId, dlStreamId, rtpSourceId ) );
       
  1337     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, dlStreamId2, 
       
  1338         KMccAudioDownlinkStream, *codec ) );
       
  1339     
       
  1340     User::LeaveIfError( 
       
  1341         iInterface.PrepareStream( sessionId, linkId, dlStreamId, rtpSourceId ) );
       
  1342     iIfStub.WaitForEvent( 
       
  1343         sessionId, linkId, dlStreamId, rtpSourceId, KMccStreamPrepared );
       
  1344     
       
  1345     User::LeaveIfError( 
       
  1346         iInterface.PrepareStream( sessionId, linkId, dlStreamId2, rtpSourceId ) );
       
  1347     iIfStub.WaitForEvent( 
       
  1348         sessionId, linkId, dlStreamId2, rtpSourceId, KMccStreamPrepared );
       
  1349     
       
  1350     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
  1351     CleanupStack::PopAndDestroy( codec );
       
  1352     }
       
  1353     
       
  1354 
       
  1355 // ---------------------------------------------------------------------------
       
  1356 // CTestInterface::TestMultiStreamPreparingL
       
  1357 // ---------------------------------------------------------------------------
       
  1358 //
       
  1359 void CTestInterface::TestMultiStreamPreparingL()
       
  1360     {
       
  1361     TUint32 sessionId;
       
  1362     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
  1363     TUint32 linkId;
       
  1364     User::LeaveIfError(
       
  1365         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId, iNetsettings ) );
       
  1366     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
  1367     
       
  1368     CMccCodecInformation* codec
       
  1369         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
  1370     CleanupStack::PushL( codec );
       
  1371     
       
  1372     // CREATE UL-STREAM
       
  1373     TUint32 upStream;
       
  1374     TUint32 dataSinkId1;
       
  1375     TUint32 dataSourceId1;
       
  1376     User::LeaveIfError(
       
  1377         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId1 ) );
       
  1378     User::LeaveIfError(
       
  1379         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId1 ) );
       
  1380     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, upStream,
       
  1381                                                  KMccAudioUplinkStream, *codec ) );
       
  1382 
       
  1383     // CREATE DL-STREAM
       
  1384     TUint32 downStream;
       
  1385     TUint32 dataSinkId2;
       
  1386     TUint32 dataSourceId2;
       
  1387     User::LeaveIfError(
       
  1388         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, dataSinkId2 ) );
       
  1389     User::LeaveIfError(
       
  1390         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, dataSourceId2 ) );
       
  1391     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, downStream,
       
  1392                                                  KMccAudioDownlinkStream, *codec ) );
       
  1393     
       
  1394     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, upStream ) );
       
  1395     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPrepared );
       
  1396     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPrepared );
       
  1397     
       
  1398     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, downStream ) );
       
  1399     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPrepared );
       
  1400     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPrepared );
       
  1401     
       
  1402     // CREATE SECOND LINK
       
  1403     TUint32 linkId2;
       
  1404     User::LeaveIfError( 
       
  1405         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId2, iNetsettings ) );
       
  1406     iIfStub.WaitForEvent( sessionId, linkId2, 0, KMccLinkCreated );
       
  1407     
       
  1408     // CREATE SECOND UL-STREAM
       
  1409     TUint32 upStream2;
       
  1410     TUint32 dataSinkId3;
       
  1411     TUint32 dataSourceId3;
       
  1412     User::LeaveIfError(
       
  1413         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId3 ) );
       
  1414     User::LeaveIfError(
       
  1415         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId3 ) );
       
  1416     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId2, upStream2,
       
  1417                                                  KMccAudioUplinkStream, *codec ) );
       
  1418 
       
  1419     // CREATE SECOND DL-STREAM
       
  1420     TUint32 downStream2;
       
  1421     TUint32 dataSinkId4;
       
  1422     TUint32 dataSourceId4;
       
  1423     User::LeaveIfError(
       
  1424         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, dataSinkId4 ) );
       
  1425     User::LeaveIfError(
       
  1426         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, dataSourceId4 ) );
       
  1427     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId2, downStream2,
       
  1428                                                  KMccAudioDownlinkStream, *codec ) );
       
  1429     
       
  1430     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId2, upStream2 ) );
       
  1431     iIfStub.WaitForEvent( sessionId, linkId2, upStream2, KMccStreamPrepared );
       
  1432     iIfStub.WaitForEvent( sessionId, linkId2, upStream2, KMccStreamPrepared );
       
  1433     
       
  1434     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId2, downStream2 ) );
       
  1435     iIfStub.WaitForEvent( sessionId, linkId2, downStream2, KMccStreamPrepared );
       
  1436     iIfStub.WaitForEvent( sessionId, linkId2, downStream2, KMccStreamPrepared );
       
  1437         
       
  1438     // TBD: REMOVE DATASINK&SOURCE
       
  1439     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, upStream ) );
       
  1440     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, downStream ) );
       
  1441     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId2, upStream2 ) );
       
  1442     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId2, downStream2 ) );
       
  1443     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
  1444     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId2 ) );
       
  1445     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
  1446     CleanupStack::PopAndDestroy( codec );
       
  1447     }
       
  1448     
       
  1449     
       
  1450 // ---------------------------------------------------------------------------
       
  1451 // CTestInterface::TestAudioStreamingL
       
  1452 // ---------------------------------------------------------------------------
       
  1453 //
       
  1454 void CTestInterface::TestAudioStreamingL( const TDesC8& aCodec )
       
  1455     {
       
  1456     iNetsettings.iLocalAddress.SetPort( KDefaultRtpPort );
       
  1457     
       
  1458     TUint32 sessionId;
       
  1459     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
  1460     TUint32 linkId;
       
  1461     User::LeaveIfError(
       
  1462         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId, iNetsettings ) );
       
  1463     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
  1464     
       
  1465     RDebug::Print( _L("CTestInterface::TestAudioStreaming: %S"), &aCodec );
       
  1466     TUint32 dataSinkId1;
       
  1467     TUint32 dataSourceId1;
       
  1468     User::LeaveIfError(
       
  1469         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId1 ) );
       
  1470     User::LeaveIfError(
       
  1471         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId1 ) );
       
  1472     
       
  1473     TUint32 ulStreamId;
       
  1474     CMccCodecInformation* codec
       
  1475         = FetchCodecByMimeSubtypeNameL( iInterface, aCodec );
       
  1476     CleanupStack::PushL( codec );
       
  1477     
       
  1478     // SET VOIP PRIORITIES FOR THE CODEC
       
  1479     codec->SetPriority( EMdaPriorityMax );
       
  1480     codec->SetPriorityPreference( KAudioPrefVoipAudioUplink );
       
  1481     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, ulStreamId, 
       
  1482         KMccAudioUplinkStream, *codec ) );
       
  1483     
       
  1484     TUint32 dlStreamId;
       
  1485     TUint32 dataSinkId2;
       
  1486     TUint32 dataSourceId2;
       
  1487     User::LeaveIfError(
       
  1488         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, dataSinkId2 ) );
       
  1489     User::LeaveIfError(
       
  1490         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, dataSourceId2 ) );
       
  1491     
       
  1492     codec->SetPriorityPreference( KAudioPrefVoipAudioDownlink );
       
  1493     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, dlStreamId, 
       
  1494         KMccAudioDownlinkStream, *codec ) );
       
  1495     
       
  1496     // START UPLINK FIRST
       
  1497     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, ulStreamId ) );
       
  1498     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamPrepared );
       
  1499     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamPrepared );
       
  1500     
       
  1501     User::LeaveIfError( iInterface.SetRemoteAddress( sessionId, linkId, 
       
  1502         iNetsettings.iRemoteAddress, iNetsettings.iRemoteRtcpPort ) );
       
  1503     
       
  1504     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, dlStreamId ) );
       
  1505     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamPrepared );
       
  1506     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamPrepared );
       
  1507     
       
  1508     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, dlStreamId ) );
       
  1509     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStarted );
       
  1510     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStarted );
       
  1511     
       
  1512     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, ulStreamId ) );
       
  1513     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStarted );
       
  1514     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStarted );
       
  1515     
       
  1516     iConsole.Printf( _L( "Press a key to stop 1\n" ) );
       
  1517     iConsole.Getch();
       
  1518     
       
  1519     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, ulStreamId ) );
       
  1520     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStopped );
       
  1521     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStopped );
       
  1522     
       
  1523     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, dlStreamId ) );
       
  1524     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStopped );
       
  1525     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStopped );
       
  1526     
       
  1527     // START DOWNLINK FIRST
       
  1528     /*
       
  1529     // PREPARING AFTER STOP DOES NOT WORK YET
       
  1530     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, ulStreamId ) );
       
  1531     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamPrepared );
       
  1532     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamPrepared );
       
  1533     
       
  1534     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, dlStreamId ) );
       
  1535     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamPrepared );
       
  1536     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamPrepared );
       
  1537     
       
  1538     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, ulStreamId ) );
       
  1539     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStarted );
       
  1540     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStarted );
       
  1541     
       
  1542     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, dlStreamId ) );
       
  1543     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStarted );
       
  1544     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStarted );
       
  1545     
       
  1546     iConsole.Printf( _L( "Press a key to stop 2\n" ) );
       
  1547     iConsole.Getch();
       
  1548     
       
  1549     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, ulStreamId ) );
       
  1550     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStopped );
       
  1551     iIfStub.WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStopped );
       
  1552     
       
  1553     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, dlStreamId ) );
       
  1554     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStopped );
       
  1555     iIfStub.WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStopped );
       
  1556     */
       
  1557     // TBD: REMOVE DATASINK&SOURCE
       
  1558     iInterface.DeleteStream( sessionId, linkId, ulStreamId );
       
  1559     iInterface.DeleteStream( sessionId, linkId, dlStreamId );
       
  1560     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
  1561     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
  1562     CleanupStack::PopAndDestroy( codec );
       
  1563     }
       
  1564     
       
  1565 
       
  1566 // ---------------------------------------------------------------------------
       
  1567 // CTestInterface::TestMultiStreamPausingL
       
  1568 // ---------------------------------------------------------------------------
       
  1569 //
       
  1570 void CTestInterface::TestMultiStreamPausingL()
       
  1571     {
       
  1572     iNetsettings.iLocalAddress.SetPort( KDefaultRtpPort );
       
  1573     
       
  1574     TUint32 sessionId;
       
  1575     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
  1576     TUint32 linkId;
       
  1577     User::LeaveIfError(
       
  1578         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId, iNetsettings ) );
       
  1579     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
  1580     
       
  1581     CMccCodecInformation* codec
       
  1582         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
  1583     CleanupStack::PushL( codec );
       
  1584     
       
  1585     TUint32 upStream;
       
  1586     TUint32 dataSinkId1;
       
  1587     TUint32 dataSourceId1;
       
  1588     User::LeaveIfError(
       
  1589         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId1 ) );
       
  1590     User::LeaveIfError(
       
  1591         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId1 ) );
       
  1592     
       
  1593     codec->SetPriority( EMdaPriorityMax );
       
  1594     codec->SetPriorityPreference( KAudioPrefVoipAudioUplink );
       
  1595     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, upStream, 
       
  1596                                                  KMccAudioUplinkStream, *codec ) );
       
  1597     TUint32 downStream;
       
  1598     TUint32 dataSinkId2;
       
  1599     TUint32 dataSourceId2;
       
  1600     User::LeaveIfError(
       
  1601         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, dataSinkId2 ) );
       
  1602     User::LeaveIfError(
       
  1603         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, dataSourceId2 ) );
       
  1604     
       
  1605     codec->SetPriorityPreference( KAudioPrefVoipAudioDownlink );
       
  1606     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, downStream, 
       
  1607                                                  KMccAudioDownlinkStream, *codec ) );
       
  1608     
       
  1609     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, upStream ) );
       
  1610     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPrepared );
       
  1611     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPrepared );
       
  1612     
       
  1613     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, downStream ) );
       
  1614     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPrepared );
       
  1615     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPrepared );
       
  1616         
       
  1617     User::LeaveIfError( iInterface.SetRemoteAddress( sessionId, linkId, 
       
  1618         iNetsettings.iRemoteAddress, iNetsettings.iRemoteRtcpPort ) );
       
  1619     
       
  1620     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, upStream) );
       
  1621     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStarted );
       
  1622     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStarted );
       
  1623     
       
  1624     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, downStream) );
       
  1625     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStarted );
       
  1626     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStarted );
       
  1627     
       
  1628     iConsole.Printf( _L( "Press a key to pause\n" ) );
       
  1629     iConsole.Getch();
       
  1630     User::LeaveIfError( iInterface.PauseStream( sessionId, linkId, upStream) );
       
  1631     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPaused );
       
  1632     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPaused );
       
  1633     
       
  1634     User::LeaveIfError( iInterface.PauseStream( sessionId, linkId, downStream) );
       
  1635     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPaused );
       
  1636     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPaused );
       
  1637     
       
  1638     iConsole.Printf( _L( "Press a key to resume\n" ) );
       
  1639     iConsole.Getch();
       
  1640     User::LeaveIfError( iInterface.ResumeStream( sessionId, linkId, upStream) );
       
  1641     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamResumed );
       
  1642     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamResumed );
       
  1643     
       
  1644     User::LeaveIfError( iInterface.ResumeStream( sessionId, linkId, downStream) );
       
  1645     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamResumed );
       
  1646     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamResumed );
       
  1647     
       
  1648     iConsole.Printf( _L( "Press a key to stop\n" ) );
       
  1649     iConsole.Getch();
       
  1650     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, upStream) );
       
  1651     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStopped );
       
  1652     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStopped );
       
  1653     
       
  1654     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, downStream) );
       
  1655     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStopped );
       
  1656     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStopped );
       
  1657     
       
  1658     // TBD: REMOVE DATASINK&SOURCE
       
  1659     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, upStream) );
       
  1660     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, downStream) );
       
  1661     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
  1662     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
  1663     CleanupStack::PopAndDestroy( codec );
       
  1664     }
       
  1665     
       
  1666 
       
  1667 // ---------------------------------------------------------------------------
       
  1668 // CTestInterface::TestAmrFecL
       
  1669 // ---------------------------------------------------------------------------
       
  1670 //
       
  1671 void CTestInterface::TestAmrFecL()
       
  1672     {
       
  1673     TUint32 sessionId;
       
  1674     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
  1675     TUint32 linkId;
       
  1676     User::LeaveIfError(
       
  1677         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId, iNetsettings ) );
       
  1678     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
  1679     
       
  1680     CMccCodecInformation* codec
       
  1681         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
  1682     CleanupStack::PushL( codec );
       
  1683     
       
  1684     // Enable forward error correction
       
  1685     User::LeaveIfError( codec->SetAlgo( EAmrFecUsed ) );
       
  1686     User::LeaveIfError( codec->SetRedCount( 2 ) );
       
  1687     
       
  1688     // CREATE UL-SREAM
       
  1689     TUint32 upStream;
       
  1690     TUint32 rtpSinkId;
       
  1691     TUint32 micSourceId;
       
  1692     User::LeaveIfError(
       
  1693         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, rtpSinkId ) );
       
  1694     User::LeaveIfError(
       
  1695         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, micSourceId ) );
       
  1696     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, upStream,
       
  1697                                                  KMccAudioUplinkStream, *codec ) );
       
  1698     
       
  1699     // CREATE DL-STREAM
       
  1700     TUint32 downStream;
       
  1701     TUint32 speakerSinkId;
       
  1702     TUint32 rtpSourceId;
       
  1703     User::LeaveIfError(
       
  1704         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, speakerSinkId ) );
       
  1705     User::LeaveIfError(
       
  1706         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, rtpSourceId ) );
       
  1707     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, downStream,
       
  1708                                                  KMccAudioDownlinkStream, *codec ) );
       
  1709     
       
  1710     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, upStream ) );
       
  1711     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPrepared );
       
  1712     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPrepared );
       
  1713     
       
  1714     User::LeaveIfError( iInterface.SetRemoteAddress( sessionId, linkId, 
       
  1715         iNetsettings.iRemoteAddress, iNetsettings.iRemoteRtcpPort ) );
       
  1716     
       
  1717     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, downStream ) );
       
  1718     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPrepared );
       
  1719     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPrepared );
       
  1720     
       
  1721     // Try the FEC algorithm
       
  1722     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, downStream ) );
       
  1723     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStarted );
       
  1724     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStarted );
       
  1725     
       
  1726     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, upStream ) );
       
  1727     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStarted );
       
  1728     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStarted );
       
  1729     
       
  1730     iConsole.Printf( _L( "Press a key to stop\n" ) );
       
  1731     iConsole.Getch();
       
  1732     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, upStream ) );
       
  1733     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStopped );
       
  1734     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStopped );
       
  1735     
       
  1736     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, downStream ) );
       
  1737     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStopped );
       
  1738     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStopped );
       
  1739     
       
  1740     // TBD: REMOVE DATASINK&SOURCE
       
  1741     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, upStream ) );   
       
  1742     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, downStream ) );
       
  1743     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
  1744     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
  1745     CleanupStack::PopAndDestroy( codec );
       
  1746     }
       
  1747 
       
  1748 // ---------------------------------------------------------------------------
       
  1749 // CTestInterface::TestRedundancyL
       
  1750 // ---------------------------------------------------------------------------
       
  1751 //
       
  1752 void CTestInterface::TestRedundancyL( const TDesC8& aCodec )
       
  1753     {
       
  1754     TUint32 sessionId;
       
  1755     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
  1756     
       
  1757     TUint32 linkId;
       
  1758     User::LeaveIfError(
       
  1759         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId,
       
  1760             iNetsettings ) );
       
  1761     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
  1762     
       
  1763     CMccCodecInformation* codec
       
  1764         = FetchCodecByMimeSubtypeNameL( iInterface, aCodec );
       
  1765     CleanupStack::PushL( codec );
       
  1766     
       
  1767     // SET VOIP PRIORITIES FOR THE CODEC
       
  1768     codec->SetPriority( EMdaPriorityMax );
       
  1769     codec->SetPriorityPreference( KAudioPrefVoipAudioUplink );
       
  1770     codec->SetAlgo( EGenRedUsed );
       
  1771     codec->SetRedundancyPT( 100 );
       
  1772     
       
  1773     TInt err = codec->SetRedCount( 2 );
       
  1774     if ( KErrArgument == err )
       
  1775         {
       
  1776         User::LeaveIfError( codec->SetRedCount( 1 ) );
       
  1777         }
       
  1778     else
       
  1779         {
       
  1780         User::Leave( KErrTotalLossOfPrecision );
       
  1781         }
       
  1782     
       
  1783     TUint32 upStream;
       
  1784     TUint32 rtpSinkId;
       
  1785     TUint32 micSourceId;
       
  1786     User::LeaveIfError( 
       
  1787         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, rtpSinkId ) );
       
  1788     User::LeaveIfError( 
       
  1789         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, micSourceId ) );
       
  1790     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, upStream,
       
  1791                                                  KMccAudioUplinkStream, *codec ) );
       
  1792 
       
  1793     TUint32 downStream;
       
  1794     TUint32 speakerSinkId;
       
  1795     TUint32 rtpSourceId;
       
  1796     User::LeaveIfError( 
       
  1797         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, speakerSinkId ) );
       
  1798     User::LeaveIfError( 
       
  1799         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, rtpSourceId ) );
       
  1800     
       
  1801     codec->SetPriorityPreference( KAudioPrefVoipAudioDownlink );
       
  1802     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, downStream,
       
  1803                                                  KMccAudioDownlinkStream, *codec ) );
       
  1804 
       
  1805     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, upStream ) );
       
  1806     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPrepared );
       
  1807     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamPrepared );
       
  1808     
       
  1809     User::LeaveIfError( iInterface.SetRemoteAddress( sessionId, linkId, 
       
  1810         iNetsettings.iRemoteAddress, iNetsettings.iRemoteRtcpPort ) );
       
  1811         
       
  1812     User::LeaveIfError( iInterface.PrepareStream( sessionId, linkId, downStream ) );
       
  1813     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPrepared );
       
  1814     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamPrepared );
       
  1815     
       
  1816     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, downStream ) );
       
  1817     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStarted );
       
  1818     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStarted );
       
  1819     
       
  1820     User::LeaveIfError( iInterface.StartStream( sessionId, linkId, upStream ) );
       
  1821     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStarted );
       
  1822     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStarted );
       
  1823     
       
  1824     iConsole.Printf( _L( "Press a key to stop\n" ) );
       
  1825     iConsole.Getch();
       
  1826     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, upStream ) );
       
  1827     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStopped );
       
  1828     iIfStub.WaitForEvent( sessionId, linkId, upStream, KMccStreamStopped );
       
  1829     
       
  1830     User::LeaveIfError( iInterface.StopStream( sessionId, linkId, downStream ) );
       
  1831     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStopped );
       
  1832     iIfStub.WaitForEvent( sessionId, linkId, downStream, KMccStreamStopped );
       
  1833     
       
  1834     // TBD: REMOVE DATASINK&SOURCE
       
  1835     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, upStream ) );   
       
  1836     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, downStream ) );
       
  1837     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
  1838     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
  1839     CleanupStack::PopAndDestroy( codec );
       
  1840     }
       
  1841 
       
  1842 
       
  1843 // ---------------------------------------------------------------------------
       
  1844 // CTestInterface::TestAudioRoutingL
       
  1845 // TBD: Update to loopback test.
       
  1846 // ---------------------------------------------------------------------------
       
  1847 //
       
  1848 void CTestInterface::TestAudioRoutingL()
       
  1849     {
       
  1850     TInt err = iInterface.SetParameter( 6, 0, 0, 0, 
       
  1851         KMccSpeakerRouting, TPckgBuf<TInt>( KMccAudioToPrivate ) );
       
  1852     if ( KErrNotFound != err )
       
  1853         {
       
  1854         User::Leave( KErrTotalLossOfPrecision );
       
  1855         }
       
  1856     
       
  1857     TUint32 audioRoute( 0 );
       
  1858     TPckgBuf<TInt> audioRoutePak( audioRoute );
       
  1859     err = iInterface.GetParameter( 6, 0, 0, 0, 
       
  1860         KMccSpeakerRouting, audioRoutePak );
       
  1861     if ( KErrNotFound != err )
       
  1862         {
       
  1863         User::Leave( KErrTotalLossOfPrecision );
       
  1864         }
       
  1865     
       
  1866     CMccCodecInformation* codec
       
  1867         = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
  1868     CleanupStack::PushL( codec );
       
  1869     
       
  1870     TUint32 sessionId;
       
  1871     User::LeaveIfError( iInterface.CreateSession( sessionId ) );
       
  1872     TUint32 linkId;
       
  1873     User::LeaveIfError(
       
  1874         iInterface.CreateLink( sessionId, KMccLinkGeneral, linkId, iNetsettings ) );
       
  1875     iIfStub.WaitForEvent( sessionId, linkId, 0, KMccLinkCreated );
       
  1876     
       
  1877     TUint32 dataSinkId1;
       
  1878     TUint32 dataSourceId1;
       
  1879     User::LeaveIfError(
       
  1880         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId1 ) );
       
  1881     User::LeaveIfError(
       
  1882         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId1 ) );
       
  1883     
       
  1884     TUint32 streamId;
       
  1885     User::LeaveIfError( iInterface.CreateStream( sessionId, linkId, streamId, 
       
  1886         KMccAudioUplinkStream, *codec ) );
       
  1887     
       
  1888     err = iInterface.SetParameter( sessionId, linkId, streamId, 0,
       
  1889         KMccSpeakerRouting, TPckgBuf<TInt>( KMccAudioToPrivate ) );
       
  1890     
       
  1891     User::LeaveIfError( iInterface.DeleteStream( sessionId, linkId, streamId ) );
       
  1892     User::LeaveIfError( iInterface.CloseLink( sessionId, linkId ) );
       
  1893     User::LeaveIfError( iInterface.CloseSession( sessionId ) );
       
  1894     CleanupStack::PopAndDestroy( codec );
       
  1895     }
       
  1896     
       
  1897     
       
  1898 // ---------------------------------------------------------------------------
       
  1899 // CTestInterface::FetchCodecByMimeSubtypeNameL
       
  1900 // ---------------------------------------------------------------------------
       
  1901 //
       
  1902 CMccCodecInformation* CTestInterface::FetchCodecByMimeSubtypeNameL( 
       
  1903         const CMccInterface& aInterface, const TDesC8& aName ) const
       
  1904     {
       
  1905     RPointerArray<CMccCodecInformation> codecArray;
       
  1906     CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray );
       
  1907     User::LeaveIfError( aInterface.GetCapabilities( codecArray ) );
       
  1908     
       
  1909     CMccCodecInformation* tmp = NULL;
       
  1910     TInt ind( codecArray.Count() );
       
  1911     
       
  1912     while ( ( ind-- ) && ( NULL == tmp ) )
       
  1913         {
       
  1914         if ( codecArray[ind]->SdpName().Compare( aName ) == 0 )
       
  1915             {
       
  1916             tmp = codecArray[ind]->CloneDetailedL();
       
  1917             }
       
  1918         }
       
  1919     
       
  1920     if ( NULL == tmp )
       
  1921         {
       
  1922         User::Leave( KErrNotFound );
       
  1923         }
       
  1924     
       
  1925     CleanupStack::PopAndDestroy( &codecArray );
       
  1926     return tmp;
       
  1927     }