multimediacommscontroller/tsrc/componenttests/src/test_async_features.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_async_features.h"
       
    23 #include "mccteststubs.h"
       
    24 #include "mmccinterface.h"
       
    25 #include "mmcccodecinformation.h"
       
    26 #include "testdefinitions.hrh"
       
    27 
       
    28 
       
    29 // ======== MEMBER FUNCTIONS =================================================
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // CTestAsyncFeat::CTestAsyncFeat
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CTestAsyncFeat::CTestAsyncFeat( CConsoleBase& aConsole,
       
    38      const TMccNetSettings& aNetsettings, CMccInterface& aIF,
       
    39      CMccInterfaceStub& aIFStub )
       
    40     : iInterface( aIF ), iConsole( aConsole ), iNetsettings( aNetsettings ),
       
    41     iIfStub( aIFStub )
       
    42     {
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // CTestAsyncFeat::ConstructL
       
    47 // Symbian 2nd phase constructor can leave.
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 void CTestAsyncFeat::ConstructL(  )
       
    51     {
       
    52     }
       
    53     
       
    54 // ---------------------------------------------------------------------------
       
    55 // CTestAsyncFeat::NewL
       
    56 // Static constructor.
       
    57 // ---------------------------------------------------------------------------
       
    58 //   
       
    59 CTestAsyncFeat* CTestAsyncFeat::NewL( CConsoleBase& aConsole,
       
    60         const TMccNetSettings& aNetsettings, CMccInterface& aIF,
       
    61         CMccInterfaceStub& aIFStub )
       
    62     {
       
    63     CTestAsyncFeat* self 
       
    64         = new ( ELeave ) CTestAsyncFeat( aConsole, aNetsettings, aIF, aIFStub );
       
    65     CleanupStack::PushL( self );
       
    66 
       
    67     self->ConstructL();
       
    68 
       
    69     CleanupStack::Pop( self );
       
    70     return self;
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CTestAsyncFeat::~CTestAsyncFeat
       
    75 // Destructor.
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 CTestAsyncFeat::~CTestAsyncFeat()
       
    79     {  
       
    80     delete iCodec;
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CTestAsyncFeat::DoRunAsyncFeatureTestsL
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CTestAsyncFeat::DoRunAsyncFeatureTestsL()
       
    88     {
       
    89     iConsole.Printf( _L("REQUEST MEDIA QUALITY\n") );
       
    90     RDebug::Print( _L("Mcc_COM_TEST_START: TestMediaQualityRequestL") );
       
    91     //__UHEAP_MARK;
       
    92     TestMediaQualityRequestL();
       
    93     //__UHEAP_MARKEND;
       
    94     RDebug::Print( _L("Mcc_COM_TEST_STOP: TestMediaQualityRequestL") );
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // CTestAsyncFeat::TestMediaQualityRequestL()
       
    99 // private
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CTestAsyncFeat::TestMediaQualityRequestL()
       
   103     {
       
   104     RDebug::Print( _L("CTestAsyncFeat::TestMediaQualityRequestL") );
       
   105     
       
   106     User::LeaveIfError( iInterface.CreateSession( iSessionId ) );
       
   107     
       
   108     RDebug::Print( _L("CTestAsyncFeat::TestMediaQualityRequestL KMccLinkGeneral") );
       
   109     User::LeaveIfError(
       
   110         iInterface.CreateLink( iSessionId, KMccLinkGeneral, iLinkId,
       
   111             iNetsettings ) );
       
   112     
       
   113     iIfStub.WaitForEvent( iSessionId, iLinkId, 0, KMccLinkCreated );
       
   114 
       
   115 //    User::LeaveIfError( iInterface.SetRemoteAddress( iSessionId, iLinkId, iNetsettings.iRemoteAddress ) );
       
   116     
       
   117     iCodec = FetchCodecByMimeSubtypeNameL( iInterface, KAMRSdpName );
       
   118     
       
   119     // AUDIO DOWNLINK STREAM CREATION
       
   120     RDebug::Print( _L("CTestAsyncFeat::TestMediaQualityRequestL ADD RSC AUDIO DL") );
       
   121 
       
   122     User::LeaveIfError(
       
   123         iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, iAudioSinkId ) );
       
   124     User::LeaveIfError(
       
   125         iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, iRtpSourceId ) );
       
   126 
       
   127     User::LeaveIfError( iInterface.CreateStream( iSessionId, iLinkId, iStreamId1, 
       
   128         KMccAudioDownlinkStream, *iCodec ) );
       
   129         
       
   130     User::LeaveIfError( iInterface.PrepareStream( iSessionId, iLinkId, iStreamId1 ) );
       
   131     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId1, KMccStreamPrepared );
       
   132     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId1, KMccStreamPrepared );
       
   133     
       
   134     User::LeaveIfError( iInterface.StartStream( iSessionId, iLinkId, iStreamId1 ) );
       
   135     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId1, KMccStreamStarted );
       
   136     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId1, KMccStreamStarted );
       
   137     
       
   138     // AUDIO UPLINK STREAM CREATION
       
   139     RDebug::Print( _L("CTestAsyncFeat::TestMediaQualityRequestL CREATE AUDIO UL") );
       
   140     
       
   141     User::LeaveIfError(
       
   142         iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, iRtpSinkId ) );
       
   143     User::LeaveIfError(
       
   144         iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, iAudioSourceId ) );
       
   145 
       
   146     User::LeaveIfError( iInterface.CreateStream( iSessionId, iLinkId, iStreamId2, 
       
   147         KMccAudioUplinkStream, *iCodec ) );
       
   148         
       
   149     User::LeaveIfError( iInterface.PrepareStream( iSessionId, iLinkId, iStreamId2 ) );
       
   150     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId2, KMccStreamPrepared );
       
   151     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId2, KMccStreamPrepared );
       
   152     
       
   153     User::LeaveIfError( iInterface.StartStream( iSessionId, iLinkId, iStreamId2 ) );
       
   154     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId2, KMccStreamStarted );
       
   155     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId2, KMccStreamStarted );
       
   156     
       
   157     iConfig.iJitterLevel = 1;
       
   158     iConfig.iPacketLoss = 1;
       
   159     iConfig.iReportType = EMccJitterReport;
       
   160     iConfig.iReportIntervalType = EMccQualityTimeBased;
       
   161     iConfig.iReportInterval = 100;
       
   162     iConfig.iSessionId = iSessionId;
       
   163     iConfig.iEndpointId = iRtpSourceId;
       
   164     
       
   165     iConsole.Printf( _L( "Media quality observing: Start\n" ) );
       
   166     User::LeaveIfError( iInterface.MediaQualityRequest( iConfig ) );
       
   167 
       
   168     iConsole.Printf( _L( "Press a key to stop \n" ) );
       
   169     iConsole.Getch();
       
   170 
       
   171     User::LeaveIfError( iInterface.CancelMediaQualityRequest( iConfig ) );
       
   172 
       
   173     User::LeaveIfError( iInterface.StopStream( iSessionId, iLinkId, iStreamId1 ) );
       
   174     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId1, KMccStreamStopped );
       
   175     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId1, KMccStreamStopped );
       
   176 
       
   177     User::LeaveIfError( iInterface.StopStream( iSessionId, iLinkId, iStreamId2 ) );
       
   178     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId2, KMccStreamStopped );
       
   179     iIfStub.WaitForEvent( iSessionId, iLinkId, iStreamId2, KMccStreamStopped );
       
   180     
       
   181     User::LeaveIfError( iInterface.DeleteStream( iSessionId, iLinkId, iStreamId1 ) );
       
   182     User::LeaveIfError( iInterface.DeleteStream( iSessionId, iLinkId, iStreamId2 ) );
       
   183     
       
   184     //iInterface.RemoveDataSink( iSessionId, iLinkId1, iStreamId1, iAudioSinkId );
       
   185     //iInterface.RemoveDataSource( iSessionId, iLinkId1, iStreamId1, iRtpSourceId );
       
   186     
       
   187     User::LeaveIfError( iInterface.CloseLink( iSessionId, iLinkId ) );
       
   188     User::LeaveIfError( iInterface.CloseSession( iSessionId ) );
       
   189     }
       
   190 
       
   191 // ---------------------------------------------------------------------------
       
   192 // CTestAsyncFeat::FetchCodecByMimeSubtypeNameL
       
   193 // Private
       
   194 // ---------------------------------------------------------------------------
       
   195 //
       
   196 CMccCodecInformation* CTestAsyncFeat::FetchCodecByMimeSubtypeNameL( 
       
   197         const CMccInterface& aInterface, const TDesC8& aName ) const
       
   198     {
       
   199     RPointerArray<CMccCodecInformation> codecArray;
       
   200     CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray );
       
   201     User::LeaveIfError( aInterface.GetCapabilities( codecArray ) );
       
   202     
       
   203     CMccCodecInformation* tmp = NULL;
       
   204     TInt ind( codecArray.Count() );
       
   205     
       
   206     while ( ( ind-- ) && ( NULL == tmp ) )
       
   207         {
       
   208         if ( codecArray[ind]->SdpName().Compare( aName ) == 0 )
       
   209             {
       
   210             tmp = codecArray[ind]->CloneDetailedL();
       
   211             }
       
   212         }
       
   213     
       
   214     if ( NULL == tmp )
       
   215         {
       
   216         User::Leave( KErrNotFound );
       
   217         }
       
   218     
       
   219     CleanupStack::PopAndDestroy( &codecArray );
       
   220     return tmp;
       
   221     }
       
   222  
       
   223 
       
   224 // End of File