sipvoipprovider/src/svpsessionbase.cpp
changeset 0 a4daefaec16c
child 6 fc8c25e5a2e8
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Session base class for SVP MO and MT sessions. Contains methods 
       
    15 *                common for SVP MO and MT sessions.
       
    16 *
       
    17 */
       
    18 
       
    19 #include <e32math.h>
       
    20 #include <escapeutils.h>
       
    21 
       
    22 #include <mcetransactiondatacontainer.h>
       
    23 #include <mceaudiostream.h>
       
    24 #include <mcertpsink.h>
       
    25 #include <mcertpsource.h>
       
    26 #include <mceaudiocodec.h>
       
    27 #include <mcedefs.h>
       
    28 #include <mcesecuresession.h> 
       
    29 #include <mcesecureoutsession.h>
       
    30 #include <mcesecureinsession.h>
       
    31 #include <mcemicsource.h>
       
    32 #include <mcespeakersink.h>
       
    33 #include <siperr.h>
       
    34 #include <telephonydomainpskeys.h> // for mute 
       
    35 
       
    36 #include "svpsessionbase.h"
       
    37 #include "svpholdcontroller.h"
       
    38 #include "svptransfercontroller.h"
       
    39 #include "svptransferstatecontext.h"
       
    40 #include "svptimer.h"
       
    41 #include "svpsipconsts.h"
       
    42 #include "svpuriparser.h"
       
    43 #include "svpaudioutility.h"
       
    44 #include "svpvolumeobserver.h"
       
    45 #include "svplogger.h"
       
    46 #include "svputility.h"
       
    47 #include "svprtpobserver.h"
       
    48 #include "svppropertywatch.h"
       
    49 #include "svpdtmfeventgenerator.h"
       
    50 
       
    51 
       
    52 // Local Consts
       
    53 const TInt KMaxTimerValueMO = 4000;
       
    54 const TInt KMinTimerValueMO = 2100;
       
    55 const TInt KMaxTimerValueMT = 2000;
       
    56 const TInt KMinTimerValueMT = 10;
       
    57 
       
    58 const TInt KRandomDividerOne = 1000000;
       
    59 const TInt KRandomDividerTwo = 1000;
       
    60 
       
    61 const TInt KMaxPhoneVolume = 10;
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CSVPSessionBase::CSVPSessionBase
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CSVPSessionBase::CSVPSessionBase( TMceTransactionDataContainer& aContainer,
       
    68     MSVPSessionObserver& aObserver, CSVPUtility& aSVPUtility,
       
    69     CSVPRtpObserver& aRtpObserver ) :
       
    70     iSVPUtility( aSVPUtility ),
       
    71     iRtpObserver( aRtpObserver ),
       
    72     iContainer( aContainer ),
       
    73     iObserver( aObserver ),
       
    74     iErrorInULandDLFirstTime ( ETrue ),
       
    75     iEarlyMediaOngoing ( EFalse )
       
    76     {
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CSVPSessionBase::~CSVPSessionBase
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 CSVPSessionBase::~CSVPSessionBase()
       
    84     {
       
    85     SVPDEBUG1( "SVPSessionBase::~CSVPSessionBase In" )
       
    86     
       
    87     delete iCallParameters;
       
    88     
       
    89     delete iHoldController;
       
    90     
       
    91     iObserver.RemoveFromArray( *this );
       
    92     
       
    93     delete iSession;
       
    94     
       
    95     StopTimers();
       
    96     
       
    97     iTimers.Close();
       
    98     
       
    99     delete iRecipient;
       
   100     
       
   101     delete iDisplayName;
       
   102     
       
   103     delete iTransferController;
       
   104     
       
   105     delete iMutePropertyWatch;
       
   106     
       
   107     delete iVolObserver;
       
   108     
       
   109     delete iFromHeader;
       
   110     
       
   111     delete iToHeader;
       
   112     
       
   113     delete iCallId;
       
   114     
       
   115     delete iCSeqHeader;
       
   116     
       
   117     delete iEventGenerator;
       
   118     
       
   119     delete (iTempSecSession != iSession ? iTempSecSession : NULL );
       
   120     
       
   121     delete iDtmfString;
       
   122     
       
   123     SVPDEBUG1( "CSVPSessionBase::~CSVPSessionBase Out" )
       
   124     }
       
   125    
       
   126 // ---------------------------------------------------------------------------
       
   127 // CSVPSessionBase::ReleaseTempSecure
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CSVPSessionBase::ReleaseTempSecure()
       
   131     {
       
   132     delete iTempSecSession;
       
   133     iTempSecSession = NULL;
       
   134     }
       
   135     
       
   136 // ---------------------------------------------------------------------------
       
   137 // CSVPSessionBase::Session
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 const CMceSession& CSVPSessionBase::Session() const   
       
   141     {
       
   142     return *iSession;
       
   143     }
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // CSVPSessionBase::StartTimerL
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 void CSVPSessionBase::StartTimerL( TInt aMilliSeconds, TInt aTimerId )
       
   150     {
       
   151     SVPDEBUG1( "CSVPSessionBase::StartTimerL In" )
       
   152     
       
   153     CSVPTimer* timer = CSVPTimer::NewL( *this, aTimerId );
       
   154     CleanupStack::PushL( timer );
       
   155     timer->SetTime( aMilliSeconds );
       
   156     iTimers.AppendL( timer );
       
   157     CleanupStack::Pop( timer );
       
   158     
       
   159     SVPDEBUG1( "CSVPSessionBase::StartTimerL Out" )
       
   160     }
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // CSVPSessionBase::StopTimers
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 void CSVPSessionBase::StopTimers()
       
   167     {
       
   168     SVPDEBUG1( "CSVPSessionBase::StopTimers In" )
       
   169     
       
   170     while ( iTimers.Count() )
       
   171         {
       
   172         iTimers[0]->Stop();
       
   173         delete iTimers[0];
       
   174         iTimers.Remove( 0 );
       
   175         }
       
   176     
       
   177     SVPDEBUG1( "CSVPSessionBase::StopTimers Out" )
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // CSVPSessionBase::ReinviteCrossoverTime
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 TInt CSVPSessionBase::ReinviteCrossoverTime()
       
   185     {
       
   186     SVPDEBUG1( "CSVPSessionBase::ReinviteCrossoverTime In" )
       
   187     
       
   188     TInt maxValue( 0 );
       
   189     TInt minValue( 0 );
       
   190     
       
   191     if ( IsMobileOriginated() )
       
   192         {
       
   193         minValue = KMinTimerValueMO;
       
   194         maxValue = KMaxTimerValueMO;
       
   195         }
       
   196     else
       
   197         {
       
   198         minValue = KMinTimerValueMT;
       
   199         maxValue = KMaxTimerValueMT; 
       
   200         }
       
   201     
       
   202     TInt timerValue( 0 );
       
   203     TTime time;
       
   204     time.HomeTime();
       
   205     TInt64 seed( time.Int64() );
       
   206     
       
   207     for ( TInt i = 0; i < ( maxValue - minValue ); i++ )
       
   208         {
       
   209         TInt random = Math::Rand( seed );
       
   210         TReal random2 =  ( TReal )random / KRandomDividerOne;
       
   211         TInt random3 = ( TInt )( minValue * random2 ) / KRandomDividerTwo;
       
   212         
       
   213         if ( minValue <= random3 && minValue >= random3 )
       
   214             {
       
   215             timerValue = random3;
       
   216             break;
       
   217             }
       
   218         }
       
   219     
       
   220     SVPDEBUG2("CSVPSessionBase::ReinviteCrossoverTime Out return: %d", timerValue )
       
   221     return timerValue;    
       
   222     }
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // CSVPSessionBase::StopTimer
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 void CSVPSessionBase::StopTimer( TInt aTimerId )
       
   229     {
       
   230     SVPDEBUG2( "CSVPSessionBase::StopTimer In, Timer -- ID: %d", aTimerId )
       
   231 
       
   232     // Find the timer and delete it.
       
   233     for ( TInt t = 0; t < iTimers.Count(); )
       
   234         {
       
   235         if ( iTimers[ t ] ->Id() == aTimerId )
       
   236             {
       
   237             iTimers[t]->Stop();
       
   238             delete iTimers[ t ];
       
   239             iTimers.Remove( t );
       
   240             }
       
   241         else
       
   242             {
       
   243             t++;
       
   244             }
       
   245         }
       
   246     
       
   247     SVPDEBUG1( "CSVPSessionBase::StopTimer Out" )
       
   248     }
       
   249 
       
   250 // ---------------------------------------------------------------------------
       
   251 // CSVPSessionBase::TimedOut
       
   252 // ---------------------------------------------------------------------------
       
   253 //    
       
   254 void CSVPSessionBase::TimedOut( TInt aTimerId )
       
   255     {
       
   256     SVPDEBUG1( "CSVPSessionBase::TimedOut In" )
       
   257      
       
   258     // Find the timer and delete it.
       
   259     for ( TInt t = 0; t < iTimers.Count(); )
       
   260         {
       
   261         if ( iTimers[ t ] ->Id() == aTimerId )
       
   262             {
       
   263             delete iTimers[ t ];
       
   264             iTimers.Remove( t );
       
   265             }
       
   266         else
       
   267             {
       
   268             t++;
       
   269             }
       
   270         }
       
   271     
       
   272     if ( KSVPInviteTimerExpired == aTimerId )
       
   273         {
       
   274         // INVITE timer expired, notify client
       
   275         SVPDEBUG1( "CSVPSessionBase::TimedOut Invite timer expired, callback" )
       
   276         ExecCbErrorOccurred( ECCPErrorNotResponding );
       
   277         
       
   278         // send cancel
       
   279         TRAPD( errCancel, static_cast< CMceOutSession* >( iSession )->CancelL() );
       
   280         
       
   281         if ( errCancel )
       
   282             {
       
   283             SVPDEBUG2( "CSVPSessionBase::TimedOut Cancel: %d", errCancel )
       
   284             }
       
   285         
       
   286         ExecCbCallStateChanged( MCCPCallObserver::ECCPStateDisconnecting );
       
   287         ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
   288         }
       
   289     
       
   290     if ( KSVPTerminationTimerExpired == aTimerId )
       
   291         {
       
   292         // Renew terminating timer to keep session alive when incoming 
       
   293         // transfer ongoing, not longer than max default expire time (120s)
       
   294         if ( IsIncomingTransfer() &&
       
   295              !IsAttended() &&
       
   296              iTerminatingRepeat < KSVPDefaultExpiresTime )
       
   297             {
       
   298             SVPDEBUG2( "CSVPSessionBase::TimedOut UnAtte case iTerminatingRepeat = %d",
       
   299                 iTerminatingRepeat )
       
   300             
       
   301             // Continue timeout time if the new session of the 
       
   302             // incoming transfer not yet established
       
   303             iTerminatingRepeat = iTerminatingRepeat +
       
   304                 KSVPTerminatingTime / KSVPMilliSecondCoefficient;
       
   305             
       
   306             TRAPD( errTimer, StartTimerL( KSVPTerminatingTime,
       
   307                     KSVPTerminationTimerExpired ) );
       
   308             
       
   309             if ( errTimer )
       
   310                 {
       
   311                 SVPDEBUG2( "CSVPSessionBase::TimedOut Termination leave with code %d",
       
   312                         errTimer )
       
   313                 }
       
   314             }
       
   315         else
       
   316             {
       
   317             SVPDEBUG1( "CSVPSessionBase::TimedOut Termination timer, callback" )
       
   318             ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
   319             }
       
   320         }
       
   321     
       
   322     if ( KSVPRemoteEndDiedExpired == aTimerId )    
       
   323         {
       
   324         SVPDEBUG1( "CSVPSessionBase::TimedOut remote end died, callback" )
       
   325         // disconnecting state callback sent before timer started
       
   326         ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
   327         }
       
   328     
       
   329     if ( KSVPHangUpTimerExpired == aTimerId )    
       
   330         {
       
   331         SVPDEBUG1( "CSVPSessionBase::TimedOut HangUp timer expired, callback" )
       
   332         // disconnecting state callback sent before timer started
       
   333         ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
   334         }
       
   335     
       
   336     if ( KSVPExpiresTimeExpired == aTimerId )
       
   337         {
       
   338         SVPDEBUG1( "CSVPSessionBase::TimedOut expires timer expired" )
       
   339         // send 487
       
   340         TRAPD( err, static_cast<CMceInSession*>( iSession )->RespondL(
       
   341                 KSVPRequestTerminatedReason, KSVPRequestTerminatedVal ) );
       
   342         
       
   343         if ( err )
       
   344             {
       
   345             // sending response failed
       
   346             // not serious because session is put to idle state anyway
       
   347             }
       
   348         // event is needed in upper level for correct bubble and log handling
       
   349         ExecCbCallEventOccurred( MCCPCallObserver::ECCPRemoteTerminated );
       
   350         // idle can be sent directly without disconnecting state
       
   351         ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
   352         }
       
   353     
       
   354     if ( KSVPHoldTimerExpired == aTimerId ||
       
   355          KSVPResumeTimerExpired == aTimerId )
       
   356         {
       
   357         if ( iHoldController )
       
   358             {
       
   359             SVPDEBUG1( "CSVPSessionBase::TimedOut - Hold/Resume request Expired" )
       
   360             
       
   361             iHoldController->TimedOut();
       
   362             TInt contErr = iHoldController->ContinueHoldProcessing( *iSession );
       
   363             
       
   364             if ( KSVPResumeTimerExpired == aTimerId &&
       
   365                  CMceSession::EEstablished == iSession->State() )
       
   366                 {
       
   367                 // MCE state error prevents cancelling session; go to terminating
       
   368                 SVPDEBUG1( "CSVPSessionBase::TimedOut - MCE established" )
       
   369                 HandleSessionStateChanged( *iSession );
       
   370                 SVPDEBUG1( "CSVPSessionBase::TimedOut - hold/resume done" )
       
   371                 }
       
   372             else
       
   373                 {
       
   374                 TRAPD( cancelErr, static_cast<CMceOutSession*>( iSession )->CancelL() );
       
   375                 
       
   376                 if ( cancelErr )
       
   377                     {
       
   378                     // This removes compile warnings; no need for other error 
       
   379                     // handling
       
   380                     SVPDEBUG2( "CSVPSessionBase::TimedOut - Hold/Resume, Err %i", 
       
   381                             cancelErr )
       
   382                     }
       
   383                 }
       
   384             
       
   385             SVPDEBUG2( "CSVPSessionBase::TimedOut - Hold/Resume Handled, Err %i",
       
   386                     contErr )
       
   387             }
       
   388         }
       
   389     
       
   390     if ( KSVPReferTimerExpired == aTimerId )
       
   391         {
       
   392         // Refer timeout
       
   393         SVPDEBUG1( "CSVPSessionBase::TimedOut Transfer/Refer timer expired" )
       
   394         
       
   395         if ( iTransferController )
       
   396             {
       
   397             // Inform application about the error
       
   398             ExecCbErrorOccurred( ECCPTransferFailed );
       
   399             // Terminate transfer
       
   400             iTransferController->TerminateTransfer();
       
   401 			}
       
   402         }
       
   403     
       
   404     if ( KSVPReInviteTimerExpired == aTimerId )
       
   405         {
       
   406         if ( iHoldController )
       
   407             {
       
   408             SVPDEBUG1( "CSVPSessionBase::TimedOut - ReInvite timer expired" )
       
   409             iHoldController->RetryHoldRequest( iSession );
       
   410             }
       
   411         }
       
   412 
       
   413     if ( KSVPICMPErrorTimerExpired == aTimerId )
       
   414         {
       
   415         TBool bothStreamsDisabled ( ETrue );
       
   416         TRAP_IGNORE( bothStreamsDisabled = IsBothStreamsDisabledL() );
       
   417         if ( bothStreamsDisabled )
       
   418             {
       
   419             SVPDEBUG1( "CSVPSessionBase::TimedOut Error In UL and DL \
       
   420             NOT First Time! -> Start Terminating Timer and BYE" )
       
   421             // notify CCE about the error & bring session down.
       
   422             ExecCbErrorOccurred( ECCPErrorConnectionError );
       
   423             ExecCbCallStateChanged( MCCPCallObserver::ECCPStateDisconnecting );
       
   424         
       
   425             TRAP_IGNORE( StartTimerL( KSVPTerminatingTime, KSVPRemoteEndDiedExpired ) );
       
   426             }
       
   427         else
       
   428             {
       
   429             SVPDEBUG1( "CSVPSessionBase::TimedOut UpLink or DownLink \
       
   430             is not Disabled! -> No Terminating Timer needed, all is OK!" )
       
   431             }
       
   432         SetErrorInULandDLFirstTime( ETrue );        
       
   433         }
       
   434 
       
   435     if ( KSVPSinkResumeICMPErrorTimerExpired == aTimerId ||
       
   436          KSVPSourceResumeICMPErrorTimerExpired == aTimerId )
       
   437         {
       
   438         if ( iHoldController )
       
   439             {
       
   440             // ICMP errors in resume disables RTP sink, try to enable it: 
       
   441             SVPDEBUG1( "CSVPSessionBase::TimedOut - Resume ICMP error timer expired" )
       
   442             TRAPD( refreshErr, HoldController().RefreshHoldStateL() );
       
   443             if ( refreshErr )
       
   444                 {
       
   445                 // Removes compile warnings; no other error handling
       
   446                 SVPDEBUG2( "CSVPSessionBase::TimedOut - refreshHold err %d", refreshErr )
       
   447                 }
       
   448             }
       
   449         }
       
   450 
       
   451     SVPDEBUG1( "CSVPSessionBase::TimedOut Out" )
       
   452     }
       
   453 
       
   454 // ---------------------------------------------------------------------------
       
   455 // CSVPSessionBase::SessionStateChanged
       
   456 // ---------------------------------------------------------------------------
       
   457 //
       
   458 void CSVPSessionBase::SessionStateChanged( TInt aStatusCode )
       
   459     {
       
   460     SVPDEBUG2( "CSVPSessionBase::SessionStateChanged  In,  aStatusCode= %d", aStatusCode )
       
   461     SVPDEBUG2( "CSVPSessionBase::SessionStateChanged iSession->State()= %d", iSession->State() )
       
   462     
       
   463     TInt status = aStatusCode;
       
   464     TCCPError err = iSVPUtility.GetCCPError( status, iTone );
       
   465     
       
   466     // On error call voip event logger with original status, 3xx are not logged.
       
   467     if ( ECCPErrorNone != err && ECCPErrorNotReached != err )
       
   468         {
       
   469         TRAP_IGNORE( iSVPUtility.LogVoipEventL( aStatusCode,
       
   470                 iSipProfileId, RemoteParty(), CSeqHeader() ) );
       
   471         }
       
   472     
       
   473     #ifdef _DEBUG   // UDEB build
       
   474     
       
   475     TRAPD( trapErr, SessionStateChangedL( aStatusCode, err, status ) );
       
   476     SVPDEBUG2( "CSVPSessionBase::SessionStateChanged trapErr: %d", trapErr )
       
   477     
       
   478     #else // UREL build
       
   479     
       
   480     TRAP_IGNORE( SessionStateChangedL( aStatusCode, err, status ) );
       
   481     
       
   482     #endif // _DEBUG
       
   483     
       
   484     SVPDEBUG1( "CSVPSessionBase::SessionStateChanged Out" )
       
   485     }
       
   486 
       
   487 // ---------------------------------------------------------------------------
       
   488 // CSVPSessionBase::InitializePropertyWatchingL
       
   489 // ---------------------------------------------------------------------------
       
   490 //
       
   491 void CSVPSessionBase::InitializePropertyWatchingL()
       
   492     {
       
   493     SVPDEBUG1( "CSVPSessionBase::InitializePropertyWatchingL In" )
       
   494     
       
   495     // create property watcher for watching mute P&S property changes
       
   496     iMutePropertyWatch = CSVPPropertyWatch::NewL(
       
   497             *this, KPSUidTelMicrophoneMuteStatus, KTelMicrophoneMuteState );
       
   498     
       
   499     // check initial mute value                                  
       
   500     TInt value( EPSTelMicMuteOff );
       
   501     RProperty::Get( KPSUidTelMicrophoneMuteStatus, 
       
   502             KTelMicrophoneMuteState, value );
       
   503     
       
   504     // check initial mute status 
       
   505     if( EPSTelMicMuteOff == value )
       
   506         {
       
   507         SVPDEBUG1( "CSVPSessionBase::InitializePropertyWatchingL Initally mute: OFF" )
       
   508         }
       
   509     else if ( EPSTelMicMuteOn == value )
       
   510         {
       
   511         SVPDEBUG1( "CSVPSessionBase::InitializePropertyWatchingL Initially Mute: ON" )
       
   512         // if mute is initially on, we must mute the audio
       
   513         ValueChangedL( KTelMicrophoneMuteState, EPSTelMicMuteOn );
       
   514         }
       
   515     
       
   516     // create instance of volume obsever
       
   517     iVolObserver = CSVPVolumeObserver::NewL( *this );
       
   518     
       
   519     SVPDEBUG1( "CSVPSessionBase::InitializePropertyWatchingL Out" )
       
   520     }
       
   521 
       
   522 // ---------------------------------------------------------------------------
       
   523 // CSVPSessionBase::ExecCbErrorOccurred
       
   524 // ---------------------------------------------------------------------------
       
   525 // 
       
   526 TInt CSVPSessionBase::ExecCbErrorOccurred( TCCPError aError )
       
   527     {
       
   528     SVPDEBUG2( "CSVPSessionBase::ExecCbErrorOccurred In, aError= %d", aError )
       
   529     
       
   530     TInt status = KErrNotFound;
       
   531     
       
   532     if ( iCCPSessionObserver )
       
   533         {
       
   534         status = KErrNone;
       
   535         iCCPSessionObserver->ErrorOccurred( aError, this );
       
   536         }
       
   537     
       
   538     SVPDEBUG2( "CSVPSessionBase::ExecCbErrorOccurred Out return=%d", status )
       
   539     return status;
       
   540     }
       
   541 
       
   542 // ---------------------------------------------------------------------------
       
   543 // CSVPSessionBase::ExecCbCallStateChanged
       
   544 // ---------------------------------------------------------------------------
       
   545 // 
       
   546 TInt CSVPSessionBase::ExecCbCallStateChanged(
       
   547         MCCPCallObserver::TCCPCallState aNewState )
       
   548     {
       
   549     SVPDEBUG2( "CSVPSessionBase::ExecCbCallStateChanged In, aNewState= %d", aNewState )
       
   550     SVPDEBUG2( "CSVPSessionBase::ExecCbCallStateChanged iSessionState= %d", iSessionState )
       
   551     
       
   552     TInt status = (TInt) aNewState;
       
   553     
       
   554     if ( !( (TInt) MCCPCallObserver::ECCPStateIdle > status ) )
       
   555         {
       
   556         // state transition OK
       
   557         iSessionState = (MCCPCallObserver::TCCPCallState) status;
       
   558         
       
   559         if ( iCCPSessionObserver )
       
   560             {
       
   561             status = KErrNone;
       
   562             iCCPSessionObserver->CallStateChanged( iSessionState, this );
       
   563             }
       
   564         }
       
   565     
       
   566     SVPDEBUG2( "CSVPSessionBase::ExecCbCallStateChanged Out return=%d", status )
       
   567     return status;
       
   568     }
       
   569 
       
   570 // ---------------------------------------------------------------------------
       
   571 // CSVPSessionBase::ExecCbCallEventOccurred
       
   572 // ---------------------------------------------------------------------------
       
   573 //
       
   574 TInt CSVPSessionBase::ExecCbCallEventOccurred(
       
   575         MCCPCallObserver::TCCPCallEvent aEvent )
       
   576     {
       
   577     SVPDEBUG2( "CSVPSessionBase::ExecCbCallEventOccurred In, aEvent= %d", aEvent )
       
   578     
       
   579     TInt status = KErrNotFound;
       
   580     
       
   581     if ( iCCPSessionObserver )
       
   582         {
       
   583         status = KErrNone;
       
   584         iCCPSessionObserver->CallEventOccurred( aEvent, this );
       
   585         }
       
   586     
       
   587     SVPDEBUG2( "CSVPSessionBase::ExecCbCallEventOccurred Out, return= %d", status )
       
   588     return status;
       
   589     }
       
   590 
       
   591 // ---------------------------------------------------------------------------
       
   592 // CSVPSessionBase::ExecCbSsEventOccurred
       
   593 // ---------------------------------------------------------------------------
       
   594 //
       
   595 TInt CSVPSessionBase::ExecCbSsEventOccurred(
       
   596         MCCPSsObserver::TCCPSsCallForwardEvent aEvent )
       
   597     {
       
   598     SVPDEBUG2( "CSVPSessionBase::ExecCbSsEventOccurred In, aEvent= %d", aEvent )
       
   599     
       
   600     TInt status = KErrNotFound;
       
   601     
       
   602     if ( iCCPSsObserver )
       
   603         {
       
   604         status = KErrNone;
       
   605         iCCPSsObserver->CallForwardEventOccurred( aEvent, *iRecipient );
       
   606         }
       
   607     
       
   608     SVPDEBUG2( "CSVPSessionBase::ExecCbSsEventOccurred Out return=%d", status )
       
   609     return status;
       
   610     }
       
   611 
       
   612 
       
   613 //----------------------------------------------------------------------------
       
   614 //CSVPSessionBase::SetSsObserver
       
   615 //----------------------------------------------------------------------------
       
   616 //
       
   617 void CSVPSessionBase::SetSsObserver( const MCCPSsObserver& aObserver )
       
   618     {
       
   619     SVPDEBUG1( "CSVPSessionBase::SetSsObserver In" )
       
   620     
       
   621     iCCPSsObserver = const_cast< MCCPSsObserver* >( &aObserver );
       
   622     
       
   623     SVPDEBUG1( "CSVPSessionBase::SetSsObserver In" )
       
   624     }
       
   625 
       
   626 //----------------------------------------------------------------------------
       
   627 //CSVPSessionBase::GetSsObserver
       
   628 //----------------------------------------------------------------------------
       
   629 //
       
   630 const MCCPSsObserver& CSVPSessionBase::GetSsObserver( )
       
   631     {
       
   632     SVPDEBUG1( "CSVPSessionBase::GetSsObserver" )
       
   633     
       
   634     return *iCCPSsObserver;    
       
   635     }
       
   636 
       
   637 // ---------------------------------------------------------------------------
       
   638 // CSVPSessionBase::SetDtmfObserver
       
   639 // ---------------------------------------------------------------------------
       
   640 //
       
   641 void CSVPSessionBase::SetDtmfObserver( const MCCPDTMFObserver& aObserver )
       
   642     {
       
   643     SVPDEBUG1( "CSVPSessionBase::SetDtmfObserver In" )
       
   644     
       
   645     iCCPDtmfObserver = const_cast< MCCPDTMFObserver* >( &aObserver );
       
   646     
       
   647     SVPDEBUG1( "CSVPSessionBase::SetDtmfObserver Out" )
       
   648     }
       
   649 
       
   650 // ---------------------------------------------------------------------------
       
   651 // CSVPSessionBase::DtmfObserver
       
   652 // ---------------------------------------------------------------------------
       
   653 //
       
   654 const MCCPDTMFObserver& CSVPSessionBase::DtmfObserver()
       
   655     {
       
   656     SVPDEBUG1( "CSVPSessionBase::DtmfObserver" )
       
   657     
       
   658     return *iCCPDtmfObserver;
       
   659     }
       
   660 
       
   661 // ---------------------------------------------------------------------------
       
   662 // CSVPSessionBase::EventStateChanged
       
   663 // ---------------------------------------------------------------------------
       
   664 //
       
   665 TInt CSVPSessionBase::EventStateChanged( CMceEvent& aEvent, TInt aStatusCode )
       
   666     {
       
   667     SVPDEBUG1( "CSVPSessionBase::EventStateChanged In" )
       
   668     
       
   669     TInt err( KErrNone );
       
   670     
       
   671     if ( iTransferController )
       
   672         {
       
   673         TRAP( err, iTransferController->HandleEventStateChangedL(
       
   674                 aEvent, aStatusCode ) );
       
   675         
       
   676         if ( KSVPErrTransferInProgress == err )
       
   677             {
       
   678             // Transfer allready in progress
       
   679             SVPDEBUG1( "CSVPSessionBase::EventStateChanged, KSVPErrTransferInProgress" )
       
   680             }
       
   681         else if ( KErrNone != err )
       
   682             {
       
   683             SVPDEBUG2( "CSVPSessionBase::EventStateChanged, err = %d", err )
       
   684             // Inform application about the error
       
   685             ExecCbErrorOccurred( ECCPTransferFailed );
       
   686             }
       
   687         }
       
   688     else
       
   689         {
       
   690         // Inform application about the error
       
   691         ExecCbErrorOccurred( ECCPTransferFailed );
       
   692         err = KSVPErrTransferErrorBase;
       
   693         }
       
   694     
       
   695     SVPDEBUG2( "CSVPSessionBase::EventStateChanged Out return=%d", err )
       
   696     return err;
       
   697     }
       
   698 
       
   699 // ---------------------------------------------------------------------------
       
   700 // CSVPSessionBase::NotifyReceived
       
   701 // ---------------------------------------------------------------------------
       
   702 //
       
   703 void CSVPSessionBase::NotifyReceived( CMceEvent& aEvent,
       
   704         TMceTransactionDataContainer* aContainer )
       
   705     {
       
   706     SVPDEBUG1( "CSVPSessionBase::NotifyReceived In" )
       
   707     
       
   708     if ( iTransferController )
       
   709         {
       
   710         TRAPD( err, iTransferController->NotifyReceivedL(
       
   711                 aEvent, aContainer ) );
       
   712         
       
   713         if ( KErrNone != err )
       
   714             {
       
   715             // Inform application about the error
       
   716             ExecCbErrorOccurred( ECCPTransferFailed );
       
   717             }
       
   718         }
       
   719     else
       
   720         {
       
   721         // Inform application about the error
       
   722         ExecCbErrorOccurred( ECCPTransferFailed );
       
   723         }
       
   724     
       
   725     SVPDEBUG1( "CSVPSessionBase::NotifyReceived Out" )
       
   726     }
       
   727 
       
   728 // ---------------------------------------------------------------------------
       
   729 // CSVPSessionBase::ReferStateChanged
       
   730 // ---------------------------------------------------------------------------
       
   731 // 
       
   732 void CSVPSessionBase::ReferStateChanged( CMceRefer& aRefer, TInt aStatusCode )
       
   733     {
       
   734     SVPDEBUG1( "CSVPSessionBase::ReferStateChangedL In" )
       
   735     
       
   736     if ( iTransferController )
       
   737         {
       
   738         TRAPD( err, iTransferController->HandleReferStateChangeL(
       
   739                 aRefer, aStatusCode ) );
       
   740         
       
   741         if ( KErrNone != err )
       
   742             {
       
   743             // Inform application about the error
       
   744             ExecCbErrorOccurred( ECCPTransferFailed );
       
   745             }
       
   746         }
       
   747     else
       
   748         {
       
   749         // Inform application about the error
       
   750         ExecCbErrorOccurred( ECCPTransferFailed );
       
   751         }
       
   752     
       
   753     SVPDEBUG1( "CSVPSessionBase::ReferStateChangedL Out" )
       
   754     }
       
   755 
       
   756 // ---------------------------------------------------------------------------
       
   757 // CSVPSessionBase::MceTransactionDataContainer
       
   758 // ---------------------------------------------------------------------------
       
   759 //
       
   760 TMceTransactionDataContainer& CSVPSessionBase::MceTransactionDataContainer()
       
   761     {
       
   762     return iContainer;
       
   763     }
       
   764 
       
   765 // ---------------------------------------------------------------------------
       
   766 // CSVPSessionBase::IncomingReferL
       
   767 // ---------------------------------------------------------------------------
       
   768 //
       
   769 void CSVPSessionBase::IncomingReferL( CMceInRefer* aRefer,
       
   770         const TDesC8& aReferTo, TMceTransactionDataContainer* aContainer )
       
   771     {
       
   772     SVPDEBUG1( "CSVPSessionBase::IncomingReferL In" )
       
   773     
       
   774     if ( !iTransferController )        
       
   775         {
       
   776         // Create new transfercontroller
       
   777         iTransferController = CSVPTransferController::NewL(
       
   778                 iSession, this, iContainer, *this );
       
   779         }
       
   780     
       
   781     iTransferController->IncomingReferL( aRefer, aReferTo, aContainer );
       
   782     
       
   783     SVPDEBUG1( "CSVPSessionBase::IncomingReferL Out" )    
       
   784     }
       
   785 
       
   786 // ---------------------------------------------------------------------------
       
   787 // CSVPSessionBase::IsMceRefer
       
   788 // ---------------------------------------------------------------------------
       
   789 //
       
   790 TBool CSVPSessionBase::IsMceRefer( CMceRefer& aRefer )
       
   791     {
       
   792     if ( iTransferController )
       
   793         {
       
   794         return iTransferController->IsMceRefer( aRefer );        
       
   795         }
       
   796     else
       
   797         {
       
   798         return EFalse;    
       
   799         }   
       
   800     }
       
   801 
       
   802 // ---------------------------------------------------------------------------
       
   803 // CSVPSessionBase::IsAttended
       
   804 // ---------------------------------------------------------------------------
       
   805 //
       
   806 TBool CSVPSessionBase::IsAttended()
       
   807     {
       
   808     if ( iTransferController )
       
   809         {
       
   810         return iTransferController->IsAttended();
       
   811         }
       
   812     else
       
   813         {
       
   814         return EFalse;
       
   815         }
       
   816     }
       
   817 
       
   818 // ---------------------------------------------------------------------------
       
   819 // CSVPSessionBase::SetTransferDataL
       
   820 // ---------------------------------------------------------------------------
       
   821 //
       
   822 void CSVPSessionBase::SetTransferDataL( CDesC8Array* aUserAgentHeaders,
       
   823         TInt aSecureStatus )
       
   824     {
       
   825     SVPDEBUG1( "CSVPSessionBase::SetTransferDataL In" )
       
   826     
       
   827     if ( iTransferController )
       
   828         {
       
   829         iTransferController->SetTransferDataL(
       
   830             aUserAgentHeaders, aSecureStatus );
       
   831         }
       
   832     
       
   833     SVPDEBUG1( "CSVPSessionBase::SetTransferDataL Out" )
       
   834     }
       
   835 
       
   836 // ---------------------------------------------------------------------------
       
   837 // CSVPSessionBase::SendNotify
       
   838 // ---------------------------------------------------------------------------
       
   839 //
       
   840 void CSVPSessionBase::SendNotify( TInt aStatusCode )
       
   841     {
       
   842     SVPDEBUG1( "CSVPSessionBase::SendNotify In" )
       
   843     
       
   844     if ( iTransferController )
       
   845         {
       
   846         #ifdef _DEBUG
       
   847         
       
   848         TRAPD( err, iTransferController->SendNotifyL( aStatusCode ) );
       
   849         SVPDEBUG2("CSVPSessionBase::SendNotify SendNotifyL err: %d", err )
       
   850         
       
   851         #else
       
   852         
       
   853         TRAP_IGNORE( iTransferController->SendNotifyL( aStatusCode ) );
       
   854         
       
   855         #endif // _DEBUG
       
   856         }
       
   857     
       
   858     SVPDEBUG1( "CSVPSessionBase::SendNotify Out" )
       
   859     }
       
   860 
       
   861 // ---------------------------------------------------------------------------
       
   862 // CSVPSessionBase::IsIncomingTransfer
       
   863 // ---------------------------------------------------------------------------
       
   864 //
       
   865 TBool CSVPSessionBase::IsIncomingTransfer()
       
   866     {
       
   867     if ( iTransferController )
       
   868         {
       
   869         return iTransferController->IsIncomingTransfer();
       
   870         }
       
   871     else
       
   872         {
       
   873         return EFalse;
       
   874         }
       
   875     }
       
   876 
       
   877 // ---------------------------------------------------------------------------
       
   878 // CSVPSessionBase::TransferTarget
       
   879 // ---------------------------------------------------------------------------
       
   880 //
       
   881 const TDesC& CSVPSessionBase::TransferTarget() const
       
   882     {
       
   883     SVPDEBUG1( "CSVPSessionBase::TransferTarget" )
       
   884     
       
   885     if ( iTransferController )
       
   886         {
       
   887         return iTransferController->TransferTarget();
       
   888         }
       
   889     else
       
   890         {
       
   891         return KNullDesC;
       
   892         }
       
   893     }
       
   894 
       
   895 // -----------------------------------------------------------------------------
       
   896 // CSVPSessionBase::SetFromHeader
       
   897 // -----------------------------------------------------------------------------
       
   898 //
       
   899 TInt CSVPSessionBase::SetFromHeader( const TDesC8& aFromHeader )
       
   900     {
       
   901     SVPDEBUG1( "CSVPSessionBase::SetFromHeader" )
       
   902     
       
   903     delete iFromHeader;
       
   904     iFromHeader = NULL;
       
   905     
       
   906     TRAPD( err, iFromHeader = aFromHeader.AllocL() );
       
   907     return err;
       
   908     }
       
   909 
       
   910 // -----------------------------------------------------------------------------
       
   911 // CSVPSessionBase::FromHeader
       
   912 // -----------------------------------------------------------------------------
       
   913 //
       
   914 TDesC8* CSVPSessionBase::FromHeader()
       
   915     {
       
   916     return iFromHeader;
       
   917     }  
       
   918 
       
   919 // -----------------------------------------------------------------------------
       
   920 // CSVPSessionBase::SetToHeader
       
   921 // -----------------------------------------------------------------------------
       
   922 //
       
   923 TInt CSVPSessionBase::SetToHeader( const TDesC8& aToHeader )
       
   924     {
       
   925     SVPDEBUG1( "CSVPSessionBase::SetToHeader" )
       
   926     
       
   927     delete iToHeader;
       
   928     iToHeader = NULL;
       
   929     
       
   930     TRAPD( err, iToHeader = aToHeader.AllocL() );
       
   931     return err;
       
   932     }
       
   933 
       
   934 // -----------------------------------------------------------------------------
       
   935 // CSVPSessionBase::ToHeader
       
   936 // -----------------------------------------------------------------------------
       
   937 //
       
   938 TDesC8* CSVPSessionBase::ToHeader()
       
   939     {
       
   940     return iToHeader;
       
   941     }
       
   942 
       
   943 // -----------------------------------------------------------------------------
       
   944 // CSVPSessionBase::SetCallId
       
   945 // -----------------------------------------------------------------------------
       
   946 //
       
   947 TInt CSVPSessionBase::SetCallId( const TDesC8& aCallId )
       
   948     {
       
   949     SVPDEBUG1( "CSVPSessionBase::SetCallId" )
       
   950     
       
   951     delete iCallId;
       
   952     iCallId = NULL;
       
   953     
       
   954     TRAPD( err, iCallId = aCallId.AllocL() );
       
   955     return err;
       
   956     }
       
   957 
       
   958 // -----------------------------------------------------------------------------
       
   959 // CSVPSessionBase::CallId
       
   960 // -----------------------------------------------------------------------------
       
   961 //
       
   962 TDesC8* CSVPSessionBase::CallId()
       
   963     {
       
   964     return iCallId;
       
   965     }
       
   966 
       
   967 // -----------------------------------------------------------------------------
       
   968 // CSVPSessionBase::SetCSeqHeader
       
   969 // -----------------------------------------------------------------------------
       
   970 //
       
   971 TInt CSVPSessionBase::SetCSeqHeader( const TDesC8& aCSeq )
       
   972     {
       
   973     SVPDEBUG1( "CSVPSessionBase::SetCSeqHeader In" )
       
   974     
       
   975     delete iCSeqHeader;
       
   976     iCSeqHeader = NULL;
       
   977     
       
   978     TRAPD( err, iCSeqHeader = HBufC::NewL( aCSeq.Length() ) );
       
   979     iCSeqHeader->Des().Copy( aCSeq );
       
   980     
       
   981     // Check "CSeq:" and remove it from the beginning if exists
       
   982     if ( 0 == iCSeqHeader->Des().FindF( KSVPCSeqPrefix ) )
       
   983         {
       
   984         // CSeq: is in the beginning of the string, remove it and 1 blank
       
   985         iCSeqHeader->Des().Delete( 0, KSVPCSeqPrefixLength + 1 );
       
   986         }
       
   987     
       
   988     // Check/remove the sequence number and the blank
       
   989     const TInt spacePosition = iCSeqHeader->Des().Find( KSVPSpace2 );
       
   990     
       
   991     if ( spacePosition != KErrNotFound )
       
   992         {
       
   993         iCSeqHeader->Des().Delete( 0, spacePosition + 1 );
       
   994         }
       
   995     
       
   996     SVPDEBUG2( "CSVPSessionBase::SetCSeqHeader Out return=%d", err )
       
   997     return err;
       
   998     }
       
   999 
       
  1000 // ---------------------------------------------------------------------------
       
  1001 // CSVPSessionBase::CSeqHeader
       
  1002 // ---------------------------------------------------------------------------
       
  1003 // 
       
  1004 const TDesC& CSVPSessionBase::CSeqHeader() const
       
  1005     {
       
  1006     SVPDEBUG1( "CSVPSessionBase::CSeqHeader In" )  
       
  1007     
       
  1008     if ( iCSeqHeader )
       
  1009         {
       
  1010         SVPDEBUG1( "CSVPSessionBase::CSeqHeader Out" )
       
  1011         return *iCSeqHeader;
       
  1012         }
       
  1013     else
       
  1014         {
       
  1015         SVPDEBUG1( "CSVPSessionBase::CSeqHeader Out KNullDesC" )
       
  1016         return KNullDesC;
       
  1017         }
       
  1018     }
       
  1019 
       
  1020 // ---------------------------------------------------------------------------
       
  1021 // CSVPSessionBase::AddObserverL
       
  1022 // ---------------------------------------------------------------------------
       
  1023 //
       
  1024 void CSVPSessionBase::AddObserverL( const MCCPCallObserver& aObserver )
       
  1025     {
       
  1026     SVPDEBUG1( "CSVPSessionBase::AddObserverL In" )
       
  1027     
       
  1028     // set session observer
       
  1029     // only one observer used at a time, replaces current one
       
  1030     iCCPSessionObserver = const_cast< MCCPCallObserver* >( &aObserver );
       
  1031     
       
  1032     SVPDEBUG1( "CSVPSessionBase::AddObserverL Out" )
       
  1033     }
       
  1034 
       
  1035 // ---------------------------------------------------------------------------
       
  1036 // CSVPSessionBase::GetCCPSessionObserver
       
  1037 // ---------------------------------------------------------------------------
       
  1038 //
       
  1039 MCCPCallObserver& CSVPSessionBase::GetCCPSessionObserver()
       
  1040     {
       
  1041     SVPDEBUG1( "CSVPSessionBase::GetCCPSessionObserver" )
       
  1042     // get session observer
       
  1043     return *iCCPSessionObserver;
       
  1044     }
       
  1045 
       
  1046 // ---------------------------------------------------------------------------
       
  1047 // CSVPSessionBase::RemoveObserver
       
  1048 // ---------------------------------------------------------------------------
       
  1049 //
       
  1050 TInt CSVPSessionBase::RemoveObserver( const MCCPCallObserver& /*aObserver*/ )
       
  1051     {
       
  1052     return KErrNotSupported; 
       
  1053     }
       
  1054 
       
  1055 // ---------------------------------------------------------------------------
       
  1056 // CSVPSessionBase::InbandDtmfEventOccurred
       
  1057 // ---------------------------------------------------------------------------
       
  1058 //
       
  1059 void CSVPSessionBase::InbandDtmfEventOccurred( TSVPDtmfEvent aEvent )
       
  1060     {
       
  1061     SVPDEBUG1( "CSVPSessionBase::InbandDtmfEventOccurred In" )
       
  1062     SVPDEBUG2( "CSVPSessionBase::InbandDtmfEventOccurred aEvent:%d", aEvent )
       
  1063       
       
  1064     switch ( aEvent )
       
  1065         {
       
  1066         case ESvpDtmfSendStarted:
       
  1067             {
       
  1068             DtmfObserver().
       
  1069                 HandleDTMFEvent( MCCPDTMFObserver::ECCPDtmfSequenceStart, 
       
  1070                                  KErrNone, 
       
  1071                                  iDtmfLex.Peek() );
       
  1072             break;
       
  1073             }
       
  1074             
       
  1075         case ESvpDtmfSendStopped:
       
  1076             {
       
  1077             DtmfObserver().HandleDTMFEvent( 
       
  1078                                  MCCPDTMFObserver::ECCPDtmfSequenceStop, 
       
  1079                                  KErrNone, 
       
  1080                                  iDtmfLex.Get() );
       
  1081             break;
       
  1082             }
       
  1083             
       
  1084         case ESvpDtmfSendCompleted:
       
  1085             {
       
  1086             DtmfObserver().HandleDTMFEvent( 
       
  1087                      MCCPDTMFObserver::ECCPDtmfStringSendingCompleted, 
       
  1088                      KErrNone, 
       
  1089                      iDtmfLex.Peek() );
       
  1090             break;
       
  1091             }
       
  1092         
       
  1093         default:
       
  1094             {
       
  1095             SVPDEBUG1( "CSVPSessionBase::InbandDtmfEventOccurred Default" )
       
  1096             break;
       
  1097             }
       
  1098         }
       
  1099     
       
  1100     SVPDEBUG1( "CSVPSessionBase::InbandDtmfEventOccurred Out" )
       
  1101     }
       
  1102 
       
  1103   
       
  1104 // ---------------------------------------------------------------------------
       
  1105 // CSVPSessionBase::ConstructAudioStreamsL
       
  1106 // ---------------------------------------------------------------------------
       
  1107 //
       
  1108 void CSVPSessionBase::ConstructAudioStreamsL()
       
  1109     {
       
  1110     SVPDEBUG1( "CSVPSessionBase::ConstructAudioStreamsL In" )
       
  1111     
       
  1112     // OUT STREAM
       
  1113     // create "audio out" stream first, puts audioOutStream to cleanupstack
       
  1114     CMceAudioStream* audioOutStream = CMceAudioStream::NewLC();     // CS: 1
       
  1115     // create mic source
       
  1116     CMceMicSource* mic = CMceMicSource::NewLC();                    // CS: 2
       
  1117     // set source for "audio out" stream, in this case it's microphone
       
  1118     // there can be only one source at a time.
       
  1119     audioOutStream->SetSourceL( mic );
       
  1120     // pop mic from cleanupstack
       
  1121     CleanupStack::Pop( mic );                                       // CS: 1
       
  1122     // create rtp sink for mic
       
  1123     CMceRtpSink* rtpSink = CMceRtpSink::NewLC();                    // CS: 2
       
  1124     audioOutStream->AddSinkL( rtpSink );
       
  1125     CleanupStack::Pop( rtpSink );                                   // CS: 1
       
  1126     
       
  1127     // IN STREAM
       
  1128     // create "audio in" stream
       
  1129     CMceAudioStream* audioInStream = CMceAudioStream::NewLC();      // CS: 2
       
  1130     // create rtp source for "audio in" stream
       
  1131     CMceRtpSource* rtpSource = CMceRtpSource::NewLC(
       
  1132             KSvpJitterBufferLength, KSvpJitterBufferThreshold, 
       
  1133             KSvpStandbyTimerInMillisecs );                          // CS: 3
       
  1134     audioInStream->SetSourceL( rtpSource );
       
  1135     // pop rtp source from cleanupstack
       
  1136     CleanupStack::Pop( rtpSource );                                 // CS: 2
       
  1137     // create speaker sink for "audio in" stream
       
  1138     CMceSpeakerSink* speakerSink = CMceSpeakerSink::NewLC();        // CS: 3
       
  1139     audioInStream->AddSinkL( speakerSink );
       
  1140     // pop speaker from cleanupstack
       
  1141     CleanupStack::Pop( speakerSink );                               // CS: 2
       
  1142     
       
  1143     // Bind "audio out" stream to "audio in" stream. Ownership of the stream
       
  1144     // is transferred thus we must pop the instream from CS.
       
  1145     audioOutStream->BindL( audioInStream );
       
  1146     CleanupStack::Pop( audioInStream );                             // CS: 1
       
  1147     
       
  1148     // Add stream to session. Note that the ownership is transferred thus
       
  1149     // we pop the audioOutStream in this phase.
       
  1150     iSession->AddStreamL( audioOutStream );
       
  1151     CleanupStack::Pop( audioOutStream );                            // CS: 0
       
  1152     
       
  1153     // establish Old way hold support 
       
  1154     iSession->SetModifierL( KMceMediaDirection,
       
  1155             KMceMediaDirectionWithAddress );
       
  1156     
       
  1157     // preconditions are set so that long negotiation is taken in to use
       
  1158     // when establishing secure call
       
  1159     if ( SecureMandatory() || SecurePreferred() )
       
  1160         {
       
  1161         iSession->SetModifierL( KMceSecPreconditions, 
       
  1162                                 KMcePreconditionsE2ESupported );
       
  1163         }
       
  1164     else
       
  1165         {
       
  1166         // else modify preconditions off
       
  1167         iSession->SetModifierL( KMcePreconditions, 
       
  1168                                 KMcePreconditionsNotUsed );
       
  1169         }
       
  1170     
       
  1171     SVPDEBUG2( "CSVPSessionBase::ConstructAudioStreamsL audioInStream codec count: %d",
       
  1172             audioInStream->Codecs().Count() )
       
  1173     SVPDEBUG2( "CSVPSessionBase::ConstructAudioStreamsL audioOutStream codec count: %d",
       
  1174             audioOutStream->Codecs().Count() )
       
  1175     
       
  1176     // add codecs to audiostream
       
  1177     iSVPUtility.SetAudioCodecsMOL(
       
  1178             iVoIPProfileId, *audioInStream, iKeepAliveValue );
       
  1179 
       
  1180     // set same local media port from InStream to OutStream 
       
  1181     audioOutStream->SetLocalMediaPortL( audioInStream->LocalMediaPort() );
       
  1182     iSVPUtility.UpdateJitterBufferSizeL( *rtpSource );
       
  1183     
       
  1184     // set MMF priorities and preferences to codecs
       
  1185     SVPDEBUG1( "CSVPSessionBase::ConstructAudioStreamsL Set MMF priorities" )
       
  1186     iSVPUtility.SetDtmfMode( SVPAudioUtility::SetPriorityCodecValuesL(
       
  1187             *audioInStream, *audioOutStream ) );
       
  1188     
       
  1189     SVPDEBUG1( "CSVPSessionBase::ConstructAudioStreamsL Out" )
       
  1190     }
       
  1191 
       
  1192 // ---------------------------------------------------------------------------
       
  1193 // CSVPSessionBase::HangUp
       
  1194 // ---------------------------------------------------------------------------
       
  1195 //
       
  1196 TInt CSVPSessionBase::HangUp()
       
  1197     {
       
  1198     SVPDEBUG1( "CSVPSessionBase::HangUp In" )
       
  1199     
       
  1200     TInt err( KErrNone );
       
  1201     
       
  1202     if ( CMceSession::EEstablished == iSession->State() )
       
  1203         {
       
  1204         SVPDEBUG1( "CSVPSessionBase::HangUp() TerminateL" )
       
  1205         
       
  1206         TRAP( err, iSession->TerminateL() );
       
  1207         
       
  1208         if ( !err )
       
  1209             {
       
  1210             ExecCbCallStateChanged( MCCPCallObserver::ECCPStateDisconnecting );
       
  1211             
       
  1212 	        // IsAttended() and different timer values needed for 
       
  1213             // attended transfer when there is also one waiting call queued
       
  1214             // and ringing tone for queued session needs to be played
       
  1215             TInt timerID = 0;
       
  1216             TInt delay = 0;
       
  1217             
       
  1218             if ( IsAttended() )
       
  1219             	{
       
  1220 	            delay = KSVPTerminatingTime;
       
  1221 	            timerID = KSVPTerminationTimerExpired;
       
  1222             	}
       
  1223             else{
       
  1224 	            delay = KSVPMoHangupTerminatingTime;
       
  1225 	            timerID = KSVPHangUpTimerExpired;
       
  1226             	}
       
  1227             
       
  1228             TRAPD( errTimer, StartTimerL( delay, timerID ) );
       
  1229             
       
  1230             if ( errTimer )
       
  1231                 {
       
  1232                 SVPDEBUG2("CSVPSessionBase::HangUp timer leave with error code %d",
       
  1233                         errTimer )
       
  1234                 }
       
  1235             else
       
  1236             	{
       
  1237             	iAlreadyTerminating = ETrue;
       
  1238             	}
       
  1239             }   
       
  1240         }
       
  1241     else
       
  1242         {
       
  1243         SVPDEBUG2( "CSVPSessionBase::HangUp() Wrong state: %d", iSession->State() )
       
  1244         
       
  1245         StopTimers();
       
  1246         ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
  1247         }
       
  1248     
       
  1249     SVPDEBUG2( "CSVPSessionBase::HangUp Out return=%d", err )
       
  1250     return err;
       
  1251     }
       
  1252 
       
  1253 // ---------------------------------------------------------------------------
       
  1254 // CSVPSessionBase::Hold
       
  1255 // ---------------------------------------------------------------------------
       
  1256 //
       
  1257 TInt CSVPSessionBase::Hold()
       
  1258     {
       
  1259     SVPDEBUG1( "CSVPSessionBase::Hold In" )
       
  1260     
       
  1261     TInt err( KErrNone );
       
  1262     
       
  1263     if ( CMceSession::EEstablished == iSession->State() )
       
  1264         {
       
  1265         if ( !iHoldController )
       
  1266             {
       
  1267             TRAP( err, iHoldController = 
       
  1268                     CSVPHoldController::NewL( *iSession, 
       
  1269                                               iContainer, 
       
  1270                                               this,
       
  1271                                               IsMobileOriginated() ) );
       
  1272             if ( KErrNone != err )
       
  1273                 {
       
  1274                 return err;
       
  1275                 }
       
  1276             }
       
  1277         
       
  1278         iHoldController->Muted( iMuted );
       
  1279         err = iHoldController->HoldSession( iSession );
       
  1280         
       
  1281         if ( KErrNone != err )
       
  1282             {
       
  1283             ExecCbErrorOccurred( ECCPLocalHoldFail );
       
  1284             }
       
  1285         else
       
  1286             {
       
  1287             TRAP( err, StartTimerL( KSVPHoldExpirationTime,
       
  1288                     KSVPHoldTimerExpired ) );
       
  1289             
       
  1290             SVPDEBUG2( "CSVPSessionBase::Hold - Started Expire timer, err %i",
       
  1291                        err )
       
  1292             }
       
  1293         }
       
  1294     
       
  1295     else
       
  1296         {
       
  1297         ExecCbErrorOccurred( ECCPLocalHoldFail );
       
  1298         }
       
  1299     
       
  1300     SVPDEBUG2( "CSVPSessionBase::Hold Out return=%d", err )
       
  1301     return err;
       
  1302     }
       
  1303 
       
  1304 // ---------------------------------------------------------------------------
       
  1305 // CSVPSessionBase::Resume
       
  1306 // ---------------------------------------------------------------------------
       
  1307 //
       
  1308 TInt CSVPSessionBase::Resume()
       
  1309     {
       
  1310     SVPDEBUG1( "CSVPSessionBase::Resume In" )
       
  1311     
       
  1312     TInt err( KErrNone );
       
  1313     
       
  1314     if ( !iHoldController )
       
  1315         {
       
  1316         TRAP( err, iHoldController = CSVPHoldController::NewL(
       
  1317                 *iSession, iContainer, this, IsMobileOriginated() ) );
       
  1318         
       
  1319         if ( KErrNone != err )
       
  1320             {
       
  1321             SVPDEBUG2( "CSVPSessionBase::Resume Out return(err)=%d", err )
       
  1322             return err;
       
  1323             }
       
  1324         }
       
  1325     
       
  1326     iHoldController->Muted( iMuted );  
       
  1327     err = iHoldController->ResumeSession( iSession );
       
  1328     
       
  1329     if ( KErrNone != err )
       
  1330         {
       
  1331         ExecCbErrorOccurred( ECCPLocalResumeFail );
       
  1332         }
       
  1333     else
       
  1334         {
       
  1335         TRAP( err, StartTimerL( KSVPResumeExpirationTime,
       
  1336                 KSVPResumeTimerExpired ) );
       
  1337         SVPDEBUG2("CSVPSessionBase::Resume - Started Expire timer, err %i",
       
  1338                    err );
       
  1339         }
       
  1340         
       
  1341     SVPDEBUG2( "CSVPSessionBase::Resume Out return=%d", err )
       
  1342     return err;  
       
  1343     }
       
  1344         
       
  1345 // ---------------------------------------------------------------------------
       
  1346 // CSVPSessionBase::IncomingRequest
       
  1347 // ---------------------------------------------------------------------------
       
  1348 //
       
  1349 TInt CSVPSessionBase::IncomingRequest( CMceInSession& aUpdatedSession )
       
  1350     {
       
  1351     SVPDEBUG1( "CSVPSessionBase::IncomingRequest In" )
       
  1352 
       
  1353     // Check if own request is ongoing
       
  1354     if ( iHoldController )
       
  1355         {
       
  1356         iHoldController->CheckCrossOver( *this );
       
  1357         }
       
  1358     
       
  1359     if ( &aUpdatedSession )
       
  1360         {
       
  1361         //Because there is an update we have to discard everything about ICMP -3
       
  1362         StopTimer ( KSVPICMPErrorTimerExpired );
       
  1363         if ( !IsErrorInULandDLFirstTime() )
       
  1364             {
       
  1365             SetErrorInULandDLFirstTime( ETrue );
       
  1366             }
       
  1367         
       
  1368         TInt err( KErrNone );
       
  1369         
       
  1370         if ( !iHoldController )
       
  1371             {
       
  1372             TRAP( err, iHoldController = CSVPHoldController::NewL(
       
  1373                     *iSession, iContainer, this, IsMobileOriginated() ) );
       
  1374             
       
  1375             if ( KErrNone != err )
       
  1376                 {
       
  1377                 return err;
       
  1378                 }
       
  1379             
       
  1380             TBool sessionUpdateOngoing = ETrue;
       
  1381             
       
  1382             // Most likely a hold case, MT needs to set the keepalive
       
  1383             TRAP_IGNORE( SetRtpKeepAliveL( &aUpdatedSession,
       
  1384                     sessionUpdateOngoing ) );
       
  1385             }
       
  1386         
       
  1387         SVPDEBUG2( "CSVPSessionBase::IncomingRequest iSession: 0x%x", iSession )
       
  1388         
       
  1389         // Update changed session to the transfercontroller
       
  1390         if ( iTransferController )
       
  1391             {
       
  1392             iTransferController->SetMceSessionObject( &aUpdatedSession );
       
  1393             }
       
  1394         
       
  1395         iHoldController->Muted( iMuted );
       
  1396         
       
  1397         TInt status = iHoldController->IncomingRequest( &aUpdatedSession );
       
  1398         SVPDEBUG2( "CSVPSessionBase::IncomingRequest Out return=%d", status )
       
  1399         return status;
       
  1400         }
       
  1401     else
       
  1402         {
       
  1403         SVPDEBUG1( "CSVPSessionBase::IncomingRequest Out illegal aUpdatedSession" )
       
  1404         return KErrArgument;
       
  1405         }
       
  1406     }
       
  1407 
       
  1408 // ---------------------------------------------------------------------------
       
  1409 // CSVPSessionBase::HoldController
       
  1410 // ---------------------------------------------------------------------------
       
  1411 //    
       
  1412 CSVPHoldController& CSVPSessionBase::HoldController() const
       
  1413     {
       
  1414     return *iHoldController;
       
  1415     }
       
  1416     
       
  1417 // ---------------------------------------------------------------------------
       
  1418 // CSVPSessionBase::HasHoldController
       
  1419 // ---------------------------------------------------------------------------
       
  1420 //
       
  1421 TBool CSVPSessionBase::HasHoldController() const
       
  1422     {
       
  1423     if ( iHoldController )
       
  1424         {
       
  1425         return ETrue;
       
  1426         }
       
  1427     else
       
  1428         {
       
  1429         return EFalse;
       
  1430         }
       
  1431     }
       
  1432     
       
  1433 // ---------------------------------------------------------------------------
       
  1434 // CSVPSessionBase::HandleSessionStateChanged
       
  1435 // ---------------------------------------------------------------------------
       
  1436 //
       
  1437 void CSVPSessionBase::HandleSessionStateChanged( CMceSession& aSession )
       
  1438     {
       
  1439     SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged In" )
       
  1440     
       
  1441 
       
  1442     if ( iHoldController )
       
  1443         {
       
  1444         if ( iHoldController->HoldInProgress() )
       
  1445             {
       
  1446             SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged HoldInProgress" )
       
  1447             
       
  1448             StopTimers();
       
  1449             iHoldController->Muted( iMuted );
       
  1450             TInt err = iHoldController->ContinueHoldProcessing( aSession );
       
  1451             
       
  1452             if ( KErrNone != err )
       
  1453                 {
       
  1454                 SVPDEBUG2( "CSVPSessionBase::HandleSessionStateChanged, err: %d", err )
       
  1455                 ExecCbErrorOccurred( ECCPLocalHoldFail );
       
  1456                 }
       
  1457             }
       
  1458         else if ( iHoldController->ResumeFailed() )
       
  1459             {
       
  1460             // Must terminate session; timer expired
       
  1461             SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged Resume failed - Terminating" )
       
  1462                        
       
  1463             TRAPD( err, iSession->TerminateL() );
       
  1464             
       
  1465             if ( !err )
       
  1466                 {
       
  1467                 SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged Disconnecting" )
       
  1468                 ExecCbCallStateChanged( MCCPCallObserver::ECCPStateDisconnecting );
       
  1469                 
       
  1470                 TRAP( err, StartTimerL( KSVPMoHangupTerminatingTime,
       
  1471                         KSVPHangUpTimerExpired ) );
       
  1472                 
       
  1473                 if ( KErrNone != err )
       
  1474                     {
       
  1475                     SVPDEBUG2("CSVPSessionBase::HandleSessionStateChanged Hangup-timer error %d",
       
  1476                             err )
       
  1477                     }
       
  1478                 }
       
  1479             else
       
  1480                 {
       
  1481                 SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged - Term ERROR!" )
       
  1482                 }
       
  1483             }
       
  1484         else if ( iHoldController->HoldFailed() )
       
  1485             {
       
  1486             // Hold timer expired; no actions needed here
       
  1487             SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged: Hold request failed - nothing to do" )
       
  1488             }
       
  1489         else
       
  1490             {
       
  1491             SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged - else" )
       
  1492             }
       
  1493         }
       
  1494     
       
  1495     SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged Out" )
       
  1496     }
       
  1497 
       
  1498 // ---------------------------------------------------------------------------
       
  1499 // CSVPSessionBase::HandleStreamStateChange
       
  1500 // ---------------------------------------------------------------------------
       
  1501 //
       
  1502 void CSVPSessionBase::HandleStreamStateChange( CMceMediaStream& aStream )
       
  1503     {
       
  1504     SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream)  stream state= %d",
       
  1505             aStream.State() )
       
  1506     SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream)  stream  type= %d",
       
  1507         aStream.Type() )
       
  1508     SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream) session state= %d",
       
  1509         aStream.Session()->State() )
       
  1510 
       
  1511     if ( CMceMediaStream::EStreaming == aStream.State() &&
       
  1512          CMceSession::EOffering == aStream.Session()->State() )
       
  1513         {
       
  1514         SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream) early media started" )
       
  1515         ExecCbCallEventOccurred( MCCPCallObserver::ECCCSPEarlyMediaStarted );
       
  1516         iEarlyMediaOngoing = ETrue;
       
  1517         }
       
  1518     TBool bothStreamsDisabled ( ETrue );
       
  1519     TRAP_IGNORE( bothStreamsDisabled = IsBothStreamsDisabledL() );
       
  1520     if ( bothStreamsDisabled &&
       
  1521          CMceSession::EEstablished == aStream.Session()->State() )
       
  1522         {
       
  1523         SetErrorInULandDLFirstTime( EFalse ); 
       
  1524         TRAP_IGNORE( StartTimerL( KSVPICMPErrorTime, KSVPICMPErrorTimerExpired ) )
       
  1525         }
       
  1526       else if ( !bothStreamsDisabled && !IsErrorInULandDLFirstTime() )
       
  1527           {
       
  1528           SetErrorInULandDLFirstTime( ETrue );
       
  1529           StopTimer ( KSVPICMPErrorTimerExpired );
       
  1530           }
       
  1531     SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream) Out" )
       
  1532     }
       
  1533 
       
  1534 // ---------------------------------------------------------------------------
       
  1535 // CSVPSessionBase::HandleStreamStateChange
       
  1536 // ---------------------------------------------------------------------------
       
  1537 // 
       
  1538 void CSVPSessionBase::HandleStreamStateChange( CMceMediaStream& aStream,
       
  1539         CMceMediaSink& aSink )
       
  1540     {
       
  1541     SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) In" )
       
  1542     
       
  1543     if ( &aStream )
       
  1544         {
       
  1545         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) stream state=%d",
       
  1546                 aStream.State() )
       
  1547         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) stream type=%d",
       
  1548                 aStream.Type() )
       
  1549         }
       
  1550     
       
  1551     if ( &aStream && aStream.Session() )
       
  1552         {
       
  1553         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) session state=%d",
       
  1554                 aStream.Session()->State() )
       
  1555         }
       
  1556     
       
  1557     if ( &aSink )
       
  1558         {
       
  1559         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) is sink enabled=%d",
       
  1560                 aSink.IsEnabled() )
       
  1561 
       
  1562         if ( HasHoldController() && ESVPConnected == HoldController().HoldState() && 
       
  1563              !aSink.IsEnabled() && CMceSession::EEstablished == aStream.Session()->State() ) 
       
  1564             {
       
  1565             // Hold state is connected but sink is disabled -> try enable after a while
       
  1566             SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange - Resume ICMP, Sink" )
       
  1567             TRAP_IGNORE( StartTimerL( KSVPSinkResumeICMPErrorTime, KSVPSinkResumeICMPErrorTimerExpired ) )
       
  1568             }
       
  1569         }
       
  1570     
       
  1571     SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) Out" )
       
  1572     }
       
  1573 
       
  1574 // ---------------------------------------------------------------------------
       
  1575 // CSVPSessionBase::HandleStreamStateChange
       
  1576 // ---------------------------------------------------------------------------
       
  1577 //
       
  1578 void CSVPSessionBase::HandleStreamStateChange( CMceMediaStream& aStream,
       
  1579         CMceMediaSource& aSource )
       
  1580     {
       
  1581     SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) In" )
       
  1582     
       
  1583     if ( &aStream )
       
  1584         {
       
  1585         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) stream state=%d",
       
  1586                 aStream.State() )
       
  1587         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) stream type=%d",
       
  1588                 aStream.Type() )
       
  1589         }
       
  1590     
       
  1591     if ( &aStream && aStream.Session() )
       
  1592         {
       
  1593         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) session state=%d",
       
  1594                 aStream.Session()->State() )
       
  1595         }
       
  1596     
       
  1597     if ( &aSource )
       
  1598         {
       
  1599         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) is source enabled=%d",
       
  1600                 aSource.IsEnabled() )
       
  1601 
       
  1602         if ( HasHoldController() && ESVPConnected == HoldController().HoldState() && 
       
  1603              !aSource.IsEnabled() && CMceSession::EEstablished == aStream.Session()->State() )
       
  1604             {
       
  1605             // Hold state is connected but source is disabled -> try enable after a while
       
  1606             SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange - Resume ICMP, Source" )
       
  1607             TRAP_IGNORE( StartTimerL( KSVPSourceResumeICMPErrorTime, KSVPSourceResumeICMPErrorTimerExpired ) )
       
  1608             }
       
  1609         }
       
  1610     
       
  1611     SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) Out" )
       
  1612     }
       
  1613 
       
  1614 // ---------------------------------------------------------------------------
       
  1615 // CSVPSessionBase::SessionLocallyHeld, from MSVPHoldObserver
       
  1616 // ---------------------------------------------------------------------------
       
  1617 // 
       
  1618 void CSVPSessionBase::SessionLocallyHeld()
       
  1619     {
       
  1620     SVPDEBUG1( "CSVPSessionBase::SessionLocallyHeld In" )
       
  1621     
       
  1622     ExecCbCallStateChanged( MCCPCallObserver::ECCPStateHold );
       
  1623     iRtpObserver.ResetSessionInObserving( this );
       
  1624     
       
  1625     SVPDEBUG1( "CSVPSessionBase::SessionLocallyHeld Out" )
       
  1626     }
       
  1627 
       
  1628 // ---------------------------------------------------------------------------
       
  1629 // CSVPSessionBase::SessionLocallyResumed, from MSVPHoldObserver
       
  1630 // ---------------------------------------------------------------------------
       
  1631 // 
       
  1632 void CSVPSessionBase::SessionLocallyResumed()
       
  1633     {
       
  1634     SVPDEBUG1( "CSVPSessionBase::SessionLocallyResumed In" )
       
  1635     
       
  1636     ExecCbCallStateChanged( MCCPCallObserver::ECCPStateConnected );
       
  1637     iRtpObserver.ResetSessionInObserving( this );
       
  1638     
       
  1639     SVPDEBUG1( "CSVPSessionBase::SessionLocallyResumed Out" )
       
  1640     }
       
  1641 
       
  1642 // ---------------------------------------------------------------------------
       
  1643 // CSVPSessionBase::SessionRemoteHeld, from MSVPHoldObserver
       
  1644 // ---------------------------------------------------------------------------
       
  1645 // 
       
  1646 void CSVPSessionBase::SessionRemoteHeld()
       
  1647     {
       
  1648     SVPDEBUG1( "CSVPSessionBase::SessionRemoteHeld In" )
       
  1649     
       
  1650     ExecCbCallEventOccurred( MCCPCallObserver::ECCPRemoteHold );
       
  1651     iRtpObserver.ResetSessionInObserving( this );
       
  1652     
       
  1653     SVPDEBUG1( "CSVPSessionBase::SessionRemoteHeld Out" )
       
  1654     }
       
  1655 
       
  1656 // ---------------------------------------------------------------------------
       
  1657 // CSVPSessionBase::SessionRemoteResumed, from MSVPHoldObserver
       
  1658 // ---------------------------------------------------------------------------
       
  1659 // 
       
  1660 void CSVPSessionBase::SessionRemoteResumed()
       
  1661     {
       
  1662     SVPDEBUG1( "CSVPSessionBase::SessionRemoteResumed In" )
       
  1663     
       
  1664     ExecCbCallEventOccurred( MCCPCallObserver::ECCPRemoteResume );
       
  1665     iRtpObserver.ResetSessionInObserving( this );
       
  1666     
       
  1667     SVPDEBUG1( "CSVPSessionBase::SessionRemoteResumed Out" )
       
  1668     }
       
  1669 
       
  1670 // ---------------------------------------------------------------------------
       
  1671 // CSVPSessionBase::HoldRequestFailed, from MSVPHoldObserver
       
  1672 // ---------------------------------------------------------------------------
       
  1673 // 
       
  1674 void CSVPSessionBase::HoldRequestFailed()
       
  1675     {
       
  1676     SVPDEBUG1( "CSVPSessionBase::HoldRequestFailed In" )
       
  1677     
       
  1678     ExecCbErrorOccurred( ECCPLocalHoldFail );
       
  1679     
       
  1680     SVPDEBUG1( "CSVPSessionBase::HoldRequestFailed Out" )
       
  1681     }
       
  1682 
       
  1683 // ---------------------------------------------------------------------------
       
  1684 // CSVPSessionBase::ResumeRequestFailed, from MSVPHoldObserver
       
  1685 // ---------------------------------------------------------------------------
       
  1686 // 
       
  1687 void CSVPSessionBase::ResumeRequestFailed()
       
  1688     {
       
  1689     SVPDEBUG1( "CSVPSessionBase::ResumeRequestFailed In" )
       
  1690     
       
  1691     ExecCbErrorOccurred( ECCPLocalResumeFail );
       
  1692     
       
  1693     SVPDEBUG1( "CSVPSessionBase::ResumeRequestFailed Out" )
       
  1694     }
       
  1695 
       
  1696 // ---------------------------------------------------------------------------
       
  1697 // CSVPSessionBase::RemoteParty
       
  1698 // ---------------------------------------------------------------------------
       
  1699 // 
       
  1700 const TDesC& CSVPSessionBase::RemoteParty() const
       
  1701     {
       
  1702     delete iRecipient;
       
  1703     iRecipient = NULL;
       
  1704     
       
  1705     // RemotePartyL is used to handle leave situations
       
  1706     TRAPD( remoteErr, RemotePartyL() );
       
  1707     
       
  1708     if ( KErrNone != remoteErr )
       
  1709         {
       
  1710         // something went wrong, return null
       
  1711         SVPDEBUG2( "CSVPSessionBase::RemoteParty remoteErr=%d", remoteErr )
       
  1712         return KNullDesC;
       
  1713         }
       
  1714     else
       
  1715         {
       
  1716         return *iRecipient;
       
  1717         }
       
  1718     }
       
  1719 
       
  1720 // ---------------------------------------------------------------------------
       
  1721 // CSVPSessionBase::RemotePartyL
       
  1722 // ---------------------------------------------------------------------------
       
  1723 // 
       
  1724 void CSVPSessionBase::RemotePartyL() const
       
  1725     {
       
  1726     SVPDEBUG1( "CSVPSessionBase::RemotePartyL In" )
       
  1727     
       
  1728     // fetch recipient from Mce, convert recipient to 16-bit descriptor
       
  1729     if ( IsMobileOriginated() )
       
  1730         {
       
  1731         SVPDEBUG1( "CSVPSessionBase::RemotePartyL, mo case, Fetch: RECIPIENT" )
       
  1732         iRecipient = HBufC::NewL( iSession->Recipient().Length() );
       
  1733         iRecipient->Des().Copy( iSession->Recipient() );
       
  1734  
       
  1735         // remove all extra parameters from recipient address
       
  1736         TInt index = iRecipient->Des().FindF( KSVPSemiColon );
       
  1737         
       
  1738         if ( KErrNotFound != index )
       
  1739             {
       
  1740             iRecipient->Des().Delete( index, iRecipient->Length() );
       
  1741             // remove left bracket if exists
       
  1742             TInt bracketLocation = iRecipient->Locate( KSVPLeftBracket );
       
  1743             if ( KErrNotFound != bracketLocation )
       
  1744                 {
       
  1745                 iRecipient->Des().Delete( bracketLocation, 1 );
       
  1746                 }
       
  1747             }
       
  1748         
       
  1749         // check if anonymous address
       
  1750         index = iRecipient->Des().FindF( KSVPAnonymous );
       
  1751         if ( KErrNotFound != index )
       
  1752             {
       
  1753             // Anonymous address case
       
  1754             SVPDEBUG2( "CSVPSessionBase::RemotePartyL: Anonymous = %d", index )
       
  1755             iRecipient->Des().Copy( KNullDesC );
       
  1756             }
       
  1757         }
       
  1758     else 
       
  1759         {
       
  1760         SVPDEBUG1( "CSVPSessionBase::RemotePartyL, mt case, Fetch: ORIGINATOR" )
       
  1761         HBufC* uri = CSVPUriParser::ParseRemotePartyUriL( 
       
  1762             iSession->Originator() );
       
  1763         delete iRecipient;
       
  1764         iRecipient = uri;
       
  1765         uri = NULL;
       
  1766         }
       
  1767     
       
  1768     SVPDEBUG1( "CSVPSessionBase::RemotePartyL Out" )
       
  1769     }
       
  1770 
       
  1771 // ---------------------------------------------------------------------------
       
  1772 // CSVPSessionBase::RemotePartyName
       
  1773 // ---------------------------------------------------------------------------
       
  1774 // 
       
  1775 const TDesC& CSVPSessionBase::RemotePartyName()
       
  1776     {
       
  1777     SVPDEBUG1( "CSVPSessionBase::RemotePartyName()" )
       
  1778     
       
  1779     HBufC* displayName = NULL;
       
  1780     TRAPD( err, displayName = CSVPUriParser::ParseDisplayNameL( 
       
  1781         iSession->Originator() ) )
       
  1782 
       
  1783     if ( err || NULL == displayName ) 
       
  1784         {
       
  1785         SVPDEBUG1( "CSVPSessionBase::RemotePartyName, return KNullDesC" )
       
  1786         delete displayName;
       
  1787         displayName = NULL;
       
  1788         return KNullDesC;
       
  1789         }
       
  1790     else
       
  1791         {
       
  1792         delete iDisplayName;
       
  1793         iDisplayName = displayName;
       
  1794         displayName = NULL;
       
  1795         return *iDisplayName;
       
  1796         }    
       
  1797     }
       
  1798 
       
  1799 // ---------------------------------------------------------------------------
       
  1800 // CSVPSessionBase::DialledParty
       
  1801 // ---------------------------------------------------------------------------
       
  1802 // 
       
  1803 const TDesC& CSVPSessionBase::DialledParty() const
       
  1804     {
       
  1805     SVPDEBUG1( "CSVPSessionBase::DialledParty not implemented" )  
       
  1806     return KNullDesC;
       
  1807     }
       
  1808 
       
  1809 // ---------------------------------------------------------------------------
       
  1810 // CSVPSessionBase::State
       
  1811 // ---------------------------------------------------------------------------
       
  1812 //
       
  1813 MCCPCallObserver::TCCPCallState CSVPSessionBase::State() const
       
  1814     {
       
  1815     SVPDEBUG1( "CSVPSessionBase::State In" )
       
  1816     SVPDEBUG2( "CSVPSessionBase::State iSession->State()=%d", iSession->State() )
       
  1817     
       
  1818     // ccpState can be safely initialized with StatusIdle
       
  1819     MCCPCallObserver::TCCPCallState ccpState =
       
  1820         MCCPCallObserver::ECCPStateIdle;
       
  1821     
       
  1822     switch ( iSession->State() )
       
  1823         {
       
  1824         case CMceSession::EIdle:
       
  1825             {
       
  1826             SVPDEBUG1( "CSVPSessionBase::State EIdle received" )
       
  1827             ccpState = MCCPCallObserver::ECCPStateIdle;
       
  1828             break;
       
  1829             }
       
  1830         case CMceSession::EOffering:
       
  1831             {
       
  1832             SVPDEBUG1( "CSVPSessionBase::State EOffering received" )
       
  1833             ccpState = MCCPCallObserver::ECCPStateConnecting;
       
  1834             break;
       
  1835             }
       
  1836         case CMceSession::EIncoming:
       
  1837             {
       
  1838             SVPDEBUG1( "CSVPSessionBase::State EIncoming received" )
       
  1839             ccpState = MCCPCallObserver::ECCPStateAnswering;
       
  1840             break;
       
  1841             }
       
  1842         case CMceSession::EReserving:
       
  1843             {
       
  1844             SVPDEBUG1( "CSVPSessionBase::State EReserving received" )
       
  1845             ccpState = MCCPCallObserver::ECCPStateConnecting;
       
  1846             break;
       
  1847             }
       
  1848         case CMceSession::EAnswering: 
       
  1849             {
       
  1850             SVPDEBUG1( "CSVPSessionBase::State EAnswering received" )
       
  1851             ccpState = MCCPCallObserver::ECCPStateAnswering;
       
  1852             break;
       
  1853             }
       
  1854         case CMceSession::EProceeding:
       
  1855             {
       
  1856             SVPDEBUG1( "CSVPSessionBase::State EProceeding received" )
       
  1857             ccpState = MCCPCallObserver::ECCPStateConnecting;
       
  1858             break;
       
  1859             }
       
  1860         case CMceSession::EEstablished:
       
  1861             {
       
  1862             SVPDEBUG1( "CSVPSessionBase::State EEstablished received" )
       
  1863             ccpState = MCCPCallObserver::ECCPStateConnected;
       
  1864             if( iHoldController && ESVPOnHold == iHoldController->HoldState() )
       
  1865                 {
       
  1866                 SVPDEBUG1( "    CSVPSessionBase::State Established and holded" )
       
  1867                 ccpState = MCCPCallObserver::ECCPStateHold;
       
  1868                 }
       
  1869             break;
       
  1870             }
       
  1871         case CMceSession::ECancelling:
       
  1872             {
       
  1873             SVPDEBUG1( "CSVPSessionBase::State ECancelling received" )
       
  1874             ccpState = MCCPCallObserver::ECCPStateIdle;  
       
  1875             break;
       
  1876             }
       
  1877         case CMceSession::ETerminating:
       
  1878             {
       
  1879             SVPDEBUG1( "CSVPSessionBase::State ETerminating received" )
       
  1880             ccpState = MCCPCallObserver::ECCPStateDisconnecting;
       
  1881             break;
       
  1882             }
       
  1883         case CMceSession::ETerminated:
       
  1884             {
       
  1885             SVPDEBUG1( "CSVPSessionBase::State ETerminated received" )
       
  1886             
       
  1887             if ( MCCPCallObserver::ECCPStateDisconnecting == iSessionState )
       
  1888                 {
       
  1889                 SVPDEBUG1( "CSVPSessionBase::State Saving state for termination timer" )
       
  1890                 ccpState = MCCPCallObserver::ECCPStateDisconnecting;
       
  1891                 }
       
  1892             else
       
  1893                 {
       
  1894                 ccpState = MCCPCallObserver::ECCPStateIdle;     
       
  1895                 }
       
  1896             
       
  1897             break;
       
  1898             }
       
  1899         default:
       
  1900             {
       
  1901             SVPDEBUG1( "CSVPSessionBase::State DEFAULT" )
       
  1902             // This block should never be reached.
       
  1903             __ASSERT_DEBUG( EFalse, User::Panic(
       
  1904                     KSVPName, KSVPPanicBadArgument ) );
       
  1905             break;
       
  1906             }
       
  1907         }
       
  1908     
       
  1909     SVPDEBUG2( "CSVPSessionBase::State Out return=%d", ccpState )
       
  1910     return ccpState;
       
  1911     }
       
  1912 
       
  1913 // ---------------------------------------------------------------------------
       
  1914 // CSVPSessionBase::GetKeepAliveTime
       
  1915 // ---------------------------------------------------------------------------
       
  1916 //    
       
  1917 TInt CSVPSessionBase::GetKeepAliveTime()
       
  1918     {
       
  1919     return iKeepAliveValue;
       
  1920     }
       
  1921 
       
  1922 // ---------------------------------------------------------------------------
       
  1923 // CSVPSessionBase::Type
       
  1924 // ---------------------------------------------------------------------------
       
  1925 //
       
  1926 TUid CSVPSessionBase::Uid() const
       
  1927     {
       
  1928     return KSVPImplementationUid;
       
  1929     }
       
  1930 
       
  1931 
       
  1932 // ---------------------------------------------------------------------------
       
  1933 // CSVPSessionBase::Conference
       
  1934 // ---------------------------------------------------------------------------
       
  1935 //
       
  1936 MCCPConferenceCall* CSVPSessionBase::ConferenceProviderL( 
       
  1937     const MCCPConferenceCallObserver& /*aObserver*/ )
       
  1938     {
       
  1939 	return NULL;    
       
  1940 	}
       
  1941 	
       
  1942 // ---------------------------------------------------------------------------
       
  1943 // CSVPSessionBase::IsSecured
       
  1944 // ---------------------------------------------------------------------------
       
  1945 //
       
  1946 TBool CSVPSessionBase::IsSecured() const
       
  1947     {
       
  1948 	SVPDEBUG2( "CSVPSessionBase::IsSecured: %d", iSecured )
       
  1949 	return iSecured;    
       
  1950 	}
       
  1951 
       
  1952 // ---------------------------------------------------------------------------
       
  1953 // CSVPSessionBase::IsMobileOriginated
       
  1954 // ---------------------------------------------------------------------------
       
  1955 //
       
  1956 TBool CSVPSessionBase::IsMobileOriginated() const
       
  1957     {
       
  1958 	SVPDEBUG1( "CSVPSessionBase::IsMobileOriginated" )
       
  1959 	return EFalse;    
       
  1960 	}
       
  1961 
       
  1962 // ---------------------------------------------------------------------------
       
  1963 // CSVPSessionBase::IsCallForwarded
       
  1964 // ---------------------------------------------------------------------------
       
  1965 //
       
  1966 TBool CSVPSessionBase::IsCallForwarded() const
       
  1967     {
       
  1968     return EFalse;
       
  1969     }
       
  1970 
       
  1971 // ---------------------------------------------------------------------------
       
  1972 // CSVPSessionBase::Swap
       
  1973 // ---------------------------------------------------------------------------
       
  1974 //
       
  1975 TInt CSVPSessionBase::Swap()
       
  1976     {
       
  1977     return KErrNotSupported;
       
  1978     }
       
  1979 
       
  1980 // ---------------------------------------------------------------------------
       
  1981 // CSVPSessionBase::Caps
       
  1982 // ---------------------------------------------------------------------------
       
  1983 // 
       
  1984 MCCPCallObserver::TCCPCallControlCaps CSVPSessionBase::Caps() const
       
  1985     {
       
  1986     SVPDEBUG1( "CSVPSessionBase::Caps return ECCPCapsPSCall" )
       
  1987     return MCCPCallObserver::ECCPCapsPSCall;
       
  1988     }
       
  1989 
       
  1990 // ---------------------------------------------------------------------------
       
  1991 // CSVPSessionBase::Release
       
  1992 // ---------------------------------------------------------------------------
       
  1993 //    
       
  1994 TInt CSVPSessionBase::Release()
       
  1995     {
       
  1996     return KErrNotSupported;
       
  1997     }
       
  1998 
       
  1999 // ---------------------------------------------------------------------------
       
  2000 // CSVPSessionBase::Dial
       
  2001 // ---------------------------------------------------------------------------
       
  2002 //
       
  2003 TInt CSVPSessionBase::Dial()
       
  2004     {
       
  2005     return KErrNotSupported;
       
  2006     }
       
  2007 
       
  2008 // ---------------------------------------------------------------------------
       
  2009 // CSVPSessionBase::Answer
       
  2010 // ---------------------------------------------------------------------------
       
  2011 //
       
  2012 TInt CSVPSessionBase::Answer()
       
  2013     {
       
  2014     return KErrNotSupported;
       
  2015     }
       
  2016 
       
  2017 // ---------------------------------------------------------------------------
       
  2018 // CSVPSessionBase::Cancel
       
  2019 // ---------------------------------------------------------------------------
       
  2020 //
       
  2021 TInt CSVPSessionBase::Cancel()
       
  2022     {
       
  2023     return KErrNotSupported;
       
  2024     }
       
  2025 
       
  2026 // ---------------------------------------------------------------------------
       
  2027 // CSVPSessionBase::Reject
       
  2028 // ---------------------------------------------------------------------------
       
  2029 // 
       
  2030 TInt CSVPSessionBase::Reject()
       
  2031     {
       
  2032     return KErrNotSupported;
       
  2033     }
       
  2034 
       
  2035 // ---------------------------------------------------------------------------
       
  2036 // CSVPSessionBase::Queue
       
  2037 // ---------------------------------------------------------------------------
       
  2038 // 
       
  2039 TInt CSVPSessionBase::Queue()
       
  2040     {
       
  2041     return KErrNotSupported;
       
  2042     }
       
  2043 
       
  2044 // ---------------------------------------------------------------------------
       
  2045 // CSVPSessionBase::Ringing
       
  2046 // ---------------------------------------------------------------------------
       
  2047 // 
       
  2048 TInt CSVPSessionBase::Ringing()
       
  2049     {
       
  2050     return KErrNotSupported;  
       
  2051     }
       
  2052    
       
  2053 // ---------------------------------------------------------------------------
       
  2054 // CSVPSessionBase::TransferProvider
       
  2055 // ---------------------------------------------------------------------------
       
  2056 //
       
  2057 MCCPTransferProvider* CSVPSessionBase::TransferProviderL(
       
  2058      const MCCPTransferObserver& aObserver )
       
  2059     {
       
  2060     SVPDEBUG1( "CSVPSessionBase::TransferProviderL In" )
       
  2061     
       
  2062     if ( !iTransferController )
       
  2063         {
       
  2064         iTransferController = CSVPTransferController::NewL( 
       
  2065                                                         iSession,
       
  2066                                                         this,
       
  2067                                                         iContainer, 
       
  2068                                                         *this );
       
  2069         iTransferController->AddObserverL( aObserver );
       
  2070         }
       
  2071     
       
  2072     SVPDEBUG1( "CSVPSessionBase::TransferProviderL Out" )
       
  2073     return iTransferController;
       
  2074 	}
       
  2075 
       
  2076 // ---------------------------------------------------------------------------
       
  2077 // CSVPSessionBase::ForwardProviderL
       
  2078 // ---------------------------------------------------------------------------
       
  2079 //
       
  2080 MCCPForwardProvider* CSVPSessionBase::ForwardProviderL(
       
  2081      const MCCPForwardObserver& /*aObserver*/ )
       
  2082     {
       
  2083     return NULL;
       
  2084     }
       
  2085 
       
  2086 
       
  2087 // transfer observer
       
  2088 
       
  2089 // ---------------------------------------------------------------------------
       
  2090 // From MSVPTransferObserver
       
  2091 // Notifier for succesful transfer.
       
  2092 // ---------------------------------------------------------------------------
       
  2093 // 
       
  2094 void CSVPSessionBase::TransferNotification( TInt aNotifyCode )
       
  2095     {
       
  2096     SVPDEBUG2( "CSVPSessionBase::TransferNotification In, aNotifyCode: %d",
       
  2097         aNotifyCode );
       
  2098     
       
  2099     if ( ESVPTransferOKHangUp == aNotifyCode )
       
  2100         {
       
  2101         SVPDEBUG1( "CSVPSessionBase::TransferNotification: ESVPTransferOKHangUp" )
       
  2102         // Transfer complete - hang up current session.
       
  2103         HangUp();
       
  2104         }
       
  2105     else if ( ESVPTransferDecline == aNotifyCode )
       
  2106         {
       
  2107         SVPDEBUG1( "CSVPSessionBase::TransferNotification: ESVPTransferDecline" )
       
  2108         // Inform application - transfer was rejected by the other party,
       
  2109         // not a failure, to be precise
       
  2110         ExecCbErrorOccurred( ECCPTransferFailed );
       
  2111         }
       
  2112     else if ( ESVPIncomingRefer == aNotifyCode )
       
  2113         {
       
  2114         SVPDEBUG1( "CSVPSessionBase::TransferNotification: ESVPIncomingRefer" )
       
  2115         // Currently no CallEventOccurred notify to the observer
       
  2116         }
       
  2117     else
       
  2118         {
       
  2119         // Internal transfer error if comes here
       
  2120         SVPDEBUG1( "CSVPSessionBase::TransferNotification: Unknown notify" )
       
  2121         }
       
  2122     
       
  2123     SVPDEBUG1( "CSVPSessionBase::TransferNotification Out" )
       
  2124     }
       
  2125 
       
  2126 // ---------------------------------------------------------------------------
       
  2127 // From MSVPTransferObserver
       
  2128 // Notifier for transfer failure.
       
  2129 // ---------------------------------------------------------------------------
       
  2130 //
       
  2131 #ifdef _DEBUG
       
  2132 void CSVPSessionBase::TransferFailed( TInt aError )
       
  2133 #else
       
  2134 void CSVPSessionBase::TransferFailed( TInt /*aError*/ )
       
  2135 #endif  // _DEBUG
       
  2136     {
       
  2137     SVPDEBUG1( "CSVPSessionBase::TransferFailed In" )
       
  2138     SVPDEBUG2(" CSVPSessionBase::TransferFailed aError=%d", aError )
       
  2139     
       
  2140     // Inform application about the error
       
  2141     ExecCbErrorOccurred( ECCPTransferFailed );
       
  2142     
       
  2143     SVPDEBUG1( "CSVPSessionBase::TransferFailed Out" )
       
  2144     }
       
  2145 
       
  2146 //  from CCP DTMF provider
       
  2147 // ---------------------------------------------------------------------------
       
  2148 // CSVPSessionBase::CancelDtmfStringSending
       
  2149 // ---------------------------------------------------------------------------
       
  2150 // 
       
  2151 TInt CSVPSessionBase::CancelDtmfStringSending()
       
  2152     {
       
  2153     SVPDEBUG1( "CSVPSessionBase::CancelDtmfStringSending In" )
       
  2154     
       
  2155     TInt dtmfErr( KErrNone );
       
  2156     
       
  2157     if ( !iSVPUtility.GetDTMFMode() ) 
       
  2158         {
       
  2159         dtmfErr = KErrNotFound;
       
  2160         if ( iEventGenerator )
       
  2161             {
       
  2162             iEventGenerator->StopEvents();
       
  2163             dtmfErr = KErrNone;
       
  2164             }
       
  2165         }
       
  2166     else 
       
  2167         {
       
  2168         const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
  2169         TInt count = streams.Count();
       
  2170         while( count )
       
  2171             {
       
  2172             count--;
       
  2173             CMceMediaStream& mediaStream = *streams[ count ];
       
  2174             if ( SVPAudioUtility::DtmfActionCapableStream( mediaStream ) )
       
  2175                 {
       
  2176                 TRAP( dtmfErr, mediaStream.Source()->CancelDtmfToneSequenceL() );
       
  2177                 }
       
  2178             else
       
  2179                 {
       
  2180                 dtmfErr = KErrNotSupported;
       
  2181                 }
       
  2182             
       
  2183             if ( KErrNone != dtmfErr )
       
  2184                 {
       
  2185                 return dtmfErr;
       
  2186                 }
       
  2187             }
       
  2188         }
       
  2189     
       
  2190     SVPDEBUG2( "CSVPSessionBase::CancelDtmfStringSending Out return=%d", dtmfErr )
       
  2191     return dtmfErr;
       
  2192     }
       
  2193 
       
  2194 // ---------------------------------------------------------------------------
       
  2195 // CSVPSessionBase::StartDtmfTone
       
  2196 // ---------------------------------------------------------------------------
       
  2197 //
       
  2198 TInt CSVPSessionBase::StartDtmfTone( const TChar aTone )
       
  2199     {
       
  2200     SVPDEBUG1( "CSVPSessionBase::StartDtmfTone In" )
       
  2201     
       
  2202     TInt dtmfErr( KErrNone );
       
  2203     
       
  2204     if ( iSVPUtility.GetDTMFMode() )
       
  2205         {
       
  2206         SVPDEBUG1( "CSVPSessionBase::StartDtmfTone DTMF Outband" )
       
  2207         // fetch streams
       
  2208         const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
  2209         TInt count = streams.Count();
       
  2210         while ( count )
       
  2211             {
       
  2212             count--;
       
  2213             CMceMediaStream& mediaStream = *streams[ count ];
       
  2214             if ( SVPAudioUtility::DtmfActionCapableStream( mediaStream ) )
       
  2215                 {
       
  2216                 TRAP( dtmfErr, mediaStream.Source()->StartDtmfToneL( aTone ) );
       
  2217                 }
       
  2218             else
       
  2219                 {
       
  2220                 dtmfErr = KErrNotSupported;
       
  2221                 }
       
  2222             
       
  2223             if ( KErrNone != dtmfErr )
       
  2224                 {
       
  2225                 SVPDEBUG2( "CSVPSessionBase::StartDtmfToneL dtmfErr: %d",
       
  2226                     dtmfErr )
       
  2227                 
       
  2228                 return dtmfErr;
       
  2229                 }
       
  2230             }
       
  2231         }
       
  2232     else
       
  2233         {
       
  2234         SVPDEBUG1( "CSVPSessionBase::StartDtmfTone DTMF Inband" )
       
  2235         iDtmfTone = aTone;
       
  2236         DtmfObserver().HandleDTMFEvent( MCCPDTMFObserver::ECCPDtmfManualStart, 
       
  2237                                         KErrNone, 
       
  2238                                         aTone );
       
  2239         }
       
  2240     
       
  2241     SVPDEBUG2( "CSVPSessionBase::StartDtmfTone Out return=%d", dtmfErr )
       
  2242     return dtmfErr;
       
  2243     }
       
  2244 
       
  2245 // ---------------------------------------------------------------------------
       
  2246 // CSVPSessionBase::StopDtmfTone
       
  2247 // ---------------------------------------------------------------------------
       
  2248 //
       
  2249 TInt CSVPSessionBase::StopDtmfTone()
       
  2250     {
       
  2251     SVPDEBUG1( "CSVPSessionBase::StopDtmfTone In" )
       
  2252     
       
  2253     TInt dtmfErr( KErrNone );
       
  2254     
       
  2255     if ( iSVPUtility.GetDTMFMode() )
       
  2256         {
       
  2257         const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
  2258         TInt count = streams.Count();
       
  2259         while( count )
       
  2260             {
       
  2261             count--;
       
  2262             CMceMediaStream& mediaStream = *streams[ count ];
       
  2263             if ( SVPAudioUtility::DtmfActionCapableStream( mediaStream ) )
       
  2264                 {
       
  2265                 TRAP( dtmfErr, mediaStream.Source()->StopDtmfToneL() );
       
  2266                 }
       
  2267             // NOP with inband.
       
  2268             
       
  2269             if ( KErrNone != dtmfErr )
       
  2270                 {
       
  2271                 SVPDEBUG2( "CSVPSessionBase::StopDtmfTone dtmfErr: %d",
       
  2272                     dtmfErr )
       
  2273                 
       
  2274                 return dtmfErr;
       
  2275                 }
       
  2276             }
       
  2277         }
       
  2278     else
       
  2279         {
       
  2280         DtmfObserver().HandleDTMFEvent( MCCPDTMFObserver::ECCPDtmfManualStop, 
       
  2281                                         KErrNone, 
       
  2282                                         iDtmfTone );
       
  2283         }
       
  2284 
       
  2285     SVPDEBUG2( "CSVPSessionBase::StopDtmfTone Out return=%d", dtmfErr )
       
  2286     return dtmfErr;
       
  2287     }
       
  2288 
       
  2289 // ---------------------------------------------------------------------------
       
  2290 // CSVPSessionBase::SendDtmfToneString
       
  2291 // ---------------------------------------------------------------------------
       
  2292 //
       
  2293 TInt CSVPSessionBase::SendDtmfToneString( const TDesC& aString )
       
  2294     {
       
  2295     SVPDEBUG1( "CSVPSessionBase::SendDtmfToneString In" )
       
  2296     
       
  2297     TInt dtmfErr( KErrNone );
       
  2298     TChar dtmfPause('p');
       
  2299     // MCE calls if outband DTMF.
       
  2300     // Exception is pause character 'p' which is handled always locally
       
  2301     if ( !iSVPUtility.GetDTMFMode() ||
       
  2302          ( aString.Length() == 1 &&
       
  2303            dtmfPause == aString[0] ) ) 
       
  2304         {
       
  2305         SVPDEBUG1( "CSVPSessionBase::SendDtmfToneString Inband" )
       
  2306         
       
  2307         delete iDtmfString;
       
  2308         iDtmfString = NULL;
       
  2309         TRAP( dtmfErr, iDtmfString = HBufC::NewL( aString.Length() ) );
       
  2310         if ( KErrNone != dtmfErr )
       
  2311             {
       
  2312             return dtmfErr;
       
  2313             }
       
  2314                 
       
  2315         *iDtmfString = aString;
       
  2316         iDtmfLex.Assign( *iDtmfString );
       
  2317         
       
  2318         if ( !iEventGenerator )
       
  2319             {
       
  2320             TRAP( dtmfErr,
       
  2321             iEventGenerator = CSVPDTMFEventGenerator::NewL( *this ) );
       
  2322             }
       
  2323         
       
  2324         if ( KErrNone != dtmfErr )
       
  2325             {
       
  2326             SVPDEBUG2( "CSVPSessionBase::SendDtmfToneString IB dtmfErr: %d",
       
  2327                 dtmfErr )
       
  2328             
       
  2329             return dtmfErr;
       
  2330             }
       
  2331         
       
  2332         // Dtmf pause length is 2500ms
       
  2333         TBool pauseChar = ( aString.Length() == 1 && 
       
  2334                             dtmfPause == aString[0] ); 
       
  2335         // start events
       
  2336         iEventGenerator->StartDtmfEvents( aString.Length(), pauseChar );
       
  2337         }
       
  2338     else
       
  2339         {
       
  2340         SVPDEBUG1( "CSVPSessionBase::SendDtmfToneString Outband" )
       
  2341         
       
  2342         const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
  2343         TInt count = streams.Count();
       
  2344         while( count )
       
  2345             {
       
  2346             count--;
       
  2347             CMceMediaStream& mediaStream = *streams[ count ];
       
  2348             
       
  2349             if ( SVPAudioUtility::DtmfActionCapableStream( mediaStream ) )
       
  2350                 {
       
  2351                 TRAP( dtmfErr,
       
  2352                     mediaStream.Source()->SendDtmfToneSequenceL( aString ) );
       
  2353                 }
       
  2354             else
       
  2355                 {
       
  2356                 dtmfErr = KErrNotSupported;
       
  2357                 }
       
  2358             
       
  2359             if ( KErrNone != dtmfErr )
       
  2360                 {
       
  2361                 SVPDEBUG2( "CSVPSessionBase::SendDtmfToneString Out OB dtmfErr: %d", dtmfErr )
       
  2362                 return dtmfErr;
       
  2363                 }
       
  2364             }
       
  2365         }
       
  2366     
       
  2367     SVPDEBUG2( "CSVPSessionBase::SendDtmfToneString Out return=%d", dtmfErr )
       
  2368     return dtmfErr;
       
  2369     }
       
  2370 
       
  2371 
       
  2372 // from MSVPPropertyWatchObserver
       
  2373 // ---------------------------------------------------------------------------
       
  2374 // CSVPSessionBase::ValueChangedL
       
  2375 // ---------------------------------------------------------------------------
       
  2376 //
       
  2377 void CSVPSessionBase::ValueChangedL( TInt aKey, TInt aValue )
       
  2378     {
       
  2379     SVPDEBUG3("CSVPSessionBase::ValueChangedL In aKey: %d, aValue: %d ", aKey, aValue )
       
  2380 
       
  2381     // fetch streams from session
       
  2382     const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
  2383 
       
  2384     switch ( aKey )
       
  2385         {
       
  2386         case KTelMicrophoneMuteState:
       
  2387             {
       
  2388             PerformMuteChangeL( streams, aValue );
       
  2389             break;
       
  2390             }
       
  2391         default:
       
  2392             {
       
  2393             SVPDEBUG1( "CSVPSessionBase::ValueChangedL DEFAULT - NOP" )
       
  2394             break;
       
  2395             }
       
  2396         }
       
  2397     
       
  2398     SVPDEBUG1( "CSVPSessionBase::ValueChangedL Out" )
       
  2399     }
       
  2400 
       
  2401 // ---------------------------------------------------------------------------
       
  2402 // CSVPSessionBase::PerformMuteChangeL
       
  2403 // ---------------------------------------------------------------------------
       
  2404 //
       
  2405 void CSVPSessionBase::PerformMuteChangeL(
       
  2406         const RPointerArray<CMceMediaStream>& aStreams, TInt aValue )
       
  2407     {
       
  2408     SVPDEBUG1( "CSVPSessionBase::PerformMuteChangeL In" )
       
  2409     
       
  2410     if ( CMceSession::EOffering == iSession->State() ||
       
  2411          iHoldController && ESVPOnHold == iHoldController->HoldState() )
       
  2412         {
       
  2413 		// call is ringing or on hold, we don't perform mute or unmute
       
  2414         SVPDEBUG1( "CSVPSessionBase::PerformMuteChangeL, no need for mute nor unmute" )
       
  2415         }
       
  2416     else
       
  2417         {
       
  2418         for ( TInt i = 0; i < aStreams.Count(); i++ )
       
  2419             {
       
  2420             if ( IsMobileOriginated() )
       
  2421                 {
       
  2422                 if ( aStreams[ i ]->Source() )
       
  2423                     {
       
  2424                     if ( EPSTelMicMuteOn == aValue )
       
  2425                         {
       
  2426                         // mute mic source
       
  2427                         SVPAudioUtility::DisableMicSourceL(
       
  2428                                 *( aStreams[ i ]->Source() ) );
       
  2429                         }
       
  2430                     else
       
  2431                         {
       
  2432                         // un-mute mic source            
       
  2433                         SVPAudioUtility::EnableMicSourceL(
       
  2434                                 *( aStreams[ i ]->Source() ) );
       
  2435                         }
       
  2436                     }
       
  2437                 }
       
  2438             else
       
  2439                 {
       
  2440                 if( CMceSession::EEstablished == iSession->State() )
       
  2441                     {
       
  2442                     if ( EPSTelMicMuteOn == aValue )
       
  2443                         {
       
  2444                         // mute mic source
       
  2445                         SVPAudioUtility::DisableMicSourceL(
       
  2446                                 *( aStreams[ i ]->BoundStreamL().Source() ) );
       
  2447                         }
       
  2448                     else
       
  2449                         {
       
  2450                         // un-mute mic source            
       
  2451                         SVPAudioUtility::EnableMicSourceL(
       
  2452                                 *( aStreams[ i ]->BoundStreamL().Source() ) );
       
  2453                         }
       
  2454                     }
       
  2455                 }
       
  2456             }
       
  2457         
       
  2458         if ( EPSTelMicMuteOff == aValue )
       
  2459             {
       
  2460             SVPDEBUG1( "CSVPSessionBase::PerformMuteChangeL - Enable Speaker" )
       
  2461             SVPAudioUtility::EnableSpeakerSinksL( aStreams );
       
  2462             }
       
  2463         }
       
  2464 
       
  2465     if ( EPSTelMicMuteOn == aValue ) { iMuted = ETrue; }
       
  2466     if ( EPSTelMicMuteOff == aValue ) { iMuted = EFalse; }
       
  2467 
       
  2468     if ( iHoldController )
       
  2469         {
       
  2470         SVPDEBUG1( "CSVPSessionBase::PerformMuteChangeL - update mute status" )
       
  2471         iHoldController->Muted( iMuted );
       
  2472         }
       
  2473 
       
  2474     SVPDEBUG1( "CSVPSessionBase::PerformMuteChangeL Out" )    
       
  2475     }
       
  2476 
       
  2477 // ---------------------------------------------------------------------------
       
  2478 // CSVPSessionBase::PropertyDeleted
       
  2479 // ---------------------------------------------------------------------------
       
  2480 //
       
  2481 #ifdef _DEBUG
       
  2482 void CSVPSessionBase::PropertyDeleted( TInt aKey )
       
  2483 #else
       
  2484 void CSVPSessionBase::PropertyDeleted( TInt /*aKey*/ )
       
  2485 #endif // __DEBUG
       
  2486     {
       
  2487     SVPDEBUG2("CSVPSessionBase::PropertyDeleted aKey=%d", aKey )
       
  2488     }
       
  2489 
       
  2490 
       
  2491 // from MSVPVolumeUpdateObserver    
       
  2492 // ---------------------------------------------------------------------------
       
  2493 // CSVPSessionBase::VolumeChanged
       
  2494 // ---------------------------------------------------------------------------
       
  2495 //  
       
  2496 void CSVPSessionBase::VolumeChanged( TInt aVolume )
       
  2497     {
       
  2498 #ifdef _DEBUG
       
  2499     TRAPD( volErr, VolumeChangedL( aVolume ) );
       
  2500     SVPDEBUG2("CSVPSessionBase::VolumeChanged volErr=%d", volErr )
       
  2501 #else
       
  2502     TRAP_IGNORE( VolumeChangedL( aVolume ) )
       
  2503 #endif // _DEBUG
       
  2504     }
       
  2505 
       
  2506 // ---------------------------------------------------------------------------
       
  2507 // CSVPSessionBase::VolumeChangedL
       
  2508 // ---------------------------------------------------------------------------
       
  2509 // 
       
  2510 void CSVPSessionBase::VolumeChangedL( TInt aVolume )
       
  2511     {
       
  2512     SVPDEBUG1( "CSVPSessionBase::VolumeChangedL In" )
       
  2513     
       
  2514     // fetch streams from session
       
  2515     const RPointerArray<CMceMediaStream>& stream = iSession->Streams();
       
  2516     
       
  2517     for ( TInt i = 0; i < stream.Count(); i++ )
       
  2518         {
       
  2519         // fetch mediastreams for handling
       
  2520         CMceMediaStream* mediaStream = stream[ i ];
       
  2521         CMceMediaStream& boundStream = mediaStream->BoundStreamL();
       
  2522         
       
  2523         // fetch sinks from current stream
       
  2524         const RPointerArray<CMceMediaSink>& sinks = mediaStream->Sinks();
       
  2525         
       
  2526         for ( TInt y = 0; y < sinks.Count(); y++ )
       
  2527             {
       
  2528             // find speaker sink
       
  2529             if ( KMceSpeakerSink == sinks[ y ]->Type() )
       
  2530                 {
       
  2531                 SVPDEBUG1( "CSVPSessionBase::VolumeChangedL Speaker found(A)" )
       
  2532                 CMceSpeakerSink* speakerSink =
       
  2533                         static_cast<CMceSpeakerSink*>( sinks[ y ] );
       
  2534                 // get sink max volume and adjust setVol accordingly
       
  2535                 TInt maxVol = speakerSink->MaxVolumeL();
       
  2536                 TInt setVol = maxVol * aVolume / KMaxPhoneVolume;
       
  2537 
       
  2538                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL maxVol=%d", maxVol )
       
  2539                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL aVolume=%d", aVolume )
       
  2540                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL setVol=%d", setVol )
       
  2541 
       
  2542                 speakerSink->SetVolumeL( setVol );
       
  2543                 }
       
  2544             } 
       
  2545         
       
  2546         const RPointerArray<CMceMediaSink>& boundSinks = boundStream.Sinks();
       
  2547         
       
  2548         for ( TInt z = 0; z < boundSinks.Count(); z++ )
       
  2549             {
       
  2550             // find speaker sink from bound stream
       
  2551             if ( KMceSpeakerSink == boundSinks[ z ]->Type() )
       
  2552                 {
       
  2553                 SVPDEBUG1( "CSVPSessionBase::VolumeChangedL Speaker found(B)" )
       
  2554                 
       
  2555                 CMceSpeakerSink* speakerSink =
       
  2556                         static_cast<CMceSpeakerSink*>( boundSinks[ z ] );
       
  2557                 // get sink max volume and adjust setVol accordingly
       
  2558                 TInt maxVol = speakerSink->MaxVolumeL();
       
  2559                 TInt setVol = maxVol * aVolume / KMaxPhoneVolume;
       
  2560                 
       
  2561                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL maxVol=%d", maxVol )
       
  2562                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL aVolume=%d", aVolume )
       
  2563                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL setVol=%d", setVol )
       
  2564 
       
  2565                 speakerSink->SetVolumeL( setVol );
       
  2566                 }
       
  2567             }
       
  2568         }
       
  2569     
       
  2570     SVPDEBUG1( "CSVPSessionBase::VolumeChangedL Out" )
       
  2571     }
       
  2572 
       
  2573 // ---------------------------------------------------------------------------
       
  2574 // CSVPSessionBase::SecureMandatory
       
  2575 // ---------------------------------------------------------------------------
       
  2576 // 
       
  2577 TBool CSVPSessionBase::SecureMandatory() const
       
  2578     {
       
  2579     SVPDEBUG2( "CSVPSessionBase::SecureMandatory=%d", iSecureMandatory )
       
  2580     return iSecureMandatory;
       
  2581     }
       
  2582 
       
  2583 // ---------------------------------------------------------------------------
       
  2584 // CSVPSessionBase::SecurePreferred
       
  2585 // ---------------------------------------------------------------------------
       
  2586 // 
       
  2587 TBool CSVPSessionBase::SecurePreferred() const
       
  2588     {
       
  2589     SVPDEBUG2( "CSVPSessionBase::SecurePreferred=%d", iSecurePreferred )
       
  2590     return iSecurePreferred;
       
  2591     }
       
  2592 
       
  2593 // ---------------------------------------------------------------------------
       
  2594 // CSVPSessionBase::SetSecureMandatory
       
  2595 // ---------------------------------------------------------------------------
       
  2596 // 
       
  2597 void CSVPSessionBase::SetSecureMandatory( TBool aSecMandatory )
       
  2598     {
       
  2599     iSecureMandatory = aSecMandatory;
       
  2600     }
       
  2601 
       
  2602 // ---------------------------------------------------------------------------
       
  2603 // CSVPSessionBase::SetSecurePreferred
       
  2604 // ---------------------------------------------------------------------------
       
  2605 // 
       
  2606 void CSVPSessionBase::SetSecurePreferred( TBool aSecPreferred )
       
  2607     {
       
  2608     iSecurePreferred = aSecPreferred;
       
  2609     }
       
  2610 
       
  2611 // ---------------------------------------------------------------------------
       
  2612 // CSVPSessionBase::SetCallEventToBeSent
       
  2613 // ---------------------------------------------------------------------------
       
  2614 // 
       
  2615 void CSVPSessionBase::SetCallEventToBeSent( MCCPCallObserver::TCCPCallEvent aCallEventToBeSent )
       
  2616     {
       
  2617     SVPDEBUG1( "CSVPSessionBase::SetCallEventToBeSent" )
       
  2618     iCallEventToBeSent = aCallEventToBeSent;
       
  2619     }
       
  2620 
       
  2621 // ---------------------------------------------------------------------------
       
  2622 // CSVPSessionBase::SetParameters
       
  2623 // ---------------------------------------------------------------------------
       
  2624 // 
       
  2625 void CSVPSessionBase::SetParameters( 
       
  2626     const CCCPCallParameters& /*aNewParams*/ )
       
  2627     {
       
  2628     SVPDEBUG1( "CSVPSessionBase::SetParameters - NOP" )
       
  2629     }
       
  2630 
       
  2631 // ---------------------------------------------------------------------------
       
  2632 // CSVPSessionBase::Parameters
       
  2633 // ---------------------------------------------------------------------------
       
  2634 // 
       
  2635 const CCCPCallParameters& CSVPSessionBase::Parameters() const
       
  2636     {
       
  2637     SVPDEBUG1( "CSVPSessionBase::Parameters In" )
       
  2638     return *iCallParameters;
       
  2639     }
       
  2640 
       
  2641 // ---------------------------------------------------------------------------
       
  2642 // CSVPSessionBase::Tone
       
  2643 // ---------------------------------------------------------------------------
       
  2644 //    
       
  2645 TCCPTone CSVPSessionBase::Tone() const
       
  2646     {
       
  2647     SVPDEBUG2( "CSVPSessionBase::Tone iTone: %d", iTone )
       
  2648     return iTone;
       
  2649     }
       
  2650     
       
  2651 // ---------------------------------------------------------------------------
       
  2652 // CSVPSessionBase::SetCryptoContextL
       
  2653 // ---------------------------------------------------------------------------
       
  2654 //
       
  2655 void CSVPSessionBase::SetCryptoContextL()
       
  2656     {
       
  2657     SVPDEBUG1( "CSVPSessionBase::SetCryptoContextL In" )
       
  2658     
       
  2659     if ( KMceSessionSecure == iSession->Type() )
       
  2660         {
       
  2661         // get supported crypto contexts
       
  2662         if ( IsMobileOriginated() )
       
  2663             {
       
  2664             SVPDEBUG1( "CSVPSessionBase::SetCryptoContextL Secure Mo" )
       
  2665             
       
  2666             const RArray<TMceCryptoContext>& cryptoContext = 
       
  2667                 static_cast<CMceSecureOutSession*> ( iSession )->
       
  2668                 SupportedCryptoContextsL();
       
  2669             SVPDEBUG2( "CSVPSessionBase::SetCryptoContextL Supported crypto context count=%d",
       
  2670                     cryptoContext.Count() )
       
  2671             
       
  2672             // set crypto contexts to session
       
  2673             static_cast<CMceSecureOutSession*> ( iSession )->
       
  2674                 SetCryptoContextsL( cryptoContext );
       
  2675             }
       
  2676         else
       
  2677             {
       
  2678             SVPDEBUG1( "CSVPSessionBase::SetCryptoContextL Secure Mt" )
       
  2679             
       
  2680             const RArray<TMceCryptoContext>& cryptoContext = 
       
  2681             static_cast<CMceSecureInSession*> ( iSession )->
       
  2682                 SupportedCryptoContextsL();
       
  2683             SVPDEBUG2( "CSVPSessionBase::SetCryptoContextL Supported crypto context count=%d",
       
  2684                     cryptoContext.Count() )
       
  2685             
       
  2686             // set crypto contexts to session
       
  2687             static_cast<CMceSecureInSession*> ( iSession )->
       
  2688                 SetCryptoContextsL( cryptoContext );
       
  2689             }
       
  2690         }
       
  2691     
       
  2692     SVPDEBUG1( "CSVPSessionBase::SetCryptoContextL Out" )
       
  2693     }
       
  2694 
       
  2695 // ---------------------------------------------------------------------------
       
  2696 // CSVPSessionBase::CheckMmfPrioritiesForDtmfL
       
  2697 // ---------------------------------------------------------------------------
       
  2698 //
       
  2699 void CSVPSessionBase::CheckMmfPrioritiesForDtmfL(
       
  2700     const RPointerArray<CMceMediaStream>& aAudioStreams ) const
       
  2701     {
       
  2702     SVPDEBUG1( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL In" )
       
  2703     
       
  2704     RPointerArray<CMceMediaSource> micsToEnable;
       
  2705     CleanupClosePushL( micsToEnable );
       
  2706     const TInt streamCount( aAudioStreams.Count() );
       
  2707     
       
  2708     SVPDEBUG2("CSVPSessionBase::CheckMmfPrioritiesForDtmfL streamCount: %d",
       
  2709         streamCount )
       
  2710     
       
  2711     // First disable the mic before doing any priority updating.
       
  2712     for ( TInt s = 0; s < streamCount; s++ )
       
  2713         {
       
  2714         CMceMediaSource* mic = aAudioStreams[s]->Source();
       
  2715         
       
  2716         if ( mic && KMceMicSource == mic->Type() && mic->IsEnabled() )
       
  2717             {
       
  2718             SVPDEBUG1( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL disable mic 1" )
       
  2719             mic->DisableL();
       
  2720             micsToEnable.AppendL( mic );
       
  2721             }
       
  2722         
       
  2723         // At this point we must have a bound stream, otherwise the session
       
  2724         // would be a bit incomplete. Thus can and should leave here if bound
       
  2725         // stream is not found.
       
  2726         mic = NULL;
       
  2727         mic = aAudioStreams[s]->BoundStreamL().Source();
       
  2728         
       
  2729         if ( mic && KMceMicSource == mic->Type() && mic->IsEnabled() )
       
  2730             {
       
  2731             SVPDEBUG1( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL disable mic 2" )
       
  2732             mic->DisableL();
       
  2733             micsToEnable.AppendL( mic );
       
  2734             }
       
  2735         
       
  2736         mic = NULL;
       
  2737         }
       
  2738     
       
  2739     // Set the correct priority and preference values.
       
  2740     for ( TInt k = 0; k < streamCount; k++ )
       
  2741         {
       
  2742         // No need to check against BoundStream(), see comments above.
       
  2743         if ( KMceAudio == aAudioStreams[k]->Type() )
       
  2744             {
       
  2745             SVPDEBUG2( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL round: %d start", k )
       
  2746             CMceAudioStream* stream = static_cast<CMceAudioStream*>( aAudioStreams[k] );
       
  2747             
       
  2748             TBool dtmfMode = EFalse;
       
  2749             
       
  2750             if ( SVPAudioUtility::IsDownlinkStream( *stream ) )
       
  2751                 {
       
  2752                 dtmfMode = SVPAudioUtility::SetPriorityCodecValuesL( *stream,
       
  2753                     static_cast<CMceAudioStream&>( stream->BoundStreamL() ) );
       
  2754                 }
       
  2755             else
       
  2756                 {
       
  2757                 dtmfMode = SVPAudioUtility::SetPriorityCodecValuesL(
       
  2758                     static_cast<CMceAudioStream&>( stream->BoundStreamL() ),
       
  2759                         *stream );
       
  2760                 }
       
  2761             
       
  2762             iSVPUtility.SetDtmfMode( dtmfMode );
       
  2763             
       
  2764             SVPDEBUG2( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL round: %d done", k )
       
  2765             }
       
  2766         }
       
  2767     
       
  2768     // Priorities are now correct, so update the session.
       
  2769     iSession->UpdateL();
       
  2770     
       
  2771     // Now enable mics after we have correct priorities.
       
  2772     const TInt mics = micsToEnable.Count();
       
  2773     
       
  2774     for ( TInt t = 0; t < mics; t++ )
       
  2775         {
       
  2776         SVPDEBUG2( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL enabling mics, round: %d", t )
       
  2777         micsToEnable[t]->EnableL();
       
  2778         }
       
  2779     
       
  2780     // Mics not owned
       
  2781     CleanupStack::PopAndDestroy( &micsToEnable );
       
  2782     
       
  2783     SVPDEBUG1( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL Out" )
       
  2784     }
       
  2785 
       
  2786 // ---------------------------------------------------------------------------
       
  2787 // CSVPSessionBase::SessionStateChangedL
       
  2788 // ---------------------------------------------------------------------------
       
  2789 //
       
  2790 void CSVPSessionBase::SessionStateChangedL( TInt aOrigStatus,
       
  2791     TCCPError aError, TInt aModStatus )
       
  2792     {
       
  2793     SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL In" )
       
  2794     SVPDEBUG2( "CSVPSessionBase::SessionStateChangedL aOrigStatus=%d",
       
  2795         aOrigStatus )
       
  2796     SVPDEBUG2( "CSVPSessionBase::SessionStateChangedL aError=%d",
       
  2797         aError )
       
  2798     SVPDEBUG2( "CSVPSessionBase::SessionStateChangedL aModStatus=%d",
       
  2799         aModStatus )
       
  2800     
       
  2801     // secure status was "secure call mandatory", only secure allowed
       
  2802     if ( KErrNone != aModStatus && SecureMandatory() )
       
  2803         {
       
  2804         if ( KSVPNotAcceptableHereVal == aModStatus ||
       
  2805              KSVPNotAcceptableVal == aModStatus ||
       
  2806              KSVPPreconditionFailureVal == aModStatus ||
       
  2807              KSVPMethodNotAllowedVal == aModStatus )
       
  2808             {
       
  2809             SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - Secure session failed!" )
       
  2810             // secure call failed due to recipients restrictions
       
  2811             User::LeaveIfError( ExecCbErrorOccurred( ECCPSecureCallFailed ) );
       
  2812             }
       
  2813         else
       
  2814             {
       
  2815             // secure call failed with SIP error response
       
  2816             // inform application about the error response received
       
  2817             User::LeaveIfError( ExecCbErrorOccurred( aError ) );
       
  2818             
       
  2819             // start termination timer, needed for UI
       
  2820             // to handle Disconnected-bubble   
       
  2821             StartTimerL( KSVPTerminatingTime, KSVPTerminationTimerExpired );
       
  2822             User::LeaveIfError( ExecCbCallStateChanged( MCCPCallObserver::ECCPStateDisconnecting ) );
       
  2823             }
       
  2824         }
       
  2825    
       
  2826     if ( KSVPRingingVal == aOrigStatus )
       
  2827         {
       
  2828         SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - 180 ringing received" )
       
  2829         User::LeaveIfError( ExecCbCallStateChanged( MCCPCallObserver::ECCPStateConnecting ) );
       
  2830         if ( iEarlyMediaOngoing )
       
  2831             {
       
  2832             // early media event is sent again to avoid simultaneous early media and ringback tone
       
  2833             SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL ringing ja earlymedia flag on" )
       
  2834             ExecCbCallEventOccurred( MCCPCallObserver::ECCCSPEarlyMediaStarted );
       
  2835             iEarlyMediaOngoing = EFalse;
       
  2836             }
       
  2837         }
       
  2838     
       
  2839     if ( KSVPQueuedVal == aOrigStatus )
       
  2840         {
       
  2841         SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - 182 queued received" )
       
  2842         User::LeaveIfError( ExecCbSsEventOccurred( MCCPSsObserver::ESsCallWaiting ) );
       
  2843         }
       
  2844     
       
  2845     switch( iSession->State() )
       
  2846         {
       
  2847         case CMceSession::EEstablished:
       
  2848             {
       
  2849             // stop mt drop out timer or mo invite timer
       
  2850             StopTimers();
       
  2851             
       
  2852             // mute status must be checked again in Mt -> 
       
  2853             // there might be one call already in mute state        
       
  2854             TInt value( EPSTelMicMuteOff );
       
  2855             RProperty::Get( KPSUidTelMicrophoneMuteStatus, 
       
  2856                     KTelMicrophoneMuteState, value );
       
  2857             
       
  2858             // check initial mute status 
       
  2859             if ( EPSTelMicMuteOn == value )
       
  2860                 {
       
  2861                 SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL Mute: ON" )
       
  2862                 ValueChangedL( KTelMicrophoneMuteState, EPSTelMicMuteOn );
       
  2863                 }
       
  2864             // secure session created successfully, set iSecured flag to ETrue
       
  2865             if ( KMceSessionSecure == iSession->Type() && 
       
  2866                  CMceSession::EControlPathSecure == iSession->ControlPathSecurityLevel() )
       
  2867                 {
       
  2868                 SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - Secure session created" )
       
  2869                 iSecured = ETrue;
       
  2870                 }
       
  2871             else
       
  2872                 {
       
  2873                 SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - Non-secure session created" )
       
  2874                 iSecured = EFalse;
       
  2875                 if ( SecurePreferred() )
       
  2876                     {
       
  2877                     // Secure preferred but unsecure session created -> send info to ccp api
       
  2878                     SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - secure was preferred" )
       
  2879                     iCallEventToBeSent = MCCPCallObserver::ECCPNotSecureCall;
       
  2880                     }
       
  2881                 }
       
  2882             
       
  2883             // We need get the call state now because session state will
       
  2884             // change when doing CheckMmfPrioritiesForDtmfL because it updates
       
  2885             // the session. This leads into 'Offering' state which will
       
  2886             // panic our State() function call.
       
  2887             // Note: session's state will fall back to 'Established' because
       
  2888             // the priority update does not lead into a real update.
       
  2889             MCCPCallObserver::TCCPCallState callState = State();
       
  2890             
       
  2891             // We need to check MMF priorities only in MO case if really
       
  2892             // neccessary
       
  2893             if ( IsMobileOriginated() &&
       
  2894                  SVPAudioUtility::MmfPriorityUpdateNeededL( iSession->Streams() ) )
       
  2895                 {
       
  2896                 CheckMmfPrioritiesForDtmfL( iSession->Streams() );
       
  2897                 }
       
  2898             if ( IsMobileOriginated() )
       
  2899                 {
       
  2900                 TBool sessionUpdateOngoing = EFalse;
       
  2901                 UpdateKeepAliveL( *iSession, sessionUpdateOngoing );
       
  2902                 }
       
  2903             
       
  2904             // enable speaker sink
       
  2905             SVPAudioUtility::EnableSpeakerSinksL( iSession->Streams() );
       
  2906             // call state callback
       
  2907             User::LeaveIfError( ExecCbCallStateChanged( callState ) );
       
  2908             
       
  2909             // 'NotSecure' call event must be sent after the
       
  2910             // 'callstatechanged' - event, not before because phone needs an
       
  2911             // active call for playing the unsecure tone.
       
  2912             if ( MCCPCallObserver::ECCPSecureNotSpecified != iCallEventToBeSent )
       
  2913                 {
       
  2914                  if ( MCCPCallObserver::ECCPSecureCall == iCallEventToBeSent ||
       
  2915                      MCCPCallObserver::ECCPNotSecureCall == iCallEventToBeSent )
       
  2916                     {
       
  2917                     SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - sending secure specific call event" )
       
  2918                     User::LeaveIfError( ExecCbCallEventOccurred( iCallEventToBeSent ) );
       
  2919                     }
       
  2920                 SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - sending remotePartyInfoChanged event" )
       
  2921                 User::LeaveIfError( ExecCbCallEventOccurred( MCCPCallObserver::ECCPNotifyRemotePartyInfoChange ) );
       
  2922                 iCallEventToBeSent = MCCPCallObserver::ECCPSecureNotSpecified;
       
  2923                 }
       
  2924             break;
       
  2925             }
       
  2926         case CMceSession::EAnswering:
       
  2927         case CMceSession::EReserving:
       
  2928         case CMceSession::EIncoming:
       
  2929         case CMceSession::EOffering:
       
  2930             {
       
  2931             SVPDEBUG1( "CSVPSessionBase:SessionStateChangedL: No action" )
       
  2932             break;
       
  2933             }
       
  2934         case CMceSession::ECancelling:
       
  2935         case CMceSession::EIdle:
       
  2936         case CMceSession::ETerminating:
       
  2937         case CMceSession::EProceeding:
       
  2938             {
       
  2939             SVPDEBUG1( "CSVPSessionBase:SessionStateChangedL: Callback state change" )
       
  2940             User::LeaveIfError( ExecCbCallStateChanged( State() ) );
       
  2941             break;
       
  2942             }
       
  2943         case CMceSession::ETerminated:
       
  2944             {
       
  2945             SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL Terminated" )
       
  2946             
       
  2947             if ( MCCPCallObserver::ECCPStateDisconnecting != iSessionState &&
       
  2948                  MCCPCallObserver::ECCPStateIdle != iSessionState &&
       
  2949                  iCCPSessionObserver )
       
  2950                 {
       
  2951                 // probably some SIP error occurred, inform client
       
  2952                 if ( aOrigStatus < 0 )
       
  2953                 	{
       
  2954                     SVPDEBUG2( "CSVPSessionBase::SessionStateChangedL, aOrigStatus=%d", aOrigStatus )
       
  2955                     
       
  2956                     switch ( aOrigStatus )
       
  2957                         {
       
  2958                         case KErrSIPForbidden:
       
  2959                             {
       
  2960                             User::LeaveIfError( ExecCbErrorOccurred( ECCPErrorNoService ) );
       
  2961                             }
       
  2962                             break;
       
  2963                         default:
       
  2964                             {
       
  2965                             User::LeaveIfError( ExecCbErrorOccurred( ECCPGlobalFailure ) );
       
  2966                             }
       
  2967                             break;
       
  2968                         }
       
  2969                     }
       
  2970                 
       
  2971                 if ( KErrNone != aModStatus )
       
  2972                     {
       
  2973                     User::LeaveIfError( ExecCbErrorOccurred( aError ) );
       
  2974                     }
       
  2975                 
       
  2976                 iSessionState = MCCPCallObserver::ECCPStateDisconnecting;
       
  2977                 iTerminatingRepeat = 0;
       
  2978                 
       
  2979                 StartTimerL( KSVPTerminatingTime, KSVPTerminationTimerExpired );
       
  2980                 User::LeaveIfError( ExecCbCallStateChanged( State() ) );
       
  2981                 
       
  2982                 // Termination engaged by the remote end ->
       
  2983                 // Client is informed with ECCPRemoteTerminated event
       
  2984                 // This prevents automatic unhold when two calls, 
       
  2985                 // one on hold and one active, exist.
       
  2986                 if ( !iAlreadyTerminating )
       
  2987                     {
       
  2988                     User::LeaveIfError( ExecCbCallEventOccurred(
       
  2989                             MCCPCallObserver::ECCPRemoteTerminated ) );
       
  2990                     }
       
  2991                 }
       
  2992             else if ( iCCPSessionObserver )
       
  2993                 {
       
  2994                 User::LeaveIfError( ExecCbCallStateChanged(
       
  2995                         MCCPCallObserver::ECCPStateIdle ) );
       
  2996                 }
       
  2997             else
       
  2998                 {
       
  2999                 SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL Session creation failed in early stage - terminate" )
       
  3000                 iObserver.TerminateSession(  (CMceInSession&) Session() );
       
  3001                 }
       
  3002             break;
       
  3003             }
       
  3004         default:
       
  3005             {
       
  3006             SVPDEBUG1( "CSVPSessionBase:SessionStateChangedL DEFAULT" )
       
  3007             break;
       
  3008             }
       
  3009         }
       
  3010     
       
  3011     SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL Out" )
       
  3012     }
       
  3013 
       
  3014 // ---------------------------------------------------------------------------
       
  3015 // CSVPSessionBase::UpdateKeepAliveL
       
  3016 // ---------------------------------------------------------------------------
       
  3017 //
       
  3018 void CSVPSessionBase::UpdateKeepAliveL( CMceSession& aSession, 
       
  3019         TBool aSessionUpdateOngoing )
       
  3020     {
       
  3021     SVPDEBUG1( "CSVPSessionBase:UpdateKeepAliveL In" )
       
  3022     
       
  3023     // update keepalive -> mo and mt
       
  3024     SVPDEBUG1( "CSVPSessionBase::UpdateKeepAliveL Starting CN handling" )
       
  3025     
       
  3026     const RPointerArray<CMceMediaStream>& streamArray = aSession.Streams();
       
  3027     TInt streamCount( streamArray.Count() );
       
  3028     TBool cnInAnswer = EFalse;
       
  3029     
       
  3030     for ( TInt i = 0; i < streamCount; i++ )
       
  3031         {
       
  3032         CMceAudioStream* stream = static_cast<CMceAudioStream*>( streamArray[ i ] );
       
  3033         
       
  3034         if ( iSVPUtility.IsComfortNoise( *stream ) )
       
  3035             {
       
  3036             cnInAnswer = ETrue;
       
  3037             SVPDEBUG1( "CSVPSessionBase::UpdateKeepAliveL CN Found" )
       
  3038             iSVPUtility.SetCNKeepAliveL( *stream, iKeepAliveValue );
       
  3039             }
       
  3040         }
       
  3041     
       
  3042     if ( !cnInAnswer )
       
  3043         {
       
  3044         SVPDEBUG1( "CSVPSessionBase::UpdateKeepAliveL CN NOT Found" )
       
  3045         SVPDEBUG2( "CSVPSessionBase::SessionStateChangedL Streamcount: %d", streamCount )
       
  3046         
       
  3047         while( streamCount-- )
       
  3048             {
       
  3049             CMceAudioStream* stream = static_cast< CMceAudioStream* >( streamArray[ streamCount ] );
       
  3050             iSVPUtility.SetKeepAliveL( *stream, iKeepAliveValue );
       
  3051             }
       
  3052         }
       
  3053     
       
  3054     if ( !aSessionUpdateOngoing )
       
  3055         {
       
  3056         SVPDEBUG1( "CSVPSessionBase::UpdateKeepAliveL  -> UPDATE" )
       
  3057         aSession.UpdateL();
       
  3058         SVPDEBUG1( "CSVPSessionBase::UpdateKeepAliveL  -> UPDATE DONE" )
       
  3059         }
       
  3060     SVPDEBUG1("CSVPSessionBase:UpdateKeepAliveL Out")
       
  3061     }
       
  3062 
       
  3063 // ---------------------------------------------------------------------------
       
  3064 // CSVPSessionBase::UpdateFailed
       
  3065 // ---------------------------------------------------------------------------
       
  3066 //    
       
  3067 void CSVPSessionBase::UpdateFailed( CMceSession& aSession, TInt aStatusCode )
       
  3068     {
       
  3069     SVPDEBUG1( "CSVPSessionBase::UpdateFailed In" )
       
  3070     SVPDEBUG2( "CSVPSessionBase::UpdateFailed aStatusCode=%d", aStatusCode )
       
  3071     
       
  3072     if ( iHoldController )
       
  3073         {
       
  3074         iHoldController->RequestFailed( aSession, aStatusCode, *this );
       
  3075         }
       
  3076     
       
  3077     SVPDEBUG1( "CSVPSessionBase::UpdateFailed Out" )
       
  3078     }
       
  3079 
       
  3080 
       
  3081 // ---------------------------------------------------------------------------
       
  3082 // CSVPSessionBase::SetRtpKeepAliveL
       
  3083 // ---------------------------------------------------------------------------
       
  3084 //
       
  3085 void CSVPSessionBase::SetRtpKeepAliveL( CMceSession* /*aSession*/, 
       
  3086                                         TBool /*aSessionUpdateOngoing*/ )
       
  3087     {
       
  3088     SVPDEBUG1( "CSVPSessionBase::SetRtpKeepAliveL" )
       
  3089     }
       
  3090 
       
  3091 // ---------------------------------------------------------------------------
       
  3092 // CSVPSessionBase::SetUpdatedSession
       
  3093 // ---------------------------------------------------------------------------
       
  3094 //
       
  3095 void CSVPSessionBase::SetUpdatedSession( CMceInSession* aUpdatedSession )
       
  3096     {
       
  3097     SVPDEBUG1( "CSVPSessionBase::SetUpdatedSession In" )
       
  3098     
       
  3099     delete iSession;
       
  3100     iSession = aUpdatedSession;
       
  3101 
       
  3102     // Update changed session also to the transfercontroller
       
  3103     if ( iTransferController )
       
  3104         {
       
  3105         SVPDEBUG1( "CSVPSessionBase::SetUpdatedSession also to the transfercontroller" )
       
  3106         iTransferController->SetMceSessionObject( aUpdatedSession );
       
  3107         }
       
  3108 
       
  3109     SVPDEBUG1( "CSVPSessionBase::SetUpdatedSession Out" )
       
  3110     }
       
  3111 
       
  3112 // ---------------------------------------------------------------------------
       
  3113 // CSVPSessionBase::SetEmptyReInvite
       
  3114 // ---------------------------------------------------------------------------
       
  3115 //
       
  3116 void CSVPSessionBase::SetEmptyReInvite()
       
  3117     {
       
  3118     SVPDEBUG1( "CSVPSessionBase::SetEmptyReInvite In" )
       
  3119     iEmptyReInvite = ETrue;
       
  3120     }
       
  3121 
       
  3122 // ---------------------------------------------------------------------------
       
  3123 // CSVPSessionBase::IsEmptyReInvite
       
  3124 // ---------------------------------------------------------------------------
       
  3125 //
       
  3126 TBool CSVPSessionBase::IsEmptyReInvite()
       
  3127     {
       
  3128     SVPDEBUG1( "CSVPSessionBase::IsEmptyReInvite In" )
       
  3129     return iEmptyReInvite;
       
  3130     }
       
  3131 
       
  3132 // ---------------------------------------------------------------------------
       
  3133 // CSVPSessionBase::IsIdle
       
  3134 // ---------------------------------------------------------------------------
       
  3135 //
       
  3136 TBool CSVPSessionBase::IsIdle()
       
  3137     {
       
  3138     SVPDEBUG1( "CSVPSessionBase::IsIdle In" )
       
  3139     return ( MCCPCallObserver::ECCPStateIdle == iSessionState );
       
  3140     }
       
  3141 
       
  3142 // ---------------------------------------------------------------------------
       
  3143 // CSVPSessionBase::SecureSpecified
       
  3144 // ---------------------------------------------------------------------------
       
  3145 //
       
  3146 TBool CSVPSessionBase::SecureSpecified( ) const 
       
  3147    {
       
  3148    return ETrue;
       
  3149    }
       
  3150 
       
  3151 // ---------------------------------------------------------------------------
       
  3152 // CSVPSessionBase::SetErrorInULandDLFirstTime
       
  3153 // ---------------------------------------------------------------------------
       
  3154 //
       
  3155 void CSVPSessionBase::SetErrorInULandDLFirstTime( TBool aFirstTime )
       
  3156     {
       
  3157     iErrorInULandDLFirstTime = aFirstTime;
       
  3158     SVPDEBUG2("CSVPSessionBase::SetErrorInULandDLFirstTime=%d",iErrorInULandDLFirstTime)
       
  3159     }
       
  3160 
       
  3161 // ---------------------------------------------------------------------------
       
  3162 // CSVPSessionBase::IsErrorInULandDLFirstTime
       
  3163 // ---------------------------------------------------------------------------
       
  3164 //
       
  3165 TBool CSVPSessionBase::IsErrorInULandDLFirstTime()
       
  3166     {
       
  3167     SVPDEBUG2("CSVPSessionBase::IsErrorInULandDLFirstTime=%d",iErrorInULandDLFirstTime)
       
  3168     return iErrorInULandDLFirstTime;
       
  3169     }
       
  3170 
       
  3171 
       
  3172 // ---------------------------------------------------------------------------
       
  3173 // CSVPSessionBase::IsBothStreamsDisabledL
       
  3174 // ---------------------------------------------------------------------------
       
  3175 //
       
  3176 TBool CSVPSessionBase::IsBothStreamsDisabledL() const
       
  3177     {
       
  3178     SVPDEBUG1( "CSVPSessionBase::IsBothStreamsDisabledL() In" )
       
  3179     TBool bothStreamsDisabled = ETrue;
       
  3180     const RPointerArray<CMceMediaStream>& streams = Session().Streams();
       
  3181     TInt streamsCount = streams.Count();
       
  3182 
       
  3183     for ( TInt i = 0; i < streamsCount; i++ )
       
  3184         {
       
  3185         if( streams[ i ]->State() != CMceMediaStream::EDisabled || 
       
  3186             streams[ i ]->BoundStreamL().State() != CMceMediaStream::EDisabled )
       
  3187             {
       
  3188             bothStreamsDisabled = EFalse;
       
  3189             }
       
  3190         }
       
  3191 
       
  3192     SVPDEBUG2("CSVPSessionBase::IsBothStreamsDisabledL Out,ret=%d",bothStreamsDisabled)
       
  3193     return bothStreamsDisabled;
       
  3194     }
       
  3195 
       
  3196 // ---------------------------------------------------------------------------
       
  3197 // CSVPSessionBase::IsSessionMuted
       
  3198 // ---------------------------------------------------------------------------
       
  3199 //
       
  3200 TBool CSVPSessionBase::IsSessionMuted() const
       
  3201     {
       
  3202     SVPDEBUG2("CSVPSessionBase::IsSessionMuted: %d", iMuted )
       
  3203     return iMuted;
       
  3204     }
       
  3205