multimediacommscontroller/mmccsubcontroller/src/mccsymsubthreadclient.cpp
changeset 0 1bce908db942
child 32 f2ed1fc4c163
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004-2008 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:    Symmetric subthread client
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <mmf/server/mmfdatasource.h>
       
    22 #include <mmf/server/mmfdatasink.h>
       
    23 
       
    24 #include "mccsymsubthreadclient.h"
       
    25 #include "mccsymulstream.h"
       
    26 #include "mccsymdlstream.h"
       
    27 #include "mccsymsimpledlstream.h"
       
    28 #include "mccdtmfdlstream.h"
       
    29 #include "mccdtmfulstream.h"
       
    30 #include "mccrtpmanager.h"
       
    31 #include "amrpayloadformatutil.h"
       
    32 #include "mccinternalevents.h"
       
    33 #include "mccsubcontrollerlogs.h"
       
    34 #include "mmccsecureinterface.h"
       
    35 
       
    36 
       
    37 // ============================ MEMBER FUNCTIONS ===============================
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CMccSymSubthreadClient::CMccSymSubthreadClient
       
    41 // C++ default constructor can NOT contain any code, that
       
    42 // might leave.
       
    43 // -----------------------------------------------------------------------------
       
    44 CMccSymSubthreadClient::CMccSymSubthreadClient(
       
    45     MMccEventHandler* aObserver,
       
    46     MMccResources* aMccResources,
       
    47     TInt aLinkType,
       
    48     TUint32 aMccSessionId ):
       
    49     CMccSubThreadClientBase( aObserver, aMccResources, aLinkType, aMccSessionId )        
       
    50     {
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CMccSymSubthreadClient::ConstructL
       
    55 // Symbian 2nd phase constructor can leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 void CMccSymSubthreadClient::ConstructL()
       
    58     {
       
    59 	__SUBCONTROLLER( "CMccSymSubthreadClient::ConstructL" )
       
    60 	User::LeaveIfNull( iObserver );
       
    61 	User::LeaveIfNull( iMccResources );
       
    62     iRtpmanager = CMccRtpManager::NewL( *this, *iMccResources, MccSessionId() );
       
    63 	__SUBCONTROLLER( "CMccSymSubthreadClient::ConstructL, exit" )
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CMccSymSubthreadClient::NewL
       
    68 // Static constructor.
       
    69 // -----------------------------------------------------------------------------
       
    70 CMccSymSubthreadClient* CMccSymSubthreadClient::NewL( 
       
    71     MMccEventHandler* aObserver, 
       
    72     MMccResources* aMccResources,
       
    73     TInt aLinkType,
       
    74     TUint32 aMccSessionId )
       
    75     {        
       
    76     CMccSymSubthreadClient* self = 
       
    77             new ( ELeave ) CMccSymSubthreadClient( aObserver, aMccResources, aLinkType, aMccSessionId );
       
    78     CleanupStack::PushL( self );
       
    79     self->ConstructL();
       
    80     CleanupStack::Pop( self );
       
    81     return self;
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CMccSymSubthreadClient::~CMccSymSubthreadClient
       
    86 // Destructor
       
    87 // -----------------------------------------------------------------------------
       
    88 CMccSymSubthreadClient::~CMccSymSubthreadClient()
       
    89     {
       
    90 	__SUBCONTROLLER( "CMccSymSubthreadClient::~CMccSymSubthreadClient" )
       
    91 		        
       
    92     iStreams.ResetAndDestroy();
       
    93     iStreams.Close();
       
    94     
       
    95     iUnusedStreams.Reset();
       
    96     iUnusedStreams.Close();
       
    97     
       
    98     if( iRtpmanager )
       
    99         {
       
   100         iRtpmanager->CloseSession();
       
   101         delete iRtpmanager;
       
   102         }    
       
   103 	__SUBCONTROLLER( "CMccSymSubthreadClient::~CMccSymSubthreadClient, exit" )
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CMccSymSubthreadClient::SetVolumeL
       
   108 // Creates a new RTP session in a subthread
       
   109 // -----------------------------------------------------------------------------
       
   110 void CMccSymSubthreadClient::SetVolumeL( TInt aVolume )
       
   111     {
       
   112 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::SetVolumeL", aVolume )
       
   113     TInt strmCount = iStreams.Count();
       
   114     if( strmCount )
       
   115         {
       
   116         for( TInt k = 0; k < strmCount; k++ )
       
   117             {
       
   118             iStreams[k]->SetVolumeL( aVolume );
       
   119             }
       
   120         }
       
   121     else
       
   122         {        
       
   123 	    __SUBCONTROLLER( "CMccSymSubthreadClient::SetVolumeL, no streams" )
       
   124         }
       
   125 	__SUBCONTROLLER( "CMccSymSubthreadClient::SetVolumeL, exit" )
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CMccSymSubthreadClient::SetGainL
       
   130 // Creates a new RTP session in a subthread
       
   131 // -----------------------------------------------------------------------------
       
   132 void CMccSymSubthreadClient::SetGainL( TInt aGain )
       
   133     {
       
   134 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::SetGainL", aGain )
       
   135     TInt strmCount = iStreams.Count();
       
   136     if( strmCount )
       
   137         {
       
   138         for( TInt k = 0; k < strmCount; k++ )
       
   139             {
       
   140             iStreams[k]->SetGainL( aGain );
       
   141             }
       
   142         }
       
   143     else
       
   144         {
       
   145 	    __SUBCONTROLLER( "CMccSymSubthreadClient::SetGainL, no streams" )
       
   146         }
       
   147 	__SUBCONTROLLER( "CMccSymSubthreadClient::SetGainL, exit" )
       
   148     }
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CMccSymSubthreadClient::VolumeL
       
   152 // Creates a new RTP session in a subthread
       
   153 // -----------------------------------------------------------------------------
       
   154 TInt CMccSymSubthreadClient::GetVolumeL( const TUint32 aStreamId )
       
   155     {
       
   156 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::GetVolumeL for streamId", aStreamId )
       
   157 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   158     TInt volume = 0;
       
   159     TInt index = FindStreamL( aStreamId );
       
   160     volume = iStreams[index]->VolumeL();
       
   161 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::GetVolumeL exit with", volume )
       
   162     return volume;
       
   163     }
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CMccSymSubthreadClient::GainL
       
   167 // Creates a new RTP session in a subthread
       
   168 // -----------------------------------------------------------------------------
       
   169 TInt CMccSymSubthreadClient::GetGainL( const TUint32 aStreamId )
       
   170     {
       
   171 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::GetGainL for streamId", aStreamId )
       
   172 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   173     TInt gain = 0;
       
   174     TInt index = FindStreamL( aStreamId );
       
   175     gain = iStreams[index]->GainL();
       
   176 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::GetGainL exit with", gain )
       
   177     return gain;
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // CMccSymSubthreadClient::MaxVolumeL
       
   182 // Creates a new RTP session in a subthread
       
   183 // -----------------------------------------------------------------------------
       
   184 TInt CMccSymSubthreadClient::MaxVolumeL( const TUint32 aStreamId )
       
   185     {
       
   186 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::MaxVolumeL for streamId", aStreamId )
       
   187 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   188     TInt maxvolume = 0;
       
   189     TInt index = FindStreamL( aStreamId );
       
   190     maxvolume = iStreams[index]->MaxVolumeL();
       
   191 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::MaxVolumeL exit with", maxvolume )
       
   192     return maxvolume;
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // CMccSymSubthreadClient::MaxGainL
       
   197 // Creates a new RTP session in a subthread
       
   198 // -----------------------------------------------------------------------------
       
   199 TInt CMccSymSubthreadClient::MaxGainL( const TUint32 aStreamId )
       
   200     {
       
   201 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::MaxGainL for streamId", aStreamId )
       
   202 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   203     TInt maxgain = 0;
       
   204     TInt index = FindStreamL( aStreamId );
       
   205     maxgain = iStreams[index]->MaxGainL();
       
   206 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::MaxGainL exit with", maxgain )
       
   207     return maxgain;
       
   208     }
       
   209 
       
   210 // -----------------------------------------------------------------------------
       
   211 // CMccSymSubthreadClient::SetBalanceL
       
   212 // From CMccSubThreadClientBase
       
   213 // -----------------------------------------------------------------------------
       
   214 void CMccSymSubthreadClient::SetBalanceL( const TUint32 aStreamId, TInt aLeftBalance, 
       
   215         TInt aRightBalance )
       
   216     {
       
   217 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::SetBalanceL for streamId", aStreamId )
       
   218 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::SetBalanceL for LeftBalance", aLeftBalance )
       
   219 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::SetBalanceL for RightBalance", aRightBalance )
       
   220 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   221     TInt index = FindStreamL( aStreamId );
       
   222     iStreams[index]->SetBalanceL( aLeftBalance, aRightBalance );
       
   223 	__SUBCONTROLLER( "CMccSymSubthreadClient::SetBalanceL exit" )
       
   224     }
       
   225     
       
   226 // -----------------------------------------------------------------------------
       
   227 // CMccSymSubthreadClient::GetBalanceL
       
   228 // From CMccSubThreadClientBase
       
   229 // -----------------------------------------------------------------------------
       
   230 void CMccSymSubthreadClient::GetBalanceL( const TUint32 aStreamId, TInt& aLeftBalance, 
       
   231         TInt& aRightBalance )
       
   232     {
       
   233 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::GetBalanceL for streamId", aStreamId )
       
   234 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   235     TInt index = FindStreamL( aStreamId );
       
   236     iStreams[index]->GetBalanceL( aLeftBalance, aRightBalance );
       
   237 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::GetBalanceL for LeftBalance", aLeftBalance )
       
   238 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::GetBalanceL for RightBalance", aRightBalance )
       
   239 	__SUBCONTROLLER( "CMccSymSubthreadClient::GetBalanceL exit" )
       
   240     }
       
   241     
       
   242 // -----------------------------------------------------------------------------
       
   243 // CMccSymSubthreadClient::OpenL
       
   244 // From CMccSubThreadClientBase
       
   245 // -----------------------------------------------------------------------------
       
   246 void CMccSymSubthreadClient::OpenL( TInt aStreamType,
       
   247                                     TFourCC aFourCC,
       
   248                                     MDataSource* aDatasource, 
       
   249                                     MDataSink* aDatasink,
       
   250                                     const TUint32 aStreamId,
       
   251                                     TMMFPrioritySettings aSettings )
       
   252     {
       
   253 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::OpenL for streamId", aStreamId )
       
   254 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient stream type", aStreamType )
       
   255     __ASSERT_ALWAYS( iSessionCreated, User::Leave( KErrNotReady ) );
       
   256     __ASSERT_ALWAYS( aDatasource, User::Leave( KErrArgument ) );
       
   257     __ASSERT_ALWAYS( aDatasink, User::Leave( KErrArgument ) );
       
   258         
       
   259     TUid sourceType = aDatasource->DataSourceType();
       
   260     TUid sinkType = aDatasink->DataSinkType();
       
   261 
       
   262 	iPrioritySettingsData = aSettings;
       
   263 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient audio priority", iPrioritySettingsData.iPriority )
       
   264 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient audio preference", iPrioritySettingsData.iPref )
       
   265 
       
   266     CMccSymStreamBase* stream( NULL );
       
   267     
       
   268     TBool localAVToDisplayStream = ( aStreamType == KMccVideoLocalStream ||
       
   269                                      aStreamType == KMccAudioLocalStream ) &&
       
   270                                      sourceType == KMccFileSourceUid &&
       
   271                                      sinkType == KMccVideoSinkUid;
       
   272     
       
   273     if ( KMccDtmfStream == aStreamType && KMccRtpSourceUid == sourceType )
       
   274         {
       
   275         __SUBCONTROLLER( "CMccSymSubthreadClient::OpenL, new CMccDtmfDlStream" )
       
   276         
       
   277         stream = CMccDtmfDlStream::NewLC( aStreamId, this, iMccResources,
       
   278             iRtpmanager, aFourCC, aStreamType, *iRtpMediaClock );
       
   279         }
       
   280     else if ( KMccDtmfStream == aStreamType && KMccRtpSinkUid == sinkType )
       
   281         {
       
   282         __SUBCONTROLLER( "CMccSymSubthreadClient::OpenL, new CMccDtmfUlStream" )
       
   283         
       
   284         stream = CMccDtmfUlStream::NewLC( aStreamId, this, iMccResources,
       
   285             iRtpmanager, aFourCC, aStreamType, *iRtpMediaClock );
       
   286         }
       
   287     // Special handling for local video if it should be displayed (treat as uplink)
       
   288     else if( sinkType == KMccRtpSinkUid ||
       
   289         localAVToDisplayStream )
       
   290         {
       
   291 	    __SUBCONTROLLER( "CMccSymSubthreadClient::OpenL, new CMccSymUlStream" )
       
   292         stream = CMccSymUlStream::NewLC( aStreamId, 
       
   293                                          this, 
       
   294                                          iMccResources, 
       
   295                                          iRtpmanager, 
       
   296                                          aFourCC, 
       
   297                                          aStreamType,
       
   298                                          *iRtpMediaClock );
       
   299         }
       
   300     else if( sourceType == KMccRtpSourceUid && sinkType != KMccVideoSinkUid )
       
   301         {
       
   302 	    __SUBCONTROLLER( "CMccSymSubthreadClient::OpenL, new CMccSymDlStream" )
       
   303         stream = CMccSymDlStream::NewLC( aStreamId, 
       
   304                                          this, 
       
   305                                          iMccResources,
       
   306                                          iRtpmanager, 
       
   307                                          aStreamType );
       
   308         }
       
   309     else if( ( sourceType == KMccRtpSourceUid && sinkType == KMccVideoSinkUid ) ||
       
   310              ( aStreamType == KMccAudioLocalStream || aStreamType == KMccVideoLocalStream ) )
       
   311         {  
       
   312         __SUBCONTROLLER( "CMccSymSubthreadClient::OpenL, new CMccSymSimpleDlStream" )      
       
   313         stream = CMccSymSimpleDlStream::NewLC( aStreamId, 
       
   314                                                this, 
       
   315                                                iMccResources,
       
   316                                                iRtpmanager, 
       
   317                                                aFourCC, 
       
   318                                                aStreamType );
       
   319                 
       
   320         }
       
   321     else
       
   322         {
       
   323 	    __SUBCONTROLLER( "CMccSymSubthreadClient::OpenL, KErrArgument" )
       
   324         User::Leave( KErrArgument );
       
   325         }
       
   326     
       
   327     stream->AddSinkAndSourceL( aDatasink, aDatasource );
       
   328     iStreams.AppendL( stream );
       
   329     CleanupStack::Pop( stream );
       
   330         
       
   331     TInt index = FindStreamL( aStreamId );     
       
   332     iStreams[ index ]->SetMMFPriority( aSettings );
       
   333    
       
   334 	__SUBCONTROLLER( "CMccSymSubthreadClient::OpenL, exit" )
       
   335     }
       
   336 
       
   337 
       
   338 // -----------------------------------------------------------------------------
       
   339 // CMccSymSubthreadClient::PrepareL
       
   340 // From CMccSubThreadClientBase
       
   341 // -----------------------------------------------------------------------------
       
   342 void CMccSymSubthreadClient::PrepareL( const TUint32 aStreamId, 
       
   343 									   const TUint32 aEndpointId )
       
   344     {
       
   345 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::PrepareL, streamId", aStreamId )
       
   346 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::PrepareL, aEndpointId", aEndpointId )
       
   347 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   348     TInt index = FindStreamL( aStreamId );
       
   349     iStreams[index]->PrimeL( aEndpointId );	
       
   350 	__SUBCONTROLLER( "CMccSymSubthreadClient::PrepareL, exit" )
       
   351     }
       
   352 
       
   353 // -----------------------------------------------------------------------------
       
   354 // CMccSymSubthreadClient::PlayL
       
   355 // From CMccSubThreadClientBase
       
   356 // -----------------------------------------------------------------------------
       
   357 void CMccSymSubthreadClient::PlayL( const TUint32 aStreamId,
       
   358                                     const TUint32 aEndpointId,
       
   359                                     TBool aStreamPaused,
       
   360                                     TBool aEnableRTCP )
       
   361     {
       
   362 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::PlayL, streamId", aStreamId )
       
   363 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::PlayL, aEndpointId", aEndpointId )
       
   364 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   365     TInt index = FindStreamL( aStreamId );
       
   366     iStreams[index]->PlayL( aEndpointId, aStreamPaused, aEnableRTCP ); 
       
   367 	__SUBCONTROLLER( "CMccSymSubthreadClient::PlayL, exit" )
       
   368     }
       
   369 
       
   370 // -----------------------------------------------------------------------------
       
   371 // CMccSymSubthreadClient::StopL
       
   372 // From CMccSubThreadClientBase
       
   373 // -----------------------------------------------------------------------------
       
   374 void CMccSymSubthreadClient::StopL( const TUint32 aStreamId,
       
   375 									const TUint32 aEndpointId )
       
   376     {
       
   377 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::StopL, streamId", aStreamId )
       
   378 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::StopL, aEndpointId", aEndpointId )
       
   379     TInt index = FindStream( aStreamId );
       
   380     if ( index != KErrNotFound )
       
   381         {
       
   382         iStreams[index]->StopL( aEndpointId );
       
   383         }
       
   384     else
       
   385         {
       
   386         // No need to stop if unused
       
   387         index = iUnusedStreams.Find( aStreamId );
       
   388         __ASSERT_ALWAYS( index != KErrNotFound, User::Leave( KErrNotFound ) );
       
   389         }
       
   390 	__SUBCONTROLLER( "CMccSymSubthreadClient::StopL, exit" )
       
   391     }
       
   392 
       
   393 // -----------------------------------------------------------------------------
       
   394 // CMccSymSubthreadClient::PauseL
       
   395 // From CMccSubThreadClientBase
       
   396 // -----------------------------------------------------------------------------
       
   397 void CMccSymSubthreadClient::PauseL( const TUint32 aStreamId,
       
   398 									 const TUint32 aEndpointId,
       
   399                                      TBool aEnableRTCP )
       
   400     {
       
   401 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::PauseL, streamId", aStreamId )
       
   402 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::PauseL, aEndpointId", aEndpointId )
       
   403 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   404     TInt index = FindStreamL( aStreamId );
       
   405     iStreams[index]->PauseL( aEndpointId, aEnableRTCP );
       
   406 	__SUBCONTROLLER( "CMccSymSubthreadClient::PauseL, exit" )
       
   407     }
       
   408     
       
   409 // -----------------------------------------------------------------------------
       
   410 // CMccSymSubthreadClient::ResumeL
       
   411 // From CMccSubThreadClientBase
       
   412 // -----------------------------------------------------------------------------
       
   413 void CMccSymSubthreadClient::ResumeL( const TUint32 aStreamId,
       
   414 									  const TUint32 aEndpointId,
       
   415                                       TBool aEnableRTCP )
       
   416     {
       
   417 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::ResumeL, streamId", aStreamId )
       
   418 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::ResumeL, aEndpointId", aEndpointId )
       
   419 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   420     TInt index = FindStreamL( aStreamId );
       
   421     iStreams[index]->ResumeL( aEndpointId, aEnableRTCP );
       
   422     __SUBCONTROLLER( "CMccSymSubthreadClient::ResumeL, exit" )
       
   423     }
       
   424 
       
   425 // -----------------------------------------------------------------------------
       
   426 // CMccSymSubthreadClient::CloseL
       
   427 // From CMccSubThreadClientBase
       
   428 // -----------------------------------------------------------------------------
       
   429 void CMccSymSubthreadClient::CloseL( const TUint32 aStreamId )
       
   430     {
       
   431 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::CloseL, streamId", aStreamId )
       
   432     
       
   433     TInt index = FindStream( aStreamId );
       
   434     if ( index != KErrNotFound )
       
   435         {
       
   436         CMccSymStreamBase* tmp = iStreams[index];
       
   437         iStreams.Remove( index );
       
   438         delete tmp;
       
   439         }
       
   440     else 
       
   441         {
       
   442         index = iUnusedStreams.Find( aStreamId );
       
   443         __ASSERT_ALWAYS( index != KErrNotFound, User::Leave( KErrNotFound ) );
       
   444 
       
   445         // Stream was already deleted
       
   446         iUnusedStreams.Remove( index );
       
   447         }
       
   448     
       
   449     // No need to fail stream deletion if manager update fails
       
   450     TRAP_IGNORE( iRtpmanager->UpdateL() )
       
   451         
       
   452 	__SUBCONTROLLER( "CMccSymSubthreadClient::CloseL, exit" )
       
   453     }
       
   454 
       
   455 // -----------------------------------------------------------------------------
       
   456 // CMccSymSubthreadClient::CloseL 
       
   457 // Closes all links
       
   458 // -----------------------------------------------------------------------------
       
   459 void CMccSymSubthreadClient::CloseL()
       
   460     {
       
   461 	__SUBCONTROLLER( "CMccSymSubthreadClient::CloseL" )
       
   462 	
       
   463     for ( TInt i = iStreams.Count() - 1; i >= 0; i-- )
       
   464     	{
       
   465         CMccSymStreamBase* tmp = iStreams[i];
       
   466         tmp->RemoveContext( 0 );
       
   467         iStreams.Remove( i );
       
   468         delete tmp;        	    	
       
   469     	}
       
   470 	__SUBCONTROLLER( "CMccSymSubthreadClient::CloseL, exit" )
       
   471     }
       
   472 
       
   473 // -----------------------------------------------------------------------------
       
   474 // CMccSymSubthreadClient::StreamsExistsL 
       
   475 // -----------------------------------------------------------------------------
       
   476 TBool CMccSymSubthreadClient::StreamsExistsL()
       
   477     {
       
   478     if (iStreams.Count())
       
   479         {
       
   480         return ETrue;
       
   481         }
       
   482     else
       
   483         {
       
   484         return  EFalse;
       
   485         }
       
   486     }
       
   487 
       
   488 // -----------------------------------------------------------------------------
       
   489 // CMccSymSubthreadClient::SendMediaSignalL
       
   490 // Send media signalling to uplink
       
   491 // -----------------------------------------------------------------------------
       
   492 //  
       
   493 void CMccSymSubthreadClient::SendMediaSignalL( const TMccEvent& aEvent )
       
   494     {
       
   495 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::SendMediaSignalL, streamId", aEvent.iStreamId )
       
   496 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   497     TInt index = FindStreamL( aEvent.iStreamId );
       
   498     iStreams[index]->SendMediaSignalL( aEvent );
       
   499 	__SUBCONTROLLER( "CMccSymSubthreadClient::SendMediaSignalL, exit" )
       
   500     }
       
   501 
       
   502 // -----------------------------------------------------------------------------
       
   503 // CMccUlSubThreadClient::SendRTCPReceiverReportL
       
   504 // Sends a RTCP receiver report
       
   505 // -----------------------------------------------------------------------------
       
   506 //  
       
   507 void CMccSymSubthreadClient::SendRTCPReceiverReportL( const TUint32 aStreamId )
       
   508     {
       
   509 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::SendRTCPReceiverReportL, streamId", aStreamId )
       
   510 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   511     TInt index = FindStreamL( aStreamId );
       
   512     iStreams[index]->SendRTCPReceiverReportL();
       
   513 	__SUBCONTROLLER( "CMccSymSubthreadClient::SendRTCPReceiverReportL, exit" )
       
   514     }
       
   515 
       
   516 // -----------------------------------------------------------------------------
       
   517 // CMccUlSubThreadClient::SendRTCPSenderReportL
       
   518 // Sends a RTCP sender report
       
   519 // -----------------------------------------------------------------------------
       
   520 // 
       
   521 void CMccSymSubthreadClient::SendRTCPSenderReportL( const TUint32 aStreamId )
       
   522     {
       
   523 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::SendRTCPSenderReportL, streamId", aStreamId )
       
   524 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   525     TInt index = FindStreamL( aStreamId );
       
   526     iStreams[index]->SendRTCPSenderReportL();
       
   527 	__SUBCONTROLLER( "CMccSymSubthreadClient::SendRTCPSenderReportL, exit" )
       
   528     }
       
   529     
       
   530 // -----------------------------------------------------------------------------
       
   531 // CMccSymSubthreadClient::SendRTCPDataL
       
   532 // Sends Non-RTCP data
       
   533 // -----------------------------------------------------------------------------
       
   534 // 
       
   535 void CMccSymSubthreadClient::SendRTCPDataL( const TUint32 aStreamId,
       
   536                                             const TDesC8& aData )
       
   537     {
       
   538 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::SendRTCPDataL, streamId", aStreamId )
       
   539 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   540     TInt index = FindStreamL( aStreamId );
       
   541     iStreams[index]->SendRTCPDataL( aData );
       
   542 	__SUBCONTROLLER( "CMccSymSubthreadClient::SendRTCPDataL, exit" )
       
   543     }
       
   544 
       
   545 // -----------------------------------------------------------------------------
       
   546 // CMccUlSubThreadClient::GetSupportedBitratesL
       
   547 // Gets the supported bitrates from the codec of the specified stream
       
   548 // -----------------------------------------------------------------------------    
       
   549 void CMccSymSubthreadClient::GetSupportedBitratesL( const TUint32 /*aStreamId*/,
       
   550                                                    RArray<TUint>& /*aBitrates*/ )
       
   551     {
       
   552     //TBI: What with the stream ID?
       
   553     //TODO //User::LeaveIfError( iSubthread.GetSupportedBitrates( aBitrates ) );
       
   554     }
       
   555     
       
   556 // -----------------------------------------------------------------------------
       
   557 // CMccUlSubThreadClient::GetSSRCL
       
   558 // Gets the syncronization source for the specified stream
       
   559 // -----------------------------------------------------------------------------    
       
   560 void CMccSymSubthreadClient::GetSSRCL( const TUint32 aStreamId, TUint32& aSSRCValue )
       
   561     {
       
   562 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::GetSSRCL, streamId", aStreamId )
       
   563 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   564     TInt index = FindStreamL( aStreamId );
       
   565     iStreams[index]->GetSSRCL( aSSRCValue );
       
   566 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::GetSSRCL, SSRC", aSSRCValue )
       
   567 	__SUBCONTROLLER( "CMccSymSubthreadClient::GetSSRCL, exit" )
       
   568     }
       
   569     
       
   570 // -----------------------------------------------------------------------------
       
   571 // CMccDlSubThreadClient::StartInactivityTimerL
       
   572 // Starts inactivity timer for a stream 
       
   573 // -----------------------------------------------------------------------------    
       
   574 void CMccSymSubthreadClient::StartInactivityTimerL( const TUint32 aStreamId,
       
   575                                                    TUint32 aTimeoutTime )
       
   576     {
       
   577 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::StartInactivityTimerL, streamId", aStreamId )
       
   578 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   579     TInt index = FindStreamL( aStreamId );
       
   580     iStreams[index]->StartInactivityTimerL( aTimeoutTime );
       
   581 	__SUBCONTROLLER( "CMccSymSubthreadClient::StartInactivityTimerL, exit" )
       
   582     }
       
   583        
       
   584 // -----------------------------------------------------------------------------
       
   585 // CMccDlSubThreadClient::StopInactivityTimerL
       
   586 // Stops inactivity timer for a stream 
       
   587 // -----------------------------------------------------------------------------    
       
   588 void CMccSymSubthreadClient::StopInactivityTimerL( const TUint32 aStreamId )
       
   589     {
       
   590 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::StopInactivityTimerL, streamId", aStreamId )
       
   591 	__ASSERT_ALWAYS( iStreams.Count(), User::Leave( KErrNotFound ) );
       
   592     TInt index = FindStreamL( aStreamId );
       
   593     iStreams[index]->StopInactivityTimerL();
       
   594 	__SUBCONTROLLER( "CMccSymSubthreadClient::StopInactivityTimerL, exit" )
       
   595     }
       
   596 
       
   597 // -----------------------------------------------------------------------------
       
   598 // CMccSymSubthreadClient::GetFmtpAttrL
       
   599 // Fetches the FMTP attribute of the current codec
       
   600 // -----------------------------------------------------------------------------
       
   601 // 
       
   602 void CMccSymSubthreadClient::GetFmtpAttrL( const TUint32 /*aStreamId*/,
       
   603                                            TDes8& /*aFmtp*/ )
       
   604     {
       
   605     
       
   606     } 
       
   607     
       
   608 // -----------------------------------------------------------------------------
       
   609 // CMccSymSubthreadClient::SetRemoteAddressL
       
   610 // Sets the remote address of uplink stream
       
   611 // -----------------------------------------------------------------------------
       
   612 void CMccSymSubthreadClient::SetRemoteAddressL( TInetAddr aRemAddr )
       
   613     {    
       
   614 	__SUBCONTROLLER( "CMccSymSubthreadClient::SetRemoteAddressL" )
       
   615     __ASSERT_ALWAYS( iRtpmanager, User::Leave( KErrArgument ) );
       
   616 
       
   617     User::LeaveIfError( iRtpmanager->SetRemoteAddress( aRemAddr ) );
       
   618     
       
   619     TInt strmCount = iStreams.Count();
       
   620     for( TInt k = 0; k < strmCount; k++ )
       
   621         {
       
   622         iStreams[k]->ResetCountersL();
       
   623         }
       
   624 	__SUBCONTROLLER( "CMccSymSubthreadClient::SetRemoteAddressL, exit" )
       
   625     }
       
   626 
       
   627 // -----------------------------------------------------------------------------
       
   628 // CMccSymSubthreadClient::SetRemoteAddressL
       
   629 // Sets the remote address of uplink stream
       
   630 // -----------------------------------------------------------------------------
       
   631 void CMccSymSubthreadClient::SetRemoteRtcpAddrL( TInetAddr aRemAddr )
       
   632     {    
       
   633 	__SUBCONTROLLER( "CMccSymSubthreadClient::SetRemoteRtcpAddrL" )
       
   634     __ASSERT_ALWAYS( iRtpmanager, User::Leave( KErrArgument ) );
       
   635 
       
   636     User::LeaveIfError( iRtpmanager->SetRemoteRtcpAddr( aRemAddr ) );
       
   637     
       
   638     TInt strmCount = iStreams.Count();
       
   639     for( TInt k = 0; k < strmCount; k++ )
       
   640         {
       
   641         iStreams[k]->ResetCountersL();
       
   642         }
       
   643 	__SUBCONTROLLER( "CMccSymSubthreadClient::SetRemoteRtcpAddrL, exit" )
       
   644     }
       
   645     
       
   646 // -----------------------------------------------------------------------------
       
   647 // CMccSymSubthreadClient::InitializeLinkL
       
   648 // Initializes the RTP session in the subthread
       
   649 // -----------------------------------------------------------------------------
       
   650 //
       
   651 void CMccSymSubthreadClient::InitializeLinkL( TRequestStatus& aStatus,
       
   652                                               TInt aIapId )
       
   653     {    
       
   654 	__SUBCONTROLLER( "CMccSymSubthreadClient::InitializeLinkL" )
       
   655     __ASSERT_ALWAYS( !iSessionCreated, User::Leave( KErrAlreadyExists ) );
       
   656     iRtpmanager->InitializeL( aStatus, aIapId );
       
   657 	__SUBCONTROLLER( "CMccSymSubthreadClient::InitializeLinkL, exit" )
       
   658     }
       
   659 
       
   660 // -----------------------------------------------------------------------------
       
   661 // CMccSymSubthreadClient::CreateRtpSessionL
       
   662 // Creates the RTP session in the subthread
       
   663 // -----------------------------------------------------------------------------
       
   664 //
       
   665 void CMccSymSubthreadClient::CreateRtpSessionL( TUint aPort, 
       
   666                                                 TBool aEnableRTCP,
       
   667                                                 TInt aIpTos, 
       
   668                                                 CMccRtpMediaClock& aClock )
       
   669     {
       
   670 	__SUBCONTROLLER( "CMccSymSubthreadClient::CreateRtpSessionL" )
       
   671     iRtpMediaClock = &aClock;
       
   672     
       
   673     TBool secure( EFalse );
       
   674     if ( KMccLinkSecure == iLinkType || KMccLinkSecureVideo == iLinkType )
       
   675         {
       
   676         secure = ETrue;
       
   677         }
       
   678     
       
   679     TBool increaseDefaultSocketSize( EFalse );
       
   680     if ( KMccLinkGeneralVideo == iLinkType || KMccLinkSecureVideo == iLinkType )
       
   681         {
       
   682         increaseDefaultSocketSize = ETrue;
       
   683         }
       
   684         
       
   685     iRtpmanager->CreateSessionL( aPort, aEnableRTCP, secure, increaseDefaultSocketSize );
       
   686     iRtpmanager->SetIpTOS( aIpTos );
       
   687 	iSessionCreated = ETrue;
       
   688 	
       
   689 	__SUBCONTROLLER( "CMccSymSubthreadClient::CreateRtpSessionL, exit" )
       
   690 	}
       
   691     
       
   692 // -----------------------------------------------------------------------------
       
   693 // CMccSymSubthreadClient::SetAudioRouteL
       
   694 // -----------------------------------------------------------------------------
       
   695 //    
       
   696 void CMccSymSubthreadClient::SetAudioRouteL( 
       
   697     TUint32 aStreamId,
       
   698     TUint32 aRoutingDestination )
       
   699     {
       
   700     __SUBCONTROLLER( "CMccSymSubthreadClient::SetAudioRouteL" )
       
   701     TInt index = FindStreamL( aStreamId );
       
   702     iStreams[ index ]->SetAudioRouteL( aRoutingDestination );
       
   703 	__SUBCONTROLLER( "CMccSymSubthreadClient::SetAudioRouteL, exit" )
       
   704     }
       
   705 
       
   706 // -----------------------------------------------------------------------------
       
   707 // CMccSymSubthreadClient::GetAudioRouteL
       
   708 // -----------------------------------------------------------------------------
       
   709 //
       
   710 void CMccSymSubthreadClient::GetAudioRouteL( 
       
   711     TUint32 aStreamId,
       
   712     TUint32& aRoutingDestination )
       
   713     {
       
   714     __SUBCONTROLLER( "CMccSymSubthreadClient::GetAudioRouteL" )
       
   715     TInt index = FindStreamL( aStreamId );
       
   716     iStreams[ index ]->GetAudioRouteL( aRoutingDestination );
       
   717 	__SUBCONTROLLER( "CMccSymSubthreadClient::GetAudioRouteL, exit" )
       
   718     }
       
   719 
       
   720 // -----------------------------------------------------------------------------
       
   721 // CMccSymSubthreadClient::UnuseL
       
   722 // -----------------------------------------------------------------------------
       
   723 //    
       
   724 void CMccSymSubthreadClient::UnuseL( TUint32 aStreamId )
       
   725     {
       
   726     __SUBCONTROLLER_INT1( "CMccSymSubthreadClient::UsuseL, streamId", aStreamId )
       
   727     
       
   728     TInt index = FindStream( aStreamId );
       
   729     if ( index != KErrNotFound )
       
   730         {
       
   731         CMccSymStreamBase* tmp = iStreams[index];
       
   732         iStreams.Remove( index );
       
   733         delete tmp;
       
   734         
       
   735         // Store stream id for later use (when stream is explicitly deleted)
       
   736         iUnusedStreams.AppendL( aStreamId );
       
   737         }
       
   738     else 
       
   739         {
       
   740         index = iUnusedStreams.Find( aStreamId );
       
   741         __ASSERT_ALWAYS( index != KErrNotFound, User::Leave( KErrNotFound ) );
       
   742         }
       
   743     
       
   744 	__SUBCONTROLLER( "CMccSymSubthreadClient::UsuseL, exit" )
       
   745     }
       
   746 
       
   747 // -----------------------------------------------------------------------------
       
   748 // CMccSymSubthreadClient::GetLocalIpAddressesL
       
   749 // -----------------------------------------------------------------------------
       
   750 //
       
   751 void CMccSymSubthreadClient::GetLocalIpAddressesL( TMccCreateLink& aClientData )
       
   752 	{
       
   753 	__SUBCONTROLLER( "CMccSymSubthreadClient::GetLocalIpAddressesL" )
       
   754 	
       
   755 	iRtpmanager->GetLocalIpAddressesL( aClientData );
       
   756 	                                      
       
   757 	__SUBCONTROLLER( "CMccSymSubthreadClient::GetLocalIpAddressesL, exit" )
       
   758 	}
       
   759 
       
   760 // -----------------------------------------------------------------------------
       
   761 // CMccSymSubthreadClient::SetParameterL
       
   762 // -----------------------------------------------------------------------------
       
   763 //     
       
   764 void CMccSymSubthreadClient::SetParameterL( 
       
   765     TUint32 aParam,
       
   766     TUint32 /*aStreamId*/,
       
   767     TUint32 /*aEndpointId*/,
       
   768     const TDesC8& aVal )
       
   769     {
       
   770     __SUBCONTROLLER( "CMccSymSubthreadClient::SetParameterL" )
       
   771     
       
   772     switch ( aParam )
       
   773         {
       
   774         case KMccRtpCName:
       
   775             {
       
   776             iRtpmanager->SetCNameL( aVal );
       
   777             break;
       
   778             }
       
   779         default:
       
   780             {
       
   781             User::Leave( KErrNotSupported );
       
   782             break;
       
   783             }
       
   784         }
       
   785         
       
   786     __SUBCONTROLLER( "CMccSymSubthreadClient::SetParameterL, exit" )
       
   787     }
       
   788 
       
   789 // -----------------------------------------------------------------------------
       
   790 // CMccSymSubthreadClient::GetParameterL
       
   791 // -----------------------------------------------------------------------------
       
   792 //          
       
   793 void CMccSymSubthreadClient::GetParameterL( 
       
   794     TUint32 /*aParam*/,
       
   795     TUint32 /*aStreamId*/,
       
   796     TUint32 /*aEndpointId*/,
       
   797     TDesC8& /*aVal*/ )
       
   798     {
       
   799     }
       
   800     
       
   801 
       
   802 // -----------------------------------------------------------------------------
       
   803 // CMccSymSubthreadClient::SendEventToClient
       
   804 // -----------------------------------------------------------------------------
       
   805 //    
       
   806 TInt CMccSymSubthreadClient::SendEventToClient( const TMMFEvent& aEvent )
       
   807 	{
       
   808 	__SUBCONTROLLER( "CMccSymSubthreadClient::SendEventToClient" )
       
   809 	
       
   810 	// Do in a bit ackward way in order to save stack memory
       
   811 	TMccEvent* mccEventPtr = 0;
       
   812 	if ( IS_MCC_EVENT( aEvent ) )
       
   813 	    {
       
   814 	    mccEventPtr = 
       
   815 	        reinterpret_cast<const TMccInternalEvent&>( aEvent ).iMccEvent;                                     
       
   816 	    }
       
   817 	
       
   818 	if ( mccEventPtr )
       
   819 	    {
       
   820 	    mccEventPtr->iLinkId = iLinkId;
       
   821 
       
   822     	__SUBCONTROLLER_EVENT( (*mccEventPtr) )	    
       
   823 
       
   824         TUid eventUid = aEvent.iEventType;
       
   825         TUid amrUid = TUid::Uid( KDllUidAmrPayloadFormat );
       
   826 	    
       
   827 	    // If RTCP BYE received remove crypto context
       
   828 	    if ( KMccRtcpReceived == mccEventPtr->iEventType )
       
   829 	        {
       
   830 	        const TMccRtcpEventData& eventdata = 
       
   831     		    (*reinterpret_cast<const TMccRtcpEventDataPackage*>( 
       
   832                 &mccEventPtr->iEventData ))();
       
   833                 
       
   834             if ( KRtcpByePacket == eventdata.iRtcpPacketType )
       
   835                 {
       
   836                 // Remove crypto context                               
       
   837                 const TInt count = iStreams.Count();
       
   838                 for( TInt k = 0; k < count; k++ )
       
   839                     {
       
   840                     // Ignore the return value as we're doing this blindly                        
       
   841                     iStreams[k]->RemoveContext( 0 );
       
   842                     }   
       
   843                 }
       
   844 	        }
       
   845 	    
       
   846         if( amrUid == eventUid )
       
   847             {
       
   848             // Amr events not forwarded
       
   849             TInt err = HandleAmrEvent( aEvent, *mccEventPtr );
       
   850             __SUBCONTROLLER( "CMccSymSubthreadClient::SendEventToClient, exit" )
       
   851             return err;
       
   852             }
       
   853             
       
   854 	    iObserver->SendMccEventToClient( *mccEventPtr );
       
   855 	    }
       
   856 	else
       
   857 	    {
       
   858 	    TMccEvent mccEvent;
       
   859 	    DoMccEvent( mccEvent, aEvent );
       
   860 
       
   861     	__SUBCONTROLLER_EVENT( mccEvent )
       
   862 
       
   863 	    iObserver->SendMccEventToClient( mccEvent );
       
   864 	    }
       
   865     
       
   866 	__SUBCONTROLLER( "CMccSymSubthreadClient::SendEventToClient, exit" )
       
   867     return KErrNone;
       
   868 	}
       
   869     
       
   870 // -----------------------------------------------------------------------------
       
   871 // CMccSymSubthreadClient::DoMccEvent
       
   872 // -----------------------------------------------------------------------------
       
   873 //
       
   874 void CMccSymSubthreadClient::DoMccEvent( 
       
   875     TMccEvent& aEvent, 
       
   876     const TMMFEvent& aMMFEvent )
       
   877     {
       
   878     aEvent.iEventCategory = KMccEventCategoryStream;
       
   879 	aEvent.iEventType = KMccStreamMMFEvent;
       
   880     aEvent.iErrorCode = aMMFEvent.iErrorCode;
       
   881     aEvent.iLinkId = iLinkId;
       
   882     }
       
   883     
       
   884 // -----------------------------------------------------------------------------
       
   885 // CMccSymSubthreadClient::DataSink
       
   886 // -----------------------------------------------------------------------------
       
   887 //
       
   888 MDataSink* CMccSymSubthreadClient::DataSink( const TUint32 aStreamId )
       
   889     {
       
   890 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::DataSink, streamId", aStreamId )
       
   891     TInt strmCount = iStreams.Count();
       
   892     if( strmCount )
       
   893         {
       
   894         TInt index = this->FindStream( aStreamId );
       
   895         if ( index != KErrNotFound )
       
   896 	        {
       
   897 	        return iStreams[index]->DataSink();        	
       
   898 	        }
       
   899         }
       
   900     return NULL;    
       
   901     }
       
   902 
       
   903 // -----------------------------------------------------------------------------
       
   904 // CMccSymSubthreadClient::DataSource
       
   905 // -----------------------------------------------------------------------------
       
   906 //
       
   907 MDataSource* CMccSymSubthreadClient::DataSource( const TUint32 aStreamId )
       
   908     {
       
   909 	__SUBCONTROLLER_INT1( "CMccSymSubthreadClient::DataSource, streamId", aStreamId )
       
   910     TInt strmCount = iStreams.Count();
       
   911     if( strmCount )
       
   912         {
       
   913         TInt index = this->FindStream( aStreamId );
       
   914         if ( index != KErrNotFound )
       
   915 	        {
       
   916 	        return iStreams[index]->DataSource();        	
       
   917 	        }
       
   918         }
       
   919     return NULL; 
       
   920     }
       
   921 
       
   922 // -----------------------------------------------------------------------------
       
   923 // CMccSymSubthreadClient::BindContextIntoStreamL
       
   924 // -----------------------------------------------------------------------------
       
   925 //
       
   926 void CMccSymSubthreadClient::BindContextIntoStreamL( TUint32 aStreamId,
       
   927                                                      TUint32 aEndpointId,
       
   928                                                      const TMccCryptoContext& aContextParams )
       
   929     {
       
   930 	__SUBCONTROLLER( "CMccSymSubthreadClient::BindContextIntoStreamL IN" )
       
   931 	
       
   932 	TInt index = this->FindStreamL( aStreamId );
       
   933 	
       
   934 	iStreams[ index ]->BindContextIntoStreamL( aEndpointId, aContextParams );
       
   935 
       
   936 	__SUBCONTROLLER( "CMccSymSubthreadClient::BindContextIntoStreamL END" )
       
   937     }   
       
   938 
       
   939 // -----------------------------------------------------------------------------
       
   940 // CMccSymSubthreadClient::RemoveContextL
       
   941 // -----------------------------------------------------------------------------
       
   942 //
       
   943 void CMccSymSubthreadClient::RemoveContextL( TUint32 aStreamId,
       
   944                                              TUint32 aEndpointId )
       
   945     {
       
   946 	__SUBCONTROLLER( "CMccSymSubthreadClient::RemoveContextL IN" )
       
   947 	
       
   948 	TInt index = this->FindStreamL( aStreamId );
       
   949 	
       
   950 	iStreams[ index ]->RemoveContext( aEndpointId );
       
   951 
       
   952 	__SUBCONTROLLER( "CMccSymSubthreadClient::RemoveContextL END" )
       
   953     }
       
   954 
       
   955 // -----------------------------------------------------------------------------
       
   956 // CMccSymSubthreadClient::HandleAmrEvent
       
   957 // -----------------------------------------------------------------------------
       
   958 //
       
   959 TInt CMccSymSubthreadClient::HandleAmrEvent( 
       
   960     const TMMFEvent& aEvent,
       
   961     const TMccEvent& aMccEvent )
       
   962     {
       
   963     const TInt internalEvent = 
       
   964         reinterpret_cast<const TMccInternalEvent&>( aEvent ).iInternalEventType; 
       
   965     
       
   966     const TMccAmrEventData& eventdata = 
       
   967 	    (*reinterpret_cast<const TMccAmrEventDataPackage*>( 
       
   968         &aMccEvent.iEventData ))();
       
   969     
       
   970     __SUBCONTROLLER_INT1( "CMccSymStreamBase::HandleAmrEvent AMR EVENT:", 
       
   971                           internalEvent );
       
   972     __SUBCONTROLLER_INT1( "CMccSymStreamBase::HandleAmrEvent AMR MODE_REQ BITRATE:", 
       
   973                           eventdata.iModeRequestBitrate );
       
   974     
       
   975     if ( EMccInternalAmrEventCmr == internalEvent )
       
   976         {
       
   977         if ( eventdata.iModeRequestBitrate > 0 )
       
   978             {
       
   979             // Mode change request, forward it to other streams
       
   980             const TInt count = iStreams.Count();
       
   981             for( TInt k = 0; k < count; k++ )
       
   982                 {
       
   983                 // Ignore the return value as we're doing this blindly
       
   984                 iStreams[k]->ChangeBitrate( eventdata.iModeRequestBitrate );
       
   985                 }
       
   986             }
       
   987         }
       
   988     return KErrNone;
       
   989     }
       
   990     
       
   991 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   992 
       
   993 //  End of File