multimediacommsengine/mmcecli/src/mcemediasource.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "mcemediasource.h"
       
    22 #include "mcesession.h"
       
    23 #include "mcemanager.h"
       
    24 #include "mcestreamobserver.h"
       
    25 #include "mcecommediasource.h"
       
    26 #include "mceitcsender.h"
       
    27 #include "mcefactory.h"
       
    28 #include "mceevents.h"
       
    29 #include "mceclientserver.h"
       
    30 #include "mceserial.h"
       
    31 #include "mceaudiostream.h"
       
    32 #include "mceclilogs.h"
       
    33 #include "mcedtmfobserver.h"
       
    34 
       
    35 
       
    36 #define _FLAT_DATA static_cast<CMceComMediaSource*>( iFlatData )
       
    37 #define FLAT_DATA( data ) _FLAT_DATA->data
       
    38 
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CMceMediaSource::~CMceMediaSource
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 EXPORT_C CMceMediaSource::~CMceMediaSource()
       
    47     {
       
    48     delete iFlatData;
       
    49     iParents.Reset();
       
    50     iParents.Close();
       
    51     }
       
    52     
       
    53 // -----------------------------------------------------------------------------
       
    54 // CMceMediaSource::Type
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 EXPORT_C TMceSourceType CMceMediaSource::Type() const
       
    58     {
       
    59     return FLAT_DATA( Type() );
       
    60     }
       
    61     
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CMceMediaSource::IsEnabled
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 EXPORT_C TBool CMceMediaSource::IsEnabled() const
       
    68     {
       
    69     return FLAT_DATA( IsEnabled() );
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CMceMediaSource::DtmfAvailable
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 TBool CMceMediaSource::DtmfAvailable()
       
    77 	{
       
    78 	TBool rtpSourceExists( EFalse );
       
    79 	TBool rtpSinkExists( EFalse );
       
    80 	TBool dtmfCodecExists( EFalse );
       
    81 	
       
    82 	for ( TInt i = 0; i < iParents.Count() && 
       
    83 	      !( rtpSourceExists && rtpSinkExists && dtmfCodecExists ); i++ )
       
    84 	    {
       
    85 	    if ( iParents[ i ]->Type() == KMceAudio )
       
    86 	        {
       
    87 	        CMceAudioStream* audioStream = 
       
    88 	            static_cast<CMceAudioStream*>( iParents[ i ] );
       
    89 	            
       
    90 	        audioStream->FindDtmfRelatedComponents( rtpSourceExists, 
       
    91                 	                                rtpSinkExists, 
       
    92                 	                                dtmfCodecExists,
       
    93                 	                                audioStream->Binder() );
       
    94 	        }
       
    95 	    }
       
    96 	return ( rtpSourceExists && rtpSinkExists && dtmfCodecExists );	
       
    97 	}
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CMceMediaSource::DtmfActive
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 TBool CMceMediaSource::DtmfActive()
       
   104 	{
       
   105 	MCECLI_DEBUG( "CMceMediaSource::DtmfActive" )
       
   106 	
       
   107 	TBool dtmfActive( EFalse );
       
   108 	if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) )
       
   109         {
       
   110         CMceSession* session = iStream->Session();
       
   111          
       
   112     	TMceIds ids;
       
   113     	session->PrepareForITC( ids );
       
   114     	ids.iMediaID   = iStream->Id();
       
   115     	ids.iSourceID  = Id();
       
   116     	ids.iSpare1     = dtmfActive;
       
   117     	
       
   118         TRAP_IGNORE( session->ITCSender().SendL( ids, 
       
   119                         static_cast<TMceItcFunctions>( EMceItcIsDtmfActive ) ) );  
       
   120 
       
   121         dtmfActive = static_cast<TBool>( ids.iSpare1 );
       
   122         }
       
   123     
       
   124     MCECLI_DEBUG_DVALUE( "CMceMediaSource::DtmfActive, Exit, active:", 
       
   125                          dtmfActive )   
       
   126     return dtmfActive;		
       
   127 	}
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CMceMediaSource::StartDtmfToneL
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 void CMceMediaSource::StartDtmfToneL( const TChar& aTone )
       
   134 	{
       
   135 	MCECLI_DEBUG_DVALUE( "CMceMediaSource::StartDtmfToneL, tone (char as int):", 
       
   136 	                     static_cast<TInt>( aTone ) )  
       
   137 	
       
   138 	__ASSERT_ALWAYS( MCE_ENDPOINT_ITC_ALLOWED( *this ), 
       
   139 	                 User::Leave( KErrNotReady ) );	
       
   140      	                 
       
   141 	DoITCSendL( EMceItcStartDtmfTone, IsEnabled(), static_cast<TUint32>( aTone ) );
       
   142 	
       
   143 	MCECLI_DEBUG( "CMceMediaSource::StartDtmfToneL, Exit" )	
       
   144 	}
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CMceMediaSource::StopDtmfToneL
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void CMceMediaSource::StopDtmfToneL()           	
       
   151 	{
       
   152 	MCECLI_DEBUG( "CMceMediaSource::StopDtmfToneL" )
       
   153 	
       
   154 	__ASSERT_ALWAYS( MCE_ENDPOINT_ITC_ALLOWED( *this ), 
       
   155 	                 User::Leave( KErrNotReady ) );	
       
   156           
       
   157 	DoITCSendL( EMceItcStopDtmfTone, IsEnabled() );
       
   158 	
       
   159 	MCECLI_DEBUG( "CMceMediaSource::StopDtmfToneL, Exit" )
       
   160 	}
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CMceMediaSource::SendDtmfToneL
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 void CMceMediaSource::SendDtmfToneL( const TChar& aTone,
       
   167 	TTimeIntervalMicroSeconds32 aDuration )
       
   168 	{
       
   169 	MCECLI_DEBUG_DVALUE( "CMceMediaSource::SendDtmfToneL, tone (char as int):", 
       
   170 	                     static_cast<TInt>( aTone ) )  
       
   171 	MCECLI_DEBUG_DVALUE( "CMceMediaSource::SendDtmfToneL, duration (microsecs):", 
       
   172 	                     aDuration.Int() )  
       
   173 	
       
   174 	__ASSERT_ALWAYS( MCE_ENDPOINT_ITC_ALLOWED( *this ), 
       
   175 	                 User::Leave( KErrNotReady ) );	
       
   176 	
       
   177 	__ASSERT_ALWAYS( aDuration.Int() >= 0 && aDuration.Int() <= (TInt)KMaxTUint32, 
       
   178 	                 User::Leave( KErrArgument ) );  
       
   179 	                           
       
   180     DoITCSendL( EMceItcSendDtmfTone, 
       
   181                 IsEnabled(), 
       
   182                 static_cast<TUint32>( aTone ), 
       
   183                 static_cast<TUint32>( aDuration.Int() ) );
       
   184                 
       
   185     MCECLI_DEBUG( "CMceMediaSource::SendDtmfToneL, Exit" )
       
   186 	}
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CMceMediaSource::SendDtmfToneSequenceL
       
   190 // -----------------------------------------------------------------------------
       
   191 //
       
   192 void CMceMediaSource::SendDtmfToneSequenceL( const TDesC& aSequence )
       
   193 	{
       
   194 	MCECLI_DEBUG_SVALUE( "CMceMediaSource::SendDtmfToneSequenceL, sequence:", 
       
   195 	                     aSequence )  
       
   196 	                     
       
   197     __ASSERT_ALWAYS( MCE_ENDPOINT_ITC_ALLOWED( *this ), 
       
   198 	                 User::Leave( KErrNotReady ) );	
       
   199 	                 
       
   200 	const TInt KMceDesConversionMultiplier = 4;
       
   201 	HBufC8* sequence = 
       
   202 	    HBufC8::NewLC( aSequence.Length() * KMceDesConversionMultiplier );
       
   203 	TPtr8 prtSequence( sequence->Des() );   
       
   204 	CnvUtfConverter::ConvertFromUnicodeToUtf8( prtSequence, aSequence );
       
   205 	
       
   206 	CMceSession* session = iStream->Session();
       
   207 		
       
   208     TMceIds ids;
       
   209 	session->PrepareForITC( ids );
       
   210 	ids.iMediaID   = iStream->Id();
       
   211 	ids.iSourceID  = Id();
       
   212 	ids.iState     = IsEnabled();  	
       
   213 	
       
   214 	session->ITCSender().WriteL( ids, EMceItcSendDtmfToneSequence, prtSequence );	
       
   215 	
       
   216 	CleanupStack::PopAndDestroy( sequence );	
       
   217 	
       
   218 	MCECLI_DEBUG( "CMceMediaSource::SendDtmfToneSequenceL, Exit" )
       
   219 	}
       
   220 
       
   221 // -----------------------------------------------------------------------------
       
   222 // CMceMediaSource::CancelDtmfToneSequenceL
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 void CMceMediaSource::CancelDtmfToneSequenceL()
       
   226 	{
       
   227 	MCECLI_DEBUG( "CMceMediaSource::CancelDtmfToneSequenceL, Entry" )  
       
   228     
       
   229     __ASSERT_ALWAYS( MCE_ENDPOINT_ITC_ALLOWED( *this ), 
       
   230                      User::Leave( KErrNotReady ) );
       
   231     
       
   232 	CMceSession* session = iStream->Session();
       
   233     
       
   234     TMceIds ids;
       
   235 	session->PrepareForITC( ids );
       
   236 	ids.iMediaID   = iStream->Id();
       
   237 	ids.iSourceID  = Id();
       
   238 	ids.iState     = IsEnabled();
       
   239 	
       
   240 	session->ITCSender().SendL( ids, EMceItcCancelSendDtmfToneSequence );		
       
   241 	
       
   242 	MCECLI_DEBUG( "CMceMediaSource::CancelDtmfToneSequenceL, Exit" )
       
   243 	}
       
   244 
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // CMceMediaSource::Id
       
   248 // -----------------------------------------------------------------------------
       
   249 //
       
   250 TMceMediaId CMceMediaSource::Id() const
       
   251     {
       
   252     return FLAT_DATA( iID );
       
   253     }
       
   254     
       
   255 
       
   256 // -----------------------------------------------------------------------------
       
   257 // CMceMediaSource::ReferenceCount
       
   258 // -----------------------------------------------------------------------------
       
   259 //
       
   260 TInt& CMceMediaSource::ReferenceCount()
       
   261     {
       
   262     return FLAT_DATA( ReferenceCount() );
       
   263     }
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // CMceMediaSource::CMceMediaSource
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 CMceMediaSource::CMceMediaSource()
       
   270     {
       
   271     }
       
   272   
       
   273     
       
   274 // -----------------------------------------------------------------------------
       
   275 // CMceMediaSource::ConstructL
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 void CMceMediaSource::ConstructL( CMceComMediaSource* aFlatData )
       
   279     {
       
   280     __ASSERT_ALWAYS( aFlatData , User::Leave( KErrArgument ) );
       
   281     iFlatData = aFlatData;
       
   282     FLAT_DATA( iID ) = TMceMediaId();//as not assigned
       
   283     
       
   284     }
       
   285       
       
   286 
       
   287 // -----------------------------------------------------------------------------
       
   288 // CMceMediaSource::SerializationId
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 TUint64 CMceMediaSource::SerializationId() const
       
   292     {
       
   293     return FLAT_DATA( SerializationId() );
       
   294     }
       
   295 
       
   296 // -----------------------------------------------------------------------------
       
   297 // CMceMediaSource::InternalizeFlatL
       
   298 // -----------------------------------------------------------------------------
       
   299 //
       
   300 void CMceMediaSource::InternalizeFlatL( RReadStream& aReadStream )
       
   301     {
       
   302     __ASSERT_ALWAYS( iFlatData , User::Leave( KErrNotReady ) );
       
   303     _FLAT_DATA->InternalizeFlatL( aReadStream );
       
   304     }
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // CMceMediaSource::ExternalizeFlatL
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 void CMceMediaSource::ExternalizeFlatL( RWriteStream& aWriteStream )
       
   311     {
       
   312     __ASSERT_ALWAYS( iFlatData , User::Leave( KErrNotReady ) );
       
   313     _FLAT_DATA->ExternalizeFlatL( aWriteStream );
       
   314     }
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CMceMediaSource::InternalizeL
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 void CMceMediaSource::InternalizeL( MMceComSerializationContext& aSerCtx )
       
   321     {
       
   322     InternalizeFlatL( aSerCtx.ReadStream() );
       
   323     }
       
   324 
       
   325 // -----------------------------------------------------------------------------
       
   326 // CMceMediaSource::ExternalizeL
       
   327 // -----------------------------------------------------------------------------
       
   328 //
       
   329 void CMceMediaSource::ExternalizeL( MMceComSerializationContext& aSerCtx )
       
   330     {
       
   331     ExternalizeFlatL( aSerCtx.WriteStream() );
       
   332     }
       
   333     
       
   334 
       
   335 
       
   336 // -----------------------------------------------------------------------------
       
   337 // CMceMediaSource::Factory
       
   338 // -----------------------------------------------------------------------------
       
   339 //
       
   340 TMceSourceFactory CMceMediaSource::Factory()
       
   341     {
       
   342     return TMceSourceFactory();
       
   343     }
       
   344 
       
   345 
       
   346 // -----------------------------------------------------------------------------
       
   347 // CMceMediaSource::InitializeL
       
   348 // -----------------------------------------------------------------------------
       
   349 //
       
   350 void CMceMediaSource::InitializeL( CMceManager* /*aManager*/ )
       
   351     {
       
   352     // NOP
       
   353     }
       
   354 
       
   355 // -----------------------------------------------------------------------------
       
   356 // CMceMediaSource::InitializeL
       
   357 // -----------------------------------------------------------------------------
       
   358 //
       
   359 void CMceMediaSource::InitializeL( CMceMediaStream& aParent )
       
   360     {
       
   361 
       
   362     if ( !Id().IsAssigned() )
       
   363         {
       
   364         __ASSERT_ALWAYS( aParent.Session() , User::Leave( KErrNotFound ) );        
       
   365         FLAT_DATA( iID ) = aParent.Session()->Manager().NextMediaId();
       
   366         MCECLI_DEBUG_DVALUES2("CMceMediaSource::InitializeL, this: type", Type(),
       
   367                               "id", Id().iId, "enabled", IsEnabled() );
       
   368         
       
   369         }
       
   370     
       
   371     }
       
   372 
       
   373 // -----------------------------------------------------------------------------
       
   374 // CMceMediaSource::StreamAddedL
       
   375 // -----------------------------------------------------------------------------
       
   376 //
       
   377 void CMceMediaSource::StreamAddedL( CMceMediaStream& aParent )
       
   378     {
       
   379     
       
   380     if ( iParents.Find( &aParent ) == KErrNotFound )
       
   381         {
       
   382         iParents.AppendL( &aParent );
       
   383         }
       
   384         
       
   385     iStream = iParents[0];
       
   386     
       
   387     }
       
   388     
       
   389 // -----------------------------------------------------------------------------
       
   390 // CMceMediaSource::UnInitialize
       
   391 // -----------------------------------------------------------------------------
       
   392 //
       
   393 void CMceMediaSource::UnInitialize( CMceMediaStream& aParent )
       
   394     {
       
   395     TInt index = iParents.Find( &aParent );
       
   396     if ( index >= 0 )
       
   397         {
       
   398         iParents.Remove( index );
       
   399         }
       
   400     iStream = NULL;
       
   401     
       
   402     if ( iParents.Count() > 0 )
       
   403         {
       
   404         iStream = iParents[0];
       
   405         }
       
   406     }
       
   407 
       
   408 
       
   409 // -----------------------------------------------------------------------------
       
   410 // CMceMediaSource::DoITCSendL
       
   411 // -----------------------------------------------------------------------------
       
   412 //
       
   413 void CMceMediaSource::DoITCSendL(
       
   414     TUint8 aITCFunction, 
       
   415     TBool aEnable,
       
   416     TUint32 aData1,
       
   417     TUint32 aData2 )
       
   418     {
       
   419     __ASSERT_ALWAYS( iStream , User::Leave( KErrNotReady ) );
       
   420     CMceSession* session = iStream->Session();
       
   421     __ASSERT_ALWAYS( session , User::Leave( KErrNotReady ) );
       
   422 
       
   423 	TMceIds ids;
       
   424 	session->PrepareForITC( ids );
       
   425 	ids.iMediaID   = iStream->Id();
       
   426 	ids.iSourceID  = Id();
       
   427 	ids.iState     = aEnable;
       
   428 	ids.iSpare1    = aData1;
       
   429 	ids.iSpare2    = aData2;
       
   430 	
       
   431     session->ITCSender().SendL( ids, static_cast<TMceItcFunctions>( aITCFunction ) );
       
   432     
       
   433 	Enabled( static_cast<TBool>( ids.iState ) );
       
   434     }
       
   435     
       
   436 
       
   437 // -----------------------------------------------------------------------------
       
   438 // CMceMediaSource::DoEnableL
       
   439 // -----------------------------------------------------------------------------
       
   440 //
       
   441 void CMceMediaSource::DoEnableL() 
       
   442     {
       
   443     if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) )
       
   444         {
       
   445         __ASSERT_ALWAYS( iStream->State() != CMceMediaStream::ETranscodingRequired, 
       
   446                          User::Leave( KErrNotReady ) );
       
   447     	DoITCSendL( EMceItcEnable, ETrue );    
       
   448         }
       
   449     else
       
   450         {
       
   451     	Enabled( ETrue );
       
   452         MCECLI_DEBUG("CMceMediaSource::DoEnableL, done locally");
       
   453         }
       
   454     }
       
   455 
       
   456 // -----------------------------------------------------------------------------
       
   457 // CMceMediaSource::DoDisableL
       
   458 // -----------------------------------------------------------------------------
       
   459 //
       
   460 void CMceMediaSource::DoDisableL() 
       
   461     {
       
   462     if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) )
       
   463         {
       
   464     	DoITCSendL( EMceItcDisable, EFalse );        
       
   465         }
       
   466     else
       
   467         {
       
   468     	Enabled( EFalse );
       
   469         MCECLI_DEBUG("CMceMediaSource::DoDisableL, done locally");
       
   470         }
       
   471     }
       
   472 
       
   473 
       
   474 // -----------------------------------------------------------------------------
       
   475 // CMceMediaSource::Enabled
       
   476 // -----------------------------------------------------------------------------
       
   477 //
       
   478 void CMceMediaSource::Enabled( TBool aValue )
       
   479     {
       
   480 	_FLAT_DATA->Enabled( aValue );
       
   481     }
       
   482 
       
   483 
       
   484 
       
   485 // -----------------------------------------------------------------------------
       
   486 // CMceMediaSource::EventReceivedL
       
   487 // -----------------------------------------------------------------------------
       
   488 //
       
   489 TInt CMceMediaSource::EventReceivedL( TMceEvent& aEvent )
       
   490     {
       
   491     TInt status = KMceEventNotOwner;
       
   492     TBool idMatch = aEvent.Id().iSourceID == Id();
       
   493     if ( !idMatch )
       
   494         {
       
   495         return KMceEventNotOwner;
       
   496         }
       
   497         
       
   498     if ( aEvent.Id().IsSourceId() )
       
   499         {
       
   500         status = HandleEvent( aEvent );
       
   501         }
       
   502     else
       
   503         {
       
   504         status = KMceEventNotConsumed;
       
   505         }
       
   506     
       
   507     return status;    
       
   508     }
       
   509 
       
   510 // -----------------------------------------------------------------------------
       
   511 // CMceMediaSource::UpdateL
       
   512 // -----------------------------------------------------------------------------
       
   513 //
       
   514 void CMceMediaSource::UpdateL( CMceMediaSource& aUpdate )
       
   515     {
       
   516     MCECLI_DEBUG("CMceMediaSource::UpdateL, Entry");
       
   517     MCECLI_DEBUG_DVALUES("this: type", Type(), "id", Id().iId );
       
   518     iFlatData->UpdateL( *aUpdate.iFlatData );
       
   519     MCECLI_DEBUG_DVALUE("CMceMediaSource::UpdateL, before exit. enabled", IsEnabled() );
       
   520     MCECLI_DEBUG("CMceMediaSource::UpdateL, Exit");
       
   521     }
       
   522 
       
   523 
       
   524 // -----------------------------------------------------------------------------
       
   525 // CMceMediaSource::Updated
       
   526 // -----------------------------------------------------------------------------
       
   527 //
       
   528 void CMceMediaSource::Updated()
       
   529     {
       
   530     MMceStreamObserver* observer = iStream->Session()->Manager().MediaObserver();
       
   531     
       
   532     if ( observer )
       
   533         {
       
   534         observer->StreamStateChanged( *iStream, *this );
       
   535         }
       
   536     
       
   537     }
       
   538 
       
   539 
       
   540 // -----------------------------------------------------------------------------
       
   541 // CMceMediaSource::HandleEvent
       
   542 // -----------------------------------------------------------------------------
       
   543 //
       
   544 TInt CMceMediaSource::HandleEvent( TMceEvent& aEvent )
       
   545     {
       
   546     MCECLI_DEBUG("CMceMediaSource::HandleEvent, Entry");
       
   547     MCECLI_DEBUG_DVALUES("this: type", Type(), "id", Id().iId );
       
   548     TInt status = KMceEventNotConsumed;
       
   549 
       
   550     if ( aEvent.MessageType() == EMceItcMsgTypeSource )
       
   551         {
       
   552         MCECLI_DEBUG("CMceMediaSource::HandleEvent, content of source changed");
       
   553         status = KMceEventUpdate;
       
   554         }
       
   555     else if ( aEvent.Action() == EMceItcStateChanged ) 
       
   556         {
       
   557         MCECLI_DEBUG("CMceMediaSource::HandleEvent, state changed");
       
   558         
       
   559     	Enabled( static_cast<TBool>( aEvent.ActionData() ) );
       
   560         
       
   561         if ( IsEnabled() )
       
   562             {
       
   563             iStream->SetState( CMceMediaStream::EStreaming );
       
   564             }
       
   565         else
       
   566             {
       
   567             iStream->SetState( CMceMediaStream::EDisabled );
       
   568             }
       
   569         Updated();
       
   570         status = KMceEventConsumed;
       
   571         }
       
   572     else if ( aEvent.Action() == EMceItcInProgress ) 
       
   573         {
       
   574         MCECLI_DEBUG("CMceMediaSource::HandleEvent, stream state changed");
       
   575         
       
   576         TInt stateContent( 0 );
       
   577         TBool isEnabled( EFalse );
       
   578         TUint32 actionData = aEvent.ActionData();
       
   579         MCE_DECODE_DOUBLE_STATE( actionData, stateContent, isEnabled );
       
   580         CMceMediaStream::TState state = static_cast<CMceMediaStream::TState>( stateContent );
       
   581         
       
   582         MCECLI_DEBUG_DVALUE("CMceMediaSource::HandleEvent, state:", state );
       
   583         MCECLI_DEBUG_DVALUE("CMceMediaSource::HandleEvent, enabled:", isEnabled );
       
   584         
       
   585         Enabled( isEnabled );
       
   586         
       
   587         TBool stateChanged = iStream->SetState( state );
       
   588         
       
   589         if ( !iStream->HandleMediaError( state, isEnabled, aEvent.Id().iStatus ) && 
       
   590              stateChanged )
       
   591             {
       
   592             Updated();
       
   593             }
       
   594         status = KMceEventConsumed;
       
   595         }
       
   596     else if ( aEvent.Action() == EMceItcDtmfSendStarted ||
       
   597               aEvent.Action() == EMceItcDtmfSendCompleted ||
       
   598               aEvent.Action() == EMceItcDtmfSendError )
       
   599         {
       
   600         MCECLI_DEBUG_DVALUE( "CMceMediaSource::HandleEvent, received dtmf event:", 
       
   601                              aEvent.Action() )
       
   602         
       
   603         MMceDtmfObserver* observer = iStream->Session()->Manager().DtmfObserver();
       
   604         if ( observer && iStream->Type() == KMceAudio )
       
   605             {
       
   606             if ( aEvent.Action() == EMceItcDtmfSendError )
       
   607                 {
       
   608                 observer->DtmfErrorOccured( *( iStream->Session() ), 
       
   609                                          *static_cast<CMceAudioStream*>( iStream ), 
       
   610                                          *this, 
       
   611                                          KErrGeneral );
       
   612                 
       
   613                 }
       
   614             else
       
   615                 {
       
   616                 MMceDtmfObserver::TMceDtmfEvent dtmfEvent = 
       
   617                     ( aEvent.Action() == EMceItcDtmfSendStarted ) ? 
       
   618                         MMceDtmfObserver::EDtmfSendStarted : 
       
   619                         MMceDtmfObserver::EDtmfSendCompleted;
       
   620                 observer->DtmfEventReceived( *( iStream->Session() ), 
       
   621                                          *static_cast<CMceAudioStream*>( iStream ), 
       
   622                                          *this, 
       
   623                                          dtmfEvent );
       
   624                 }
       
   625             }
       
   626         status = KMceEventConsumed;
       
   627         }
       
   628     else
       
   629         {
       
   630         //NOP
       
   631         MCECLI_DEBUG("CMceMediaSource::HandleEvent, not consumed");
       
   632         }
       
   633         
       
   634     MCECLI_DEBUG_DVALUE("CMceMediaSource::HandleEvent, before exit. enabled", IsEnabled() );
       
   635     MCECLI_DEBUG_DVALUE("CMceMediaSource::HandleEvent, Exit. status", status );
       
   636     return status;
       
   637     }