multimediacommscontroller/mmccsubcontroller/src/mccsymdlstream.cpp
changeset 0 1bce908db942
child 32 f2ed1fc4c163
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005-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:    Mcc Symmetric subthread downlink stream
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <mmf/server/mmfformat.h>
       
    22 #include <mmf/server/mmfaudiooutput.h>
       
    23 #include "mccsymdlstream.h"
       
    24 #include "mccdldatapath.h"
       
    25 #include "mccjitterbuffer.h"
       
    26 #include "mccrtpmanager.h"
       
    27 #include "mcccodecconfigurator.h"
       
    28 #include "mccinternaldef.h"
       
    29 #include "mccaudiorouter.h"
       
    30 #include "mccsubcontrollerlogs.h"
       
    31 #include "mccmultiplexer.h"
       
    32 #include "mccresources.h"
       
    33 #include "mccredpayloadread.h"
       
    34 
       
    35 // CONSTANTS
       
    36 
       
    37 // ============================= LOCAL FUNCTIONS ===============================
       
    38 
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CMccSymDlStream::CMccSymDlStream
       
    43 // C++ default constructor can NOT contain any code, that
       
    44 // might leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CMccSymDlStream::CMccSymDlStream( 
       
    48     TUint32 aMccStreamId, 
       
    49     MAsyncEventHandler* aEventhandler, 
       
    50     MMccResources* aMccResources, 
       
    51     CMccRtpManager* aManager, 
       
    52     TInt aStreamType ) : 
       
    53     CMccSymStreamBase( aMccStreamId, 
       
    54                        aEventhandler, 
       
    55                        aMccResources, 
       
    56                        aManager, 
       
    57                        aStreamType ), 
       
    58     iJitterBuffer( NULL ), 
       
    59     iFormatDecode( NULL )
       
    60     {
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CMccSymDlStream::NewL
       
    65 // Two-phased constructor.
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CMccSymDlStream* CMccSymDlStream::NewLC( 
       
    69     TUint32 aMccStreamId, 
       
    70     MAsyncEventHandler* aEventhandler, 
       
    71     MMccResources* aMccResources,
       
    72     CMccRtpManager* aManager, 
       
    73     TInt aStreamType ) 
       
    74     {
       
    75     CMccSymDlStream* s = 
       
    76             new ( ELeave ) CMccSymDlStream( aMccStreamId, 
       
    77                                             aEventhandler, 
       
    78                                             aMccResources,
       
    79                                             aManager, 
       
    80                                             aStreamType );
       
    81     CleanupStack::PushL( s );
       
    82     s->ConstructL();
       
    83     return s;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CMccSymDlStream::ConstructL
       
    88 // Symbian 2nd phase constructor can leave.
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void CMccSymDlStream::ConstructL()
       
    92     {
       
    93     iDatapath = 
       
    94         CMccDlDataPath::NewL( this, iMccResources, KUidMediaTypeAudio );
       
    95     iJitterBuffer = CMccJitterBuffer::NewL( this );
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CMccSymDlStream::~CMccSymDlStream
       
   100 // Destructor
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 CMccSymDlStream::~CMccSymDlStream()
       
   104     {
       
   105     delete iAudioRouter;
       
   106     
       
   107     if ( iSoundDevice )
       
   108         {
       
   109         iSoundDevice = NULL;
       
   110         }
       
   111         
       
   112     if ( iJitterBuffer )
       
   113         {
       
   114         iJitterBuffer->SinkThreadLogoff();
       
   115         delete iJitterBuffer;
       
   116         iJitterBuffer = NULL;
       
   117         }
       
   118     
       
   119     // Must do mux cleanup before decoder (mux sink) deletion
       
   120     MultiplexerCleanup();
       
   121          
       
   122     if ( iFormatDecode )
       
   123         {
       
   124         iFormatDecode->SourceThreadLogoff();
       
   125         delete iFormatDecode;
       
   126         iFormatDecode = NULL;
       
   127         }
       
   128     
       
   129     delete iRedFormatDecode;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CMccSymDlStream::SetPrioritySettingsL
       
   134 // Sets the MMF priority settings for this stream
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 void CMccSymDlStream::SetPrioritySettingsL( 
       
   138         const TMMFPrioritySettings& aPriority )
       
   139     {
       
   140     __ASSERT_ALWAYS( iDatasink, User::Leave( KErrNotReady ) );    
       
   141     
       
   142     iDatasink->SetSinkPrioritySettings( aPriority );
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CMccSymDlStream::AddSinkAndSourceL
       
   147 // From CMccSymStreamBase
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void CMccSymDlStream::AddSinkAndSourceL( MDataSink* aDatasink, 
       
   151         MDataSource* aDatasource )
       
   152     {
       
   153     __SUBCONTROLLER( "CMccSymDlStream::AddSinkAndSourceL" )
       
   154     
       
   155     __ASSERT_ALWAYS( aDatasink && aDatasource, User::Leave( KErrArgument ) );
       
   156 
       
   157     iDatasink = aDatasink;
       
   158     iDatasource = aDatasource;
       
   159 
       
   160     iMultiplexer = iMccResources->MultiplexerL( iDatasource );
       
   161     
       
   162  	if ( iDatasink->DataSinkType() == KUidMmfAudioOutput )
       
   163     	{
       
   164 	    iJitterBuffer->AddDataSinkL( iDatasink );
       
   165 	    
       
   166 	    // Cause the devsound to be loaded, as this call will pass through
       
   167 	    // jitterbuffer
       
   168 	    User::LeaveIfError( iJitterBuffer->SinkThreadLogon( *this ) );
       
   169 	    
       
   170 	    __SUBCONTROLLER( "CMccSymDlStream::AddSinkAndSourceL, devsound loaded" )
       
   171 	    
       
   172 	    iSoundDevice = &( static_cast<MMMFAudioOutput*>( iDatasink )->SoundDevice() );
       
   173 	    
       
   174 	    // Create new audio router
       
   175 	    delete iAudioRouter;
       
   176         iAudioRouter = 0;
       
   177         iAudioRouter = CMccAudioRouter::NewL( *iSoundDevice );
       
   178     
       
   179         iDatapath->AddDataSinkL( iJitterBuffer );
       
   180     	}
       
   181     else if ( iDatasink->DataSinkType() == KMccVideoSinkUid )
       
   182     	{
       
   183         iDatapath->AddDataSinkL( iDatasink );
       
   184                                  
       
   185         User::LeaveIfError( iDatasink->SinkThreadLogon(*this ) );
       
   186     	}
       
   187     else
       
   188         {
       
   189         }
       
   190         
       
   191     // Inform datapath about ids of associated sink and source
       
   192     iDatapath->SetAssociatedSink( iDatasink );
       
   193     iDatapath->SetAssociatedSource( iDatasource );
       
   194     
       
   195     __SUBCONTROLLER( "CMccSymDlStream::AddSinkAndSourceL, exit" )
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CMccSymDlStream::LoadCodecL
       
   200 // From CMccSymStreamBase
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 void CMccSymDlStream::LoadCodecL( const TMccCodecInfo& aCodecInfo,
       
   204                                   const TDesC8& aFmtp )
       
   205     {
       
   206     __SUBCONTROLLER_INT1( "CMccSymDlStream::LoadCodecL codec state:", 
       
   207         CurrentCodecState() )
       
   208     
       
   209     __ASSERT_ALWAYS( CurrentCodecState() == EStateCodecNone || 
       
   210                      iCodecInfo.iFourCC == aCodecInfo.iFourCC,
       
   211                      User::Leave( KErrArgument ) );
       
   212     
       
   213     TMccCodecInfo orig = iCodecInfo;
       
   214     iCodecInfo = aCodecInfo;
       
   215     
       
   216     if ( CurrentCodecState() == EStateCodecNone )
       
   217         {
       
   218         delete iFmtpAttr;
       
   219         iFmtpAttr = NULL;
       
   220 
       
   221     	iFmtpAttr = HBufC8::NewL( aFmtp.Length() );
       
   222         iFmtpAttr->Des().Copy( aFmtp );
       
   223         
       
   224         iCodecInfo.iFmtpLength = iFmtpAttr->Length();
       
   225         CreatePayloadFormatDecoderL();
       
   226         
       
   227         // Just negotiate the codec, load it later
       
   228         static_cast<CMccDlDataPath*>( iDatapath )->NegotiateL( *iFormatDecode );
       
   229         
       
   230         SetCodecState( EStateCodecNegotiated );        	
       
   231         }
       
   232     else if ( CurrentCodecState() == EStateCodecNegotiated )
       
   233         {
       
   234         // Codec is not fully usable yet, do just formatter initialization
       
   235         MccCodecConfigurator::ConfigureCodecL( *iFormatDecode,
       
   236                                                 *iDatasink,
       
   237                                                 aCodecInfo,
       
   238                                                 *iRtpMediaClock,
       
   239                                                 CurrentCodecState() );
       
   240                                                 
       
   241         SetCodecState( EStateCodecPrepared );
       
   242         }
       
   243     else if ( CurrentCodecState() == EStateCodecPrepared )
       
   244         {
       
   245         if ( CodecLoadingAllowed() )
       
   246             {
       
   247             // Load the codec
       
   248             static_cast<CMccDlDataPath*>( iDatapath )->LoadL( *iFormatDecode );
       
   249             
       
   250             TInt jbufLen = iCodecInfo.iMaxPtime;
       
   251             iJitterBuffer->SetupL( jbufLen, 
       
   252                                    iCodecInfo.iJitterBufThreshold, 
       
   253                                    iCodecInfo );
       
   254             
       
   255             // Set state before updating as the state affects to update functionality
       
   256             SetCodecState( EStateCodecLoaded );
       
   257                                                
       
   258             UpdateCodecInformationL( orig, iCodecInfo );
       
   259             }
       
   260         }
       
   261     else if ( CurrentCodecState() == EStateCodecLoaded ||
       
   262               CurrentCodecState() == EStateCodecLoadedAndUpdating )
       
   263         {
       
   264         // Update codec info
       
   265         if ( iDatasource->DataSourceType() == KMccRtpSourceUid )
       
   266        	    {
       
   267             CMccRtpDataSource* dataSource = 
       
   268                 static_cast<CMccRtpDataSource*>( iDatasource );
       
   269             
       
   270             // For updating keep alive parameters
       
   271             TMccCodecInfoBuffer infoBuffer( iCodecInfo );     
       
   272             dataSource->ConfigureL( infoBuffer );
       
   273        	    }
       
   274         SetCodecState( EStateCodecLoadedAndUpdating );
       
   275     	UpdateCodecInformationL( orig, iCodecInfo );
       
   276         }
       
   277     else
       
   278         {
       
   279         User::Leave( KErrNotReady );
       
   280         }
       
   281         
       
   282     __SUBCONTROLLER_INT1( "CMccSymDlStream::LoadCodecL exit, new state:", 
       
   283         CurrentCodecState() )
       
   284     }
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // CMccSymDlStream::UpdateCodecInformationL
       
   288 // From CMccSymStreamBase
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 void CMccSymDlStream::UpdateCodecInformationL( const TMccCodecInfo& aOriginal,
       
   292     const TMccCodecInfo& aNew )
       
   293     {
       
   294     __SUBCONTROLLER( "CMccSymDlStream::UpdateCodecInformationL Entry" )
       
   295     
       
   296     // UpdateCodecInformationL is called from LoadCodecL which checks that
       
   297     // codec itself is not changed. Here we re-configure the codec
       
   298     // parameters.
       
   299     __ASSERT_ALWAYS( iFormatDecode, User::Leave( KErrNotReady ) );
       
   300     __ASSERT_ALWAYS( iDatasink, User::Leave( KErrNotReady ) );
       
   301     
       
   302     HandleSpecialSinksAndSources();
       
   303     
       
   304     // NB; updated in LoadCodecL, update information added here
       
   305     iCodecInfo.iIsUpdate = ETrue;
       
   306     
       
   307     TBool specNeed = MccCodecConfigurator::IlbcNeedsStopResume(
       
   308             aOriginal.iBitrate,
       
   309             iCodecInfo.iBitrate,
       
   310             iCodecInfo.iFourCC );
       
   311     
       
   312     // Need to check also the codec state because CurrentCodecState may
       
   313     // return such codec state that does not allow iLBC reconfiguration.
       
   314     TCodecState codecState = CurrentCodecState();
       
   315     if ( specNeed && EStateStreaming == CurrentState() )
       
   316         {
       
   317         iJitterBuffer->SinkStopL();
       
   318         codecState = CMccSymStreamBase::EStateCodecLoaded;
       
   319         }
       
   320     
       
   321     MccCodecConfigurator::ConfigureCodecL( *iFormatDecode,
       
   322                                            *iDatasink,
       
   323                                            aNew,
       
   324                                            *iRtpMediaClock,
       
   325                                            codecState );
       
   326     
       
   327     if ( specNeed && EStateStreaming == CurrentState() )
       
   328         {
       
   329         iJitterBuffer->SinkPlayL();
       
   330         }
       
   331     
       
   332     __SUBCONTROLLER( "CMccSymDlStream::UpdateCodecInformationL Exit" )
       
   333     }
       
   334     
       
   335 
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 // CMccSymDlStream::CreatePayloadFormatDecoderL
       
   339 // Creates the payload format decoder
       
   340 // -----------------------------------------------------------------------------
       
   341 //
       
   342 void CMccSymDlStream::CreatePayloadFormatDecoderL()
       
   343     {
       
   344     __SUBCONTROLLER( "CMccSymDlStream::CreatePayloadFormatEncoderL" )
       
   345     __ASSERT_ALWAYS( NULL == iFormatDecode, User::Leave( KErrAlreadyExists ) );
       
   346     __ASSERT_ALWAYS( iMultiplexer, User::Leave( KErrNotReady ) );
       
   347     
       
   348     TUid formatuid;
       
   349     formatuid.iUid = iCodecInfo.iPayloadFormatDecoder;
       
   350     
       
   351     RArray<TUint> payloads;
       
   352     CleanupClosePushL( payloads );
       
   353     ParsePayloadTypesL( payloads, iCodecInfo );
       
   354     
       
   355     if ( EGenRedUsed == iCodecInfo.iAlgoUsed )
       
   356         {
       
   357         __ASSERT_ALWAYS( KMccPayloadTypeMax != iCodecInfo.iRedundantPayload,
       
   358             User::Leave( KErrArgument ) );
       
   359         
       
   360         iRedFormatDecode = CMMFFormatDecode::NewL(
       
   361             TUid::Uid( KImplUidRedPayloadFormatDecode ), iMultiplexer );
       
   362         
       
   363         iFormatDecode = CMMFFormatDecode::NewL( formatuid, iRedFormatDecode );
       
   364         User::LeaveIfError( iMultiplexer->MultiplexerSourceThreadLogon( *this, 
       
   365             *iRedFormatDecode, ETrue, Type(), EFalse ) );
       
   366         
       
   367         iMultiplexer->RegClientForPayloadsL( *iRedFormatDecode, payloads );
       
   368         }
       
   369     else
       
   370         {
       
   371         iFormatDecode = CMMFFormatDecode::NewL( formatuid, iMultiplexer );
       
   372         User::LeaveIfError( iMultiplexer->MultiplexerSourceThreadLogon( *this, 
       
   373             *iFormatDecode, ETrue, Type(), EFalse ) );
       
   374         
       
   375         iMultiplexer->RegClientForPayloadsL( *iFormatDecode, payloads );
       
   376         }
       
   377     
       
   378     iFormatDecode->SetSourceDataTypeCode( iCodecInfo.iFourCC, Type() );
       
   379     User::LeaveIfError( iFormatDecode->SourceThreadLogon( *this ) );
       
   380 
       
   381     CleanupStack::PopAndDestroy( &payloads );
       
   382     }
       
   383 
       
   384 // -----------------------------------------------------------------------------
       
   385 // CMccSymDlStream::PrimeL
       
   386 // Primes the audio stream ready
       
   387 // -----------------------------------------------------------------------------
       
   388 //
       
   389 void CMccSymDlStream::PrimeL( const TUint32 aEndpointId )
       
   390     {
       
   391     __SUBCONTROLLER( "CMccSymDlStream::PrimeL" )
       
   392     
       
   393     TBool controlNetworkResources = SetStateL( EStatePrepared, aEndpointId );    
       
   394 
       
   395     if ( controlNetworkResources )
       
   396         {
       
   397         iRtpmanager->CreateReceiveStreamL( *iDatasource, iCodecInfo );
       
   398         }
       
   399             
       
   400     LoadCodecL( iCodecInfo, KNullDesC8 ); 
       
   401                                                     
       
   402     DoPrimeL();
       
   403     
       
   404     InformStreamStateChange( KMccStreamPrepared, aEndpointId );
       
   405     }
       
   406 
       
   407 // -----------------------------------------------------------------------------
       
   408 // CMccSymDlStream::PlayL
       
   409 // Starts audio streaming
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 void CMccSymDlStream::PlayL( const TUint32 aEndpointId,
       
   413 							 TBool /*aStreamPaused*/, 
       
   414                              TBool aEnableRtcp )
       
   415     {
       
   416     __SUBCONTROLLER( "CMccSymDlStream::PlayL" )
       
   417         
       
   418     TBool controlNetworkResources = SetStateL( EStateStreaming, aEndpointId );
       
   419     
       
   420     if ( controlNetworkResources )
       
   421         {
       
   422         iRtpmanager->StartSessionL();
       
   423         }
       
   424     
       
   425     User::LeaveIfError( iRtpmanager->SetRTCPSendReceive( aEnableRtcp ) ); 
       
   426     
       
   427     UpdateCodecLoadingPermission( IsCodecOperationAllowed() );
       
   428     
       
   429     LoadCodecL( iCodecInfo, KNullDesC8 );
       
   430     
       
   431     DoPlayL();
       
   432     
       
   433     HandleStandby( aEndpointId, EFalse );
       
   434 
       
   435     InformStreamStateChange( KMccStreamStarted, aEndpointId );
       
   436     
       
   437     __SUBCONTROLLER( "CMccSymDlStream::PlayL, exit" )
       
   438     }
       
   439 
       
   440 // -----------------------------------------------------------------------------
       
   441 // CMccSymDlStream::PauseL
       
   442 // Pauses audio streaming
       
   443 // -----------------------------------------------------------------------------
       
   444 //
       
   445 void CMccSymDlStream::PauseL( const TUint32 aEndpointId, TBool aEnableRtcp )
       
   446     {
       
   447     __SUBCONTROLLER( "CMccSymDlStream::PauseL" )
       
   448     
       
   449     /*TBool standbyEndpointControl( StandbyStream() && 
       
   450                                   aEndpointId == MCC_ENDPOINT_ID( iDatasink ) );*/
       
   451     
       
   452     SetStateL( EStatePaused, aEndpointId );
       
   453     User::LeaveIfError( iRtpmanager->SetRTCPSendReceive( aEnableRtcp ) );
       
   454     
       
   455     DoPauseL();
       
   456     
       
   457     HandleStandby( aEndpointId, ETrue );
       
   458     
       
   459     InformStreamStateChange( KMccStreamPaused, aEndpointId ); 
       
   460     }
       
   461 
       
   462 // -----------------------------------------------------------------------------
       
   463 // CMccSymDlStream::ResumeL
       
   464 // Resumes paused audio streaming
       
   465 // -----------------------------------------------------------------------------
       
   466 //
       
   467 void CMccSymDlStream::ResumeL( const TUint32 aEndpointId, TBool aEnableRtcp )
       
   468     { 
       
   469     __SUBCONTROLLER( "CMccSymDlStream::ResumeL" )
       
   470     
       
   471     // In first resume of the standby stream sink is treated as in normal
       
   472     // startup phase
       
   473     TBool standbyEndpointControl( StandbyStream() && 
       
   474                                   aEndpointId == MCC_ENDPOINT_ID( iDatasink ) );
       
   475     
       
   476     if ( standbyEndpointControl && !iFirstResumeDone )
       
   477         {
       
   478         __SUBCONTROLLER( "CMccSymDlStream::ResumeL, standby, first resume" )
       
   479         
       
   480         SetStateL( EStateStreaming, aEndpointId );
       
   481         
       
   482         UpdateCodecLoadingPermission( IsCodecOperationAllowed() );
       
   483     
       
   484         LoadCodecL( iCodecInfo, KNullDesC8 );
       
   485         
       
   486         DoPlayL();
       
   487         
       
   488         iFirstResumeDone = IsControllingMmfEndpoint();
       
   489         }
       
   490     else
       
   491         {
       
   492         /*TBool controlNetworkResources = */
       
   493         SetStateL( EStateStreaming, aEndpointId );
       
   494 
       
   495         User::LeaveIfError( iRtpmanager->SetRTCPSendReceive( aEnableRtcp ) );
       
   496 
       
   497         DoResumeL();
       
   498         }
       
   499         
       
   500     HandleStandby( aEndpointId, EFalse );
       
   501        
       
   502     InformStreamStateChange( KMccStreamResumed, aEndpointId );
       
   503     
       
   504     __SUBCONTROLLER( "CMccSymDlStream::ResumeL, exit" )
       
   505     }
       
   506 
       
   507 // -----------------------------------------------------------------------------
       
   508 // CMccSymDlStream::StopL
       
   509 // Stops the audio streaming
       
   510 // -----------------------------------------------------------------------------
       
   511 //
       
   512 void CMccSymDlStream::StopL( const TUint32 aEndpointId )
       
   513     {
       
   514     __SUBCONTROLLER( "CMccSymDlStream::StopL" )
       
   515     
       
   516     SetStateL( EStateStopped, aEndpointId );    
       
   517     
       
   518     DoStopL();
       
   519     
       
   520     InformStreamStateChange( KMccStreamStopped, aEndpointId );
       
   521     }
       
   522     
       
   523 // -----------------------------------------------------------------------------
       
   524 // CMccSymDlStream::SetBalanceL
       
   525 // Sets the current play balance
       
   526 // -----------------------------------------------------------------------------
       
   527 //
       
   528 void CMccSymDlStream::SetBalanceL( TInt aLeftBal, TInt aRightBal )
       
   529     {
       
   530     if( !iSoundDevice )
       
   531         {
       
   532         User::Leave( KErrNotReady );
       
   533         }
       
   534     else
       
   535         {
       
   536         iSoundDevice->SetPlayBalanceL( aLeftBal, aRightBal );
       
   537         }
       
   538     }
       
   539 
       
   540 // -----------------------------------------------------------------------------
       
   541 // CMccSymDlStream::GetBalanceL
       
   542 // Returns the current play balance
       
   543 // -----------------------------------------------------------------------------
       
   544 //
       
   545 void CMccSymDlStream::GetBalanceL( TInt& aLeftbal, TInt& aRightbal )
       
   546     {
       
   547     if( !iSoundDevice )
       
   548         {
       
   549         User::Leave( KErrNotReady );
       
   550         }
       
   551     else
       
   552         {
       
   553         iSoundDevice->GetPlayBalanceL( aLeftbal, aRightbal );
       
   554         }
       
   555     }
       
   556     
       
   557 // -----------------------------------------------------------------------------
       
   558 // CMccSymDlStream::GetSSRCL
       
   559 // Returns SSRC value
       
   560 // -----------------------------------------------------------------------------
       
   561 //
       
   562 void CMccSymDlStream::GetSSRCL( TUint32& /*aSSRCValue*/ )
       
   563     {
       
   564     User::Leave ( KErrNotSupported );
       
   565     }
       
   566 
       
   567 
       
   568 // -----------------------------------------------------------------------------
       
   569 // CMccSymDlStream::ResetCountersL
       
   570 // Resets Jitterbuffer
       
   571 // -----------------------------------------------------------------------------
       
   572 //
       
   573 void CMccSymDlStream::ResetCountersL( )
       
   574     {
       
   575     }
       
   576 
       
   577 // -----------------------------------------------------------------------------
       
   578 // CMccSymDlStream::SendMediaSignalL
       
   579 // Downlink can send RTCP media signals (only receiver reports)
       
   580 // -----------------------------------------------------------------------------
       
   581 //
       
   582 void CMccSymDlStream::SendMediaSignalL( const TMccEvent& aEvent )
       
   583     {
       
   584     __ASSERT_ALWAYS( iDatasource, User::Leave( KErrNotReady ) );
       
   585     
       
   586     CMccRtpDataSource* p = static_cast<CMccRtpDataSource*>( iDatasource );
       
   587     p->SendMediaSignallingL( aEvent );
       
   588     }
       
   589         
       
   590 // -----------------------------------------------------------------------------
       
   591 // CMccSymDlStream::SendRTCPReceiverReportL
       
   592 // Sends a RTCP receiver report
       
   593 // -----------------------------------------------------------------------------
       
   594 //  
       
   595 void CMccSymDlStream::SendRTCPReceiverReportL()
       
   596     {
       
   597     User::LeaveIfNull( iDatasource );
       
   598     CMccRtpDataSource* dSource = static_cast<CMccRtpDataSource*>( iDatasource );
       
   599     User::LeaveIfError( dSource->SendRTCPReceiverReport() );
       
   600     }
       
   601 
       
   602 // -----------------------------------------------------------------------------
       
   603 // CMccSymDlStream::StartInactivityTimerL
       
   604 // Starts inactivity timer for a stream
       
   605 // -----------------------------------------------------------------------------
       
   606 // 
       
   607 void CMccSymDlStream::StartInactivityTimerL( TUint32 aTimeoutTime )
       
   608     {
       
   609     User::LeaveIfNull( iDatasource );
       
   610     CMccRtpDataSource* dSource = static_cast<CMccRtpDataSource*>( iDatasource );
       
   611     dSource->StartInactivityTimerL( aTimeoutTime );
       
   612     }
       
   613 
       
   614       
       
   615 // -----------------------------------------------------------------------------
       
   616 // CMccSymDlStream::StopInactivityTimerL
       
   617 // Stops inactivity timer for a stream 
       
   618 // -----------------------------------------------------------------------------
       
   619 // 
       
   620 void CMccSymDlStream::StopInactivityTimerL()
       
   621     {
       
   622     User::LeaveIfNull( iDatasource );
       
   623     CMccRtpDataSource* dSource = static_cast<CMccRtpDataSource*>( iDatasource );
       
   624     dSource->StopInactivityTimerL( );
       
   625     }
       
   626 
       
   627 // -----------------------------------------------------------------------------
       
   628 // CMccSymDlStream::IsUplink
       
   629 // -----------------------------------------------------------------------------
       
   630 // 
       
   631 TBool CMccSymDlStream::IsUplink()
       
   632     {
       
   633     return EFalse;
       
   634     }
       
   635 
       
   636 // -----------------------------------------------------------------------------
       
   637 // CMccSymDlStream::StandByL
       
   638 // -----------------------------------------------------------------------------
       
   639 // 
       
   640 void CMccSymDlStream::StandByL()
       
   641     {
       
   642     User::LeaveIfNull( iDatasource );
       
   643     CMccRtpDataSource* dSource = static_cast<CMccRtpDataSource*>( iDatasource );
       
   644     dSource->StandBy( EForceStandby, iCodecInfo.iPayloadType );
       
   645     iJitterBuffer->ResetBuffer( EFalse );
       
   646     }
       
   647 
       
   648 // -----------------------------------------------------------------------------
       
   649 // CMccSymDlStream::SetAudioRouteL
       
   650 // -----------------------------------------------------------------------------
       
   651 //    
       
   652 void CMccSymDlStream::SetAudioRouteL( TUint32 aRoutingDestination )
       
   653     {
       
   654     __ASSERT_ALWAYS( iAudioRouter, User::Leave( KErrNotReady ) );
       
   655     iAudioRouter->SetAudioRouteL( aRoutingDestination );
       
   656     }
       
   657 
       
   658 // -----------------------------------------------------------------------------
       
   659 // CMccSymDlStream::GetAudioRouteL
       
   660 // -----------------------------------------------------------------------------
       
   661 //     
       
   662 void CMccSymDlStream::GetAudioRouteL( TUint32& aRoutingDestination )
       
   663     {
       
   664     __ASSERT_ALWAYS( iAudioRouter, User::Leave( KErrNotReady ) );
       
   665     iAudioRouter->GetAudioRouteL( aRoutingDestination );
       
   666     }
       
   667 
       
   668 // -----------------------------------------------------------------------------
       
   669 // CMccSymDlStream::JitterBufferError
       
   670 // -----------------------------------------------------------------------------
       
   671 //
       
   672 void CMccSymDlStream::JitterBufferError( TInt aError )
       
   673     {
       
   674     __SUBCONTROLLER_INT1("CMccSymDlStream::JitterBufferError, err=", aError)
       
   675     if ( aError == MJitterBufferObserver::EBufferOverflow && iDatasource )
       
   676         {
       
   677         CMccRtpDataSource* dSource = static_cast<CMccRtpDataSource*>( iDatasource );
       
   678         dSource->StandBy( EForceStandby, iCodecInfo.iPayloadType ); 
       
   679         }
       
   680        
       
   681     __SUBCONTROLLER( "CMccSymDlStream::JitterBufferError, exit" )
       
   682 
       
   683     }
       
   684     
       
   685 // -----------------------------------------------------------------------------
       
   686 // CMccSymDlStream::MultiplexerSink
       
   687 // -----------------------------------------------------------------------------
       
   688 //
       
   689 MDataSink* CMccSymDlStream::MultiplexerSink()
       
   690     {
       
   691     if ( EGenRedUsed == iCodecInfo.iAlgoUsed )
       
   692         {
       
   693         return iRedFormatDecode;
       
   694         }
       
   695     else
       
   696         {
       
   697         return iFormatDecode;
       
   698         }
       
   699     }
       
   700 
       
   701 // -----------------------------------------------------------------------------
       
   702 // CMccSymDlStream::DynamicBufferChangeRequest
       
   703 // -----------------------------------------------------------------------------
       
   704 //
       
   705 void CMccSymDlStream::DynamicBufferChangeRequest( TInt aBufferSize )
       
   706     {
       
   707     const TInt KMccBitsPerByte = 8;
       
   708     const TInt hwFrameTime( aBufferSize / KMccBitsPerByte );
       
   709     
       
   710     __SUBCONTROLLER_INT1("CMccSymDlStream::DynamicBufferChangeRequest, aBufferSize = ", aBufferSize ) 
       
   711     __SUBCONTROLLER_INT1("CMccSymDlStream::DynamicBufferChangeRequest, hwFrameTime = ", hwFrameTime )
       
   712     __SUBCONTROLLER_INT1("CMccSymDlStream::DynamicBufferChangeRequest, iHwFrameTime = ", iCodecInfo.iHwFrameTime )
       
   713     
       
   714     if ( hwFrameTime != iCodecInfo.iHwFrameTime
       
   715         && iCodecInfo.iFourCC == KMccFourCCIdG711 )
       
   716         {
       
   717         TRAPD( err, DoDynamicFrameSizeChangeL( hwFrameTime ) );
       
   718         if ( KErrNone == err )
       
   719             {
       
   720             iCodecInfo.iHwFrameTime = hwFrameTime;
       
   721             }
       
   722         }
       
   723     }
       
   724 
       
   725 // -----------------------------------------------------------------------------
       
   726 // CMccSymDlStream::DynamicBufferChangeRequest
       
   727 // -----------------------------------------------------------------------------
       
   728 //
       
   729 void CMccSymDlStream::DoDynamicFrameSizeChangeL( TInt aFrameTime )
       
   730     {
       
   731     __SUBCONTROLLER( "CMccSymDlStream::DoDynamicFrameSizeChangeL" )
       
   732     
       
   733     __ASSERT_ALWAYS( iFormatDecode && iJitterBuffer,
       
   734                     User::Leave( KErrNotReady ) );
       
   735     
       
   736     TMccCodecInfo codecInfo( iCodecInfo );
       
   737     codecInfo.iHwFrameTime = aFrameTime;
       
   738     codecInfo.iIsUpdate = ETrue;
       
   739     const TMccCodecInfoBuffer buffer( codecInfo );
       
   740     
       
   741     CPayloadFormatRead* g711Format(
       
   742         static_cast<CPayloadFormatRead*>( iFormatDecode ) );
       
   743         
       
   744     g711Format->ConfigurePayloadFormatL( buffer );
       
   745         
       
   746     const TInt jbufLen( codecInfo.iMaxPtime );
       
   747     iJitterBuffer->SetupL( jbufLen, 
       
   748                            codecInfo.iJitterBufThreshold,
       
   749                            codecInfo );
       
   750     }
       
   751 
       
   752 // -----------------------------------------------------------------------------
       
   753 // CMccSymDlStream::BindContextIntoStreamL
       
   754 // -----------------------------------------------------------------------------
       
   755 //
       
   756 void CMccSymDlStream::BindContextIntoStreamL( TUint32 aEndpointId,
       
   757                                       const TMccCryptoContext& aContextParams )
       
   758     {
       
   759     __ASSERT_ALWAYS( iDatasource, User::Leave( KErrNotReady ) );   
       
   760     
       
   761     if ( iDatasource->DataSourceType() == KMccRtpSourceUid &&
       
   762          aEndpointId == MCC_ENDPOINT_ID( iDatasource )  )
       
   763 	    {
       
   764         CMccRtpDataSource* dataSource =
       
   765             static_cast<CMccRtpDataSource*>( iDatasource );
       
   766             
       
   767         dataSource->ApplyCryptoContextL( aContextParams );
       
   768 	    }
       
   769 	else
       
   770 	    {
       
   771 	    User::Leave( KErrNotFound );
       
   772 	    }        
       
   773     }
       
   774 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   775 
       
   776 //  End of File