multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediamanager.cpp
changeset 0 1bce908db942
child 3 513a8b745b2f
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 FILES
       
    22 #include <AudioPreference.h>
       
    23 
       
    24 #include <mmcccodecinformationfactory.h>
       
    25 #include <mmcccodecinformation.h>
       
    26 #include <mmccinterface.h>
       
    27 
       
    28 #include <sdpdocument.h>
       
    29 #include <sdpcodecstringpool.h>
       
    30 
       
    31 #include "mcemediasource.h"
       
    32 #include "mcemediastream.h"
       
    33 #include "mceaudiostream.h"
       
    34 #include "mcemicsource.h"
       
    35 #include "mcertpsource.h"
       
    36 #include "mcertpsink.h"
       
    37 #include "mcecamerasource.h"
       
    38 #include "mcefilesource.h"
       
    39 #include "mcedisplaysink.h"
       
    40 #include "mceaudiocodec.h"
       
    41 #include "mceamrcodec.h"
       
    42 #include "mcenatpluginmanager.h"
       
    43 
       
    44 #include "mcecssessionimplementation.h"
       
    45 #include "mcemediamanager.h"
       
    46 #include "mcemediaobserver.h"
       
    47 #include "mcesdpsession.h"
       
    48 #include "mcemediadefs.h"
       
    49 
       
    50 #include "mcecommediastream.h"
       
    51 #include "mcecomaudiostream.h"
       
    52 #include "mcecomsession.h"
       
    53 #include "mcecomaudiocodec.h"
       
    54 #include "mcecomvideocodec.h"
       
    55 #include "mcecommediasource.h"
       
    56 #include "mcecommediasink.h"
       
    57 #include "mcecomrtpsource.h"
       
    58 #include "mcecomdisplaysink.h"
       
    59 #include "mcecomcamerasource.h"
       
    60 #include "mcecomrtpsink.h"
       
    61 #include "mcecomspeakersink.h"
       
    62 
       
    63 #include "mcemmlogs.h"
       
    64 
       
    65 #include "mcecomfactory.h"
       
    66 #include "mcesrvstreamiterator.h"
       
    67 #include "mcesrvsink.h"
       
    68 #include "mcesrvsource.h"
       
    69 #include "mceevents.h"
       
    70 #include "mcemediastate.h"
       
    71 
       
    72 #include "mceaudiosdpcodec.h"
       
    73 #include "mcevideosdpcodec.h"
       
    74 #include "cleanupresetanddestroy.h"
       
    75 #include "mcedtmfhandler.h"
       
    76 #include "mcecomendpointproxy.h"
       
    77 
       
    78 #define MCE_HEAP_CONSTRUCT_LC( type, variable ) \
       
    79 type* variable = new ( ELeave ) type; \
       
    80 CleanupStack::PushL( variable );
       
    81 
       
    82 #define MCE_HEAP_CONSTRUCT_WITH_PARAM_LC( type, variable, param ) \
       
    83 type* variable = new ( ELeave ) type( param ); \
       
    84 CleanupStack::PushL( variable );
       
    85 
       
    86 const TInt KMceMaxFileName8 = KMceMaxFileNameLength * 4;
       
    87 
       
    88 
       
    89 // ================ MEMBER FUNCTIONS =======================
       
    90 
       
    91 // ---------------------------------------------------------
       
    92 // CMceMediaManager::CMceMediaManager
       
    93 // ---------------------------------------------------------
       
    94 CMceMediaManager::CMceMediaManager() 
       
    95     {
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------
       
    99 // CMceMediaManager::ConstructL
       
   100 // ---------------------------------------------------------
       
   101 void CMceMediaManager::ConstructL( MMceMediaGeneralObserver& aObserver )
       
   102     {  
       
   103     iObserver = &aObserver;
       
   104     iMccInterface = CMccInterface::NewL( *this );
       
   105     iMccSecureInterface = CMccSecureInterface::NewL( *iMccInterface );
       
   106     
       
   107     SdpCodecStringPool::OpenL();
       
   108     
       
   109     iNatPluginManager = CMceNatPluginManager::NewL();
       
   110     
       
   111     CMceSdpCodec* sdpCodec = NULL;
       
   112  
       
   113     //audio SDP codec
       
   114     sdpCodec = CMceAudioSdpCodec::NewL();
       
   115     CleanupStack::PushL( sdpCodec );
       
   116     iSdpCodecs.AppendL( sdpCodec );
       
   117     CleanupStack::Pop( sdpCodec );
       
   118     
       
   119 
       
   120     //video SDP codec
       
   121     sdpCodec = CMceVideoSdpCodec::NewL();
       
   122     CleanupStack::PushL( sdpCodec );
       
   123     iSdpCodecs.AppendL( sdpCodec );
       
   124     CleanupStack::Pop( sdpCodec );
       
   125     
       
   126     }
       
   127 
       
   128 
       
   129 // ---------------------------------------------------------
       
   130 // CMceMediaManager::SdpCodec
       
   131 // ---------------------------------------------------------
       
   132 CMceSdpCodec* CMceMediaManager::SdpCodec( const CSdpMediaField& aMedia )
       
   133     {
       
   134     CMceSdpCodec* sdpCodec = NULL;
       
   135     TInt index = 0;
       
   136     while( !sdpCodec && index < iSdpCodecs.Count() )
       
   137         {
       
   138         sdpCodec = iSdpCodecs[ index++ ];
       
   139         sdpCodec = sdpCodec->Decodes( aMedia ) ? sdpCodec : NULL;
       
   140         }
       
   141     
       
   142     return sdpCodec;
       
   143     
       
   144     }
       
   145 
       
   146 
       
   147 // ---------------------------------------------------------
       
   148 // CMceMediaManager::SdpCodec
       
   149 // ---------------------------------------------------------
       
   150 CMceSdpCodec* CMceMediaManager::SdpCodec( CMceComMediaStream& aStream )
       
   151     {
       
   152     CMceSdpCodec* sdpCodec = NULL;
       
   153     TInt index = 0;
       
   154     while( !sdpCodec && index < iSdpCodecs.Count() )
       
   155         {
       
   156         sdpCodec = iSdpCodecs[ index++ ];
       
   157         sdpCodec = sdpCodec->Encodes( aStream ) ? sdpCodec : NULL;
       
   158         }
       
   159     
       
   160     return sdpCodec;
       
   161     
       
   162     }
       
   163 
       
   164 
       
   165 // ---------------------------------------------------------
       
   166 // CMceMediaManager::NewL
       
   167 // ---------------------------------------------------------
       
   168  CMceMediaManager* CMceMediaManager::NewL( 
       
   169                                     MMceMediaGeneralObserver& aObserver )
       
   170     {
       
   171     CMceMediaManager* self = NewLC( aObserver );
       
   172     CleanupStack::Pop( self );
       
   173     return self;
       
   174     }
       
   175 
       
   176 
       
   177 // ---------------------------------------------------------
       
   178 // CMceMediaManager::NewLC
       
   179 // ---------------------------------------------------------
       
   180  CMceMediaManager* CMceMediaManager::NewLC( 
       
   181                                     MMceMediaGeneralObserver& aObserver )
       
   182     {
       
   183     CMceMediaManager* self = new ( ELeave ) CMceMediaManager;
       
   184     CleanupStack::PushL( self );
       
   185     self->ConstructL( aObserver );
       
   186     return self;
       
   187     }
       
   188 
       
   189 
       
   190 // ---------------------------------------------------------
       
   191 // CMceMediaManager::~CMceMediaManager
       
   192 // ---------------------------------------------------------    
       
   193  CMceMediaManager::~CMceMediaManager()
       
   194     {
       
   195     MCEMM_DEBUG("CMceMediaManager::~CMceMediaManager(), Entry ");
       
   196     
       
   197     delete iMccSecureInterface;
       
   198     iMccSecureInterface=NULL;
       
   199     
       
   200     delete iNatPluginManager;
       
   201     iNatPluginManager = NULL;
       
   202 
       
   203     delete iMccInterface;
       
   204     iMccInterface = NULL;
       
   205     iMceSdpSessions.ResetAndDestroy();
       
   206     iSdpCodecs.ResetAndDestroy();
       
   207     iTranscodeSessions.ResetAndDestroy();
       
   208     SdpCodecStringPool::Close();
       
   209     MCEMM_DEBUG("CMceMediaManager::~CMceMediaManager(), Exit ");
       
   210     
       
   211     }   
       
   212     
       
   213     
       
   214 
       
   215 // ---------------------------------------------------------
       
   216 // CMceMediaManager::CreateSessionL
       
   217 // ---------------------------------------------------------    
       
   218 CMceSdpSession& CMceMediaManager::CreateSessionL( CMceComSession& aSession )
       
   219     {
       
   220     MCEMM_DEBUG("CMceMediaManager::CreateSessionL(), Entry ");
       
   221     
       
   222     CMceSdpSession* sdpSession = CMceSdpSession::NewL( aSession, *this );
       
   223     CleanupStack::PushL( sdpSession );
       
   224 
       
   225     aSession.AttachSDPSessionL( *sdpSession );
       
   226     User::LeaveIfError (iMceSdpSessions.Append( sdpSession ));
       
   227     CleanupStack::Pop( sdpSession ); 
       
   228 
       
   229     MCEMM_DEBUG("CMceMediaManager::CreateSessionL(), Exit ");
       
   230 
       
   231     return *sdpSession;
       
   232     }
       
   233 
       
   234 // ---------------------------------------------------------
       
   235 // CMceMediaManager::NatMediaManager
       
   236 // ---------------------------------------------------------    
       
   237 CMceNatPluginManager& CMceMediaManager::NatPluginManager()
       
   238     {
       
   239     return *iNatPluginManager;
       
   240     }
       
   241 
       
   242 // ---------------------------------------------------------
       
   243 // CMceMediaManager::EncodeL
       
   244 // ---------------------------------------------------------    
       
   245 CSdpDocument* CMceMediaManager::EncodeL( CMceComSession& aSession )
       
   246     {
       
   247 
       
   248     MCEMM_DEBUG("CMceMediaManager::EncodeL(), Entry ");
       
   249 
       
   250     if ( !SdpSession( aSession ) )
       
   251         {
       
   252         CreateSessionL( aSession );
       
   253         }
       
   254 
       
   255 	TMceMMState negotationStateId = aSession.NegotiationState().Id();
       
   256     MCEMM_DEBUG_STATE( "current state", 
       
   257                         negotationStateId );
       
   258     CSdpDocument* sdp = aSession.NegotiationState().EncodeL();
       
   259     
       
   260     MCEMM_DEBUG("CMceMediaManager::EncodeL(), Exit ");
       
   261     
       
   262     return sdp;
       
   263     
       
   264     }
       
   265 
       
   266 // ---------------------------------------------------------
       
   267 // CMceMediaManager::DecodeL
       
   268 // ---------------------------------------------------------    
       
   269 TMceSipWarningCode CMceMediaManager::DecodeL( 
       
   270                             CMceComSession& aSession,
       
   271                             CSdpDocument& aSdpDocument )
       
   272     {
       
   273     MCEMM_DEBUG("CMceMediaManager::DecodeL(), Entry ");
       
   274 
       
   275     if ( !SdpSession( aSession ) )
       
   276         {
       
   277         CreateSessionL( aSession );
       
   278         }
       
   279 	TMceMMState negotationStateId = aSession.NegotiationState().Id();
       
   280     MCEMM_DEBUG_STATE( "CMceMediaManager::DecodeL(): current state", 
       
   281                         negotationStateId );
       
   282     TMceSipWarningCode result = 
       
   283         aSession.NegotiationState().DecodeL( aSdpDocument );
       
   284 
       
   285     MCEMM_DEBUG("CMceMediaManager::DecodeL(), Exit ");
       
   286         
       
   287     return result; 
       
   288     
       
   289     }
       
   290 
       
   291 // ---------------------------------------------------------
       
   292 // CMceMediaManager::UpdateL
       
   293 // ---------------------------------------------------------    
       
   294 TMceReturnStatus CMceMediaManager::UpdateL( CMceComSession& aSession )
       
   295     {
       
   296     MCEMM_DEBUG("CMceMediaManager::UpdateL(), Entry ");
       
   297 
       
   298     TMceReturnStatus status = KMceAsync;
       
   299     
       
   300     if ( !SdpSession( aSession ) )
       
   301         {
       
   302         CreateSessionL( aSession );
       
   303         }
       
   304 	TMceMMState negotationStateId = aSession.NegotiationState().Id();
       
   305     MCEMM_DEBUG_STATE( "CMceMediaManager::UpdateL(): current state", 
       
   306                        negotationStateId );
       
   307     aSession.NegotiationState().UpdateL();
       
   308     status = !aSession.NegotiationState().CallbackAllowed() ? 
       
   309              KMceReady : KMceAsync;
       
   310     MCEMM_DEBUG("CMceMediaManager::UpdateL(), Exit ");
       
   311     return status;
       
   312     }
       
   313               
       
   314 // ---------------------------------------------------------
       
   315 // CMceMediaManager::ReserveL
       
   316 // ---------------------------------------------------------    
       
   317 
       
   318 TMceReturnStatus CMceMediaManager::ReserveL( CMceComSession& aSession, 
       
   319                                              const TDesC8& /*aToken*/ )
       
   320     {
       
   321     MCEMM_DEBUG("CMceMediaManager::ReserveL(), Entry ");
       
   322     
       
   323     TMceReturnStatus status = KMceReady;
       
   324     
       
   325     CMceSdpSession* sdpSession = SdpSession( aSession );
       
   326     __ASSERT_ALWAYS( sdpSession, User::Leave( KErrNotFound ) );
       
   327     
       
   328     MCEMM_DEBUG_STATE_1( "CMceMediaManager::ReserveL(): current state", 
       
   329                         aSession );
       
   330     if ( sdpSession )
       
   331         {
       
   332         status = aSession.NegotiationState().ReserveL();
       
   333         }
       
   334     
       
   335     
       
   336     MCEMM_DEBUG("CMceMediaManager::ReserveL(), Exit ");
       
   337 
       
   338     return status;
       
   339     
       
   340     }
       
   341 
       
   342 // ---------------------------------------------------------
       
   343 // CMceMediaManager::ReservationNeeded
       
   344 // ---------------------------------------------------------    
       
   345 TBool CMceMediaManager::ReservationNeeded( CMceComSession& aSession )
       
   346     {
       
   347     MCEMM_DEBUG("CMceMediaManager::ReservationNeeded(), Entry ");
       
   348     TBool reservationNeeded = EFalse;
       
   349     CMceSdpSession* sdpSession = SdpSession( aSession );
       
   350     
       
   351     MCEMM_DEBUG_STATE_1( "CMceMediaManager::ReservationNeeded(): current state", 
       
   352                         aSession );
       
   353     if ( sdpSession )
       
   354         {
       
   355         reservationNeeded = aSession.NegotiationState().ReservationNeeded();
       
   356         }
       
   357         
       
   358     MCEMM_DEBUG("CMceMediaManager::ReservationNeeded(), Exit ");
       
   359     return reservationNeeded;
       
   360     
       
   361     }
       
   362 
       
   363 // ---------------------------------------------------------
       
   364 // CMceMediaManager::NeedToNegotiate
       
   365 // ---------------------------------------------------------    
       
   366 TBool CMceMediaManager::NeedToNegotiate( CMceComSession& aSession,
       
   367                                          CSdpDocument* aSdpDocument )
       
   368     {
       
   369     MCEMM_DEBUG("CMceMediaManager::NeedToNegotiate(), Entry ");
       
   370     TBool needToNegotiate = EFalse;
       
   371     CMceSdpSession* sdpSession = SdpSession( aSession );
       
   372 
       
   373     MCEMM_DEBUG_STATE_1( "CMceMediaManager::NeedToNegotiate(): current state", 
       
   374                        aSession );
       
   375     if ( sdpSession )
       
   376         {
       
   377         needToNegotiate = aSession.NegotiationState().NeedToNegotiate( aSdpDocument );
       
   378         }
       
   379     
       
   380     MCEMM_DEBUG("CMceMediaManager::NeedToNegotiate(), Exit ");
       
   381     return needToNegotiate;
       
   382     
       
   383     }
       
   384 
       
   385 
       
   386 // ---------------------------------------------------------
       
   387 // CMceMediaManager::ConfirmationNeeded
       
   388 // --------------------------------------------------------- 
       
   389 //   
       
   390 TBool CMceMediaManager::ConfirmationNeeded( CMceComSession& aSession )
       
   391     {
       
   392     MCEMM_DEBUG("CMceMediaManager::ConfirmationNeeded(), Entry ");
       
   393     TBool needToNegotiate = EFalse;
       
   394     CMceSdpSession* sdpSession = SdpSession( aSession );
       
   395 
       
   396     MCEMM_DEBUG_STATE_1( "CMceMediaManager::ConfirmationNeeded(): current state", 
       
   397                         aSession);
       
   398     if ( sdpSession )
       
   399         {
       
   400         needToNegotiate = aSession.NegotiationState().ConfirmationNeeded();
       
   401         }
       
   402     
       
   403     MCEMM_DEBUG("CMceMediaManager::ConfirmationNeeded(), Exit ");
       
   404     return needToNegotiate;
       
   405     }
       
   406     
       
   407 
       
   408 // ---------------------------------------------------------
       
   409 // CMceMediaManager::GetRole
       
   410 // --------------------------------------------------------- 
       
   411 //   
       
   412 
       
   413 TMceNegotiationRole CMceMediaManager::GetRole( CMceComSession& aSession )
       
   414 	{
       
   415 	MCEMM_DEBUG("CMceMediaManager::GetRole()");
       
   416 	
       
   417 	return aSession.NegotiationState().Role();
       
   418 	}
       
   419 
       
   420 
       
   421 // ---------------------------------------------------------
       
   422 // CMceMediaManager::CreateRejectedAnswer
       
   423 // --------------------------------------------------------- 
       
   424 //   
       
   425  void CMceMediaManager::CreateRejectedAnswer( CMceComSession& aSession )
       
   426     { 
       
   427     MCEMM_DEBUG("CMceMediaManager::CreateRejectedAnswer(), Entry ");
       
   428 
       
   429     CMceSdpSession* sdpSession = SdpSession( aSession );
       
   430     if( !sdpSession )
       
   431         {
       
   432         return;
       
   433         }
       
   434     TRAPD( err, sdpSession->CreateAnswerL( aSession, ETrue ) );
       
   435     if( err != KErrNone )
       
   436         {
       
   437         MCEMM_DEBUG_DVALUE( "CMceMediaManager::CreateRejectedAnswer(): \
       
   438 ERROR: Creating rejected answer", err );
       
   439         iObserver->MediaError( err );
       
   440         }
       
   441     MCEMM_DEBUG("CMceMediaManager::CreateRejectedAnswer(), Exit ");
       
   442     }
       
   443 
       
   444 
       
   445 // ---------------------------------------------------------
       
   446 // CMceMediaManager::PauseL 
       
   447 // ---------------------------------------------------------   
       
   448 // 
       
   449  void CMceMediaManager::PauseL( CMceComMediaSink& aSink )
       
   450     {
       
   451     MCEMM_DEBUG("CMceMediaManager::PauseL() - sink, Entry ");
       
   452     CMceComSession* session = aSink.MediaStream()->Session();
       
   453     
       
   454     TMceSrvStreamIterator streams( session->MccStreams(), aSink );
       
   455     CMceSrvStream* stream = NULL;
       
   456     
       
   457     while( streams.Next( stream ) )
       
   458         {
       
   459         if ( !stream->Sink().DisableL( *stream ) )
       
   460             {
       
   461             SynchronizeMccStreamL( *stream, 0, stream->Sink().Id() );
       
   462             }
       
   463         }
       
   464         
       
   465     MCEMM_DEBUG("CMceMediaManager::PauseL() - sink, Exit ");
       
   466     }
       
   467     
       
   468 // ---------------------------------------------------------
       
   469 // CMceMediaManager::PauseL
       
   470 // ---------------------------------------------------------  
       
   471 // 
       
   472  void CMceMediaManager::PauseL( CMceComMediaSource& aSource )
       
   473     { 
       
   474     MCEMM_DEBUG("CMceMediaManager::PauseL() - source, Entry ");
       
   475     CMceComSession* session = aSource.MediaStream()->Session();
       
   476     
       
   477     TMceSrvStreamIterator streams( session->MccStreams(), aSource );
       
   478     CMceSrvStream* stream = NULL;
       
   479     
       
   480     while( streams.Next( stream ) )
       
   481         {
       
   482         if ( !stream->Source().DisableL( *stream ) )
       
   483             {
       
   484             SynchronizeMccStreamL( *stream, 0, stream->Source().Id() );
       
   485             }
       
   486         }
       
   487 
       
   488     MCEMM_DEBUG("CMceMediaManager::PauseL() - source, Exit ");
       
   489     }
       
   490     
       
   491     
       
   492 // ---------------------------------------------------------
       
   493 // CMceMediaManager::ResumeL 
       
   494 // ---------------------------------------------------------    
       
   495 //
       
   496  void CMceMediaManager::ResumeL( CMceComMediaSink& aSink )
       
   497     { 
       
   498     MCEMM_DEBUG("CMceMediaManager::ResumeL() - sink, Entry ");
       
   499     CMceComSession* session = aSink.MediaStream()->Session();
       
   500     
       
   501     TMceSrvStreamIterator streams( session->MccStreams(), aSink );
       
   502     CMceSrvStream* stream = NULL;
       
   503     
       
   504     while( streams.Next( stream ) )
       
   505         {
       
   506         if ( !stream->Sink().EnableL( *stream ) )
       
   507             {
       
   508             MCEMM_DEBUG_STREAM( "CMceMediaManager::ResumeL() - sink: \
       
   509 synchronize stream", *stream );
       
   510             SynchronizeMccStreamL( *stream, stream->Sink().Id(), 0 );
       
   511             }
       
   512         }
       
   513         
       
   514     MCEMM_DEBUG("CMceMediaManager::ResumeL() - sink, Exit ");
       
   515     }
       
   516     
       
   517     
       
   518 // ---------------------------------------------------------
       
   519 // CMceMediaManager::ResumeL 
       
   520 // ---------------------------------------------------------  
       
   521 //  
       
   522  void CMceMediaManager::ResumeL( CMceComMediaSource& aSource )
       
   523     { 
       
   524     MCEMM_DEBUG("CMceMediaManager::ResumeL() - source, Entry ");
       
   525     CMceComSession* session = aSource.MediaStream()->Session();
       
   526     
       
   527     TMceSrvStreamIterator streams( session->MccStreams(), aSource );
       
   528     CMceSrvStream* stream = NULL;
       
   529     
       
   530     while( streams.Next( stream ) )
       
   531         {
       
   532         if ( !stream->Source().EnableL( *stream ) )
       
   533             {
       
   534             MCEMM_DEBUG_STREAM( "CMceMediaManager::ResumeL() - source: \
       
   535 synchronize stream", *stream );
       
   536             SynchronizeMccStreamL( *stream, stream->Source().Id(), 0 );
       
   537             }
       
   538         }
       
   539 
       
   540     MCEMM_DEBUG("CMceMediaManager::ResumeL() - source, Exit ");
       
   541     }
       
   542 
       
   543 
       
   544 // ---------------------------------------------------------
       
   545 // CMceMediaManager::StartInactivityTimerL 
       
   546 // ---------------------------------------------------------    
       
   547 //
       
   548 void CMceMediaManager::StartInactivityTimerL( 
       
   549                             const CMceComRtpSource& aRtpSource, 
       
   550                             TUint32 aInactivityTimeout )
       
   551     { 
       
   552     MCEMM_DEBUG("CMceMediaManager::StartInactivityTimerL(), Entry ");
       
   553     
       
   554     CMceComSession* session = aRtpSource.MediaStream()->Session();
       
   555     
       
   556     TMceSrvStreamIterator streams( session->MccStreams(), aRtpSource );
       
   557     CMceSrvStream* stream = NULL;
       
   558     
       
   559     while( streams.Next( stream ) )
       
   560         {
       
   561         MCEMM_DEBUG_STREAM( "CMceMediaManager::StartInactivityTimerL(): \
       
   562 start inactivity timer for stream", *stream );
       
   563         User::LeaveIfError( 
       
   564             iMccInterface->StartInactivityTimer( 
       
   565                                     stream->SessionId(),
       
   566                                     stream->LinkId(),
       
   567                                     stream->Id(),
       
   568                                     aInactivityTimeout ) );
       
   569                             
       
   570         }
       
   571 
       
   572     MCEMM_DEBUG("CMceMediaManager::StartInactivityTimerL(), Exit ");
       
   573    
       
   574     }
       
   575     
       
   576 // ---------------------------------------------------------
       
   577 // CMceMediaManager::StopInactivityTimerL 
       
   578 // ---------------------------------------------------------    
       
   579 //
       
   580 void CMceMediaManager::StopInactivityTimerL( 
       
   581                     const CMceComRtpSource& aRtpSource )
       
   582     { 
       
   583     
       
   584     MCEMM_DEBUG("CMceMediaManager::StopInactivityTimerL(), Entry ");
       
   585     
       
   586     CMceComSession* session = aRtpSource.MediaStream()->Session();
       
   587     
       
   588     TMceSrvStreamIterator streams( session->MccStreams(), aRtpSource );
       
   589     CMceSrvStream* stream = NULL;
       
   590     
       
   591     while( streams.Next( stream ) )
       
   592         {
       
   593         MCEMM_DEBUG_STREAM( "CMceMediaManager::StopInactivityTimerL(): \
       
   594 stop inactivity timer for stream", *stream );
       
   595         User::LeaveIfError( 
       
   596             iMccInterface->StopInactivityTimer( 
       
   597                                     stream->SessionId(),
       
   598                                     stream->LinkId(),
       
   599                                     stream->Id() ) );
       
   600                             
       
   601         }
       
   602 
       
   603     MCEMM_DEBUG("CMceMediaManager::StopInactivityTimerL(), Exit ");
       
   604    
       
   605     }
       
   606 
       
   607 // ---------------------------------------------------------
       
   608 // CMceMediaManager::SendRTCPAnyDataL 
       
   609 // ---------------------------------------------------------    
       
   610 //
       
   611 void CMceMediaManager::SendRTCPAnyDataL( const CMceComMediaStream& aMediaStream,
       
   612                                          const TDesC8& aData )
       
   613     { 
       
   614     MCEMM_DEBUG("CMceMediaManager::SendRTCPAnyDataL(), Entry ");
       
   615     
       
   616     CMceComMediaSink* rtpSink = NULL;
       
   617     TInt index = 0;
       
   618     while( !rtpSink && index < aMediaStream.iSinks.Count() )
       
   619         {
       
   620         rtpSink = aMediaStream.iSinks[ index++ ];
       
   621         rtpSink = rtpSink->iType != KMceRTPSink ? NULL : rtpSink;
       
   622         }
       
   623 
       
   624     if ( !rtpSink )
       
   625         {
       
   626         MCEMM_DEBUG("No target!");
       
   627         return;
       
   628         }
       
   629         
       
   630     CMceComSession* session = aMediaStream.Session();
       
   631     
       
   632     TMceSrvStreamIterator streams( session->MccStreams(), *rtpSink );
       
   633     CMceSrvStream* stream = NULL;
       
   634     
       
   635     // Taking some precautions to avoid stack memory overuse
       
   636     //
       
   637     TMccEvent* event = new ( ELeave ) TMccEvent;
       
   638     CleanupStack::PushL( event );
       
   639     
       
   640     event->iEventCategory = KMccEventCategoryRtcp;
       
   641     event->iEventType = KMccRtcpControl;
       
   642     
       
   643     {       
       
   644     TMccRtcpEventData eventData;
       
   645     eventData.iRtcpPacketType = KRtcpAnyPacket;
       
   646     eventData.iRtcpPacketData.Copy( aData );
       
   647     TMccRtcpEventDataPackage eventDataBuf( eventData );
       
   648     event->iEventData.Copy( eventDataBuf );
       
   649     }
       
   650     
       
   651     while( streams.Next( stream ) )
       
   652         {
       
   653 
       
   654         MCEMM_DEBUG_STREAM( "CMceMediaManager::SendRTCPAnyDataL(): \
       
   655 send rtcp any data to stream", *stream );
       
   656         event->iSessionId = stream->SessionId();
       
   657         event->iLinkId = stream->LinkId();
       
   658         event->iStreamId = stream->Id();
       
   659         event->iEndpointId = stream->Sink().Id();
       
   660         
       
   661         iMccInterface->SendMediaSignalL( *event );
       
   662         
       
   663         }
       
   664 
       
   665     CleanupStack::PopAndDestroy( event );
       
   666     
       
   667     MCEMM_DEBUG("CMceMediaManager::SendRTCPAnyDataL(), Exit ");
       
   668    
       
   669     }
       
   670 
       
   671     
       
   672 
       
   673 // ---------------------------------------------------------
       
   674 // CMceMediaManager::SendRTCPReceiverReportL 
       
   675 // ---------------------------------------------------------    
       
   676 //
       
   677 void CMceMediaManager::SendRTCPReceiverReportL( 
       
   678                             const CMceComRtpSource& aRtpSource )
       
   679     { 
       
   680     MCEMM_DEBUG("CMceMediaManager::SendRTCPReceiverReportL(), Entry ");
       
   681     
       
   682     CMceComSession* session = aRtpSource.MediaStream()->Session();
       
   683     
       
   684     TMceSrvStreamIterator streams( session->MccStreams(), aRtpSource );
       
   685     CMceSrvStream* stream = NULL;
       
   686     
       
   687     // Taking some precautions to avoid stack memory overuse
       
   688     //
       
   689     TMccEvent* event = new ( ELeave ) TMccEvent;
       
   690     CleanupStack::PushL( event );
       
   691     
       
   692     event->iEventCategory = KMccEventCategoryRtcp;
       
   693     event->iEventType = KMccRtcpControl;
       
   694     
       
   695     {  
       
   696     TMccRtcpEventData eventData;
       
   697     eventData.iRtcpPacketType = KRtcpRrPacket;
       
   698     TMccRtcpEventDataPackage eventDataBuf( eventData );
       
   699     event->iEventData.Copy( eventDataBuf );
       
   700     }
       
   701     
       
   702     while( streams.Next( stream ) )
       
   703         {
       
   704         
       
   705         MCEMM_DEBUG_STREAM( "CMceMediaManager::SendRTCPReceiverReportL(): \
       
   706 send rtcp receiver report to stream", *stream );
       
   707         event->iSessionId = stream->SessionId();
       
   708         event->iLinkId = stream->LinkId();
       
   709         event->iStreamId = stream->Id();
       
   710         event->iEndpointId = stream->Source().Id();
       
   711 
       
   712         iMccInterface->SendMediaSignalL( *event );
       
   713         
       
   714         }
       
   715 
       
   716     CleanupStack::PopAndDestroy( event );
       
   717     
       
   718     MCEMM_DEBUG("CMceMediaManager::SendRTCPReceiverReportL(), Exit ");
       
   719     
       
   720     }
       
   721     
       
   722 // ---------------------------------------------------------
       
   723 // CMceMediaManager::SendRTCPSenderReportL 
       
   724 // ---------------------------------------------------------   
       
   725 // 
       
   726 void CMceMediaManager::SendRTCPSenderReportL( 
       
   727                             const CMceComRtpSink& aRtpSink )
       
   728     { 
       
   729     MCEMM_DEBUG("CMceMediaManager::SendRTCPSenderReportL(), Entry ");
       
   730     
       
   731     CMceComSession* session = aRtpSink.MediaStream()->Session();
       
   732     
       
   733     TMceSrvStreamIterator streams( session->MccStreams(), aRtpSink );
       
   734     CMceSrvStream* stream = NULL;
       
   735     
       
   736     // Taking some precautions to avoid stack memory overuse
       
   737     //
       
   738     TMccEvent* event = new ( ELeave ) TMccEvent;
       
   739     CleanupStack::PushL( event );
       
   740     
       
   741     event->iEventCategory = KMccEventCategoryRtcp;
       
   742     event->iEventType = KMccRtcpControl;
       
   743      
       
   744     {  
       
   745     TMccRtcpEventData eventData;
       
   746     eventData.iRtcpPacketType = KRtcpSrPacket;
       
   747     TMccRtcpEventDataPackage eventDataBuf( eventData );
       
   748     event->iEventData.Copy( eventDataBuf );
       
   749     }
       
   750     
       
   751     while( streams.Next( stream ) )
       
   752         {
       
   753 
       
   754         MCEMM_DEBUG_STREAM( "CMceMediaManager::SendRTCPSenderReportL(): \
       
   755 send rtcp sender report to stream", *stream );
       
   756         event->iSessionId = stream->SessionId();
       
   757         event->iLinkId = stream->LinkId();
       
   758         event->iStreamId = stream->Id();
       
   759         event->iEndpointId = stream->Sink().Id();
       
   760 
       
   761         iMccInterface->SendMediaSignalL( *event );
       
   762         
       
   763         }
       
   764 
       
   765     CleanupStack::PopAndDestroy( event );
       
   766     
       
   767     MCEMM_DEBUG("CMceMediaManager::SendRTCPSenderReportL(), Exit ");
       
   768    
       
   769     }   
       
   770 
       
   771 
       
   772 // ---------------------------------------------------------
       
   773 // CMceMediaManager::GetMaxVolumeL
       
   774 // --------------------------------------------------------- 
       
   775 //   
       
   776 void CMceMediaManager::GetMaxVolumeL( TInt& aMaxVolume )
       
   777     {
       
   778     MCEMM_DEBUG("CMceMediaManager::GetMaxVolumeL(), Entry ");
       
   779     
       
   780     TPckgBuf<TInt> maxVolume( aMaxVolume );
       
   781     
       
   782     // Max volume can be asked always after MCC creation
       
   783     User::LeaveIfError( iMccInterface->GetParameter( 
       
   784         0, 0, 0, 0, KMccSpeakerMaxVolume, maxVolume ) );
       
   785     
       
   786     aMaxVolume = maxVolume();
       
   787     
       
   788     MCEMM_DEBUG("CMceMediaManager::GetMaxVolumeL(), Exit ");
       
   789       
       
   790     }   
       
   791 
       
   792 // ---------------------------------------------------------
       
   793 // CMceMediaManager::GetVolumeL
       
   794 // ---------------------------------------------------------    
       
   795 //
       
   796 void CMceMediaManager::GetVolumeL( const CMceComMediaSink& aSink, 
       
   797                                    TInt& aVolume )
       
   798     { 
       
   799     MCEMM_DEBUG("CMceMediaManager::GetVolumeL(), Entry ");
       
   800 
       
   801     TPckgBuf<TInt> volume( aVolume );
       
   802       
       
   803     GetMccParameterL( aSink, KMccSpeakerVolume, volume );
       
   804     aVolume = volume();
       
   805     
       
   806     MCEMM_DEBUG("CMceMediaManager::GetVolumeL(), Exit ");
       
   807     
       
   808     }     
       
   809 
       
   810 // ---------------------------------------------------------
       
   811 // CMceMediaManager::SetVolumeL 
       
   812 // ---------------------------------------------------------  
       
   813 //  
       
   814 void CMceMediaManager::SetVolumeL( const CMceComMediaSink& aSink, 
       
   815                                   TInt aVolume )
       
   816     { 
       
   817     MCEMM_DEBUG("CMceMediaManager::SetVolumeL(), Entry ");
       
   818 
       
   819     TPckgBuf<TInt> volume( aVolume );
       
   820     
       
   821     if ( aSink.EndpointProxy() )
       
   822         {
       
   823         aSink.EndpointProxy()->SetParameterL( aSink, KMccSpeakerVolume, volume );
       
   824         }
       
   825     else
       
   826         {
       
   827         SetMccParameterL( aSink, KMccSpeakerVolume, volume );
       
   828         }
       
   829     
       
   830     MCEMM_DEBUG("CMceMediaManager::SetVolumeL(), Exit ");
       
   831     
       
   832     }   
       
   833 
       
   834 
       
   835 // ---------------------------------------------------------
       
   836 // CMceMediaManager::GetAudioRoutingL 
       
   837 // ---------------------------------------------------------    
       
   838 //
       
   839 void CMceMediaManager::GetAudioRoutingL( 
       
   840                        const CMceComSpeakerSink& aSpeaker, 
       
   841                        TInt& aRoutingDestination )
       
   842     { 
       
   843     MCEMM_DEBUG("CMceMediaManager::GetAudioRoutingL(), Entry ");
       
   844 
       
   845     TPckgBuf<TInt> routingDestination( aRoutingDestination );
       
   846     
       
   847     GetMccParameterL( aSpeaker, KMccSpeakerRouting, 
       
   848                       routingDestination );
       
   849                                    
       
   850     aRoutingDestination = routingDestination();
       
   851     
       
   852     MCEMM_DEBUG("CMceMediaManager::GetAudioRoutingL(), Exit ");
       
   853     
       
   854     }     
       
   855 
       
   856 // ---------------------------------------------------------
       
   857 // CMceMediaManager::SetAudioRoutingL
       
   858 // ---------------------------------------------------------  
       
   859 //  
       
   860  void CMceMediaManager::SetAudioRoutingL( 
       
   861                             const CMceComSpeakerSink& aSpeaker, 
       
   862                             TInt aRoutingDestination )
       
   863     { 
       
   864     MCEMM_DEBUG("CMceMediaManager::SetAudioRoutingL(), Entry ");
       
   865 
       
   866     TPckgBuf<TInt> routingDestination( aRoutingDestination );
       
   867     
       
   868     SetMccParameterL( aSpeaker, KMccSpeakerRouting, 
       
   869                       routingDestination );
       
   870                                    
       
   871     MCEMM_DEBUG("CMceMediaManager::SetAudioRoutingL(), Exit ");
       
   872     
       
   873     }   
       
   874 
       
   875 // ---------------------------------------------------------
       
   876 // CMceMediaManager::SetBalanceL 
       
   877 // ---------------------------------------------------------    
       
   878 //
       
   879 void CMceMediaManager::SetBalanceL( 
       
   880                         const CMceComMediaSink& aSink, 
       
   881                         TInt aBalance )
       
   882     { 
       
   883     MCEMM_DEBUG("CMceMediaManager::SetBalanceL(), Entry ");
       
   884 
       
   885     TPckgBuf<TInt> balance( aBalance );
       
   886     
       
   887     SetMccParameterL( aSink, KMccSpeakerBalance, balance );
       
   888     
       
   889     MCEMM_DEBUG("CMceMediaManager::SetBalanceL(), Exit ");
       
   890     
       
   891     }  
       
   892 
       
   893 
       
   894 // ---------------------------------------------------------
       
   895 // CMceMediaManager::SetBalanceL
       
   896 // ---------------------------------------------------------    
       
   897 //
       
   898 void CMceMediaManager::SetBalanceL( 
       
   899                         const CMceComMediaSource& aSource, 
       
   900                         TInt aBalance )
       
   901     { 
       
   902     MCEMM_DEBUG("CMceMediaManager::SetBalanceL(), Entry ");
       
   903 
       
   904     TPckgBuf<TInt> balance( aBalance );
       
   905     
       
   906     SetMccParameterL( aSource, KMccMicBalance, balance );
       
   907                                    
       
   908     MCEMM_DEBUG("CMceMediaManager::SetBalanceL(), Exit ");
       
   909     
       
   910     }  
       
   911 
       
   912 // ---------------------------------------------------------
       
   913 // CMceMediaManager::GetGainL 
       
   914 // ---------------------------------------------------------    
       
   915 //
       
   916 void CMceMediaManager::GetGainL( 
       
   917                         const CMceComMediaSource& aSource, 
       
   918                         TInt& aGain )
       
   919     {
       
   920     MCEMM_DEBUG("CMceMediaManager::GetGainL(), Entry ");
       
   921 
       
   922     TPckgBuf<TInt> gain( aGain );
       
   923     
       
   924     GetMccParameterL( aSource, KMccMicGain, gain );
       
   925                                    
       
   926     aGain = gain();
       
   927     
       
   928     MCEMM_DEBUG("CMceMediaManager::GetGainL(), Exit ");
       
   929     
       
   930     }  
       
   931 
       
   932 // ---------------------------------------------------------
       
   933 // CMceMediaManager::GetMaxGainL
       
   934 // ---------------------------------------------------------    
       
   935 //
       
   936 void CMceMediaManager::GetMaxGainL( TInt& aMaxGain )
       
   937     { 
       
   938     MCEMM_DEBUG("CMceMediaManager::GetMaxGainL(), Entry ");
       
   939     
       
   940     TPckgBuf<TInt> maxGain( aMaxGain );
       
   941     
       
   942     // Max gain can be asked always after MCC creation
       
   943     User::LeaveIfError( iMccInterface->GetParameter( 
       
   944         0, 0, 0, 0, KMccMicMaxGain, maxGain ) );
       
   945     
       
   946     aMaxGain = maxGain();
       
   947     
       
   948     MCEMM_DEBUG("CMceMediaManager::GetMaxGainL(), Exit ");
       
   949     }      
       
   950 
       
   951 
       
   952 // ---------------------------------------------------------
       
   953 // CMceMediaManager::SetGainL 
       
   954 // --------------------------------------------------------- 
       
   955 //   
       
   956 void CMceMediaManager::SetGainL( 
       
   957                 const CMceComMediaSource& aSource,
       
   958                 TInt aGain )
       
   959     { 
       
   960     MCEMM_DEBUG("CMceMediaManager::SetGainL(), Entry ");
       
   961 
       
   962     TPckgBuf<TInt> gain( aGain );
       
   963     
       
   964     SetMccParameterL( aSource, KMccMicGain, gain );
       
   965     
       
   966     MCEMM_DEBUG("CMceMediaManager::SetGainL(), Exit ");
       
   967     
       
   968     }   
       
   969 
       
   970 
       
   971 // ---------------------------------------------------------
       
   972 // CMceMediaManager::GetDisplaysAvailableL 
       
   973 // --------------------------------------------------------- 
       
   974 //   
       
   975 void CMceMediaManager::GetDisplaysAvailableL( 
       
   976                         TInt& aDisplaysAvailable )
       
   977     {
       
   978     MCEMM_DEBUG("CMceMediaManager::GetDisplaysAvailableL(), Entry ");
       
   979 
       
   980     const TInt KMceDefDisplaysAvailable = 1;
       
   981 
       
   982     aDisplaysAvailable = KMceDefDisplaysAvailable;
       
   983     
       
   984     MCEMM_DEBUG_DVALUE("Default value", aDisplaysAvailable );
       
   985     
       
   986     MCEMM_DEBUG("CMceMediaManager::GetDisplaysAvailableL(), Exit ");
       
   987     
       
   988     
       
   989     }
       
   990 
       
   991 // ---------------------------------------------------------
       
   992 // CMceMediaManager::GetDisplayRectL
       
   993 // --------------------------------------------------------- 
       
   994 //   
       
   995 void CMceMediaManager::GetDisplayRectL( CMceComDisplaySink& aSink, 
       
   996                                        TRect& aDisplayRect )
       
   997     {
       
   998     MCEMM_DEBUG("CMceMediaManager::GetDisplayRectL(), Entry ");
       
   999 
       
  1000     TMccVideoSinkSetting display;
       
  1001     TMccVideoSinkSettingBuf displayBuf( display );
       
  1002     
       
  1003     GetMccParameterL( aSink, aSink.MccParameterName(), 
       
  1004                       displayBuf );
       
  1005                                    
       
  1006     display = displayBuf();
       
  1007     aDisplayRect = TRect( display.iLocation, display.iSize );
       
  1008 
       
  1009     aSink.SetDisplayRect( aDisplayRect );
       
  1010 
       
  1011     MCEMM_DEBUG("CMceMediaManager::GetDisplayRectL(), Exit ");
       
  1012     
       
  1013     }
       
  1014 
       
  1015 // ---------------------------------------------------------
       
  1016 // CMceMediaManager::SetDisplayRectL
       
  1017 // --------------------------------------------------------- 
       
  1018 //   
       
  1019 void CMceMediaManager::SetDisplayRectL( CMceComDisplaySink& aSink, 
       
  1020                                        TRect aDisplayRect )
       
  1021     {
       
  1022     MCEMM_DEBUG("CMceMediaManager::SetDisplayRectL(), Entry ");
       
  1023 
       
  1024     aSink.SetDisplayRect( aDisplayRect );
       
  1025 
       
  1026     TMccVideoSinkSetting display;
       
  1027     TMccVideoSinkSettingBuf displayBuf( display );
       
  1028     GetMccParameterL( aSink, aSink.MccParameterName(), 
       
  1029                       displayBuf );
       
  1030                       
       
  1031     display = displayBuf();
       
  1032     CMceComDisplaySink::ToPointAndSize( aDisplayRect,
       
  1033                                         display.iLocation,
       
  1034                                         display.iSize );
       
  1035     TMccVideoSinkSettingBuf updateBuf( display );
       
  1036     SetMccParameterL( aSink, aSink.MccParameterName(), 
       
  1037                       updateBuf );
       
  1038                                
       
  1039 
       
  1040     MCEMM_DEBUG("CMceMediaManager::SetDisplayRectL(), Exit ");
       
  1041     
       
  1042     }
       
  1043 
       
  1044 // ---------------------------------------------------------
       
  1045 // CMceMediaManager::GetDisplayPriorityL 
       
  1046 // --------------------------------------------------------- 
       
  1047 //   
       
  1048 void CMceMediaManager::GetDisplayPriorityL( CMceComDisplaySink& aSink, 
       
  1049                          TInt& aDisplayPriority )
       
  1050     {
       
  1051     
       
  1052     MCEMM_DEBUG("CMceMediaManager::GetDisplayPriorityL(), Entry ");
       
  1053 
       
  1054     TMccVideoSinkSetting display;
       
  1055     TMccVideoSinkSettingBuf displayBuf( display );
       
  1056     
       
  1057     GetMccParameterL( aSink, aSink.MccParameterName(), 
       
  1058                       displayBuf );
       
  1059                                    
       
  1060     display = displayBuf();
       
  1061     aDisplayPriority = display.iPriority.iPriority;
       
  1062     
       
  1063     aSink.iPriority = aDisplayPriority;
       
  1064 
       
  1065     MCEMM_DEBUG("CMceMediaManager::GetDisplayPriorityL(), Exit ");
       
  1066     
       
  1067     }
       
  1068 
       
  1069 
       
  1070 // ---------------------------------------------------------
       
  1071 // CMceMediaManager::SetDisplayPriorityL 
       
  1072 // --------------------------------------------------------- 
       
  1073 //   
       
  1074 void CMceMediaManager::SetDisplayPriorityL( CMceComDisplaySink& aSink, 
       
  1075                                            TInt aDisplayPriority )
       
  1076     {
       
  1077     MCEMM_DEBUG("CMceMediaManager::SetDisplayPriorityL(), Entry ");
       
  1078 
       
  1079     aSink.iPriority = aDisplayPriority;
       
  1080 
       
  1081     TMccVideoSinkSetting display;
       
  1082     TMccVideoSinkSettingBuf displayBuf( display );
       
  1083     GetMccParameterL( aSink, aSink.MccParameterName(), 
       
  1084                              displayBuf );
       
  1085                              
       
  1086     display = displayBuf();
       
  1087     display.iPriority.iPriority = aSink.iPriority;
       
  1088                            
       
  1089     SetMccParameterL( aSink, aSink.MccParameterName(), 
       
  1090                       displayBuf );
       
  1091                                
       
  1092                                
       
  1093     MCEMM_DEBUG("CMceMediaManager::SetDisplayPriorityL(), Exit ");
       
  1094     }
       
  1095 
       
  1096 
       
  1097 // ---------------------------------------------------------
       
  1098 // CMceMediaManager::GetDisplayRotationL 
       
  1099 // --------------------------------------------------------- 
       
  1100 //   
       
  1101 void CMceMediaManager::GetDisplayRotationL( CMceComDisplaySink& aSink, 
       
  1102                                             TInt& aDisplayRotation )
       
  1103     {
       
  1104     MCEMM_DEBUG("CMceMediaManager::GetDisplayRotationL(), Entry ");
       
  1105 
       
  1106     User::LeaveIfError( aSink.MccParameterName() == KMccCamLocalVideo 
       
  1107                         ? KErrNotSupported : KErrNone );
       
  1108 
       
  1109     TMccVideoSinkSetting display;
       
  1110     TMccVideoSinkSettingBuf displayBuf( display );
       
  1111     
       
  1112     GetMccParameterL( aSink, aSink.MccParameterName(), 
       
  1113                       displayBuf );
       
  1114                                    
       
  1115     display = displayBuf();
       
  1116     aDisplayRotation = display.iRotation;
       
  1117     
       
  1118     aSink.iRotation = 
       
  1119         static_cast<CMceDisplaySink::TRotation>( aDisplayRotation );
       
  1120 
       
  1121     MCEMM_DEBUG("CMceMediaManager::GetDisplayRotationL(), Exit ");
       
  1122     }
       
  1123 
       
  1124 // ---------------------------------------------------------
       
  1125 // CMceMediaManager::SetDisplayRotationL 
       
  1126 // --------------------------------------------------------- 
       
  1127 //   
       
  1128 void CMceMediaManager::SetDisplayRotationL( CMceComDisplaySink& aSink, 
       
  1129                                             TInt aDisplayRotation )
       
  1130     {
       
  1131     MCEMM_DEBUG("CMceMediaManager::SetDisplayRotationL(), Entry ");
       
  1132 
       
  1133     User::LeaveIfError( aSink.MccParameterName() == KMccCamLocalVideo 
       
  1134                         ? KErrNotSupported : KErrNone );
       
  1135     
       
  1136     aSink.iRotation = 
       
  1137         static_cast<CMceDisplaySink::TRotation>( aDisplayRotation );
       
  1138 
       
  1139     TMccVideoSinkSetting display;
       
  1140     TMccVideoSinkSettingBuf displayBuf( display );
       
  1141     GetMccParameterL( aSink, aSink.MccParameterName(), 
       
  1142                              displayBuf );
       
  1143                              
       
  1144     display = displayBuf();
       
  1145     display.iRotation = static_cast<TMccVideoRotation>( aSink.iRotation );
       
  1146     displayBuf = display;
       
  1147                            
       
  1148     SetMccParameterL( aSink, aSink.MccParameterName(), 
       
  1149                       displayBuf );
       
  1150     
       
  1151     MCEMM_DEBUG("CMceMediaManager::SetDisplayRotationL(), Exit ");
       
  1152     }
       
  1153 
       
  1154 // ---------------------------------------------------------
       
  1155 // CMceMediaManager::SetDisplayIndexL 
       
  1156 // --------------------------------------------------------- 
       
  1157 //   
       
  1158 void CMceMediaManager::SetDisplayIndexL( CMceComDisplaySink& aSink, 
       
  1159                                         TInt aDisplayIndex )
       
  1160     {
       
  1161     
       
  1162     MCEMM_DEBUG("CMceMediaManager::SetDisplayIndexL(), Entry ");
       
  1163 
       
  1164     aSink.iDisplayIndex = aDisplayIndex;
       
  1165 
       
  1166     TMccVideoSinkSetting display;
       
  1167     TMccVideoSinkSettingBuf displayBuf( display );
       
  1168     GetMccParameterL( aSink, aSink.MccParameterName(), 
       
  1169                       displayBuf );
       
  1170                       
       
  1171     display = displayBuf();
       
  1172     display.iDeviceIndex = static_cast<TUint>( aSink.iDisplayIndex );
       
  1173                            
       
  1174     SetMccParameterL( aSink, aSink.MccParameterName(), 
       
  1175                       displayBuf );
       
  1176                                
       
  1177 
       
  1178     MCEMM_DEBUG("CMceMediaManager::SetDisplayIndexL(), Exit ");
       
  1179     
       
  1180     }
       
  1181  
       
  1182 
       
  1183 // ---------------------------------------------------------
       
  1184 // CMceMediaManager::GetCameraInfoL 
       
  1185 // --------------------------------------------------------- 
       
  1186 //   
       
  1187 void CMceMediaManager::GetCameraInfoL( TInt aCameraIndex, 
       
  1188                                        TCameraInfo& aCameraInfo )
       
  1189     {    
       
  1190     MCEMM_DEBUG("CMceMediaManager::GetCameraInfoL(), Entry ");
       
  1191 
       
  1192     TMccVideoInfo2 info;
       
  1193     info.iCameraIndex = aCameraIndex;
       
  1194     
       
  1195     TMccVideoInfoBuf2 videoInfo( info );
       
  1196     GetMccParameterL( KMccCamInfo, videoInfo );
       
  1197                                    
       
  1198     aCameraInfo = videoInfo().iInfo;
       
  1199 
       
  1200     MCEMM_DEBUG("CMceMediaManager::GetCameraInfoL(), Exit ");
       
  1201     
       
  1202     
       
  1203     }
       
  1204 
       
  1205 // ---------------------------------------------------------
       
  1206 // CMceMediaManager::GetCamerasAvailableL 
       
  1207 // --------------------------------------------------------- 
       
  1208 //   
       
  1209 void CMceMediaManager::GetCamerasAvailableL( TInt& aCamerasAvailable )
       
  1210     {
       
  1211     MCEMM_DEBUG("CMceMediaManager::GetCamerasAvailableL(), Entry ");
       
  1212 
       
  1213     TPckgBuf<TInt> camerasAvailable( aCamerasAvailable );
       
  1214 
       
  1215     GetMccParameterL( KMccCamCount, camerasAvailable );
       
  1216 
       
  1217     aCamerasAvailable = camerasAvailable();
       
  1218 
       
  1219     MCEMM_DEBUG("CMceMediaManager::GetCamerasAvailableL(), Exit ");
       
  1220     
       
  1221     }
       
  1222 
       
  1223 // ---------------------------------------------------------
       
  1224 // CMceMediaManager::GetZoomFactorL 
       
  1225 // --------------------------------------------------------- 
       
  1226 //   
       
  1227 void CMceMediaManager::GetZoomFactorL( CMceComCameraSource& aSource, 
       
  1228                                       TInt& aZoomFactor )
       
  1229     {
       
  1230     
       
  1231     MCEMM_DEBUG("CMceMediaManager::GetZoomFactorL(), Entry ");
       
  1232 
       
  1233     TPckgBuf<TInt> zoomFactor( aZoomFactor );
       
  1234 
       
  1235     GetMccParameterL( aSource, KMccCamZoomFactor, zoomFactor );
       
  1236                                    
       
  1237     aZoomFactor = zoomFactor();
       
  1238     aSource.iZoomFactor = aZoomFactor;
       
  1239 
       
  1240     MCEMM_DEBUG("CMceMediaManager::GetZoomFactorL(), Exit ");
       
  1241     
       
  1242     
       
  1243     }
       
  1244 
       
  1245 // ---------------------------------------------------------
       
  1246 // CMceMediaManager::GetDigitalZoomFactorL 
       
  1247 // --------------------------------------------------------- 
       
  1248 //   
       
  1249 void CMceMediaManager::GetDigitalZoomFactorL( CMceComCameraSource& aSource, 
       
  1250                                              TInt& aDigitalZoomFactor )
       
  1251     {
       
  1252     MCEMM_DEBUG("CMceMediaManager::GetDigitalZoomFactorL(), Entry ");
       
  1253 
       
  1254     TPckgBuf<TInt> digitalZoomFactor( aDigitalZoomFactor );
       
  1255 
       
  1256     GetMccParameterL( aSource, KMccCamDigitZoomFactor, 
       
  1257                       digitalZoomFactor );
       
  1258                                    
       
  1259     aDigitalZoomFactor = digitalZoomFactor();
       
  1260     aSource.iDigitalZoomFactor = aDigitalZoomFactor;
       
  1261 
       
  1262     MCEMM_DEBUG("CMceMediaManager::GetDigitalZoomFactorL(), Exit ");
       
  1263     
       
  1264     }
       
  1265 
       
  1266 
       
  1267 
       
  1268 // ---------------------------------------------------------
       
  1269 // CMceMediaManager::GetContrastL 
       
  1270 // --------------------------------------------------------- 
       
  1271 //   
       
  1272 void CMceMediaManager::GetContrastL( CMceComCameraSource& aSource, 
       
  1273                                     TInt& aContrast )
       
  1274     {
       
  1275     MCEMM_DEBUG("CMceMediaManager::GetContrastL(), Entry ");
       
  1276 
       
  1277     TPckgBuf<TInt> contrast( aContrast );
       
  1278 
       
  1279     GetMccParameterL( aSource, KMccCamContrast, contrast );
       
  1280                                    
       
  1281     aContrast = contrast();
       
  1282     aSource.iContrast = aContrast;
       
  1283 
       
  1284     MCEMM_DEBUG("CMceMediaManager::GetContrastL(), Exit ");
       
  1285     
       
  1286     }
       
  1287 
       
  1288 
       
  1289 // ---------------------------------------------------------
       
  1290 // CMceMediaManager::GetBrightnessL 
       
  1291 // --------------------------------------------------------- 
       
  1292 //   
       
  1293 void CMceMediaManager::GetBrightnessL( CMceComCameraSource& aSource, 
       
  1294                                       TInt& aBrightness )
       
  1295     {
       
  1296     MCEMM_DEBUG("CMceMediaManager::GetBrightnessL(), Entry ");
       
  1297 
       
  1298     TPckgBuf<TInt> brightness( aBrightness );
       
  1299 
       
  1300     GetMccParameterL( aSource, KMccCamBrightness, 
       
  1301                       brightness );
       
  1302                                    
       
  1303     aBrightness = brightness();
       
  1304     aSource.iBrightness = aBrightness;
       
  1305 
       
  1306     MCEMM_DEBUG("CMceMediaManager::GetBrightnessL(), Exit ");
       
  1307     
       
  1308     }
       
  1309 
       
  1310 // ---------------------------------------------------------
       
  1311 // CMceMediaManager::GetExposureL 
       
  1312 // --------------------------------------------------------- 
       
  1313 //   
       
  1314 void CMceMediaManager::GetExposureL( 
       
  1315     CMceComCameraSource& aSource, 
       
  1316     TInt& aExposure )
       
  1317     {
       
  1318     MCEMM_DEBUG("CMceMediaManager::GetExposureL(), Entry ");
       
  1319 
       
  1320     TPckgBuf<TInt> exposure( aExposure );
       
  1321 
       
  1322     GetMccParameterL( aSource, KMccCamExposure, 
       
  1323                       exposure );
       
  1324                                    
       
  1325     aExposure = exposure();
       
  1326     aSource.iExposure = aExposure;
       
  1327 
       
  1328     MCEMM_DEBUG("CMceMediaManager::GetExposureL(), Exit ");   
       
  1329     }
       
  1330     
       
  1331 
       
  1332 // ---------------------------------------------------------
       
  1333 // CMceMediaManager::GetWhiteBalanceL 
       
  1334 // --------------------------------------------------------- 
       
  1335 //   
       
  1336 void CMceMediaManager::GetWhiteBalanceL( CMceComCameraSource& aSource, 
       
  1337                                         TInt& aWhiteBalance )
       
  1338     {
       
  1339     MCEMM_DEBUG("CMceMediaManager::GetWhiteBalanceL(), Entry ");
       
  1340 
       
  1341     TPckgBuf<TInt> whiteBalance( aWhiteBalance );
       
  1342 
       
  1343     GetMccParameterL( aSource, KMccCamWhiteBalance, 
       
  1344                       whiteBalance );
       
  1345                                    
       
  1346     aWhiteBalance = whiteBalance();
       
  1347     aSource.iWhiteBalance = aWhiteBalance;
       
  1348 
       
  1349     MCEMM_DEBUG("CMceMediaManager::GetWhiteBalanceL(), Exit ");
       
  1350     
       
  1351     }
       
  1352 
       
  1353 // ---------------------------------------------------------
       
  1354 // CMceMediaManager::SetCameraIndexL 
       
  1355 // --------------------------------------------------------- 
       
  1356 //   
       
  1357 void CMceMediaManager::SetCameraIndexL( CMceComCameraSource& aSource, 
       
  1358                                         TInt aCameraIndex,
       
  1359                                         TCameraInfo& aCameraInfo )
       
  1360     {
       
  1361     MCEMM_DEBUG("CMceMediaManager::SetCameraIndexL(), Entry ");
       
  1362 
       
  1363     aSource.iCameraIndex = aCameraIndex;
       
  1364                       
       
  1365     UpdateMccSourceL( aSource );
       
  1366     
       
  1367     GetCameraInfoL( aCameraIndex, aCameraInfo );
       
  1368 
       
  1369     MCEMM_DEBUG("CMceMediaManager::SetCameraIndexL(), Exit ");
       
  1370     
       
  1371     }
       
  1372 
       
  1373 // ---------------------------------------------------------
       
  1374 // CMceMediaManager::SetZoomFactorL
       
  1375 // --------------------------------------------------------- 
       
  1376 //   
       
  1377 void CMceMediaManager::SetZoomFactorL( CMceComCameraSource& aSource, 
       
  1378                                       TInt aZoomFactor )
       
  1379     {
       
  1380     MCEMM_DEBUG("CMceMediaManager::SetZoomFactorL(), Entry ");
       
  1381 
       
  1382     aSource.iZoomFactor = aZoomFactor;
       
  1383     TPckgBuf<TInt> zoomFactor( aSource.iZoomFactor );
       
  1384 
       
  1385     SetMccParameterL( aSource, KMccCamZoomFactor, 
       
  1386                       zoomFactor );
       
  1387                                    
       
  1388     MCEMM_DEBUG("CMceMediaManager::SetZoomFactorL(), Exit ");
       
  1389     
       
  1390     }
       
  1391 
       
  1392 // ---------------------------------------------------------
       
  1393 // CMceMediaManager::SetDigitalZoomFactorL 
       
  1394 // --------------------------------------------------------- 
       
  1395 //   
       
  1396 void CMceMediaManager::SetDigitalZoomFactorL( CMceComCameraSource& aSource, 
       
  1397                                              TInt aDigitalZoomFactor )
       
  1398     {
       
  1399     MCEMM_DEBUG("CMceMediaManager::SetDigitalZoomFactorL(), Entry ");
       
  1400 
       
  1401     aSource.iDigitalZoomFactor = aDigitalZoomFactor;
       
  1402     TPckgBuf<TInt> digitalZoomFactor( aSource.iDigitalZoomFactor );
       
  1403 
       
  1404     SetMccParameterL( aSource, KMccCamDigitZoomFactor, 
       
  1405                       digitalZoomFactor );
       
  1406                                    
       
  1407 
       
  1408     MCEMM_DEBUG("CMceMediaManager::SetDigitalZoomFactorL(), Exit ");
       
  1409     
       
  1410     }
       
  1411 
       
  1412 // ---------------------------------------------------------
       
  1413 // CMceMediaManager::SetContrastL 
       
  1414 // --------------------------------------------------------- 
       
  1415 //   
       
  1416 void CMceMediaManager::SetContrastL( CMceComCameraSource& aSource, 
       
  1417                                     TInt aContrast )
       
  1418     {
       
  1419     MCEMM_DEBUG("CMceMediaManager::SetContrastL(), Entry ");
       
  1420 
       
  1421     aSource.iContrast = aContrast;
       
  1422     TPckgBuf<TInt> contrast( aSource.iContrast );
       
  1423 
       
  1424     SetMccParameterL( aSource, KMccCamContrast, 
       
  1425                       contrast );
       
  1426 
       
  1427     MCEMM_DEBUG("CMceMediaManager::SetContrastL(), Exit ");
       
  1428     
       
  1429     }
       
  1430 
       
  1431 // ---------------------------------------------------------
       
  1432 // CMceMediaManager::SetBrightnessL 
       
  1433 // --------------------------------------------------------- 
       
  1434 //   
       
  1435 void CMceMediaManager::SetBrightnessL( CMceComCameraSource& aSource, 
       
  1436                                       TInt aBrightness )
       
  1437     {
       
  1438     MCEMM_DEBUG("CMceMediaManager::SetBrightnessL(), Entry ");
       
  1439 
       
  1440     aSource.iBrightness = aBrightness;
       
  1441     TPckgBuf<TInt> brightness( aSource.iBrightness );
       
  1442 
       
  1443     SetMccParameterL( aSource, KMccCamBrightness, 
       
  1444                      brightness );
       
  1445                                    
       
  1446 
       
  1447     MCEMM_DEBUG("CMceMediaManager::SetBrightnessL(), Exit ");
       
  1448     
       
  1449     }
       
  1450 
       
  1451 // ---------------------------------------------------------
       
  1452 // CMceMediaManager::SetExposureL 
       
  1453 // --------------------------------------------------------- 
       
  1454 //   
       
  1455 void CMceMediaManager::SetExposureL( 
       
  1456     CMceComCameraSource& aSource, 
       
  1457     TInt aExposure)
       
  1458     {
       
  1459     MCEMM_DEBUG("CMceMediaManager::SetExposureL(), Entry ");
       
  1460 
       
  1461     aSource.iExposure = aExposure;
       
  1462     TPckgBuf<TInt> exposure( aSource.iExposure );
       
  1463 
       
  1464     SetMccParameterL( aSource, KMccCamExposure, 
       
  1465                       exposure );
       
  1466                                    
       
  1467     MCEMM_DEBUG("CMceMediaManager::SetExposureL(), Exit ");
       
  1468     }
       
  1469 
       
  1470 // ---------------------------------------------------------
       
  1471 // CMceMediaManager::SetWhiteBalanceL
       
  1472 // --------------------------------------------------------- 
       
  1473 //   
       
  1474 void CMceMediaManager::SetWhiteBalanceL( CMceComCameraSource& aSource, 
       
  1475                                         TInt aWhiteBalance )
       
  1476     {
       
  1477     MCEMM_DEBUG("CMceMediaManager::SetWhiteBalanceL(), Entry ");
       
  1478 
       
  1479     aSource.iWhiteBalance = aWhiteBalance;
       
  1480     TPckgBuf<TInt> whiteBalance( aSource.iWhiteBalance );
       
  1481 
       
  1482     SetMccParameterL( aSource, KMccCamWhiteBalance, 
       
  1483                       whiteBalance );
       
  1484                                    
       
  1485     MCEMM_DEBUG("CMceMediaManager::SetWhiteBalanceL(), Exit ");
       
  1486     
       
  1487     }
       
  1488 
       
  1489 // ---------------------------------------------------------
       
  1490 // CMceMediaManager::GetFileInfoL 
       
  1491 // --------------------------------------------------------- 
       
  1492 //   
       
  1493 void CMceMediaManager::GetFileInfoL( CMceComFileSource& aSource, 
       
  1494                                      TMceFileInfo& aFileInfo )
       
  1495     {
       
  1496 
       
  1497     MCEMM_DEBUG("CMceMediaManager::GetFileInfoL(), Entry ");
       
  1498 
       
  1499     if ( aSource.MediaStream() )
       
  1500         {
       
  1501         MCE_HEAP_CONSTRUCT_LC( TMccFileSourceSetting, fileInfo );
       
  1502         MCE_HEAP_CONSTRUCT_WITH_PARAM_LC( TMccFileSourceSettingBuf, fileInfoBuf, *fileInfo );
       
  1503         
       
  1504         GetMccParameterL( aSource, KMccFileInfo, *fileInfoBuf );
       
  1505         
       
  1506         FillMceFileInfoL( (*fileInfoBuf)(), aFileInfo );
       
  1507         
       
  1508         aSource.iFileInfo = aFileInfo;
       
  1509         
       
  1510         CleanupStack::PopAndDestroy( fileInfoBuf );
       
  1511         CleanupStack::PopAndDestroy( fileInfo );
       
  1512         }
       
  1513     else
       
  1514         {
       
  1515         GetFileInfoL( aFileInfo );
       
  1516         }
       
  1517 
       
  1518     MCEMM_DEBUG("CMceMediaManager::GetFileInfoL(), Exit ");
       
  1519     
       
  1520     }
       
  1521 
       
  1522 
       
  1523 // ---------------------------------------------------------
       
  1524 // CMceMediaManager::SetFileInfoL 
       
  1525 // --------------------------------------------------------- 
       
  1526 //   
       
  1527 void CMceMediaManager::SetFileInfoL( CMceComFileSource& aSource, 
       
  1528                                      TMceFileInfo& aFileInfo )
       
  1529     {
       
  1530 
       
  1531     MCEMM_DEBUG("CMceMediaManager::SetFileInfoL(), Entry ");
       
  1532 
       
  1533     MCE_HEAP_CONSTRUCT_LC( TMccFileSourceSetting, fileInfo );
       
  1534     
       
  1535     fileInfo->iFileName = aFileInfo.iFileName;
       
  1536     
       
  1537     MCE_HEAP_CONSTRUCT_WITH_PARAM_LC( TMccFileSourceSettingBuf, fileInfoBuf, *fileInfo );
       
  1538 
       
  1539     SetMccParameterL( aSource, KMccFileName, 
       
  1540                       *fileInfoBuf );
       
  1541                       
       
  1542     CleanupStack::PopAndDestroy( fileInfoBuf );
       
  1543     CleanupStack::PopAndDestroy( fileInfo );
       
  1544     
       
  1545     MCEMM_DEBUG("CMceMediaManager::SetFileInfoL(), Exit ");
       
  1546     }
       
  1547 
       
  1548 // ---------------------------------------------------------
       
  1549 // CMceMediaManager::GetFileInfoL 
       
  1550 // --------------------------------------------------------- 
       
  1551 //   
       
  1552 void CMceMediaManager::GetFileInfoL( TMceFileInfo& aFileInfo )
       
  1553     {
       
  1554     MCEMM_DEBUG("CMceMediaManager::GetFileInfoL(), Entry ");
       
  1555     
       
  1556     MCE_HEAP_CONSTRUCT_LC( TMccFileSourceSetting, fileInfo );
       
  1557     
       
  1558     fileInfo->iFileName = aFileInfo.iFileName;
       
  1559     
       
  1560     MCE_HEAP_CONSTRUCT_WITH_PARAM_LC( TMccFileSourceSettingBuf, fileInfoBuf, *fileInfo );
       
  1561     
       
  1562     GetMccParameterL( KMccFileInfo, *fileInfoBuf );
       
  1563     
       
  1564     FillMceFileInfoL( (*fileInfoBuf)(), aFileInfo );
       
  1565     
       
  1566     CleanupStack::PopAndDestroy( fileInfoBuf );
       
  1567     CleanupStack::PopAndDestroy( fileInfo );
       
  1568     
       
  1569     MCEMM_DEBUG("CMceMediaManager::GetFileInfoL(), Exit ");
       
  1570     
       
  1571     }
       
  1572     
       
  1573 
       
  1574 // ---------------------------------------------------------
       
  1575 // CMceMediaManager::GetFilePositionL 
       
  1576 // --------------------------------------------------------- 
       
  1577 //   
       
  1578 void CMceMediaManager::GetFilePositionL( CMceComFileSource& aSource, 
       
  1579                                          TTimeIntervalMicroSeconds& aFilePosition )
       
  1580     {
       
  1581     
       
  1582     MCEMM_DEBUG("CMceMediaManager::GetFilePositionL(), Entry ");
       
  1583 
       
  1584     MCE_HEAP_CONSTRUCT_LC( TMccFileSourceSetting, fileInfo );
       
  1585     MCE_HEAP_CONSTRUCT_WITH_PARAM_LC( TMccFileSourceSettingBuf, fileInfoBuf, *fileInfo );
       
  1586     
       
  1587     GetMccParameterL( aSource, KMccFilePosition, 
       
  1588                       *fileInfoBuf );
       
  1589     
       
  1590     aFilePosition = (*fileInfoBuf)().iPosition;
       
  1591     
       
  1592     CleanupStack::PopAndDestroy( fileInfoBuf );
       
  1593     CleanupStack::PopAndDestroy( fileInfo );
       
  1594     
       
  1595     MCEMM_DEBUG("CMceMediaManager::GetFilePositionL(), Exit ");
       
  1596     
       
  1597     }
       
  1598 
       
  1599 // ---------------------------------------------------------
       
  1600 // CMceMediaManager::SetFilePositionL 
       
  1601 // --------------------------------------------------------- 
       
  1602 //   
       
  1603 void CMceMediaManager::SetFilePositionL( CMceComFileSource& aSource, 
       
  1604                                          TTimeIntervalMicroSeconds& aFilePosition )
       
  1605     {
       
  1606 
       
  1607     MCEMM_DEBUG("CMceMediaManager::SetFilePositionL(), Entry ");
       
  1608 
       
  1609     MCE_HEAP_CONSTRUCT_LC( TMccFileSourceSetting, fileInfo );
       
  1610     
       
  1611     fileInfo->iPosition = aFilePosition;
       
  1612     
       
  1613     MCE_HEAP_CONSTRUCT_WITH_PARAM_LC( TMccFileSourceSettingBuf, fileInfoBuf, *fileInfo );
       
  1614     
       
  1615     SetMccParameterL( aSource, KMccFilePosition, 
       
  1616                       *fileInfoBuf );
       
  1617     
       
  1618     CleanupStack::PopAndDestroy( fileInfoBuf );
       
  1619     CleanupStack::PopAndDestroy( fileInfo );                  
       
  1620 
       
  1621     MCEMM_DEBUG("CMceMediaManager::SetFilePositionL(), Exit ");
       
  1622     
       
  1623     }
       
  1624 
       
  1625 // ---------------------------------------------------------
       
  1626 // CMceMediaManager::FastForwardL 
       
  1627 // --------------------------------------------------------- 
       
  1628 //   
       
  1629 void CMceMediaManager::FastForwardL( CMceComFileSource& /*aSource*/, 
       
  1630                                     TBool& /*aOnOff*/ )
       
  1631     {
       
  1632     MCEMM_DEBUG("CMceMediaManager::FastForwardL(), Entry ");
       
  1633 /*    
       
  1634     TMceFileInfo fileInfo;
       
  1635     TTimeIntervalMicroSeconds position;
       
  1636 
       
  1637     GetFileInfoL( aSource, fileInfo );
       
  1638     GetFilePositionL( aSource, position );
       
  1639     
       
  1640     TTimeIntervalMicroSeconds newPosition(
       
  1641             position.Int64() + 
       
  1642              (TInt64)( KMceOneSecondAsMicros * 
       
  1643                        KMceFastForwardMultiplier ) );
       
  1644                                    
       
  1645     if ( newPosition < fileInfo.iDuration )
       
  1646         {
       
  1647         SetFilePositionL( aSource, newPosition );
       
  1648         aSource.iPosition = newPosition;
       
  1649         }
       
  1650     else
       
  1651         {
       
  1652         MCEMM_DEBUG("At the end. No forward");
       
  1653         }
       
  1654 */
       
  1655     MCEMM_DEBUG("CMceMediaManager::FastForwardL(), Exit ");
       
  1656     }
       
  1657 
       
  1658 // ---------------------------------------------------------
       
  1659 // CMceMediaManager::FastRewindL 
       
  1660 // --------------------------------------------------------- 
       
  1661 //   
       
  1662 void CMceMediaManager::FastRewindL( CMceComFileSource& /*aSource*/, 
       
  1663                                    TBool& /*aOnOff*/ )
       
  1664     {
       
  1665     MCEMM_DEBUG("CMceMediaManager::FastRewindL(), Entry ");
       
  1666 /*    
       
  1667     TMceFileInfo fileInfo;
       
  1668     TTimeIntervalMicroSeconds position;
       
  1669 
       
  1670     GetFileInfoL( aSource, fileInfo );
       
  1671     GetFilePositionL( aSource, position );
       
  1672     
       
  1673     TTimeIntervalMicroSeconds newPosition(
       
  1674             position.Int64() - 
       
  1675              (TInt64)( KMceOneSecondAsMicros * 
       
  1676                        KMceFastForwardMultiplier ) );
       
  1677                                    
       
  1678     if ( newPosition > 0 )
       
  1679         {
       
  1680         SetFilePositionL( aSource, newPosition );
       
  1681         aSource.iPosition = newPosition;
       
  1682         }
       
  1683     else
       
  1684         {
       
  1685         MCEMM_DEBUG("At the beginning. No rewind");
       
  1686         }
       
  1687 */    
       
  1688     MCEMM_DEBUG("CMceMediaManager::FastRewindL(), Exit ");
       
  1689     }
       
  1690 
       
  1691 
       
  1692 // ---------------------------------------------------------
       
  1693 // CMceMediaManager::TranscodeFileL 
       
  1694 // --------------------------------------------------------- 
       
  1695 //   
       
  1696 TUint32 CMceMediaManager::TranscodeFileL( CMceComFileSource* aFile )
       
  1697     {
       
  1698     MCEMM_DEBUG("CMceMediaManager::TranscodeFileL(), Entry ");
       
  1699     __ASSERT_ALWAYS( aFile, User::Leave( KErrArgument ) );
       
  1700     
       
  1701     MCEMM_DEBUG_SVALUE(" from", aFile->iFileInfo.iFileName );
       
  1702     MCEMM_DEBUG_SVALUE(" to", aFile->iTranscodeInfo.iFileName );
       
  1703 
       
  1704      HBufC8* sourceFileBuf = HBufC8::NewLC( KMceMaxFileName8 );
       
  1705      TPtr8 sourceFile = sourceFileBuf->Des();
       
  1706      HBufC8* destFileBuf = HBufC8::NewLC( KMceMaxFileName8 );
       
  1707      TPtr8 destFile = destFileBuf->Des();
       
  1708      
       
  1709     TInt cnvRet = 
       
  1710         CnvUtfConverter::ConvertFromUnicodeToUtf8( sourceFile,
       
  1711                                                    aFile->iFileInfo.iFileName );
       
  1712 
       
  1713     MCEMM_DEBUG_DVALUE( "CMceMediaManager::TranscodeFileL(), source name converted: ", 
       
  1714                         cnvRet )
       
  1715     __ASSERT_ALWAYS( !cnvRet, User::Leave( KErrGeneral ) );
       
  1716     
       
  1717     cnvRet = CnvUtfConverter::ConvertFromUnicodeToUtf8( destFile,
       
  1718                                                      aFile->iTranscodeInfo.iFileName );
       
  1719      
       
  1720     MCEMM_DEBUG_DVALUE( "CMceMediaManager::TranscodeFileL(), dest name converted: ", 
       
  1721                         cnvRet )
       
  1722     __ASSERT_ALWAYS( !cnvRet, User::Leave( KErrGeneral ) );
       
  1723      
       
  1724     CMccCodecInformation* audioCodec = NULL;
       
  1725     CMccCodecInformation* videoCodec = NULL;
       
  1726     if ( aFile->MediaStream() && aFile->MediaStream()->Session() )
       
  1727     	{
       
  1728     	CreateTranscodingOutputCodecsL( &audioCodec,&videoCodec,aFile );
       
  1729     	}
       
  1730     if ( audioCodec )
       
  1731     	{
       
  1732     	CleanupStack::PushL( audioCodec );
       
  1733     	}
       
  1734     if ( videoCodec )
       
  1735     	{
       
  1736     	CleanupStack::PushL( videoCodec );
       
  1737     	}
       
  1738     	
       
  1739      User::LeaveIfError ( iMccInterface->TranscodeFile( 
       
  1740                           sourceFile,
       
  1741                           destFile,
       
  1742                           aFile->iTranscodeInfo.iQuality,
       
  1743                           aFile->iTranscodeInfo.iTranscodeSessionId,
       
  1744                           videoCodec,
       
  1745                           audioCodec ) );
       
  1746     if ( videoCodec )
       
  1747     	{
       
  1748     	CleanupStack::PopAndDestroy();
       
  1749     	}
       
  1750     if ( audioCodec )
       
  1751     	{
       
  1752     	CleanupStack::PopAndDestroy();
       
  1753     	}  
       
  1754                           
       
  1755     CleanupStack::PopAndDestroy( destFileBuf );
       
  1756     CleanupStack::PopAndDestroy( sourceFileBuf );
       
  1757  	   
       
  1758     iTranscodeSessions.AppendL( aFile );
       
  1759 
       
  1760     MCEMM_DEBUG_DVALUE(" sessionid", aFile->iTranscodeInfo.iTranscodeSessionId );
       
  1761     MCEMM_DEBUG("CMceMediaManager::TranscodeFileL(), Exit ");
       
  1762     
       
  1763     return aFile->iTranscodeInfo.iTranscodeSessionId;                     
       
  1764     }
       
  1765     
       
  1766     
       
  1767 // ---------------------------------------------------------
       
  1768 // CMceMediaManager::CreateTranscodingOutputCodecsL 
       
  1769 // --------------------------------------------------------- 
       
  1770 //   
       
  1771 void CMceMediaManager::CreateTranscodingOutputCodecsL( 
       
  1772 										   CMccCodecInformation** aAudioCodec ,
       
  1773         								   CMccCodecInformation** aVideoCodec ,
       
  1774         								   CMceComFileSource* aFile )
       
  1775     {  
       
  1776     MCEMM_DEBUG("CMceMediaManager::CreateTranscodingOutputCodecsL(),entry ");
       
  1777     CMceComSession* tempSession = aFile->MediaStream()->Session();
       
  1778     RPointerArray<CMceComMediaStream>& streams = tempSession->Streams();
       
  1779     CMceSrvStream* audioSrvStream = NULL;
       
  1780     CMceSrvStream* videoSrvStream = NULL;
       
  1781     TInt cleanitems = 0;
       
  1782     CMceComAudioStream* audioStream = NULL;
       
  1783     CMceComVideoStream* videoStream	= NULL;
       
  1784    
       
  1785     for ( int i = 0; i < streams.Count();i++ )
       
  1786     	{
       
  1787     	if ( streams[i]->iType == KMceAudio &&  !audioSrvStream )
       
  1788     		{
       
  1789     		audioStream = static_cast<CMceComAudioStream*>( 
       
  1790                   								tempSession->Streams()[ i ] );
       
  1791     		if ( audioStream->Codecs().Count() )
       
  1792     			{
       
  1793     			audioSrvStream = CMceSrvStream::NewL( *this, *aFile->MediaStream(),
       
  1794     												 *aFile->MediaStream()->Source(),
       
  1795     												 *aFile->MediaStream()->Sinks()[0],
       
  1796     												 *(audioStream->Codecs()[0])	);
       
  1797     			CleanupStack::PushL( audioSrvStream );
       
  1798     			cleanitems++;
       
  1799     			MCEMM_DEBUG("CMceMediaManager::CreateTranscodingOutputCodecsL(), AudioCodec  found ");
       
  1800     			}
       
  1801     		}
       
  1802     			
       
  1803     	if ( streams[i]->iType == KMceVideo &&  !videoSrvStream )
       
  1804     		{
       
  1805     		videoStream = static_cast<CMceComVideoStream*>( 
       
  1806                     							tempSession->Streams()[ i ] );
       
  1807     		if ( videoStream->Codecs().Count() )
       
  1808     			{
       
  1809     			videoSrvStream = CMceSrvStream::NewL( *this, *aFile->MediaStream(),
       
  1810     												 *aFile->MediaStream()->Source(),
       
  1811     												 *aFile->MediaStream()->Sinks()[0],
       
  1812     												 *(videoStream->Codecs()[0])	);
       
  1813     			CleanupStack::PushL( videoSrvStream );
       
  1814     			cleanitems++;
       
  1815     			MCEMM_DEBUG("CMceMediaManager::CreateTranscodingOutputCodecsL(), VideoCodec found ");
       
  1816     			}
       
  1817     		}
       
  1818     	
       
  1819     
       
  1820     	}
       
  1821     if ( audioSrvStream )
       
  1822     	{
       
  1823     	*aAudioCodec = CreateMccCodecLC( *audioSrvStream, EMceRoleOfferer );
       
  1824     	cleanitems++;
       
  1825     	}
       
  1826     		
       
  1827     if ( videoSrvStream )
       
  1828     	{
       
  1829     	*aVideoCodec = CreateMccCodecLC( *videoSrvStream, EMceRoleOfferer );
       
  1830     	cleanitems++;
       
  1831     	}	
       
  1832     CleanupStack::Pop( cleanitems );
       
  1833     delete audioSrvStream;
       
  1834     audioSrvStream = NULL;
       
  1835     delete videoSrvStream;
       
  1836     videoSrvStream = NULL;
       
  1837     MCEMM_DEBUG("CMceMediaManager::CreateTranscodingOutputCodecsL(),exit ");
       
  1838     }
       
  1839 
       
  1840 // ---------------------------------------------------------
       
  1841 // CMceMediaManager::CancelTranscodeFileL 
       
  1842 // --------------------------------------------------------- 
       
  1843 //   
       
  1844 void CMceMediaManager::CancelTranscodeFileL( TUint32 aSessionId )
       
  1845     {
       
  1846     
       
  1847     MCEMM_DEBUG("CMceMediaManager::CancelTranscodeFileL(), Entry ");
       
  1848     MCEMM_DEBUG_DVALUE(" sessionid", aSessionId );
       
  1849     
       
  1850     CMceComFileSource* session = TranscodingSession( aSessionId );
       
  1851     
       
  1852     if ( session )
       
  1853         {
       
  1854         MCEMM_DEBUG("CMceMediaManager::CancelTranscodeFileL(), cancelling ");
       
  1855         
       
  1856         User::LeaveIfError ( 
       
  1857             iMccInterface->CancelTranscodeFile( 
       
  1858                 session->iTranscodeInfo.iTranscodeSessionId ) );
       
  1859         
       
  1860         TInt index = iTranscodeSessions.Find( session );
       
  1861         
       
  1862         iTranscodeSessions.Remove( index );
       
  1863         delete session;
       
  1864         }
       
  1865     
       
  1866     MCEMM_DEBUG("CMceMediaManager::CancelTranscodeFileL(), Exit ");
       
  1867     }
       
  1868 
       
  1869 
       
  1870 // ---------------------------------------------------------
       
  1871 // CMceMediaManager::TranscodingSession 
       
  1872 // ---------------------------------------------------------    
       
  1873 //
       
  1874 CMceComFileSource* CMceMediaManager::TranscodingSession( 
       
  1875                         const CMceComFileSource& aFile ) const
       
  1876     {
       
  1877     CMceComFileSource* session = NULL;
       
  1878     TInt index = 0;
       
  1879     while( !session && index < iTranscodeSessions.Count() )
       
  1880         {
       
  1881         session = iTranscodeSessions[ index++ ];
       
  1882         session = session->Id() == aFile.Id() ? session : NULL;
       
  1883         
       
  1884         }
       
  1885 
       
  1886     return session;
       
  1887     
       
  1888     }
       
  1889     
       
  1890 // ---------------------------------------------------------
       
  1891 // CMceMediaManager::TranscodingSession 
       
  1892 // ---------------------------------------------------------    
       
  1893 //
       
  1894 CMceComFileSource* CMceMediaManager::TranscodingSession( 
       
  1895                                 TUint32 aTcSessionId ) const
       
  1896     {
       
  1897     CMceComFileSource* session = NULL;
       
  1898     TInt index = 0;
       
  1899     while( !session && index < iTranscodeSessions.Count() )
       
  1900         {
       
  1901         session = iTranscodeSessions[ index++ ];
       
  1902         session = 
       
  1903             session->iTranscodeInfo.iTranscodeSessionId == 
       
  1904                                 aTcSessionId ? session : NULL;
       
  1905         
       
  1906         }
       
  1907 
       
  1908     return session;
       
  1909     
       
  1910     }
       
  1911     
       
  1912   
       
  1913 // ---------------------------------------------------------
       
  1914 // CMceMediaManager::GetSupportedCodecs 
       
  1915 // ---------------------------------------------------------    
       
  1916 //
       
  1917  TInt CMceMediaManager::GetSupportedCodecs( RArray<TFourCC>& /*aCodecs*/  )
       
  1918     { 
       
  1919     MCEMM_DEBUG("CMceMediaManager::GetSupportedCodecs(), Entry ");
       
  1920     /*
       
  1921     TInt err = iMccInterface->GetSupportedCodecs( aCodecs );
       
  1922     */
       
  1923     MCEMM_DEBUG("NO IMPLEMENTATION");
       
  1924     TInt err = KErrNone;
       
  1925     MCEMM_DEBUG("CMceMediaManager::GetSupportedCodecs(), Exit ");
       
  1926     return err;
       
  1927     }     
       
  1928 
       
  1929 // ---------------------------------------------------------
       
  1930 // CMceMediaManager::GetCapabilities 
       
  1931 // ---------------------------------------------------------  
       
  1932 //  
       
  1933 void CMceMediaManager::GetCapabilitiesL( 
       
  1934                     RPointerArray<CMceComAudioCodec>& aCapabilities  )
       
  1935     { 
       
  1936     MCEMM_DEBUG("CMceMediaManager::GetCapabilitiesL() - audio , Entry ");
       
  1937     RPointerArray<CMccCodecInformation> mccCapabilities;
       
  1938     
       
  1939     TMceComAudioCodecFactory codecFactory;
       
  1940     RStringF audio = MCE_SDP_STRING_AUDIOL();
       
  1941     
       
  1942     TInt index = 0;
       
  1943     CMceSdpCodec* audioSdpCodec = NULL;
       
  1944     while( !audioSdpCodec && index < iSdpCodecs.Count() )
       
  1945         {
       
  1946         audioSdpCodec = iSdpCodecs[ index++ ];
       
  1947         audioSdpCodec = audioSdpCodec->Media() == audio ? audioSdpCodec : NULL;
       
  1948         }
       
  1949 
       
  1950     User::LeaveIfNull ( audioSdpCodec );
       
  1951     
       
  1952     User::LeaveIfError ( iMccInterface->GetCapabilities( mccCapabilities ) );
       
  1953 
       
  1954     MceCleanupResetAndDestroyPushL( mccCapabilities );
       
  1955     
       
  1956     for( int i = 0; i < mccCapabilities.Count(); i++ )
       
  1957         {
       
  1958         CMccCodecInformation* mccCodec = mccCapabilities[i];
       
  1959         if ( mccCodec->Type() == KUidMediaTypeAudio )
       
  1960             {
       
  1961             CMceComAudioCodec* codec = codecFactory.CreateCodecLC( mccCodec->SdpName() );
       
  1962             if ( codec )
       
  1963                 {
       
  1964                 *codec = *mccCodec;
       
  1965                 
       
  1966                 aCapabilities.AppendL( codec );
       
  1967                 CleanupStack::Pop( codec );
       
  1968             
       
  1969                 MCEMM_DEBUG("audio capabilities");
       
  1970                 MCEMM_DEBUG_SVALUE("codec", codec->iSdpName );
       
  1971                 MCEMM_DEBUG_DVALUE("sampling freq", codec->iSamplingFreq )
       
  1972                 MCEMM_DEBUG_DVALUE("payload type", codec->iPayloadType )
       
  1973                 MCEMM_DEBUG_DVALUE("bitrate", codec->iBitrate )
       
  1974                 MCEMM_DEBUG_DVALUE("max ptime", codec->iMaxPTime )
       
  1975                 MCEMM_DEBUG_DVALUE("ptime", codec->iPTime )
       
  1976                 MCEMM_DEBUG_DVALUE("VAD", codec->iEnableVAD )
       
  1977                 MCEMM_DEBUG_DVALUE("codec mode",codec->iCodecMode )
       
  1978                 MCEMM_DEBUG_DVALUE("fourCC", codec->iFourCC )
       
  1979                 MCEMM_DEBUG_SVALUE("fmtp", *codec->iFmtpAttr )
       
  1980 
       
  1981                 audioSdpCodec->AddCapabilityL( mccCodec->SdpName() );
       
  1982                 audioSdpCodec->AddCapabilityPayloadTypeL( mccCodec->PayloadType() );
       
  1983                 }
       
  1984             else
       
  1985                 {
       
  1986                 MCEMM_DEBUG_SVALUE("Not supported codec",mccCodec->SdpName() );
       
  1987                 }
       
  1988             }
       
  1989         }
       
  1990     CleanupStack::PopAndDestroy();//mccCapabilities
       
  1991     
       
  1992     MCEMM_DEBUG("CMceMediaManager::GetCapabilitiesL() - audio , Exit ");
       
  1993          
       
  1994     }
       
  1995 
       
  1996 
       
  1997 // ---------------------------------------------------------
       
  1998 // CMceMediaManager::GetCapabilities 
       
  1999 // ---------------------------------------------------------  
       
  2000 //  
       
  2001 void CMceMediaManager::GetCapabilitiesL( 
       
  2002                     RPointerArray<CMceComVideoCodec>& aCapabilities  )
       
  2003     { 
       
  2004     MCEMM_DEBUG("CMceMediaManager::GetCapabilitiesL() - video, Entry ");
       
  2005     
       
  2006     
       
  2007     RPointerArray<CMccCodecInformation> mccCapabilities;
       
  2008     TMceComVideoCodecFactory codecFactory;
       
  2009     RStringF video = MCE_SDP_STRING_VIDEOL();
       
  2010     
       
  2011     TInt index = 0;
       
  2012     CMceSdpCodec* videoSdpCodec = NULL;
       
  2013     while( !videoSdpCodec && index < iSdpCodecs.Count() )
       
  2014         {
       
  2015         videoSdpCodec = iSdpCodecs[ index++ ];
       
  2016         videoSdpCodec = videoSdpCodec->Media() == video ? videoSdpCodec : NULL;
       
  2017         }
       
  2018 
       
  2019     User::LeaveIfNull ( videoSdpCodec );
       
  2020     User::LeaveIfError ( iMccInterface->GetCapabilities( mccCapabilities ) );
       
  2021 
       
  2022     MceCleanupResetAndDestroyPushL( mccCapabilities );
       
  2023     
       
  2024     for( int i = 0; i < mccCapabilities.Count(); i++ )
       
  2025         {
       
  2026         CMccCodecInformation* mccCodec = mccCapabilities[i];
       
  2027         if ( mccCodec->Type() == KUidMediaTypeVideo )
       
  2028             {
       
  2029             CMceComVideoCodec* codec = codecFactory.CreateCodecLC( mccCodec->SdpName() );
       
  2030             
       
  2031             if ( codec )
       
  2032                 {
       
  2033                 *codec = *mccCodec;
       
  2034                 
       
  2035                 aCapabilities.AppendL( codec );
       
  2036                 CleanupStack::Pop( codec );
       
  2037 
       
  2038                 MCEMM_DEBUG("video capabilities");
       
  2039                 MCEMM_DEBUG_SVALUE("codec", codec->iSdpName );
       
  2040                 MCEMM_DEBUG_DVALUE("clock rate", codec->iClockRate )
       
  2041                 MCEMM_DEBUG_DVALUE("payload type", codec->iPayloadType )
       
  2042                 MCEMM_DEBUG_DVALUE("bitrate", codec->iBitrate )
       
  2043                 MCEMM_DEBUG_DVALUE("framerate", (TInt)codec->iFrameRate )
       
  2044                 MCEMM_DEBUG_DVALUE("max bitrate", codec->iMaxBitRate )
       
  2045                 MCEMM_DEBUG_DVALUE("resolution width", codec->iResolutionWidth )
       
  2046                 MCEMM_DEBUG_DVALUE("resolution height", codec->iResolutionHeight )
       
  2047                 MCEMM_DEBUG_DVALUE("codec mode",codec->iCodecMode )
       
  2048                 MCEMM_DEBUG_DVALUE("fourCC", codec->iFourCC )
       
  2049                 MCEMM_DEBUG_SVALUE("fmtp", *codec->iFmtpAttr )
       
  2050                 
       
  2051                 
       
  2052                 videoSdpCodec->AddCapabilityL( mccCodec->SdpName() );
       
  2053                 videoSdpCodec->AddCapabilityPayloadTypeL(mccCodec->PayloadType());
       
  2054                 }
       
  2055             else 
       
  2056                 {
       
  2057                 MCEMM_DEBUG_SVALUE("Not supported codec",mccCodec->SdpName() );    
       
  2058                 }
       
  2059             }
       
  2060         }
       
  2061     CleanupStack::PopAndDestroy();//mccCapabilities
       
  2062     
       
  2063         
       
  2064     MCEMM_DEBUG("CMceMediaManager::GetCapabilitiesL() - video, Exit ");
       
  2065     }
       
  2066 
       
  2067 // ---------------------------------------------------------
       
  2068 // CMceMediaManager::DtmfL
       
  2069 // ---------------------------------------------------------    
       
  2070 //
       
  2071 void CMceMediaManager::DtmfL( 
       
  2072     CMceComMediaSource& aSource, 
       
  2073     TMceComEvent& aEvent,
       
  2074     const TDesC8& aSequence )
       
  2075     {
       
  2076     MCEMM_DEBUG("CMceMediaManager::DtmfL(), Entry ");
       
  2077 
       
  2078     
       
  2079     TBool handled = DoDtmfL( aSource, aEvent, aSequence );
       
  2080     if ( !handled && aSource.MediaStream()->BoundStream() )
       
  2081         {
       
  2082         handled = DoDtmfL( aSource, aEvent, aSequence, ETrue );
       
  2083         }
       
  2084     
       
  2085     __ASSERT_ALWAYS( handled, User::Leave( KErrNotSupported ) );
       
  2086     
       
  2087     MCEMM_DEBUG("CMceMediaManager::DtmfL(), Exit ");
       
  2088     }
       
  2089 
       
  2090 // ---------------------------------------------------------
       
  2091 // CMceMediaManager::SetCNameL
       
  2092 // ---------------------------------------------------------    
       
  2093 //
       
  2094 void CMceMediaManager::SetCNameL( 
       
  2095     const CMceComEndpoint& aEndpoint, 
       
  2096     const TDesC8& aCName )
       
  2097     {
       
  2098     MCEMM_DEBUG_SVALUE("CMceMediaManager::SetCNameL(), cname:", aCName );
       
  2099     
       
  2100     CMceComMediaStream* endpointMediaStream = aEndpoint.MediaStream();
       
  2101     if ( IS_RECEIVESTREAM( endpointMediaStream ) &&
       
  2102          aEndpoint.iType == KMceRTPSource )
       
  2103         {
       
  2104         SetMccParameterL( static_cast<const CMceComMediaSource&>( aEndpoint ), 
       
  2105                           KMccRtpCName,
       
  2106                           aCName,
       
  2107                           ETrue );
       
  2108         }
       
  2109     else if ( IS_SENDSTREAM( endpointMediaStream ) &&
       
  2110               aEndpoint.iType == KMceRTPSink )
       
  2111         {
       
  2112         SetMccParameterL( static_cast<const CMceComMediaSink&>( aEndpoint ), 
       
  2113                           KMccRtpCName,
       
  2114                           aCName,
       
  2115                           ETrue );
       
  2116         }
       
  2117     else
       
  2118         {
       
  2119         User::Leave( KErrNotSupported );
       
  2120         }
       
  2121         
       
  2122     MCEMM_DEBUG("CMceMediaManager::SetCNameL(), Exit ");
       
  2123     }
       
  2124 
       
  2125 // ---------------------------------------------------------
       
  2126 // CMceMediaManager::UpdateConfigKeyL
       
  2127 // ---------------------------------------------------------    
       
  2128 //
       
  2129 void CMceMediaManager::UpdateConfigKeyL( const CMceComMediaSource& aSource )
       
  2130     {
       
  2131     MCEMM_DEBUG("CMceMediaManager::UpdateConfigKeyL(), Entry ");
       
  2132     
       
  2133     if ( aSource.MediaStream() &&
       
  2134          aSource.MediaStream()->iType == KMceVideo &&
       
  2135        ( aSource.Type() == KMceCameraSource || aSource.Type() == KMceFileSource ) )
       
  2136         {
       
  2137         TInt err( KErrNone );
       
  2138         HBufC8* configKey = HBufC8::NewLC( KMaxConfigKeyLen );
       
  2139         TPtr8 configKeyPtr( configKey->Des() );
       
  2140 
       
  2141         TMceSrvStreamIterator streams( 
       
  2142                         aSource.MediaStream()->Session()->MccStreams(), aSource );
       
  2143         
       
  2144         CMceComMediaStream* mediaStream = NULL;
       
  2145         CMceSrvStream* stream = NULL;
       
  2146         while ( streams.Next( stream ) && !err )
       
  2147             {
       
  2148             mediaStream = &stream->Data();
       
  2149             if ( mediaStream->iType != KMceVideo )
       
  2150                 {
       
  2151                 // NOP
       
  2152                 }
       
  2153             else if ( CMceComVideoCodec::IsConfigKeyValid( configKey ) )
       
  2154                 {
       
  2155                 DoConfigKeyUpdateL( *mediaStream, configKey );
       
  2156                 }
       
  2157             else if ( stream->IsMccPrepared() )
       
  2158                 {
       
  2159                 err = iMccInterface->GetParameter( stream->SessionId(),
       
  2160                                                    stream->LinkId(),
       
  2161                                                    stream->Id(),
       
  2162                                                    stream->Source().Id(),
       
  2163                                                    KMccConfigKey,
       
  2164                                                    configKeyPtr );                                 
       
  2165                 if ( !err && CMceComVideoCodec::IsConfigKeyValid( configKey ) )
       
  2166                     {
       
  2167                     streams.Reset();
       
  2168                     }
       
  2169                 }
       
  2170             else
       
  2171                 {
       
  2172                 // NOP
       
  2173                 }
       
  2174             }
       
  2175 
       
  2176         CleanupStack::PopAndDestroy( configKey );
       
  2177         }
       
  2178     
       
  2179     
       
  2180     MCEMM_DEBUG("CMceMediaManager::UpdateConfigKeyL(), Exit ");
       
  2181     }
       
  2182     
       
  2183 // ---------------------------------------------------------
       
  2184 // CMceMediaManager::GetSSRCL
       
  2185 // ---------------------------------------------------------    
       
  2186 //
       
  2187 TUint32 CMceMediaManager::GetSSRCL( CMceSrvStream& aStream )
       
  2188     {
       
  2189     MCEMM_DEBUG("CMceMediaManager::GetSSRCL(), Entry ");
       
  2190     
       
  2191     TUint32 ssrc = 0;
       
  2192     
       
  2193     User::LeaveIfError( iMccInterface->GetSSRC( 
       
  2194                                         aStream.SessionId(),
       
  2195                                         aStream.LinkId(),
       
  2196                                         aStream.Id(),
       
  2197                                         0,
       
  2198                                         ssrc ) );
       
  2199                                         
       
  2200     MCEMM_DEBUG("CMceMediaManager::GetSSRCL(), Exit ");
       
  2201     return ssrc;
       
  2202     
       
  2203     }
       
  2204 
       
  2205 
       
  2206 
       
  2207 // ---------------------------------------------------------------------------
       
  2208 // CMceMediaManager::EnableViewFinderL
       
  2209 // ---------------------------------------------------------------------------
       
  2210 //
       
  2211 void CMceMediaManager::EnableViewFinderL( const CMceComMediaSink& /*aMediaSink*/, 
       
  2212                                           const TDesC8& aParam )
       
  2213     {
       
  2214     MCEMM_DEBUG("CMceMediaManager::EnableViewFinderL(), Entry ");
       
  2215     
       
  2216     SetMccParameterL( KMccCamLocalVideo, aParam );
       
  2217 
       
  2218     MCEMM_DEBUG("CMceMediaManager::EnableViewFinderL(), Exit ");
       
  2219     
       
  2220     }
       
  2221 
       
  2222 
       
  2223 // ---------------------------------------------------------------------------
       
  2224 // CMceMediaManager::DisableViewFinderL
       
  2225 // ---------------------------------------------------------------------------
       
  2226 //
       
  2227 void CMceMediaManager::DisableViewFinderL( const CMceComMediaSink& /*aMediaSink*/ )
       
  2228     {
       
  2229     MCEMM_DEBUG("CMceMediaManager::DisableViewFinderL(), Entry ");
       
  2230 
       
  2231     SetMccParameterL( KMccCamLocalVideo, KNullDesC8 );
       
  2232     
       
  2233     MCEMM_DEBUG("CMceMediaManager::DisableViewFinderL(), Exit ");
       
  2234     
       
  2235     }
       
  2236 
       
  2237 
       
  2238 // ---------------------------------------------------------
       
  2239 // CMceMediaManager::CreateMccSessionL
       
  2240 // ---------------------------------------------------------    
       
  2241 //
       
  2242 void CMceMediaManager::CreateMccSessionL( CMceComSession& aSession )
       
  2243     {
       
  2244     User::LeaveIfError( iMccInterface->CreateSession( aSession.iMccID ) );
       
  2245     }
       
  2246 
       
  2247 
       
  2248 // ---------------------------------------------------------
       
  2249 // CMceMediaManager::CreateMccLinkL
       
  2250 // ---------------------------------------------------------    
       
  2251 //
       
  2252 void CMceMediaManager::CreateMccLinkL( CMceSrvStream& aStream )
       
  2253     {      
       
  2254     MCEMM_DEBUG("CMceMediaManager::CreateMccLinkL(), Entry ");
       
  2255     
       
  2256     __ASSERT_ALWAYS( aStream.State() != CMceSrvStream::EAdopted,
       
  2257                      User::Leave( KErrArgument ) );
       
  2258     __ASSERT_ALWAYS( aStream.State() == CMceSrvStream::ECreated,
       
  2259                      User::Leave( KErrArgument ) );
       
  2260     
       
  2261     TMccNetSettings netSettings;
       
  2262     netSettings.iIapId = aStream.IapId();
       
  2263     netSettings.iLocalAddress.SetPort( aStream.LocalMediaPort() );
       
  2264     netSettings.iMediaQosValue = aStream.Data().Session()->iServiceType;
       
  2265     TUint32 linkId = aStream.LinkId();
       
  2266     
       
  2267     if ( linkId == KMceNotAssigned && 
       
  2268          !ReuseLink( aStream ) )
       
  2269         {
       
  2270         MCEMM_DEBUG("CMceMediaManager::CreateMccLinkL(): no link. creating link");
       
  2271         User::LeaveIfError( 
       
  2272             iMccInterface->CreateLink( aStream.SessionId(),
       
  2273                                        aStream.LinkType(), 
       
  2274                                        linkId,
       
  2275                                        netSettings ) );
       
  2276         
       
  2277         aStream.SetLinkId( linkId );
       
  2278         
       
  2279         SetPendingState( aStream, 0, CMceSrvStream::ECreatingLink );
       
  2280         
       
  2281         if ( aStream.Data().Session()->SecureSession() )
       
  2282         	{
       
  2283         	aStream.Data().Session()->SecureSession()->iCryptoContextUpdate = ETrue;		
       
  2284         	}
       
  2285         }
       
  2286     else
       
  2287         {
       
  2288         TMceSrvStreamIterator creatingLink( aStream.Data().Session()->MccStreams() );
       
  2289         TMceMccComEvent event( KMccEventNone,
       
  2290                                aStream.LinkId(), 
       
  2291                                0, 
       
  2292                                0 );
       
  2293         
       
  2294         CMceSrvStream* stream = NULL;
       
  2295         TBool creatingLinkCurrently( EFalse );
       
  2296         while ( creatingLink.Next( stream, event ) && !creatingLinkCurrently )
       
  2297             {
       
  2298             if ( stream != &aStream && stream->State() == CMceSrvStream::ECreatingLink )
       
  2299                 {
       
  2300                 MCEMM_DEBUG("CMceMediaManager::CreateMccLinkL(): link not ready. waiting");
       
  2301                 SetPendingState( aStream, 0, CMceSrvStream::ECreatingLink );
       
  2302                 creatingLinkCurrently = ETrue;
       
  2303                 }
       
  2304             }
       
  2305         
       
  2306         if ( !creatingLinkCurrently )
       
  2307             {
       
  2308             MCEMM_DEBUG("CMceMediaManager::CreateMccLinkL(): link exists");
       
  2309             SetPendingState( aStream, 0, CMceSrvStream::ELinkCreated );
       
  2310             }
       
  2311         }
       
  2312    
       
  2313         
       
  2314     MCEMM_DEBUG("CMceMediaManager::CreateMccLinkL(), Exit ");
       
  2315         
       
  2316     }
       
  2317     
       
  2318 
       
  2319 
       
  2320 // ---------------------------------------------------------
       
  2321 // CMceMediaManager::InitializeMccStreamL
       
  2322 // ---------------------------------------------------------    
       
  2323 //
       
  2324 void CMceMediaManager::InitializeMccStreamL( CMceSrvStream& aStream )
       
  2325     {
       
  2326 
       
  2327     MCEMM_DEBUG("CMceMediaManager::InitializeMccStreamL(), Entry ");
       
  2328 
       
  2329     __ASSERT_ALWAYS( aStream.State() != CMceSrvStream::EAdopted,
       
  2330                      User::Leave( KErrArgument ) );
       
  2331     
       
  2332     //create codec information
       
  2333     CMccCodecInformationFactory* codecFactory = 
       
  2334         CMccCodecInformationFactory::NewL();
       
  2335     CleanupStack::PushL( codecFactory );
       
  2336     
       
  2337     CMccCodecInformation* codec = 
       
  2338         codecFactory->CreateCodecInformationL( aStream.Codec().iSdpName );
       
  2339             
       
  2340     CleanupStack::PushL( codec );
       
  2341     aStream.Codec().MccDecodeL( *codec );
       
  2342 
       
  2343     CleanupStack::PopAndDestroy( codec );
       
  2344     CleanupStack::PopAndDestroy( codecFactory );
       
  2345     
       
  2346     MCEMM_DEBUG("CMceMediaManager::InitializeMccStreamL(), Exit ");
       
  2347     }
       
  2348     
       
  2349 
       
  2350 // ---------------------------------------------------------
       
  2351 // CMceMediaManager::CreateMccCodecLC
       
  2352 // ---------------------------------------------------------    
       
  2353 //
       
  2354 CMccCodecInformation* CMceMediaManager::CreateMccCodecLC( 
       
  2355                                         CMceSrvStream& aStream,
       
  2356                                         TMceNegotiationRole aRole )
       
  2357     {
       
  2358 
       
  2359     //create codec information
       
  2360     CMccCodecInformationFactory* codecFactory = 
       
  2361         CMccCodecInformationFactory::NewL();
       
  2362     CleanupStack::PushL( codecFactory );
       
  2363     
       
  2364     CMccCodecInformation* codec = 
       
  2365         codecFactory->CreateCodecInformationL( aStream.Codec().iSdpName );
       
  2366 
       
  2367     CleanupStack::PopAndDestroy( codecFactory );
       
  2368             
       
  2369     CleanupStack::PushL( codec );
       
  2370     aStream.Codec().MccPopulateL( *codec, aStream, aRole );
       
  2371 
       
  2372     return codec;
       
  2373         
       
  2374     }
       
  2375     
       
  2376 // ---------------------------------------------------------
       
  2377 // CMceMediaManager::CreateMccStreamL
       
  2378 // ---------------------------------------------------------    
       
  2379 //
       
  2380 void CMceMediaManager::CreateMccStreamL( 
       
  2381             CMceSrvStream& aStream,
       
  2382             TMceNegotiationRole aRole )
       
  2383     {
       
  2384 
       
  2385     MCEMM_DEBUG("CMceMediaManager::CreateMccStreamL(), Entry ");
       
  2386 
       
  2387     __ASSERT_ALWAYS( aStream.State() != CMceSrvStream::EAdopted,
       
  2388                      User::Leave( KErrArgument ) );
       
  2389     
       
  2390     // Create mcc codec even if mcc prepare is not needed in order to
       
  2391     // construct fmtp info also for local codecs. That information might
       
  2392     // be needed in some stream matching cases later on.
       
  2393     CMccCodecInformation* mccCodec = CreateMccCodecLC( aStream, aRole );
       
  2394         
       
  2395     if ( !aStream.PrepareL() )
       
  2396         {
       
  2397         CMceComCodec& codec = aStream.Codec();
       
  2398 
       
  2399         if ( ReuseSource( aStream ) )
       
  2400             {
       
  2401             MCEMM_DEBUG("CMceMediaManager::CreateMccStreamL(): resuing source ");
       
  2402             
       
  2403             //reuse source
       
  2404             iMccInterface->Reuse( aStream.SessionId(),
       
  2405                                   aStream.Id(),
       
  2406                                   aStream.LinkId(),
       
  2407                                   aStream.Source().Id() );
       
  2408             }
       
  2409         else
       
  2410             {
       
  2411             MCEMM_DEBUG("CMceMediaManager::CreateMccStreamL(): adding source ");
       
  2412             //add source
       
  2413             iMccInterface->AddDataSource( aStream.Source().Type(),
       
  2414                                           aStream.Source().Data().InitParamL( codec ),
       
  2415                                           aStream.Source().Id() );
       
  2416             }
       
  2417             
       
  2418         if ( ReuseSink( aStream ) )
       
  2419             {
       
  2420             MCEMM_DEBUG("CMceMediaManager::CreateMccStreamL(): resuing sink ");
       
  2421             //reuse sink
       
  2422             iMccInterface->Reuse( aStream.SessionId(),
       
  2423                                   aStream.Id(),
       
  2424                                   aStream.LinkId(),
       
  2425                                   aStream.Sink().Id() );
       
  2426             }
       
  2427         else
       
  2428             {
       
  2429             MCEMM_DEBUG("CMceMediaManager::CreateMccStreamL(): adding sink ");
       
  2430             //add sink
       
  2431             iMccInterface->AddDataSink( aStream.Sink().Type(),
       
  2432                                         aStream.Sink().Data().InitParamL( codec ),
       
  2433                                         aStream.Sink().Id() );
       
  2434             }
       
  2435 
       
  2436         MCEMM_DEBUG_STREAM( "CMceMediaManager::CreateMccStreamL(): creating stream", aStream );
       
  2437         //create stream    
       
  2438         User::LeaveIfError( iMccInterface->CreateStream( 
       
  2439                                     aStream.SessionId(),
       
  2440                                     aStream.LinkId(),
       
  2441                                     aStream.Id(),
       
  2442                                     aStream.MccStreamType(),
       
  2443                                     *mccCodec ) );
       
  2444         
       
  2445         aStream.Source().Data().InitializedL();
       
  2446         aStream.Sink().Data().InitializedL();
       
  2447 
       
  2448         }
       
  2449 
       
  2450     CleanupStack::PopAndDestroy( mccCodec );
       
  2451     
       
  2452     MCEMM_DEBUG("CMceMediaManager::CreateMccStreamL(), Exit ");
       
  2453     }
       
  2454 
       
  2455     
       
  2456 // ---------------------------------------------------------
       
  2457 // CMceMediaManager::PrepareMccStreamL
       
  2458 // ---------------------------------------------------------    
       
  2459 //
       
  2460 void CMceMediaManager::PrepareMccStreamL( 
       
  2461             CMceSrvStream& aStream,
       
  2462             TMceNegotiationRole /*aRole*/ )
       
  2463     {
       
  2464 
       
  2465     MCEMM_DEBUG("CMceMediaManager::PrepareMccStreamL(), Entry ");
       
  2466 
       
  2467     __ASSERT_ALWAYS( aStream.State() != CMceSrvStream::EAdopted,
       
  2468                      User::Leave( KErrArgument ) );
       
  2469     
       
  2470     if ( !aStream.PrepareL() )
       
  2471         {
       
  2472         //prepare stream
       
  2473         TUint32 endpointId = 0;
       
  2474         User::LeaveIfError( iMccInterface->PrepareStream( 
       
  2475                                     aStream.SessionId(),
       
  2476                                     aStream.LinkId(),
       
  2477                                     aStream.Id(),
       
  2478                                     endpointId ) );
       
  2479 
       
  2480         SetPendingState( aStream, endpointId, CMceSrvStream::EPreparing );
       
  2481         
       
  2482         aStream.MccPrepareCalledL();
       
  2483         
       
  2484         }
       
  2485     MCEMM_DEBUG_STREAM( "CMceMediaManager::PrepareMccStreamL(): after prepare", aStream );
       
  2486 
       
  2487     MCEMM_DEBUG("CMceMediaManager::PrepareMccStreamL(), Exit ");
       
  2488     }
       
  2489 
       
  2490 
       
  2491 // ---------------------------------------------------------
       
  2492 // CMceMediaManager::SetRemoteAddressL
       
  2493 // ---------------------------------------------------------   
       
  2494 //
       
  2495 void CMceMediaManager::SetRemoteAddressL( CMceSrvStream& aStream )
       
  2496     {
       
  2497     TInetAddr remoteIpAddress = aStream.RemoteIpAddress();
       
  2498     
       
  2499     MCEMM_DEBUG_DVALUE( "CMceMediaManager::SetRemoteAddressL address",
       
  2500         remoteIpAddress.Address() )
       
  2501     MCEMM_DEBUG_DVALUE( "CMceMediaManager::SetRemoteAddressL port",
       
  2502         remoteIpAddress.Port() ) 
       
  2503     
       
  2504     //for rtp
       
  2505     if ( !remoteIpAddress.IsUnspecified() &&
       
  2506     	 remoteIpAddress.Port() != 0 &&
       
  2507          aStream.IsMccPrepared() )
       
  2508         {
       
  2509         User::LeaveIfError( 
       
  2510             iMccInterface->SetRemoteAddress( 
       
  2511                     aStream.SessionId(),
       
  2512                     aStream.LinkId(),
       
  2513                     remoteIpAddress ) );
       
  2514         
       
  2515          // for rtcp
       
  2516     	if ( aStream.Data().RemoteMediaPort() != 0 &&
       
  2517     	     aStream.Data().iRemoteRtcpPort != 0 )
       
  2518 		    {
       
  2519 		    if ( !aStream.Data().iRemoteRtcpAddress.IsUnspecified() )
       
  2520 		    	{
       
  2521 		    	//copy address
       
  2522 		    	remoteIpAddress = aStream.Data().iRemoteRtcpAddress;
       
  2523 		    	}
       
  2524 		    	
       
  2525 		    remoteIpAddress.SetPort( 
       
  2526 		    			aStream.Data().iRemoteRtcpPort );
       
  2527 		    
       
  2528 		    User::LeaveIfError( 
       
  2529 		        iMccInterface->SetRemoteAddress( 
       
  2530 		                aStream.SessionId(),
       
  2531 		                aStream.LinkId(),
       
  2532 		                remoteIpAddress,
       
  2533 		                aStream.Data().iRemoteRtcpPort ) );
       
  2534 		    }
       
  2535         }
       
  2536     }
       
  2537 
       
  2538 
       
  2539 // ---------------------------------------------------------
       
  2540 // CMceMediaManager::StartMccStreamL
       
  2541 // ---------------------------------------------------------   
       
  2542 //
       
  2543 void CMceMediaManager::StartMccStreamL( CMceSrvStream& aStream )
       
  2544     {
       
  2545     
       
  2546     MCEMM_DEBUG("CMceMediaManager::StartMccStreamL(), Entry ");
       
  2547     
       
  2548     __ASSERT_ALWAYS( aStream.State() != CMceSrvStream::EAdopted,
       
  2549                      User::Leave( KErrArgument ) );
       
  2550     __ASSERT_ALWAYS( aStream.State() == CMceSrvStream::EPrepared, 
       
  2551                      User::Leave( KErrArgument ) );
       
  2552 
       
  2553     if ( !aStream.StartL() )
       
  2554         {
       
  2555         //set remote address for link
       
  2556         SetRemoteAddressL( aStream );
       
  2557         
       
  2558         if ( !DoStartEndpointsL( aStream, 0, 0 ) &&
       
  2559              aStream.Sink().State() == CMceSrvStream::EPrepared &&
       
  2560              aStream.Source().State() == CMceSrvStream::EPrepared )
       
  2561              
       
  2562         	{
       
  2563             SetPendingState( aStream, 0, CMceSrvStream::EPending );
       
  2564         	}
       
  2565         }
       
  2566 
       
  2567     MCEMM_DEBUG_STREAM( "CMceMediaManager::StartMccStreamL(): after start", aStream );
       
  2568         
       
  2569     MCEMM_DEBUG("CMceMediaManager::StartMccStreamL(), Exit ");
       
  2570     }
       
  2571 
       
  2572 
       
  2573 // ---------------------------------------------------------
       
  2574 // CMceMediaManager::StopMccStream
       
  2575 // ---------------------------------------------------------   
       
  2576 //
       
  2577 void CMceMediaManager::StopMccStream( CMceSrvStream& aStream )
       
  2578     {
       
  2579     MCEMM_DEBUG("CMceMediaManager::StopMccStream(), Entry ");
       
  2580     
       
  2581     if ( !aStream.Stop() )
       
  2582         {
       
  2583 
       
  2584         TMccNetSettings netSettings;
       
  2585         netSettings.iIapId = aStream.IapId();
       
  2586         netSettings.iLocalAddress.SetPort( aStream.LocalMediaPort() );
       
  2587         TUint32 linkId = aStream.LinkId();
       
  2588         
       
  2589         iMccInterface->StopStream( aStream.SessionId(), 
       
  2590                                    linkId, 
       
  2591                                    aStream.Id() );
       
  2592         
       
  2593         aStream.Cleanup();
       
  2594         
       
  2595         iMccInterface->DeleteStream( aStream.SessionId(), 
       
  2596                                      linkId, 
       
  2597                                      aStream.Id() );
       
  2598                                      
       
  2599         if ( !iMccInterface->StreamsExists( aStream.SessionId(), 
       
  2600                                             linkId ) )
       
  2601             {
       
  2602             MCEMM_DEBUG("CMceMediaManager::StopMccStream(): closing link ");
       
  2603             iMccInterface->CloseLink( aStream.SessionId(),
       
  2604                                       linkId );
       
  2605             aStream.SetLinkId( KMceNotAssigned );
       
  2606             }
       
  2607             
       
  2608         }
       
  2609         
       
  2610     aStream.Invalidate();
       
  2611     
       
  2612     MCEMM_DEBUG_STREAM( "CMceMediaManager::StopMccStream(): after stop", aStream );
       
  2613     MCEMM_DEBUG("CMceMediaManager::StopMccStream(), Exit ");
       
  2614     
       
  2615     }
       
  2616 
       
  2617 
       
  2618 // ---------------------------------------------------------
       
  2619 // CMceMediaManager::CanReleaseEndpoint
       
  2620 // ---------------------------------------------------------   
       
  2621 //
       
  2622 TBool CMceMediaManager::CanReleaseEndpoint( CMceSrvStream& aStream, 
       
  2623                                             TUint32 aEndpointId )
       
  2624     {
       
  2625     TBool remove = EFalse;
       
  2626     TUint referenceCount = 0;
       
  2627     if ( iMccInterface->ReferenceCount( aStream.SessionId(), 
       
  2628                                         aStream.LinkId(), 
       
  2629                                         aStream.Id(),
       
  2630                                         aEndpointId,
       
  2631                                         referenceCount ) == KErrNone )
       
  2632         {
       
  2633         MCEMM_DEBUG_DVALUE("CMceMediaManager::CanReleaseEndpoint(): \
       
  2634 reference count", referenceCount );
       
  2635         remove = referenceCount == 1;
       
  2636         }
       
  2637 
       
  2638     return remove;
       
  2639     
       
  2640     }
       
  2641 
       
  2642 
       
  2643 // ---------------------------------------------------------
       
  2644 // CMceMediaManager::ReleaseSink
       
  2645 // ---------------------------------------------------------   
       
  2646 //
       
  2647 TInt CMceMediaManager::ReleaseSink( CMceSrvStream& aStream,
       
  2648                                     TUint32 aEndpointId )
       
  2649     {
       
  2650     MCEMM_DEBUG("CMceMediaManager::ReleaseSink(), Entry ");
       
  2651     MCEMM_DEBUG_DVALUE("  SessionID", aStream.SessionId() );
       
  2652     MCEMM_DEBUG_DVALUE("  LinkID", aStream.LinkId() );
       
  2653     MCEMM_DEBUG_DVALUE("  StreamID", aStream.Id() );
       
  2654     MCEMM_DEBUG_DVALUE("  EndpointID", aEndpointId );
       
  2655 
       
  2656     TInt err = 
       
  2657         iMccInterface->RemoveDataSink( aStream.SessionId(), 
       
  2658                                        aStream.LinkId(),
       
  2659                                        aStream.Id(),
       
  2660                                        aEndpointId );
       
  2661                                        
       
  2662     MCEMM_DEBUG_DVALUE("CMceMediaManager::ReleaseSink(), Exit. ", err );
       
  2663 
       
  2664     return err;    
       
  2665     }
       
  2666 
       
  2667 // ---------------------------------------------------------
       
  2668 // CMceMediaManager::ReleaseSource
       
  2669 // ---------------------------------------------------------   
       
  2670 //
       
  2671 TInt CMceMediaManager::ReleaseSource( CMceSrvStream& aStream,
       
  2672                                       TUint32 aEndpointId )
       
  2673     {
       
  2674     MCEMM_DEBUG("CMceMediaManager::ReleaseSource(), Entry ");
       
  2675     MCEMM_DEBUG_DVALUE("  SessionID", aStream.SessionId() );
       
  2676     MCEMM_DEBUG_DVALUE("  LinkID", aStream.LinkId() );
       
  2677     MCEMM_DEBUG_DVALUE("  StreamID", aStream.Id() );
       
  2678     MCEMM_DEBUG_DVALUE("  EndpointID", aEndpointId );
       
  2679 
       
  2680     TInt err = 
       
  2681         iMccInterface->RemoveDataSource( aStream.SessionId(), 
       
  2682                                        aStream.LinkId(),
       
  2683                                        aStream.Id(),
       
  2684                                        aEndpointId );
       
  2685                                        
       
  2686     MCEMM_DEBUG_DVALUE("CMceMediaManager::ReleaseSource(), Exit. ", err );
       
  2687     
       
  2688     return err;    
       
  2689     }
       
  2690     
       
  2691 
       
  2692 // ---------------------------------------------------------
       
  2693 // CMceMediaManager::CleanupL
       
  2694 // ---------------------------------------------------------   
       
  2695 //
       
  2696 void CMceMediaManager::CleanupL( CMceComSession& aSession )
       
  2697     {
       
  2698 
       
  2699     MCEMM_DEBUG("CMceMediaManager::CleanupL(), Entry ");
       
  2700     CMceSrvStream* stream = NULL;
       
  2701 
       
  2702     if ( aSession.AnswerType() == KMceNegotiationAnswerTypeFinal )
       
  2703         {
       
  2704         // check if non-local media was rejected, if yes then stop the stream
       
  2705 
       
  2706         TMceSrvStreamIterator rejects( aSession.MccStreams(), 
       
  2707                                        TMceSrvStreamIterator::EReceive );
       
  2708 
       
  2709         //stop all started downgraded receive streams, which are downgraded by the answer
       
  2710         while( rejects.Next( stream, CMceSrvStream::EStarted, 
       
  2711                                      TMceSrvStreamIterator::GreaterOrEqualMatch ) )
       
  2712             {
       
  2713             if ( !stream->Data().IsEnabled() )
       
  2714                 {
       
  2715                 MCEMM_DEBUG_STREAM( "CMceMediaManager::CleanupL(): \
       
  2716     synchronizing downgraded stream", *stream );
       
  2717                 SynchronizeMccStreamL( *stream, aSession.NegotiationState().Role() );
       
  2718                 }
       
  2719             }
       
  2720                                        
       
  2721         
       
  2722         TMceSrvStreamIterator iterator( aSession.MccStreams(), 
       
  2723                                         TMceSrvStreamIterator::ELocal );
       
  2724         
       
  2725         //cleanup rejected media
       
  2726         while( iterator.Next( stream, TMceSrvStreamIterator::ExactReverseMatch ) )
       
  2727             {
       
  2728             if ( stream->Data().RemoteMediaPort() == 0 )
       
  2729                 {
       
  2730                 MCEMM_DEBUG_STREAM( "CMceMediaManager::CleanupL(): \
       
  2731     stream rejected. Disposing stream", *stream );
       
  2732                 CMceComMediaStream* media = &stream->Data();
       
  2733                 DisposeMediaStreamL( media );
       
  2734                 iterator.Reset();
       
  2735                 }
       
  2736             }
       
  2737 
       
  2738         iterator.Reset();
       
  2739         
       
  2740         //cleanup rejected codecs
       
  2741         while( iterator.Next( stream, TMceSrvStreamIterator::ExactReverseMatch ) )
       
  2742             {
       
  2743             if ( !stream->Codec().iIsNegotiated )
       
  2744                 {
       
  2745                 MCEMM_DEBUG_STREAM( "CMceMediaManager::CleanupL(): \
       
  2746     codec rejected. Disposing codec", *stream );
       
  2747                 CMceComCodec* codec = &stream->Codec();
       
  2748                 DisposeCodecL( codec );
       
  2749                 iterator.Reset();
       
  2750                 }
       
  2751             }
       
  2752         }
       
  2753      
       
  2754     for ( TInt i = 0; i < aSession.Streams().Count(); i++ )
       
  2755         {    
       
  2756         // First codec of send streams is always enabled automatically,
       
  2757         // if such codec is removed/changed because of negotiation, first
       
  2758         // one of the selected codecs is enabled.
       
  2759         //
       
  2760         MCEMM_DEBUG("CMceMediaManager::CleanupL(), updating default codecs ");
       
  2761         
       
  2762         CMceComMediaStream* sendStream = aSession.Streams()[ i ]->SendStream();
       
  2763         if ( sendStream )
       
  2764             {
       
  2765             sendStream->UpdateDefaultCodecL();
       
  2766             }
       
  2767         }
       
  2768 
       
  2769     
       
  2770     MCEMM_DEBUG("CMceMediaManager::CleanupL(), Exit ");
       
  2771 
       
  2772     }
       
  2773 
       
  2774 
       
  2775 // ---------------------------------------------------------
       
  2776 // CMceMediaManager::DisposeMediaStreamL
       
  2777 // ---------------------------------------------------------   
       
  2778 //
       
  2779 void CMceMediaManager::DisposeMediaStreamL( CMceComMediaStream* aStream )
       
  2780     {
       
  2781     __ASSERT_ALWAYS( aStream, User::Leave( KErrArgument ) );
       
  2782     
       
  2783     CMceSrvStream* stream = NULL;
       
  2784     CMceComSession& session = *aStream->Session();
       
  2785 
       
  2786     //find all mcc streams related to stream and
       
  2787     //and remove mcc streams
       
  2788     TMceSrvStreamIterator removed( session.MccStreams(), 
       
  2789                                    *aStream );
       
  2790     while( removed.Next( stream ) )
       
  2791         {
       
  2792         MCEMM_DEBUG_DVALUE("CMceMediaManager::DisposeMediaStreamL(): \
       
  2793 stopping and removing stream", stream->Id() );
       
  2794         StopMccStream( *stream );
       
  2795         removed.Remove( session.MccStreams() );
       
  2796         delete stream;
       
  2797         stream = NULL;
       
  2798         }
       
  2799     //make it inactive        
       
  2800     aStream->Enable( EFalse, ETrue );
       
  2801 
       
  2802     //if not found strem is bounded stream        
       
  2803     TInt streamIndex = session.Streams().Find( aStream );
       
  2804     
       
  2805     if ( streamIndex >= 0 && !aStream->iLinkedStream )
       
  2806         {
       
  2807         session.Streams().Remove( streamIndex );
       
  2808         delete aStream;
       
  2809         }
       
  2810         
       
  2811     }
       
  2812 
       
  2813 
       
  2814 // ---------------------------------------------------------
       
  2815 // CMceMediaManager::DisposeCodecL
       
  2816 // ---------------------------------------------------------   
       
  2817 //
       
  2818 void CMceMediaManager::DisposeCodecL( CMceComCodec* aCodec )
       
  2819     {
       
  2820     if ( aCodec )
       
  2821         {
       
  2822         CMceSrvStream* stream = NULL;
       
  2823         CMceComSession& session = *aCodec->Stream()->Session();
       
  2824 
       
  2825         MCEMM_DEBUG_SVALUE("CMceMediaManager::DisposeCodecL(): \
       
  2826     about to remove codec", aCodec->iSdpName );
       
  2827         
       
  2828         //find all mcc streams related to stream and
       
  2829         //and remove mcc streams
       
  2830         TMceSrvStreamIterator removed( session.MccStreams(), 
       
  2831                                        *aCodec );
       
  2832         while( removed.Next( stream ) )
       
  2833             {
       
  2834             MCEMM_DEBUG_STREAM( "CMceMediaManager::DisposeCodecL(): \
       
  2835     stopping and removing stream", *stream );
       
  2836 
       
  2837             StopMccStream( *stream );
       
  2838             removed.Remove( session.MccStreams() );
       
  2839             
       
  2840             // dispose also associated local streams                                 
       
  2841             TMceSrvStreamIterator associatedLocalStreams( 
       
  2842                 session.MccStreams(), stream->Source().Data(), 
       
  2843                 ETrue, TMceSrvStreamIterator::ELocal, aCodec );
       
  2844             CMceSrvStream* associatedLocalStream = NULL;
       
  2845             while( associatedLocalStreams.Next( associatedLocalStream ) )
       
  2846                 {
       
  2847                 MCEMM_DEBUG_STREAM( "CMceMediaManager::DisposeCodecL(): \
       
  2848     stopping and removing associated local stream", *associatedLocalStream );
       
  2849     
       
  2850                 StopMccStream( *associatedLocalStream );
       
  2851                 associatedLocalStreams.Remove( session.MccStreams() );
       
  2852                 delete associatedLocalStream;
       
  2853                 associatedLocalStream = NULL;
       
  2854                 }
       
  2855             delete stream;
       
  2856             stream = NULL;
       
  2857             }
       
  2858         MCEMM_DEBUG_SVALUE("CMceMediaManager::DisposeCodecL(): \
       
  2859     removing codec", aCodec->iSdpName );
       
  2860     
       
  2861         CMceComCodec* boundCodec = NULL;
       
  2862         if ( aCodec->Stream()->BoundStream() )
       
  2863             {
       
  2864             boundCodec = aCodec->Stream()->BoundStreamL().FindCodecL( *aCodec );
       
  2865             }
       
  2866             
       
  2867         aCodec->Stream()->RemoveCodecL( aCodec );
       
  2868         
       
  2869         DisposeCodecL( boundCodec );
       
  2870         
       
  2871         MCEMM_DEBUG("CMceMediaManager::DisposeCodecL(), done ");
       
  2872         }
       
  2873     }
       
  2874 
       
  2875 
       
  2876 // ---------------------------------------------------------
       
  2877 // CMceMediaManager::AdjustMccStreamL
       
  2878 // ---------------------------------------------------------   
       
  2879 //
       
  2880 void CMceMediaManager::AdjustMccStreamL( CMceSrvStream& aStream )
       
  2881     {
       
  2882 
       
  2883     MCEMM_DEBUG("CMceMediaManager::AdjustMccStreamL(), Entry ");
       
  2884     
       
  2885     CMceComCodec* bidirectional = DoAdjustMccStreamL( aStream );
       
  2886     
       
  2887     if ( bidirectional )
       
  2888         {
       
  2889         CMceSrvStream* stream = NULL;
       
  2890         TMceSrvStreamIterator streams( aStream.Codec().Stream()->Session()->MccStreams(), 
       
  2891                                        *bidirectional );
       
  2892         while( streams.Next( stream ) )
       
  2893             {
       
  2894             DoAdjustMccStreamL( *stream );
       
  2895             }
       
  2896         }
       
  2897         
       
  2898     MCEMM_DEBUG("CMceMediaManager::AdjustMccStreamL(), Exit ");
       
  2899     
       
  2900     }
       
  2901 
       
  2902 
       
  2903 
       
  2904 // ---------------------------------------------------------
       
  2905 // CMceMediaManager::ValidateMccStreamL
       
  2906 // ---------------------------------------------------------   
       
  2907 //
       
  2908 void CMceMediaManager::ValidateMccStreamL( CMceSrvStream& aStream )
       
  2909     {
       
  2910     
       
  2911     MCEMM_DEBUG("CMceMediaManager::ValidateMccStreamL(), Entry ");
       
  2912     
       
  2913     __ASSERT_ALWAYS( aStream.State() != CMceSrvStream::EAdopted,
       
  2914                      User::Leave( KErrArgument ) );
       
  2915     
       
  2916     //if valid
       
  2917     if ( aStream.Validate() )
       
  2918         {
       
  2919         return;
       
  2920         }
       
  2921          
       
  2922     TMceNegotiationRole role = EMceRoleOfferer;
       
  2923             
       
  2924     CMccCodecInformation* codec = NULL;
       
  2925     
       
  2926     if ( !aStream.IsMccPrepared() )
       
  2927         {
       
  2928         role = EMceRoleAnswerer;
       
  2929         //create codec information
       
  2930         CMccCodecInformationFactory* codecFactory = 
       
  2931             CMccCodecInformationFactory::NewL();
       
  2932         CleanupStack::PushL( codecFactory );
       
  2933         
       
  2934         codec = 
       
  2935             codecFactory->CreateCodecInformationL( aStream.Codec().iSdpName );
       
  2936 
       
  2937         CleanupStack::PopAndDestroy( codecFactory );
       
  2938             
       
  2939         }
       
  2940     else
       
  2941         {
       
  2942         //get codec
       
  2943         codec = 
       
  2944             iMccInterface->CodecL(         
       
  2945                     aStream.SessionId(),
       
  2946                     aStream.LinkId(),
       
  2947                     aStream.Id() );
       
  2948         }
       
  2949         
       
  2950     CleanupStack::PushL( codec );
       
  2951         
       
  2952     //validate codec
       
  2953     aStream.Codec().MccValidateL( *codec, aStream, role );
       
  2954 
       
  2955     CleanupStack::PopAndDestroy( codec );
       
  2956     
       
  2957     MCEMM_DEBUG("CMceMediaManager::ValidateMccStreamL(), Exit ");
       
  2958     }
       
  2959 
       
  2960 
       
  2961 
       
  2962 // ---------------------------------------------------------
       
  2963 // CMceMediaManager::PrepareUpdateL 
       
  2964 // ---------------------------------------------------------    
       
  2965 //
       
  2966 void CMceMediaManager::PrepareUpdateL( CMceSdpSession& aSession )
       
  2967     {
       
  2968     MCEMM_DEBUG("CMceMediaManager::PrepareUpdateL(), Entry ");
       
  2969 
       
  2970     CMceComSession* session = aSession.MediaSession();
       
  2971     CMceComSession* backup = aSession.Backup();
       
  2972     
       
  2973     TInt action = RequireSignallingL( *session, *backup );
       
  2974     
       
  2975     //do local update
       
  2976     if ( action != KMceRequiresSignalling )
       
  2977         {
       
  2978         MCEMM_DEBUG("CMceMediaManager::PrepareUpdateL(): \
       
  2979 no need for new mcc session. Doing merge"); 
       
  2980         session->Merge( *backup );
       
  2981         }
       
  2982      else if( session )
       
  2983      	{
       
  2984 	     if( session->iCodecSelection == KMceCodecSelectionMerge )
       
  2985 	     	{
       
  2986 	     	session->Merge( *backup );
       
  2987 	     	}
       
  2988      	}
       
  2989      	
       
  2990 
       
  2991     aSession.SignallingRequired() = action;
       
  2992     
       
  2993     MCEMM_DEBUG("CMceMediaManager::PrepareUpdateL(), Exit ");
       
  2994     
       
  2995     }
       
  2996 
       
  2997 
       
  2998 // ---------------------------------------------------------
       
  2999 // CMceMediaManager::RequireSignallingL 
       
  3000 // ---------------------------------------------------------    
       
  3001 //
       
  3002 TInt CMceMediaManager::RequireSignallingL( 
       
  3003                                   CMceComSession& aSession,
       
  3004                                   CMceComSession& aBackup )
       
  3005  
       
  3006     {
       
  3007     MCEMM_DEBUG("CMceMediaManager::RequireSignallingL(), Entry ");
       
  3008 
       
  3009     TInt action = KMceNoSignalling;
       
  3010 
       
  3011     TMceSrvStreamIterator streams( 
       
  3012                         aBackup.MccStreams(), 
       
  3013                         TMceSrvStreamIterator::ESendOrReceive );
       
  3014                         
       
  3015     TMceSrvStreamIterator updates( 
       
  3016                         aSession.MccStreams(),
       
  3017                         TMceSrvStreamIterator::ESendOrReceive );
       
  3018     
       
  3019     CMceSrvStream* update = NULL;
       
  3020     CMceSrvStream* stream = NULL;
       
  3021     //intersection i.e. streams both in update and original
       
  3022     while( !action && 
       
  3023             updates.NextIntersect( update, streams, stream ) )
       
  3024         {
       
  3025         //current codec
       
  3026         if ( stream->IsMccPrepared() )
       
  3027             {
       
  3028             
       
  3029             CMccCodecInformation* codec = 
       
  3030                 iMccInterface->CodecL( stream->SessionId(),
       
  3031                                        stream->LinkId(),
       
  3032                                        stream->Id() );
       
  3033             
       
  3034             CleanupStack::PushL( codec );
       
  3035             
       
  3036             //updated codec
       
  3037             CMccCodecInformation* codecUpdate = 
       
  3038                 CreateMccCodecLC( *update, EMceRoleOfferer );
       
  3039                                           
       
  3040             action = update->RequireSignalling( *stream,
       
  3041                                                 *codec,
       
  3042                                                 *codecUpdate );
       
  3043                                                    
       
  3044             CleanupStack::PopAndDestroy( codecUpdate );
       
  3045             CleanupStack::PopAndDestroy( codec );
       
  3046             }
       
  3047         else 
       
  3048             {
       
  3049             action = stream->RequireSignalling( aSession.MccStreams() );
       
  3050             }
       
  3051         }
       
  3052 
       
  3053     updates.Reset();
       
  3054     //added to update
       
  3055     while( !action && 
       
  3056             updates.NextComplement( update, streams ) )
       
  3057         {
       
  3058         action = update->RequireSignalling( aSession.MccStreams() );
       
  3059         }
       
  3060 
       
  3061     streams.Reset();
       
  3062     //removed from update
       
  3063     while( !action && 
       
  3064             streams.NextComplement( stream, updates ) )
       
  3065                 
       
  3066         {
       
  3067         action = stream->RequireSignalling( aSession.MccStreams() );
       
  3068         }
       
  3069 
       
  3070         
       
  3071     MCEMM_DEBUG("CMceMediaManager::RequireSignallingL(), Exit ");
       
  3072     return action;
       
  3073             
       
  3074     }
       
  3075 
       
  3076 
       
  3077 // ---------------------------------------------------------
       
  3078 // CMceMediaManager::SynchronizeMccStreamL 
       
  3079 // ---------------------------------------------------------    
       
  3080 //
       
  3081 void CMceMediaManager::SynchronizeMccStreamL( 
       
  3082     CMceSrvStream& aStream, 
       
  3083     TMceNegotiationRole aRole,
       
  3084     TBool aSyncCodecOnly )
       
  3085     {
       
  3086     MCEMM_DEBUG("CMceMediaManager::SynchronizeMccStreamL(), Entry ");
       
  3087     
       
  3088     if ( !aStream.SynchronizeL() )
       
  3089         {
       
  3090     
       
  3091         CMccCodecInformation* codec = 
       
  3092             iMccInterface->CodecL( aStream.SessionId(),
       
  3093                                    aStream.LinkId(),
       
  3094                                    aStream.Id() );
       
  3095         CleanupStack::PushL( codec );
       
  3096         //re-populate codec with updated values
       
  3097         aStream.Codec().MccPopulateL( *codec, aStream, aRole );
       
  3098         
       
  3099         MCEMM_DEBUG("CMceMediaManager::SynchronizeMccStreamL(): \
       
  3100 re-setting codec");
       
  3101         
       
  3102         User::LeaveIfError( 
       
  3103             iMccInterface->SetCodec( 
       
  3104                     aStream.SessionId(),
       
  3105                     aStream.LinkId(),
       
  3106                     aStream.Id(),
       
  3107                     *codec ) );
       
  3108                     
       
  3109         CleanupStack::PopAndDestroy( codec );
       
  3110 
       
  3111         if ( !aSyncCodecOnly )
       
  3112             {
       
  3113             SynchronizeMccStreamL( aStream );
       
  3114             }
       
  3115         }
       
  3116         
       
  3117     MCEMM_DEBUG("CMceMediaManager::SynchronizeMccStreamL(), Exit ");
       
  3118     }
       
  3119     
       
  3120 // ---------------------------------------------------------
       
  3121 // CMceMediaManager::SynchronizeMccStreamL 
       
  3122 // ---------------------------------------------------------    
       
  3123 //
       
  3124 void CMceMediaManager::SynchronizeMccStreamL( 
       
  3125     CMceSrvStream& aStream, 
       
  3126     TUint32 aForceEnableEndpoint, 
       
  3127     TUint32 aForceDisableEndpoint )
       
  3128     {
       
  3129     MCEMM_DEBUG("CMceMediaManager::SynchronizeMccStreamL() two, Entry ");
       
  3130     
       
  3131     if ( !DoStartEndpointsL( aStream, aForceEnableEndpoint, aForceDisableEndpoint ) )
       
  3132         {
       
  3133         if ( !DoResumeEndpointsL( aStream, aForceEnableEndpoint ) )
       
  3134             {
       
  3135             DoPauseEndpointsL( aStream, aForceDisableEndpoint );
       
  3136             }
       
  3137         }
       
  3138         
       
  3139     MCEMM_DEBUG_STREAM( "CMceMediaManager::SynchronizeMccStreamL() two: \
       
  3140 syncronized stream", aStream );
       
  3141 
       
  3142     MCEMM_DEBUG("CMceMediaManager::SynchronizeMccStreamL() two, Exit ");
       
  3143     }
       
  3144     
       
  3145 // ---------------------------------------------------------
       
  3146 // CMceMediaManager::ReuseLink
       
  3147 // ---------------------------------------------------------    
       
  3148 //
       
  3149 TBool CMceMediaManager::ReuseLink( CMceSrvStream& aStream )
       
  3150     {
       
  3151     TBool inUse = EFalse;
       
  3152 
       
  3153     CMceComSession* session = aStream.Data().Session();
       
  3154     CMceSrvStream* stream = NULL;
       
  3155     
       
  3156     TMceSrvStreamIterator 
       
  3157         sourceMatchStreams( session->MccStreams(), 
       
  3158                             aStream.Source().Data(),
       
  3159                             KMceComUseProxyMatch );
       
  3160 
       
  3161     TMceSrvStreamIterator 
       
  3162         sinkMatchStreams( session->MccStreams(), 
       
  3163                           aStream.Sink().Data(),
       
  3164                           KMceComUseProxyMatch );
       
  3165                                    
       
  3166     while( !inUse && sourceMatchStreams.Next( stream ) )
       
  3167         {
       
  3168         if ( ( aStream.Data().iStreamType == CMceComMediaStream::ELocalStream || 
       
  3169                aStream.Source().Data().Type() == KMceRTPSource ) &&
       
  3170                stream->Data().iLinkId != KMceNotAssigned )
       
  3171             {
       
  3172             inUse = ETrue;
       
  3173             aStream.Data().iLinkId = stream->Data().iLinkId;
       
  3174             }
       
  3175         }
       
  3176 
       
  3177     while( !inUse && sinkMatchStreams.Next( stream ) )
       
  3178         {
       
  3179         if ( ( aStream.Data().iStreamType == CMceComMediaStream::ELocalStream || 
       
  3180                aStream.Sink().Data().Type() == KMceRTPSink ) &&
       
  3181                stream->Data().iLinkId != KMceNotAssigned )
       
  3182             {
       
  3183             inUse = ETrue;
       
  3184             aStream.Data().iLinkId = stream->Data().iLinkId;
       
  3185             }
       
  3186         }
       
  3187     
       
  3188     return inUse;
       
  3189     
       
  3190     }
       
  3191     
       
  3192 // ---------------------------------------------------------
       
  3193 // CMceMediaManager::ReuseSource
       
  3194 // ---------------------------------------------------------    
       
  3195 //
       
  3196 TBool CMceMediaManager::ReuseSource( CMceSrvStream& aStream )
       
  3197     {
       
  3198     TBool inUse = EFalse;
       
  3199     
       
  3200     if ( aStream.Source().Reusable( aStream ) )
       
  3201         {
       
  3202         CMceComSession* session = aStream.Data().Session();
       
  3203         CMceSrvStream* stream = NULL;
       
  3204         
       
  3205         TMceSrvStreamIterator streams( session->MccStreams(), 
       
  3206                                        aStream.Source().Data(),
       
  3207                                        KMceComUseProxyMatch );
       
  3208                                        
       
  3209         while( !inUse && streams.Next( stream ) )
       
  3210             {
       
  3211             if ( stream->Source().Id() != KMceNotAssigned )
       
  3212                 {
       
  3213                 inUse = ETrue;
       
  3214                 aStream.Id() = stream->Id();
       
  3215                 aStream.Source().Id() = stream->Source().Id();
       
  3216                 }
       
  3217             }
       
  3218         }
       
  3219         
       
  3220     return inUse;
       
  3221     
       
  3222     }
       
  3223 
       
  3224 // ---------------------------------------------------------
       
  3225 // CMceMediaManager::ReuseSink
       
  3226 // ---------------------------------------------------------    
       
  3227 //
       
  3228 TBool CMceMediaManager::ReuseSink( CMceSrvStream& aStream )
       
  3229     {
       
  3230     TBool inUse = EFalse;
       
  3231 
       
  3232     if ( aStream.Sink().Reusable( aStream ) )
       
  3233         {
       
  3234         CMceComSession* session = aStream.Data().Session();
       
  3235         CMceSrvStream* stream = NULL;
       
  3236         
       
  3237         TMceSrvStreamIterator streams( session->MccStreams(), 
       
  3238                                        aStream.Sink().Data(),
       
  3239                                        KMceComUseProxyMatch );
       
  3240                                        
       
  3241         while( !inUse && streams.Next( stream ) )
       
  3242             {
       
  3243             if ( stream->Sink().Id() != KMceNotAssigned )
       
  3244                 {
       
  3245                 inUse = ETrue;
       
  3246                 aStream.Id() = stream->Id();
       
  3247                 aStream.Sink().Id() = stream->Sink().Id();
       
  3248                 }
       
  3249             }
       
  3250         }
       
  3251         
       
  3252     return inUse;
       
  3253     
       
  3254     }
       
  3255 
       
  3256 // ---------------------------------------------------------
       
  3257 // CMceMediaManager::SetMccParameterL 
       
  3258 // ---------------------------------------------------------    
       
  3259 //
       
  3260 void CMceMediaManager::SetMccParameterL( TUint32 aParam,
       
  3261                                          const TDesC8& aValue ) const
       
  3262     {
       
  3263     
       
  3264     User::LeaveIfError( 
       
  3265         iMccInterface->SetParameter( 0, 0, 0, 0, aParam, aValue ) );
       
  3266     
       
  3267     }
       
  3268 
       
  3269 // ---------------------------------------------------------
       
  3270 // CMceMediaManager::GetMccParameterL 
       
  3271 // ---------------------------------------------------------    
       
  3272 //
       
  3273 void CMceMediaManager::GetMccParameterL( TUint32 aParam,
       
  3274                                          TDes8& aValue ) const
       
  3275     {
       
  3276     User::LeaveIfError( 
       
  3277         iMccInterface->GetParameter( 0, 0, 0, 0, aParam, aValue ) );
       
  3278     }
       
  3279     
       
  3280 
       
  3281 // ---------------------------------------------------------
       
  3282 // CMceMediaManager::SetMccParameterL 
       
  3283 // ---------------------------------------------------------    
       
  3284 //
       
  3285 void CMceMediaManager::SetMccParameterL( const CMceComMediaSink& aMediaSink,
       
  3286                                         TUint32 aParam,
       
  3287                                         const TDesC8& aValue,
       
  3288                                         TBool aAllowNonPrepared ) const
       
  3289                                                 
       
  3290     { 
       
  3291     CMceComSession* session = aMediaSink.MediaStream()->Session();
       
  3292     
       
  3293     TMceSrvStreamIterator streams( session->MccStreams(), aMediaSink );
       
  3294     CMceSrvStream* stream = NULL;
       
  3295     TBool done = EFalse;
       
  3296     
       
  3297     while( !done && streams.Next( stream ) )
       
  3298         {
       
  3299         if ( stream->IsMccPrepared() || aAllowNonPrepared )
       
  3300             {
       
  3301             MCEMM_DEBUG_STREAM( "CMceMediaManager::SetMccParameterL(): \
       
  3302 setting parameter of stream", *stream );
       
  3303             User::LeaveIfError( 
       
  3304                 iMccInterface->SetParameter( stream->SessionId(),
       
  3305                                               stream->LinkId(),
       
  3306                                               stream->Id(),
       
  3307                                               stream->Sink().Id(),
       
  3308                                               aParam,
       
  3309                                               aValue ) );
       
  3310             }
       
  3311         else
       
  3312             {
       
  3313             SetMccParameterL( aParam, aValue );
       
  3314             }
       
  3315         done = ETrue;
       
  3316         }
       
  3317         
       
  3318     }
       
  3319 
       
  3320 // ---------------------------------------------------------
       
  3321 // CMceMediaManager::SetMccParameterL 
       
  3322 // ---------------------------------------------------------    
       
  3323 //
       
  3324 void CMceMediaManager::SetMccParameterL( const CMceComMediaSource& aMediaSource,
       
  3325                                          TUint32 aParam,
       
  3326                                          const TDesC8& aValue,
       
  3327                                          TBool aAllowNonPrepared ) const
       
  3328                                                 
       
  3329     { 
       
  3330     
       
  3331     CMceComSession* session = aMediaSource.MediaStream()->Session();
       
  3332     
       
  3333     TMceSrvStreamIterator streams( session->MccStreams(), aMediaSource );
       
  3334     CMceSrvStream* stream = NULL;
       
  3335     TBool done = EFalse;
       
  3336     
       
  3337     while( !done && streams.Next( stream ) )
       
  3338         {
       
  3339         if ( stream->IsMccPrepared() || aAllowNonPrepared )
       
  3340             {
       
  3341             MCEMM_DEBUG_STREAM( "CMceMediaManager::SetMccParameterL(): \
       
  3342 setting parameter of stream", *stream );
       
  3343             User::LeaveIfError( 
       
  3344                 iMccInterface->SetParameter( stream->SessionId(),
       
  3345                                               stream->LinkId(),
       
  3346                                               stream->Id(),
       
  3347                                               stream->Source().Id(),
       
  3348                                               aParam,
       
  3349                                               aValue ) );
       
  3350             }
       
  3351         else
       
  3352             {
       
  3353             SetMccParameterL( aParam, aValue );
       
  3354             }
       
  3355         done = ETrue;
       
  3356         }
       
  3357     
       
  3358     }
       
  3359 
       
  3360     
       
  3361 
       
  3362 
       
  3363 // ---------------------------------------------------------
       
  3364 // CMceMediaManager::GetMccParameterL 
       
  3365 // ---------------------------------------------------------    
       
  3366 //
       
  3367 void CMceMediaManager::GetMccParameterL( const CMceComMediaSink& aMediaSink,
       
  3368                                          TUint32 aParam,
       
  3369                                          TDes8& aValue,
       
  3370                                          TBool aAllowNonPrepared ) const
       
  3371                                                 
       
  3372     { 
       
  3373     
       
  3374     CMceComSession* session = aMediaSink.MediaStream()->Session();
       
  3375     
       
  3376     TMceSrvStreamIterator streams( session->MccStreams(), aMediaSink );
       
  3377     CMceSrvStream* stream = NULL;
       
  3378     TBool done = EFalse;
       
  3379     
       
  3380     while( !done && streams.Next( stream ) )
       
  3381         {
       
  3382         if ( stream->IsMccPrepared() || aAllowNonPrepared )
       
  3383             {
       
  3384             MCEMM_DEBUG_STREAM( "CMceMediaManager::GetMccParameterL(): \
       
  3385 getting parameter of stream", *stream );
       
  3386             User::LeaveIfError( 
       
  3387                 iMccInterface->GetParameter( stream->SessionId(),
       
  3388                                               stream->LinkId(),
       
  3389                                               stream->Id(),
       
  3390                                               stream->Sink().Id(),
       
  3391                                               aParam,
       
  3392                                               aValue ) );
       
  3393             }
       
  3394         else
       
  3395             {
       
  3396             GetMccParameterL( aParam, aValue );
       
  3397             }
       
  3398         done = ETrue;
       
  3399         }
       
  3400     }
       
  3401 
       
  3402 // ---------------------------------------------------------
       
  3403 // CMceMediaManager::GetMccParameterL 
       
  3404 // ---------------------------------------------------------    
       
  3405 //
       
  3406 void CMceMediaManager::GetMccParameterL( const CMceComMediaSource& aMediaSource,
       
  3407                                          TUint32 aParam,
       
  3408                                          TDes8& aValue,
       
  3409                                          TBool aAllowNonPrepared ) const
       
  3410                                                 
       
  3411     { 
       
  3412     
       
  3413     CMceComSession* session = aMediaSource.MediaStream()->Session();
       
  3414     
       
  3415     TMceSrvStreamIterator streams( session->MccStreams(), aMediaSource );
       
  3416     CMceSrvStream* stream = NULL;
       
  3417     TBool done = EFalse;
       
  3418     
       
  3419     while( !done && streams.Next( stream ) )
       
  3420         {
       
  3421         if ( stream->IsMccPrepared() || aAllowNonPrepared )
       
  3422             {
       
  3423             MCEMM_DEBUG_STREAM( "CMceMediaManager::GetMccParameterL(): \
       
  3424 getting parameter of stream", *stream );
       
  3425             User::LeaveIfError( 
       
  3426                 iMccInterface->GetParameter( stream->SessionId(),
       
  3427                                               stream->LinkId(),
       
  3428                                               stream->Id(),
       
  3429                                               stream->Source().Id(),
       
  3430                                               aParam,
       
  3431                                               aValue ) );
       
  3432             
       
  3433             }
       
  3434         else
       
  3435             {
       
  3436             GetMccParameterL( aParam, aValue );
       
  3437             }
       
  3438         done = ETrue;
       
  3439         }
       
  3440     
       
  3441     }
       
  3442 
       
  3443 
       
  3444 // ---------------------------------------------------------
       
  3445 // CMceMediaManager::UpdateMccSourceL 
       
  3446 // --------------------------------------------------------- 
       
  3447 //   
       
  3448 void CMceMediaManager::UpdateMccSourceL( CMceComCameraSource& aMediaSource )
       
  3449     {
       
  3450     CMceComSession* session = aMediaSource.MediaStream()->Session();
       
  3451     
       
  3452     TMceSrvStreamIterator streams( session->MccStreams(), aMediaSource );
       
  3453     CMceSrvStream* stream = NULL;
       
  3454     TBool done = EFalse;
       
  3455     
       
  3456     while( !done && streams.Next( stream ) )
       
  3457         {
       
  3458         CMceComCodec& codec = stream->Codec();
       
  3459         
       
  3460         if ( stream->IsMccPrepared() )
       
  3461             {
       
  3462             MCEMM_DEBUG_STREAM( "CMceMediaManager::UpdateMccSourceL(): \
       
  3463 updating data source of stream", *stream );
       
  3464             User::LeaveIfError( 
       
  3465                 iMccInterface->UpdateDataSource( stream->SessionId(),
       
  3466                                                  stream->LinkId(),
       
  3467                                                  stream->Id(),
       
  3468                                                  stream->Source().Id(),
       
  3469                                                  aMediaSource.InitParamL( codec ) ) );
       
  3470             done = ETrue;
       
  3471             }
       
  3472         }
       
  3473     }
       
  3474 
       
  3475 /*
       
  3476 ** From MMccCtrlObserver ***
       
  3477 */
       
  3478 
       
  3479 // ---------------------------------------------------------
       
  3480 // CMceMediaManager::MccMediaLinkCreated 
       
  3481 // ---------------------------------------------------------    
       
  3482 //
       
  3483 void CMceMediaManager::MccMediaLinkCreated( TUint32 aSessionId,
       
  3484                                             TUint32 aLinkId,
       
  3485                                             const TDesC8& aNetSettings )
       
  3486 
       
  3487     {
       
  3488     MCEMM_DEBUG("CMceMediaManager::MccMediaLinkCreated(), Entry ");
       
  3489     MCEMM_DEBUG_DVALUE("  SessionID", aSessionId );
       
  3490     MCEMM_DEBUG_DVALUE("  LinkID", aLinkId );
       
  3491 
       
  3492     CMceComSession* session = Session( aSessionId );
       
  3493     if ( session )
       
  3494         {
       
  3495         TMceMccComEvent event( KMccLinkCreated,
       
  3496                                aLinkId, 
       
  3497                                0, 
       
  3498                                0 );
       
  3499 
       
  3500         event.SetDataDesC( aNetSettings );
       
  3501         
       
  3502         TRAPD( err, 
       
  3503             session->NegotiationState().MccLinkCreatedL( event ) );
       
  3504             
       
  3505         if( err != KErrNone )
       
  3506             {
       
  3507             MCEMM_DEBUG_DVALUE("Error occured!, error", err );
       
  3508             session->NegotiationState().MccError( err, event );
       
  3509             }
       
  3510         }
       
  3511     else
       
  3512         {
       
  3513         MCEMM_DEBUG("No Session!");
       
  3514         iObserver->MediaError( KErrGeneral );
       
  3515         }
       
  3516         
       
  3517     MCEMM_DEBUG("CMceMediaManager::MccMediaLinkCreated(), Exit ");
       
  3518         
       
  3519     }
       
  3520 
       
  3521     
       
  3522 // ---------------------------------------------------------
       
  3523 // CMceMediaManager::MccMediaPrepared 
       
  3524 // ---------------------------------------------------------    
       
  3525 //
       
  3526 void CMceMediaManager::MccMediaPrepared( TUint32 aSessionId,
       
  3527                                          TUint32 aLinkId,
       
  3528                                          TUint32 aStreamId,
       
  3529                                          TUint32 aSinkSourceId )
       
  3530     {
       
  3531     MCEMM_DEBUG("CMceMediaManager::MccMediaPrepared(), Entry ");
       
  3532     MCEMM_DEBUG_DVALUE("  SessionID", aSessionId );
       
  3533     MCEMM_DEBUG_DVALUE("  LinkID", aLinkId );
       
  3534     MCEMM_DEBUG_DVALUE("  StreamID", aStreamId );
       
  3535     MCEMM_DEBUG_DVALUE("  EndpointID", aSinkSourceId );
       
  3536 
       
  3537     CMceComSession* session = Session( aSessionId );
       
  3538     if ( session )
       
  3539         {
       
  3540         TMceMccComEvent event( KMccStreamPrepared,
       
  3541                                aLinkId, 
       
  3542                                aStreamId, 
       
  3543                                aSinkSourceId );
       
  3544         
       
  3545         TRAPD( err, 
       
  3546             session->NegotiationState().MccMediaPreparedL( event ) );
       
  3547             
       
  3548         if( err != KErrNone )
       
  3549             {
       
  3550             MCEMM_DEBUG_DVALUE("CMceMediaManager::MccMediaPrepared(): \
       
  3551 Error occured!, error", err );
       
  3552             session->NegotiationState().MccError( err, event );
       
  3553             }
       
  3554         }
       
  3555     else
       
  3556         {
       
  3557         MCEMM_DEBUG("No Session!");
       
  3558         iObserver->MediaError( KErrGeneral );
       
  3559         }
       
  3560         
       
  3561     MCEMM_DEBUG("CMceMediaManager::MccMediaPrepared(), Exit ");
       
  3562         
       
  3563     }
       
  3564 
       
  3565 // ---------------------------------------------------------
       
  3566 // CMceMediaManager::MccMediaStarted
       
  3567 // --------------------------------------------------------- 
       
  3568 //   
       
  3569 void CMceMediaManager::MccMediaStarted( TUint32 aSessionId,
       
  3570                                         TUint32 aLinkId,     
       
  3571                                         TUint32 aStreamId,
       
  3572                                         TUint32 aSinkSourceId )
       
  3573     {
       
  3574     MCEMM_DEBUG("CMceMediaManager::MccMediaStarted(), Entry ");
       
  3575     MCEMM_DEBUG_DVALUE("  SessionID", aSessionId );
       
  3576     MCEMM_DEBUG_DVALUE("  LinkID", aLinkId );
       
  3577     MCEMM_DEBUG_DVALUE("  StreamID", aStreamId );
       
  3578     MCEMM_DEBUG_DVALUE("  EndpointID", aSinkSourceId );
       
  3579 
       
  3580     CMceComSession* session = Session( aSessionId );
       
  3581     if ( session )
       
  3582         {
       
  3583         TMceMccComEvent event( KMccStreamStarted,
       
  3584                                aLinkId, 
       
  3585                                aStreamId, 
       
  3586                                aSinkSourceId );
       
  3587 
       
  3588         TRAPD( err, 
       
  3589             session->NegotiationState().MccMediaStartedL( event ) );
       
  3590         if( err != KErrNone )
       
  3591             {
       
  3592             MCEMM_DEBUG_DVALUE("CMceMediaManager::MccMediaStarted(): \
       
  3593 Error occured!, error", err );
       
  3594             session->NegotiationState().MccError( err, event );
       
  3595             }
       
  3596         }
       
  3597     else
       
  3598         {
       
  3599         MCEMM_DEBUG("No Session!");
       
  3600         iObserver->MediaError( KErrGeneral );
       
  3601         }
       
  3602     MCEMM_DEBUG("CMceMediaManager::MccMediaStarted(), Exit ");
       
  3603     }
       
  3604         
       
  3605     
       
  3606 // ---------------------------------------------------------
       
  3607 // CMceMediaManager::MccMediaStopped
       
  3608 // --------------------------------------------------------- 
       
  3609 //      
       
  3610 void CMceMediaManager::MccMediaStopped( TUint32 aSessionId,
       
  3611                                         TUint32 aLinkId,     
       
  3612                                         TUint32 aStreamId,
       
  3613                                         TUint32 aSinkSourceId )
       
  3614     {
       
  3615     MCEMM_DEBUG("CMceMediaManager::MccMediaStopped(), Entry ");
       
  3616     MCEMM_DEBUG_DVALUE("  SessionID", aSessionId );
       
  3617     MCEMM_DEBUG_DVALUE("  LinkID", aLinkId );
       
  3618     MCEMM_DEBUG_DVALUE("  StreamID", aStreamId );
       
  3619     MCEMM_DEBUG_DVALUE("  EndpointID", aSinkSourceId );
       
  3620     
       
  3621     CMceComSession* session = Session( aSessionId );
       
  3622     if ( session )
       
  3623         {
       
  3624         TMceMccComEvent event( KMccStreamStopped,
       
  3625                                aLinkId, 
       
  3626                                aStreamId, 
       
  3627                                aSinkSourceId );
       
  3628     
       
  3629         CMceSrvStream::EventReceived( session->MccStreams(), event );
       
  3630     
       
  3631         }
       
  3632     else
       
  3633         {
       
  3634         MCEMM_DEBUG("No Session!");
       
  3635         iObserver->MediaError( KErrGeneral );
       
  3636         }
       
  3637     MCEMM_DEBUG("CMceMediaManager::MccMediaStopped(), Exit ");
       
  3638         
       
  3639     }
       
  3640 
       
  3641     
       
  3642 // ---------------------------------------------------------
       
  3643 // CMceMediaManager::MccMediaPaused
       
  3644 // ---------------------------------------------------------  
       
  3645 //      
       
  3646 void CMceMediaManager::MccMediaPaused( TUint32 aSessionId,
       
  3647                                        TUint32 aLinkId,
       
  3648                                        TUint32 aStreamId,
       
  3649                                        TUint32 aSinkSourceId )
       
  3650     {
       
  3651     MCEMM_DEBUG("CMceMediaManager::MccMediaPaused(), Entry ");
       
  3652     MCEMM_DEBUG_DVALUE("  SessionID", aSessionId );
       
  3653     MCEMM_DEBUG_DVALUE("  LinkID", aLinkId );
       
  3654     MCEMM_DEBUG_DVALUE("  StreamID", aStreamId );
       
  3655     MCEMM_DEBUG_DVALUE("  EndpointID", aSinkSourceId );
       
  3656     
       
  3657     CMceComSession* session = Session( aSessionId );
       
  3658     if ( session )
       
  3659         {
       
  3660         TMceMccComEvent event( KMccStreamPaused,
       
  3661                                aLinkId, 
       
  3662                                aStreamId, 
       
  3663                                aSinkSourceId );
       
  3664                                
       
  3665         TRAPD( err, 
       
  3666             session->NegotiationState().MccMediaPausedL( event ) );
       
  3667         if( err != KErrNone )
       
  3668             {
       
  3669             MCEMM_DEBUG_DVALUE("CMceMediaManager::MccMediaPaused(): \
       
  3670 Error occured!, error", err );
       
  3671             session->NegotiationState().MccError( err, event );
       
  3672             }
       
  3673         }
       
  3674     else
       
  3675         {
       
  3676         MCEMM_DEBUG("No Session!");
       
  3677         iObserver->MediaError( KErrGeneral );
       
  3678         }
       
  3679     MCEMM_DEBUG("CMceMediaManager::MccMediaPaused(), Exit ");
       
  3680     }
       
  3681 
       
  3682 
       
  3683                            
       
  3684 // ---------------------------------------------------------
       
  3685 // CMceMediaManager::MccMediaResumed
       
  3686 // --------------------------------------------------------- 
       
  3687 //      
       
  3688 void CMceMediaManager::MccMediaResumed( TUint32 aSessionId,
       
  3689                                         TUint32 aLinkId,
       
  3690                                         TUint32 aStreamId,
       
  3691                                         TUint32 aSinkSourceId )
       
  3692     {
       
  3693     MCEMM_DEBUG("CMceMediaManager::MccMediaResumed(), Entry ");
       
  3694     MCEMM_DEBUG_DVALUE("  SessionID", aSessionId );
       
  3695     MCEMM_DEBUG_DVALUE("  LinkID", aLinkId );
       
  3696     MCEMM_DEBUG_DVALUE("  StreamID", aStreamId );
       
  3697     MCEMM_DEBUG_DVALUE("  EndpointID", aSinkSourceId );
       
  3698     
       
  3699     CMceComSession* session = Session( aSessionId );
       
  3700     if ( session )
       
  3701         {
       
  3702         TMceMccComEvent event( KMccStreamResumed,
       
  3703                                aLinkId, 
       
  3704                                aStreamId, 
       
  3705                                aSinkSourceId );
       
  3706     
       
  3707         TRAPD( err, 
       
  3708             session->NegotiationState().MccMediaResumedL( event ) );
       
  3709         if( err != KErrNone )
       
  3710             {
       
  3711             MCEMM_DEBUG_DVALUE("CMceMediaManager::MccMediaResumed(): \
       
  3712 Error occured!, error", err );
       
  3713             session->NegotiationState().MccError( err, event );
       
  3714             }
       
  3715         }
       
  3716     else
       
  3717         {
       
  3718         MCEMM_DEBUG("No Session!");
       
  3719         iObserver->MediaError( KErrGeneral );
       
  3720         }
       
  3721     MCEMM_DEBUG("CMceMediaManager::MccMediaResumed(), Exit ");
       
  3722     }
       
  3723 
       
  3724 // ---------------------------------------------------------
       
  3725 // CMceMediaManager::MccMediaInactive
       
  3726 // ---------------------------------------------------------    
       
  3727 //  
       
  3728 
       
  3729 void CMceMediaManager::MccMediaInactive( TUint32 aSessionId,
       
  3730                                        TUint32 aLinkId,
       
  3731                                        TUint32 aStreamId,
       
  3732                                        TUint32 aSinkSourceId )
       
  3733     {
       
  3734     MCEMM_DEBUG("CMceMediaManager::MccMediaInactive(), Entry ");
       
  3735     MCEMM_DEBUG_DVALUE("  SessionID", aSessionId );
       
  3736     MCEMM_DEBUG_DVALUE("  LinkID", aLinkId );
       
  3737     MCEMM_DEBUG_DVALUE("  StreamID", aStreamId );
       
  3738     MCEMM_DEBUG_DVALUE("  EndpointID", aSinkSourceId );
       
  3739     
       
  3740     CMceComSession* session = Session( aSessionId );
       
  3741     if ( session )
       
  3742         {
       
  3743         TMceMccComEvent event( KMccInactivityEvent, 
       
  3744                                aLinkId, 
       
  3745                                aStreamId, 
       
  3746                                aSinkSourceId );
       
  3747     
       
  3748         CMceSrvStream::EventReceived( session->MccStreams(), event );
       
  3749     
       
  3750         }
       
  3751     else
       
  3752         {
       
  3753         MCEMM_DEBUG("No Session!");
       
  3754         iObserver->MediaError( KErrGeneral );
       
  3755         }
       
  3756     MCEMM_DEBUG("CMceMediaManager::MccMediaInactive(), Exit ");
       
  3757     }
       
  3758     
       
  3759 
       
  3760 // ---------------------------------------------------------
       
  3761 // CMceMediaManager::MccMediaActive
       
  3762 // ---------------------------------------------------------    
       
  3763 //  
       
  3764 
       
  3765 void CMceMediaManager::MccMediaActive( TUint32 aSessionId,
       
  3766                                        TUint32 aLinkId,
       
  3767                                        TUint32 aStreamId,
       
  3768                                        TUint32 aSinkSourceId )
       
  3769     {
       
  3770     MCEMM_DEBUG("CMceMediaManager::MccMediaActive(), Entry ");
       
  3771     MCEMM_DEBUG_DVALUE("  SessionID", aSessionId );
       
  3772     MCEMM_DEBUG_DVALUE("  LinkID", aLinkId );
       
  3773     MCEMM_DEBUG_DVALUE("  StreamID", aStreamId );
       
  3774     MCEMM_DEBUG_DVALUE("  EndpointID", aSinkSourceId );
       
  3775     
       
  3776     CMceComSession* session = Session( aSessionId );
       
  3777     if ( session )
       
  3778         {
       
  3779         TMceMccComEvent event( KMccActivityEvent, 
       
  3780                                aLinkId, 
       
  3781                                aStreamId, 
       
  3782                                aSinkSourceId );
       
  3783     
       
  3784         CMceSrvStream* stream = 
       
  3785             CMceSrvStream::EventReceived( session->MccStreams(), event );
       
  3786     
       
  3787         CMceSrvStream* adopted = session->RemoveAdoptedStream( *stream );
       
  3788         if ( adopted )
       
  3789             {
       
  3790             MCEMM_DEBUG_DVALUE("CMceMediaManager::MccMediaActive(): \
       
  3791 stopping adopted stream. id", adopted->Id() );
       
  3792             StopMccStream( *adopted );
       
  3793             if ( !session->IsMerged() && session->AdoptedMccStreams().Count() == 0 )
       
  3794                 {
       
  3795                 MCEMM_DEBUG_DVALUE("Closing session. id", adopted->SessionId() );
       
  3796                 iMccInterface->CloseSession( adopted->SessionId() );
       
  3797                 }
       
  3798             delete adopted;
       
  3799             }
       
  3800         }
       
  3801     else
       
  3802         {
       
  3803         MCEMM_DEBUG("No Session!");
       
  3804         iObserver->MediaError( KErrGeneral );
       
  3805         }
       
  3806     MCEMM_DEBUG("CMceMediaManager::MccMediaActive(), Exit ");
       
  3807     }
       
  3808                              
       
  3809 // ---------------------------------------------------------
       
  3810 // CMceMediaManager::MccCtrlError
       
  3811 // ---------------------------------------------------------    
       
  3812 //  
       
  3813 /*void CMceMediaManager::MccCtrlError( TInt aError )
       
  3814     {
       
  3815     MCEMM_DEBUG("CMceMediaManager::MccCtrlError(), Entry ");
       
  3816     MCEMM_DEBUG_DVALUE("  aError", aError );
       
  3817     
       
  3818     iObserver->MediaError( aError );
       
  3819     MCEMM_DEBUG("CMceMediaManager::MccCtrlError(), Exit ");
       
  3820     }*/
       
  3821 
       
  3822 // ---------------------------------------------------------
       
  3823 // CMceMediaManager::MccCtrlError
       
  3824 // ---------------------------------------------------------   
       
  3825 //  
       
  3826 void CMceMediaManager::MccCtrlError( TInt aError,
       
  3827                                        TUint32 aSessionId,
       
  3828                                        TUint32 aLinkId,
       
  3829                                        TUint32 aStreamId,
       
  3830                                        TUint32 aSinkSourceId )
       
  3831     {   
       
  3832     MCEMM_DEBUG("CMceMediaManager::MccCtrlError(), Entry ");
       
  3833     MCEMM_DEBUG_DVALUE("  SessionID", aSessionId );
       
  3834     MCEMM_DEBUG_DVALUE("  LinkID", aLinkId );
       
  3835     MCEMM_DEBUG_DVALUE("  StreamID", aStreamId );
       
  3836     MCEMM_DEBUG_DVALUE("  EndpointID", aSinkSourceId );
       
  3837     MCEMM_DEBUG_DVALUE("  error", aError );
       
  3838 
       
  3839     CMceComSession* session = Session( aSessionId );
       
  3840     if ( session )
       
  3841         {
       
  3842         TMceMccComEvent event( KMccStreamError, 
       
  3843                                aLinkId, 
       
  3844                                aStreamId, 
       
  3845                                aSinkSourceId );
       
  3846         
       
  3847         session->NegotiationState().MccError( aError, event );
       
  3848             
       
  3849         }
       
  3850     else
       
  3851         {
       
  3852         MCEMM_DEBUG("No Session!");
       
  3853         iObserver->MediaError( KErrGeneral );
       
  3854         }
       
  3855     MCEMM_DEBUG("CMceMediaManager::MccCtrlError(), Exit ");
       
  3856         
       
  3857     }
       
  3858 
       
  3859 // ---------------------------------------------------------
       
  3860 // CMceMediaManager::MccEventReceived
       
  3861 // --------------------------------------------------------- 
       
  3862 //      
       
  3863 void CMceMediaManager::MccEventReceived( const TMccEvent& aEvent )
       
  3864     {
       
  3865     MCEMM_DEBUG("CMceMediaManager::MccEventReceived(), Entry ");
       
  3866     MCEMM_DEBUG_DVALUE("  SessionID", aEvent.iSessionId );
       
  3867     MCEMM_DEBUG_DVALUE("  LinkID", aEvent.iLinkId );
       
  3868     MCEMM_DEBUG_DVALUE("  StreamID", aEvent.iStreamId );
       
  3869     MCEMM_DEBUG_DVALUE("  EndpointID", aEvent.iEndpointId );
       
  3870     
       
  3871     MCEMM_DEBUG_DVALUE("  Event category", aEvent.iEventCategory );
       
  3872     MCEMM_DEBUG_DVALUE("  Event type", aEvent.iEventType );
       
  3873     
       
  3874     if ( aEvent.iEventCategory == KMccEventCategoryTranscode )
       
  3875         {
       
  3876         MccTranscodeEventReceived( aEvent );
       
  3877         }
       
  3878     else if ( aEvent.iEventType == KMccLinkCreated ||
       
  3879               aEvent.iEventType == KMccLinkSecure ||
       
  3880     		  aEvent.iEventType == KMccLinkSecureVideo )
       
  3881         {
       
  3882         MccMediaLinkCreated( aEvent.iSessionId, aEvent.iLinkId,
       
  3883                              aEvent.iEventData );
       
  3884         }
       
  3885     else
       
  3886         {
       
  3887                     
       
  3888         CMceComSession* session = Session( aEvent.iSessionId );
       
  3889         if ( !session )
       
  3890             {
       
  3891             MCEMM_DEBUG("no session");
       
  3892             MCEMM_DEBUG("CMceMediaManager::MccEventReceived(), Exit ");
       
  3893             return;
       
  3894             }
       
  3895 
       
  3896         TMceMccComEvent event( aEvent.iEventType,
       
  3897                                aEvent.iLinkId, 
       
  3898                                aEvent.iStreamId, 
       
  3899                                aEvent.iEndpointId );
       
  3900         event.SetDataDesC( aEvent.iEventData );
       
  3901         
       
  3902         TMceSrvStreamIterator iterator( session->MccStreams() );
       
  3903         CMceSrvStream* stream = NULL;
       
  3904         if ( iterator.Next( stream, event ) )
       
  3905             {
       
  3906             if ( aEvent.iEventCategory == KMccEventCategoryDtmf )
       
  3907                 {
       
  3908                 // CodeScanner can't see properly inside to TRAP
       
  3909                 // and in some cases it report Problem: 
       
  3910                 // Leaving functions called in non-leaving functions.
       
  3911                 TRAP_IGNORE( \
       
  3912                 	stream->DtmfHandlerL( *iMccInterface ).DtmfReceivedL( \
       
  3913                 	aEvent, event ) );
       
  3914                 
       
  3915                 // Event destination might have been modified
       
  3916                 }
       
  3917             else if( aEvent.iEventType == KMccMasterKeyStaled )
       
  3918             	{
       
  3919             	if ( aEvent.iEventNumData > 0 && 
       
  3920             	     session->SecureSession() )
       
  3921             		{
       
  3922 	            	// set up in the session
       
  3923 	            	session->SecureSession()->ContextNeedUpdated( aEvent.iEventNumData );
       
  3924             		}
       
  3925             	}
       
  3926             else if ( aEvent.iEventCategory == KMccEventCategoryRtcp )
       
  3927                 {
       
  3928                 const TMccRtcpEventData& rtcpEvent = 
       
  3929                     (*reinterpret_cast<const TMccRtcpEventDataPackage*>( 
       
  3930                         &aEvent.iEventData ))();
       
  3931                         
       
  3932                 event.iEventSubType = rtcpEvent.iRtcpPacketType;
       
  3933                 event.SetDataDesC( rtcpEvent.iRtcpPacketData );
       
  3934                 }
       
  3935             else
       
  3936                 {
       
  3937                 // NOP
       
  3938                 }
       
  3939             
       
  3940             // Event might contain only link id (e.g. rtcp rr) but
       
  3941             // we do not want to propagate it to all streams of that link.                               
       
  3942             CMceSrvStream::EventReceived( session->MccStreams(), event, ETrue );
       
  3943             }
       
  3944         else
       
  3945             {
       
  3946             MCEMM_DEBUG("CMceMediaManager::MccEventReceived(): \
       
  3947 ERROR: Unknown stream" );
       
  3948             }
       
  3949         }
       
  3950         
       
  3951     MCEMM_DEBUG("CMceMediaManager::MccEventReceived(), Exit ");
       
  3952     
       
  3953     }
       
  3954 
       
  3955 
       
  3956 
       
  3957 // ---------------------------------------------------------
       
  3958 // CMceMediaManager::MccTranscodeEventReceived
       
  3959 // ---------------------------------------------------------    
       
  3960 //
       
  3961 void CMceMediaManager::MccTranscodeEventReceived( const TMccEvent& aEvent )
       
  3962     {
       
  3963     MCEMM_DEBUG("CMceMediaManager::MccTranscodeEventReceived(), Entry ");
       
  3964     MCEMM_DEBUG_DVALUE("  SessionID", aEvent.iSessionId );
       
  3965     
       
  3966     CMceComFileSource* session = TranscodingSession( aEvent.iSessionId );
       
  3967     if ( !session )
       
  3968         {
       
  3969         MCEMM_DEBUG("no session");
       
  3970         MCEMM_DEBUG("CMceMediaManager::MccTranscodeEventReceived(), Exit ");
       
  3971         return;
       
  3972         }
       
  3973 
       
  3974     TMceMccComEvent event( aEvent.iEventType, 0, 0, 0 );
       
  3975     event.iSource = session;
       
  3976     event.iItcEvent = aEvent.iEventType == KMccTranscodeCompleted ?
       
  3977                       EMceItcTranscodingCompleted : EMceItcTranscodingInProgress;
       
  3978                       
       
  3979     event.iItcData = aEvent.iEventNumData;
       
  3980     event.iError = aEvent.iErrorCode;
       
  3981     
       
  3982     session->iClient->EventReceived( event );
       
  3983     
       
  3984     if ( aEvent.iEventType == KMccTranscodeCompleted )
       
  3985         {
       
  3986         TInt index = iTranscodeSessions.Find( session );
       
  3987         if ( index >= 0 )
       
  3988             {
       
  3989             iTranscodeSessions.Remove( index );
       
  3990             delete session;
       
  3991             }
       
  3992         }
       
  3993         
       
  3994     MCEMM_DEBUG("CMceMediaManager::MccTranscodeEventReceived(), Exit ");
       
  3995     
       
  3996     }
       
  3997     
       
  3998     
       
  3999 /*
       
  4000 * Private functions for internal use
       
  4001 */
       
  4002 
       
  4003 
       
  4004 
       
  4005 
       
  4006 // ---------------------------------------------------------
       
  4007 // CMceMediaManager::Session
       
  4008 // ---------------------------------------------------------    
       
  4009 //
       
  4010 CMceComSession* CMceMediaManager::Session( TUint32 aSessionId )
       
  4011     {
       
  4012     MCEMM_DEBUG("CMceMediaManager::Session(), Entry ");
       
  4013     
       
  4014     CMceComSession* session = NULL;
       
  4015     
       
  4016     for ( TInt i=0; i < iMceSdpSessions.Count() && !session; i++ )
       
  4017         {
       
  4018         CMceSdpSession* sdpSession = iMceSdpSessions[ i ];
       
  4019         if ( sdpSession->IsMaster() )
       
  4020             {
       
  4021             session = sdpSession->Consumes( aSessionId );
       
  4022             }
       
  4023         }
       
  4024         
       
  4025     if ( !session )
       
  4026         {
       
  4027         MCEMM_DEBUG_DVALUE("Session not found! id", aSessionId )
       
  4028         iObserver->MediaError( KErrNotFound );
       
  4029         }
       
  4030         
       
  4031     MCEMM_DEBUG("CMceMediaManager::Session(), Exit ");
       
  4032     return session;
       
  4033     }
       
  4034 
       
  4035 // ---------------------------------------------------------
       
  4036 // CMceMediaManager::SdpSession
       
  4037 // ---------------------------------------------------------    
       
  4038 //
       
  4039 CMceSdpSession* CMceMediaManager::SdpSession( CMceComSession& aSession )
       
  4040     {
       
  4041 
       
  4042     MCEMM_DEBUG("CMceMediaManager::SdpSession(), Entry ");
       
  4043     
       
  4044     TInt error = KErrNone;
       
  4045     
       
  4046     CMceSdpSession* sdpSession = &aSession.SdpSession();
       
  4047     if ( !sdpSession ) //possible clone
       
  4048         {
       
  4049         sdpSession = aSession.iCloneOrigin ? &aSession.iCloneOrigin->SdpSession() : NULL;
       
  4050         
       
  4051         if ( sdpSession )
       
  4052         	{
       
  4053         	sdpSession->SetMediaSession( aSession.iCloneOrigin );
       
  4054         	}
       
  4055         }
       
  4056         
       
  4057     if ( sdpSession )
       
  4058         {
       
  4059         
       
  4060         if ( &aSession != sdpSession->MediaSession() &&
       
  4061              &aSession != sdpSession->Backup() )
       
  4062             {
       
  4063             TRAP( error, aSession.AttachSDPSessionL( *sdpSession ) );
       
  4064             }
       
  4065             
       
  4066         if ( MCE_IS_NULL_PTR( sdpSession->Backup() ) && //is not update
       
  4067             !sdpSession->IsMaster() && //is not master
       
  4068             sdpSession->Context() ) // has context
       
  4069             {
       
  4070             sdpSession->ContextSwitch();
       
  4071             }
       
  4072         }
       
  4073 
       
  4074         
       
  4075     if ( error != KErrNone )
       
  4076         {
       
  4077         sdpSession = NULL;
       
  4078         }
       
  4079         
       
  4080     MCEMM_DEBUG("CMceMediaManager::SdpSession(), Exit ");
       
  4081     return sdpSession;
       
  4082     }
       
  4083     
       
  4084 
       
  4085 // ---------------------------------------------------------
       
  4086 // CMceMediaManager::CloseSession
       
  4087 // Closes MCC session and removes the internal sdp session
       
  4088 // Status : Draft
       
  4089 // ---------------------------------------------------------    
       
  4090 TInt CMceMediaManager::CloseSession( CMceComSession& aSession )
       
  4091     { 
       
  4092     MCEMM_DEBUG("CMceMediaManager::CloseSession(), Entry ");
       
  4093 
       
  4094     TInt error = KErrNone;
       
  4095 
       
  4096     CMceSdpSession* sdpSession = SdpSession( aSession );
       
  4097     if ( !sdpSession )
       
  4098         {
       
  4099         MCEMM_DEBUG("No session!");
       
  4100         MCEMM_DEBUG("CMceMediaManager::CloseSession(), Exit ");
       
  4101         return KErrNotFound;
       
  4102         }
       
  4103     
       
  4104     CMceComSession* backup = aSession.Backup();
       
  4105     
       
  4106     if ( !backup )
       
  4107     //no backup => close session
       
  4108         {
       
  4109         if ( sdpSession->IsMaster() )
       
  4110             {
       
  4111             TRAP( error, CleanupSessionL( aSession ) );
       
  4112             iMccInterface->CloseSession( aSession.iMccID );
       
  4113             }
       
  4114         RemoveSession( sdpSession );
       
  4115         }
       
  4116     else if ( &aSession == backup )
       
  4117     //update accepted => close backup
       
  4118         {
       
  4119         TRAP( error, UpdateAcceptedL( *sdpSession ) );
       
  4120         }
       
  4121     else
       
  4122     //update rejected => rollback
       
  4123         {
       
  4124         TRAP( error, UpdateRejectedL( *sdpSession ) );
       
  4125         }
       
  4126             
       
  4127     MCEMM_DEBUG("CMceMediaManager::CloseSession(), Exit ");
       
  4128     
       
  4129     return error;
       
  4130 
       
  4131     }
       
  4132     
       
  4133 
       
  4134 // ---------------------------------------------------------
       
  4135 // CMceMediaManager::UpdateAcceptedL
       
  4136 // ---------------------------------------------------------    
       
  4137 void CMceMediaManager::UpdateAcceptedL( CMceSdpSession& aSdpSession )
       
  4138     { 
       
  4139     MCEMM_DEBUG("CMceMediaManager::UpdateAcceptedL(), Entry ");
       
  4140     
       
  4141     CMceComSession* session = aSdpSession.MediaSession();
       
  4142     CMceComSession* backup = aSdpSession.Backup();
       
  4143     __ASSERT_ALWAYS( session && backup, User::Leave( KErrNotFound ) );
       
  4144     
       
  4145     if ( !session->IsMerged() )
       
  4146     //if not merged session
       
  4147         {
       
  4148         MCEMM_DEBUG("CMceMediaManager::UpdateAcceptedL(): \
       
  4149 session is not merged");
       
  4150         //stop backup's all send streams. 
       
  4151         //No local streams or receive streams
       
  4152         TMceSrvStreamIterator 
       
  4153             sendStreams( backup->MccStreams(), 
       
  4154                          TMceSrvStreamIterator::ESend );
       
  4155         CMceSrvStream* sendStream = NULL;
       
  4156         while( sendStreams.Next( 
       
  4157                     sendStream,
       
  4158                     CMceSrvStream::EPrepared, 
       
  4159                     TMceSrvStreamIterator::GreaterOrEqualMatch ) )
       
  4160             {
       
  4161             MCEMM_DEBUG_DVALUE("CMceMediaManager::UpdateAcceptedL(): \
       
  4162 Stopping send stream. id", sendStream->Id() );
       
  4163             StopMccStream( *sendStream );
       
  4164             }
       
  4165         
       
  4166         //adopt backup's all active receive streams to session
       
  4167         TMceSrvStreamIterator 
       
  4168             receiveStreams( backup->MccStreams(), 
       
  4169                             TMceSrvStreamIterator::EReceive );
       
  4170         CMceSrvStream* receiveStream = NULL;
       
  4171         TBool canClose = ETrue;
       
  4172         while( receiveStreams.Next( 
       
  4173                         receiveStream,
       
  4174                         CMceSrvStream::EPrepared, 
       
  4175                         TMceSrvStreamIterator::GreaterOrEqualMatch ) )
       
  4176             {
       
  4177             if ( receiveStream->Data().IsEnabled() )
       
  4178                 {
       
  4179                 MCEMM_DEBUG_DVALUE("CMceMediaManager::UpdateAcceptedL(): \
       
  4180 adopting receive stream. id", receiveStream->Id() );
       
  4181                 session->AdoptStreamL( *receiveStream );
       
  4182                 canClose = EFalse;
       
  4183                 }
       
  4184             else
       
  4185                 {
       
  4186                 MCEMM_DEBUG_DVALUE("CMceMediaManager::UpdateAcceptedL(): \
       
  4187 stopping receive stream. Id", receiveStream->Id() );
       
  4188                 StopMccStream( *receiveStream );
       
  4189                 }
       
  4190             }
       
  4191         //if no receive streams were adopted, backup can be closed
       
  4192         if ( canClose )
       
  4193             {
       
  4194             MCEMM_DEBUG_DVALUE("CMceMediaManager::UpdateAcceptedL(): \
       
  4195 closing session. Id", backup->iMccID );
       
  4196             iMccInterface->CloseSession( backup->iMccID );
       
  4197             }
       
  4198         }
       
  4199     else
       
  4200         {
       
  4201         MCEMM_DEBUG("CMceMediaManager::UpdateAcceptedL(): \
       
  4202 session is merged");
       
  4203         CleanupSessionL( *backup );
       
  4204         session->UnMerge();
       
  4205         }
       
  4206     
       
  4207     backup->DetachSDPSession();
       
  4208     aSdpSession.SetBackup( NULL );
       
  4209     }
       
  4210 
       
  4211 
       
  4212 // ---------------------------------------------------------
       
  4213 // CMceMediaManager::UpdateRejectedL
       
  4214 // ---------------------------------------------------------    
       
  4215 void CMceMediaManager::UpdateRejectedL( CMceSdpSession& aSdpSession )
       
  4216     { 
       
  4217     MCEMM_DEBUG("CMceMediaManager::UpdateRejected(), Entry ");
       
  4218     
       
  4219     CMceComSession* session = aSdpSession.MediaSession();
       
  4220     CMceComSession* backup = aSdpSession.Backup();
       
  4221     __ASSERT_ALWAYS( session && backup, User::Leave( KErrNotFound ) );
       
  4222     
       
  4223     CleanupSessionL( *session );
       
  4224     if ( !session->IsMerged() )
       
  4225     //if not merged session
       
  4226         {
       
  4227         MCEMM_DEBUG_DVALUE("Closing session. Id", session->iMccID );
       
  4228         iMccInterface->CloseSession( session->iMccID );
       
  4229         }
       
  4230     else
       
  4231         {
       
  4232         MCEMM_DEBUG_DVALUE("Unmerging session. Id", backup->iMccID );
       
  4233         backup->UnMergeL( *session );
       
  4234         }
       
  4235     
       
  4236     session->DetachSDPSession();
       
  4237     aSdpSession.SetMediaSession( backup );
       
  4238     aSdpSession.SetBackup( NULL );
       
  4239     
       
  4240     MCEMM_DEBUG("CMceMediaManager::UpdateRejected(), Exit ");
       
  4241     }
       
  4242 
       
  4243 // ---------------------------------------------------------
       
  4244 // CMceMediaManager::CleanupSessionL
       
  4245 // ---------------------------------------------------------    
       
  4246 void CMceMediaManager::CleanupSessionL( CMceComSession& aSession )
       
  4247     { 
       
  4248     MCEMM_DEBUG("CMceMediaManager::CleanupSessionL(), Entry ");
       
  4249 
       
  4250     CMceComSession* session = aSession.SdpSession().MediaSession();
       
  4251     CMceComSession* backup = aSession.SdpSession().Backup();
       
  4252     
       
  4253     //close all started unmerged streams
       
  4254     TMceSrvStreamIterator streams( aSession.MccStreams() );
       
  4255     CMceSrvStream* stream= NULL;
       
  4256     while( streams.Next( 
       
  4257                  stream, 
       
  4258                  CMceSrvStream::EPrepared, 
       
  4259                  TMceSrvStreamIterator::GreaterOrEqualMatch ) )
       
  4260         {
       
  4261         if ( !stream->IsMerged() )//added or removed
       
  4262             {
       
  4263             MCEMM_DEBUG_DVALUE("CMceMediaManager::CleanupSessionL(): \
       
  4264 stopping unmerged stream. Id", stream->Id() );
       
  4265             StopMccStream( *stream );
       
  4266             }
       
  4267         }
       
  4268 
       
  4269     //close all adopted streams
       
  4270     TUint32 sessionId = KMceNotAssigned;
       
  4271     TMceSrvStreamIterator adopts( aSession.AdoptedMccStreams() );
       
  4272     CMceSrvStream* adopted = NULL;
       
  4273     while( adopts.Next( adopted ) )
       
  4274         {
       
  4275         if ( backup && &aSession == backup )
       
  4276             {
       
  4277             MCEMM_DEBUG_DVALUE("CMceMediaManager::CleanupSessionL(): \
       
  4278 re-adopting adopted stream. Id", adopted->Id() );
       
  4279             adopted = aSession.RemoveAdoptedStream( *adopted );
       
  4280             CleanupStack::PushL( adopted );
       
  4281             session->AdoptedMccStreams().AppendL( adopted );
       
  4282             CleanupStack::Pop( adopted );
       
  4283             }
       
  4284         else
       
  4285             {
       
  4286             MCEMM_DEBUG_DVALUE("CMceMediaManager::CleanupSessionL(): \
       
  4287 stopping adopted stream. Id", adopted->Id() );
       
  4288             sessionId = adopted->SessionId();
       
  4289             StopMccStream( *adopted );
       
  4290             }
       
  4291         
       
  4292         if ( sessionId != KMceNotAssigned )
       
  4293             {
       
  4294             MCEMM_DEBUG_DVALUE("CMceMediaManager::CleanupSessionL(): \
       
  4295 closing session. Id", sessionId );
       
  4296             iMccInterface->CloseSession( sessionId );
       
  4297             }
       
  4298         }
       
  4299         
       
  4300     MCEMM_DEBUG("CMceMediaManager::CleanupSessionL(), Exit ");
       
  4301     }
       
  4302     
       
  4303 
       
  4304 // ---------------------------------------------------------
       
  4305 // CMceMediaManager::RemoveSession
       
  4306 // ---------------------------------------------------------    
       
  4307 //
       
  4308 void CMceMediaManager::RemoveSession( CMceSdpSession* aSdpSession )
       
  4309   
       
  4310     {
       
  4311     MCEMM_DEBUG("CMceMediaManager::RemoveSession(), Entry ");
       
  4312     
       
  4313     TUint32 sessionId = aSdpSession->MediaSession()->iMccID;
       
  4314     TBool isMaster = aSdpSession->IsMaster();
       
  4315     CMceSdpSession* sdpSession = NULL;
       
  4316     CMceSdpSession::TIterator sdpSessions( iMceSdpSessions );
       
  4317     TBool loop = ETrue;
       
  4318     
       
  4319     // remove all sessions, which does not have media session
       
  4320     while( loop && sdpSessions.Next( sdpSession ) )
       
  4321         {
       
  4322         if ( sdpSession == aSdpSession ||
       
  4323              !sdpSession->MediaSession() ||
       
  4324              sdpSession->Consumes( sessionId ) )
       
  4325               
       
  4326             {
       
  4327             if ( isMaster || sdpSession == aSdpSession )
       
  4328                 {
       
  4329                 sdpSessions.Remove();
       
  4330                 delete sdpSession;
       
  4331                 MCEMM_DEBUG("SDP session removed");
       
  4332                 }
       
  4333             loop = isMaster;
       
  4334             }
       
  4335         }
       
  4336         
       
  4337     MCEMM_DEBUG("CMceMediaManager::RemoveSession(), Exit ");
       
  4338     }
       
  4339 
       
  4340 
       
  4341 
       
  4342 // ---------------------------------------------------------
       
  4343 // CMceMediaManager::UseRtcp
       
  4344 // ---------------------------------------------------------    
       
  4345 //
       
  4346 TBool CMceMediaManager::UseRtcp( CMceSrvStream& aStream )
       
  4347     {
       
  4348     MCEMM_DEBUG("CMceMediaManager::UseRtcp(), Entry ")
       
  4349     
       
  4350     TBool useRtcp( ETrue );
       
  4351     TMceSrvStreamIterator streams( aStream.Data().Session()->MccStreams() );
       
  4352     CMceSrvStream* stream = NULL;
       
  4353     while( streams.Next( stream ) && useRtcp )
       
  4354         {
       
  4355         if ( aStream.LinkId() == stream->LinkId() )
       
  4356             {
       
  4357             useRtcp = useRtcp && aStream.Data().Session()->UseRtcp();
       
  4358             }
       
  4359         }
       
  4360 
       
  4361     MCEMM_DEBUG_DVALUE( "CMceMediaManager::UseRtcp() stream id:", aStream.Id() )
       
  4362     MCEMM_DEBUG_DVALUE( "CMceMediaManager::UseRtcp() use rtcp:", useRtcp )
       
  4363                     
       
  4364     return useRtcp;
       
  4365     }
       
  4366 
       
  4367 // ---------------------------------------------------------
       
  4368 // CMceMediaManager::FillMceFileInfoL
       
  4369 // ---------------------------------------------------------    
       
  4370 //    
       
  4371 void CMceMediaManager::FillMceFileInfoL( 
       
  4372     TMccFileSourceSetting& aMccFileInfo,
       
  4373     TMceFileInfo& aMceFileInfo ) const
       
  4374     {
       
  4375     CMccCodecInformationFactory* codecFactory = 
       
  4376             CMccCodecInformationFactory::NewL();
       
  4377     CleanupStack::PushL( codecFactory );
       
  4378     
       
  4379     aMceFileInfo.iAudioCodec = KNullDesC8;   
       
  4380     aMceFileInfo.iAudioElementCount = 0;
       
  4381      
       
  4382     if ( aMccFileInfo.iAudioFourCC != KMMFFourCCCodeNULL )
       
  4383         {
       
  4384         // File might contain unsupported audio, ignore leave
       
  4385         CMccCodecInformation* codec = NULL;
       
  4386         TRAP_IGNORE( 
       
  4387             (codec = codecFactory->CreateCodecInformationL( aMccFileInfo.iAudioFourCC ) ))
       
  4388         if ( codec )
       
  4389             {
       
  4390             aMceFileInfo.iAudioCodec = codec->SdpName();
       
  4391             aMceFileInfo.iAudioBitRate = aMccFileInfo.iAudioBitRate;  
       
  4392             }
       
  4393         
       
  4394         delete codec;
       
  4395         aMceFileInfo.iAudioElementCount = 1;
       
  4396         }
       
  4397      
       
  4398     aMceFileInfo.iVideoCodec = KNullDesC8;
       
  4399     aMceFileInfo.iVideoElementCount = 0;
       
  4400            
       
  4401     if ( aMccFileInfo.iVideoFourCC != KMMFFourCCCodeNULL )
       
  4402         {
       
  4403         // File might contain unsupported video, ignore leave
       
  4404         CMccCodecInformation* codec = NULL;
       
  4405         TRAP_IGNORE( 
       
  4406             (codec = codecFactory->CreateCodecInformationL( aMccFileInfo.iVideoFourCC ) ))
       
  4407         if ( codec )
       
  4408             {
       
  4409             aMceFileInfo.iVideoCodec = codec->SdpName();
       
  4410             aMceFileInfo.iVideoFrameRate = aMccFileInfo.iVideoFrameRate;
       
  4411             aMceFileInfo.iVideoBitRate = aMccFileInfo.iVideoBitRate;
       
  4412             aMceFileInfo.iVideoFrameSize = aMccFileInfo.iVideoFrameSize;
       
  4413             }
       
  4414         
       
  4415         delete codec;
       
  4416         aMceFileInfo.iVideoElementCount = 1;
       
  4417         }
       
  4418     
       
  4419     aMceFileInfo.iDuration = aMccFileInfo.iDuration;
       
  4420     
       
  4421     CleanupStack::PopAndDestroy( codecFactory );
       
  4422     }
       
  4423 
       
  4424 // ---------------------------------------------------------
       
  4425 // CMceMediaManager::DoStartEndpointsL
       
  4426 // ---------------------------------------------------------    
       
  4427 //
       
  4428 TBool CMceMediaManager::DoStartEndpointsL( 
       
  4429     CMceSrvStream& aStream,
       
  4430     TUint32 aForceEnableEndpoint,
       
  4431     TUint32 aForceDisableEndpoint )
       
  4432     {
       
  4433     MCEMM_DEBUG("CMceMediaManager::DoStartEndpointsL(), Entry ");
       
  4434     
       
  4435     if ( aForceDisableEndpoint )
       
  4436         {
       
  4437         // No need to start if explicitly disabling
       
  4438         MCEMM_DEBUG("CMceMediaManager::DoStartEndpointsL(), Exit ");
       
  4439         return EFalse;
       
  4440         }
       
  4441     
       
  4442     TBool sinkForced( aStream.Sink().Id() == aForceEnableEndpoint );
       
  4443     TBool sourceForced( aStream.Source().Id() == aForceEnableEndpoint );
       
  4444     
       
  4445     TBool sinkNeedsStart( 
       
  4446           aStream.Codec().iIsEnabled &&
       
  4447         ( aStream.Sink().State() < CMceSrvStream::EStarted && 
       
  4448           aStream.Sink().State() != CMceSrvStream::EStarting ) &&
       
  4449         ( aStream.Sink().Data().IsEnabled( KMceEnabledE2e ) || 
       
  4450           sinkForced ) &&
       
  4451         ( aStream.Sink().State() == CMceSrvStream::EPrepared ||
       
  4452           aStream.Sink().State() == CMceSrvStream::EPending ) );
       
  4453                           
       
  4454     TBool sourceNeedsStart( 
       
  4455           aStream.Codec().iIsEnabled &&
       
  4456         ( aStream.Source().State() < CMceSrvStream::EStarted && 
       
  4457           aStream.Source().State() != CMceSrvStream::EStarting ) &&
       
  4458         ( aStream.Source().Data().IsEnabled( KMceEnabledE2e ) || 
       
  4459           sourceForced ) &&
       
  4460         ( aStream.Source().State() == CMceSrvStream::EPrepared ||
       
  4461           aStream.Source().State() == CMceSrvStream::EPending ) );
       
  4462     
       
  4463     MCEMM_DEBUG_DVALUE(" forced (0 means no) endpoint ", aForceEnableEndpoint );
       
  4464     MCEMM_DEBUG_DVALUE(" start sink", sinkNeedsStart );
       
  4465     MCEMM_DEBUG_DVALUE(" start source", sourceNeedsStart );
       
  4466     
       
  4467     TBool startNeeded( sinkNeedsStart || sourceNeedsStart );
       
  4468     TUint32 startEndpointId = 0;
       
  4469 
       
  4470     // Resolve resumed endpoints
       
  4471     //
       
  4472     if ( sinkNeedsStart ^ sourceNeedsStart )
       
  4473         {
       
  4474         startEndpointId = sinkNeedsStart ? aStream.Sink().Id() : 
       
  4475                                            aStream.Source().Id();
       
  4476         }
       
  4477         
       
  4478     if ( startNeeded )
       
  4479         {
       
  4480         MCEMM_DEBUG_DVALUE("starting (0 means all) endpoint(s) ", startEndpointId );
       
  4481         User::LeaveIfError( 
       
  4482                 iMccInterface->StartStream( 
       
  4483                             aStream.SessionId(),
       
  4484                             aStream.LinkId(),
       
  4485                             aStream.Id(),
       
  4486                             startEndpointId,
       
  4487                             EFalse,
       
  4488                             UseRtcp( aStream ) ) );
       
  4489         
       
  4490         SetPendingState( aStream, startEndpointId, CMceSrvStream::EStarting );
       
  4491         }
       
  4492     else 
       
  4493         {
       
  4494         MCEMM_DEBUG("no need to start");
       
  4495         }
       
  4496         
       
  4497     aStream.UpdateEndpointStates( sinkForced, sourceForced, ETrue );
       
  4498        
       
  4499     MCEMM_DEBUG("CMceMediaManager::DoStartEndpointsL(), Exit ");
       
  4500     
       
  4501     return startNeeded;
       
  4502     }
       
  4503     
       
  4504 // ---------------------------------------------------------
       
  4505 // CMceMediaManager::DoResumeEndpointsL
       
  4506 // ---------------------------------------------------------    
       
  4507 //
       
  4508 TBool CMceMediaManager::DoResumeEndpointsL( 
       
  4509     CMceSrvStream& aStream,
       
  4510     TUint32 aForceEnableEndpoint )
       
  4511     {
       
  4512     MCEMM_DEBUG("CMceMediaManager::DoResumeEndpointsL(), Entry ");
       
  4513     
       
  4514     TBool sinkForced( aStream.Sink().Id() == aForceEnableEndpoint );
       
  4515     TBool sourceForced( aStream.Source().Id() == aForceEnableEndpoint );
       
  4516     
       
  4517     // Do not allow resuming streams which have disabled codec
       
  4518     //
       
  4519     TBool sinkNeedsResume( 
       
  4520           aStream.Codec().iIsEnabled &&
       
  4521         ( aStream.Sink().Data().IsEnabled( KMceEnabledE2e ) || sinkForced ) &&
       
  4522         ( aStream.Sink().State() == CMceSrvStream::EPaused ||
       
  4523           aStream.Sink().State() == CMceSrvStream::EPausing ) );
       
  4524                           
       
  4525     TBool sourceNeedsResume( 
       
  4526           aStream.Codec().iIsEnabled &&
       
  4527         ( aStream.Source().Data().IsEnabled( KMceEnabledE2e ) || sourceForced ) &&
       
  4528         ( aStream.Source().State() == CMceSrvStream::EPaused ||
       
  4529           aStream.Source().State() == CMceSrvStream::EPausing ) );
       
  4530     
       
  4531     MCEMM_DEBUG_DVALUE(" forced (0 means no) endpoint ", aForceEnableEndpoint );
       
  4532     MCEMM_DEBUG_DVALUE(" resume sink", sinkNeedsResume );
       
  4533     MCEMM_DEBUG_DVALUE(" resume source", sourceNeedsResume );
       
  4534     
       
  4535     TBool resumeNeeded( sinkNeedsResume || sourceNeedsResume );
       
  4536     TUint32 resumeEndpointId = 0;
       
  4537 
       
  4538     // Resolve resumed endpoints
       
  4539     //
       
  4540     if ( sinkNeedsResume ^ sourceNeedsResume )
       
  4541         {
       
  4542         resumeEndpointId = sinkNeedsResume ? aStream.Sink().Id() : 
       
  4543                                              aStream.Source().Id();
       
  4544         }
       
  4545         
       
  4546     if ( resumeNeeded )
       
  4547         {
       
  4548         MCEMM_DEBUG_DVALUE("resuming (0 means all) endpoint(s) ", resumeEndpointId );
       
  4549         User::LeaveIfError( 
       
  4550             iMccInterface->ResumeStream( 
       
  4551                         aStream.SessionId(),
       
  4552                         aStream.LinkId(),
       
  4553                         aStream.Id(),
       
  4554                         resumeEndpointId,
       
  4555                         UseRtcp( aStream ) ) );
       
  4556             
       
  4557         SetPendingState( aStream, resumeEndpointId, CMceSrvStream::EStarting );
       
  4558         }
       
  4559     else 
       
  4560         {
       
  4561         MCEMM_DEBUG("no need to resume");
       
  4562         }
       
  4563         
       
  4564     aStream.UpdateEndpointStates( sinkForced, sourceForced, ETrue );
       
  4565         
       
  4566     MCEMM_DEBUG("CMceMediaManager::DoResumeEndpointsL(), Exit ");
       
  4567     
       
  4568     return resumeNeeded;
       
  4569     }
       
  4570     
       
  4571 // ---------------------------------------------------------
       
  4572 // CMceMediaManager::DoPauseEndpointsL
       
  4573 // ---------------------------------------------------------    
       
  4574 //
       
  4575 TBool CMceMediaManager::DoPauseEndpointsL( 
       
  4576     CMceSrvStream& aStream, 
       
  4577     TUint32 aForceDisableEndpoint )
       
  4578     {
       
  4579     MCEMM_DEBUG("CMceMediaManager::DoPauseEndpointsL(), Entry ");
       
  4580     
       
  4581     TBool sinkForced( aStream.Sink().Id() == aForceDisableEndpoint );
       
  4582     TBool sourceForced( aStream.Source().Id() == aForceDisableEndpoint );
       
  4583     
       
  4584     // Do not allow streams with disabled codec to run
       
  4585     //
       
  4586     TBool sinkNeedsPause( 
       
  4587         ( !aStream.Codec().iIsEnabled || 
       
  4588           !aStream.Sink().Data().IsEnabled( KMceEnabledE2e ) || 
       
  4589           sinkForced ) &&
       
  4590         ( aStream.Sink().State() == CMceSrvStream::EStarted ||
       
  4591           aStream.Sink().State() == CMceSrvStream::EStarting ) );
       
  4592                           
       
  4593     TBool sourceNeedsPause( 
       
  4594         ( !aStream.Codec().iIsEnabled ||
       
  4595           !aStream.Source().Data().IsEnabled( KMceEnabledE2e ) ||
       
  4596           sourceForced ) &&
       
  4597         ( aStream.Source().State() == CMceSrvStream::EStarted ||
       
  4598           aStream.Source().State() == CMceSrvStream::EStarting ) );
       
  4599     
       
  4600     MCEMM_DEBUG_DVALUE(" forced (0 means no) endpoint ", aForceDisableEndpoint );
       
  4601     MCEMM_DEBUG_DVALUE(" pause sink", sinkNeedsPause );
       
  4602     MCEMM_DEBUG_DVALUE(" pasue source", sourceNeedsPause );
       
  4603     
       
  4604     TBool pauseNeeded( sinkNeedsPause || sourceNeedsPause );
       
  4605     TUint32 pauseEndpointId = 0;
       
  4606 
       
  4607     // Resolve paused endpoints
       
  4608     //
       
  4609     if ( sinkNeedsPause ^ sourceNeedsPause )
       
  4610         {
       
  4611         pauseEndpointId = sinkNeedsPause ? aStream.Sink().Id() : 
       
  4612                                            aStream.Source().Id();
       
  4613         }
       
  4614         
       
  4615     if ( pauseNeeded )
       
  4616         {
       
  4617         MCEMM_DEBUG_DVALUE("pausing (0 means all) endpoint(s) ", pauseEndpointId );
       
  4618         User::LeaveIfError( 
       
  4619             iMccInterface->PauseStream( 
       
  4620                         aStream.SessionId(),
       
  4621                         aStream.LinkId(),
       
  4622                         aStream.Id(),
       
  4623                         pauseEndpointId,
       
  4624                         UseRtcp( aStream ) ) );
       
  4625                             
       
  4626         SetPendingState( aStream, pauseEndpointId, CMceSrvStream::EPausing );
       
  4627         }
       
  4628     else 
       
  4629         {
       
  4630         MCEMM_DEBUG("no need to pause");
       
  4631         }
       
  4632         
       
  4633     aStream.UpdateEndpointStates( sinkForced, sourceForced, EFalse );
       
  4634         
       
  4635     MCEMM_DEBUG("CMceMediaManager::DoPauseEndpointsL(), Exit ");
       
  4636     
       
  4637     return pauseNeeded;
       
  4638     }
       
  4639 
       
  4640 // ---------------------------------------------------------
       
  4641 // CMceMediaManager::SetPendingState
       
  4642 // ---------------------------------------------------------    
       
  4643 //
       
  4644 void CMceMediaManager::SetPendingState( 
       
  4645     CMceSrvStream& aStream, 
       
  4646     TUint32 aEndpointId, 
       
  4647     CMceSrvStream::TState aState )
       
  4648     {
       
  4649     if ( aEndpointId == 0 || aStream.Source().Id() == aEndpointId )
       
  4650         {
       
  4651         aStream.Source().SetState( aState );
       
  4652         }
       
  4653         
       
  4654     if ( aEndpointId == 0 || aStream.Sink().Id() == aEndpointId )
       
  4655         {
       
  4656         aStream.Sink().SetState( aState );
       
  4657         }
       
  4658     }
       
  4659 
       
  4660 // ---------------------------------------------------------
       
  4661 // CMceMediaManager::DoDtmfL
       
  4662 // ---------------------------------------------------------    
       
  4663 //
       
  4664 TBool CMceMediaManager::DoDtmfL(
       
  4665     CMceComMediaSource& aSource, 
       
  4666     TMceComEvent& aEvent,
       
  4667     const TDesC8& aSequence,
       
  4668     TBool aUseBoundStream )
       
  4669     {
       
  4670     CMceComSession* session = aSource.MediaStream()->Session();
       
  4671     __ASSERT_ALWAYS( session, User::Leave( KErrNotReady ) );
       
  4672     
       
  4673     CMceComMediaStream* comStream = aSource.MediaStream();
       
  4674     if ( aUseBoundStream )
       
  4675         {
       
  4676         comStream = &( comStream->BoundStreamL() );
       
  4677         __ASSERT_ALWAYS( comStream, User::Leave( KErrNotSupported ) );
       
  4678         }
       
  4679     // Sending dtmf signals is only possible through dtmf uplink
       
  4680     TBool handled( EFalse );    
       
  4681     if ( IS_RECEIVESTREAM( comStream ) )
       
  4682         {
       
  4683         return handled;
       
  4684         }
       
  4685 
       
  4686     TMceSrvStreamIterator streams( session->MccStreams(), *comStream );
       
  4687     CMceSrvStream* stream = NULL;
       
  4688     
       
  4689     
       
  4690     while( streams.Next( stream ) && !handled )
       
  4691         {
       
  4692         if ( stream->MccStreamType() == KMccDtmfStream )
       
  4693             {
       
  4694             stream->DtmfHandlerL( *iMccInterface ).DtmfL( aSource,
       
  4695                                                           aEvent,
       
  4696                                                           aSequence );
       
  4697             handled = ETrue;
       
  4698             }
       
  4699         }
       
  4700         
       
  4701     return handled;
       
  4702     }
       
  4703 
       
  4704 // ---------------------------------------------------------
       
  4705 // CMceMediaManager::DoAdjustMccStreamL
       
  4706 // ---------------------------------------------------------    
       
  4707 //
       
  4708 CMceComCodec* CMceMediaManager::DoAdjustMccStreamL( CMceSrvStream& aStream )
       
  4709     {  
       
  4710     MCEMM_DEBUG("CMceMediaManager::DoAdjustMccStreamL(), Entry ")
       
  4711     
       
  4712     __ASSERT_ALWAYS( aStream.State() != CMceSrvStream::EAdopted,
       
  4713                      User::Leave( KErrArgument ) );
       
  4714     __ASSERT_ALWAYS( aStream.State() >= CMceSrvStream::EPrepared,
       
  4715                      User::Leave( KErrArgument ) );
       
  4716 
       
  4717     //get codec
       
  4718     CMccCodecInformation* codec = 
       
  4719         iMccInterface->CodecL(         
       
  4720                 aStream.SessionId(),
       
  4721                 aStream.LinkId(),
       
  4722                 aStream.Id() );
       
  4723                 
       
  4724     CleanupStack::PushL( codec );
       
  4725     
       
  4726     //adjust codec
       
  4727     CMceComCodec* bidirectional = 
       
  4728         aStream.Codec().MccValidateL( *codec, aStream, EMceRoleOfferer );
       
  4729     aStream.Codec().MccAdjustL( *codec, aStream );
       
  4730 
       
  4731     User::LeaveIfError( 
       
  4732         iMccInterface->SetCodec( 
       
  4733                 aStream.SessionId(),
       
  4734                 aStream.LinkId(),
       
  4735                 aStream.Id(),
       
  4736                 *codec ) );
       
  4737                 
       
  4738     CleanupStack::PopAndDestroy( codec );
       
  4739     
       
  4740     MCEMM_DEBUG("CMceMediaManager::DoAdjustMccStreamL(), Exit ")
       
  4741     
       
  4742     return bidirectional;
       
  4743     }
       
  4744 
       
  4745 // ---------------------------------------------------------
       
  4746 // CMceMediaManager::DoConfigKeyUpdateL
       
  4747 // ---------------------------------------------------------    
       
  4748 //
       
  4749 void CMceMediaManager::DoConfigKeyUpdateL( 
       
  4750     CMceComMediaStream& aStream,
       
  4751     HBufC8* aConfigKey )
       
  4752     {
       
  4753     MCEMM_DEBUG("CMceMediaManager::DoConfigKeyUpdateL(), Entry ");
       
  4754     
       
  4755     __ASSERT_ALWAYS( aStream.iType == KMceVideo, User::Leave( KErrArgument ) );
       
  4756     __ASSERT_ALWAYS( aConfigKey, User::Leave( KErrArgument ) );
       
  4757     
       
  4758     RPointerArray<CMceComMediaSink>& sinks = aStream.Sinks();
       
  4759     for ( TInt i = 0; i < sinks.Count(); i++ )
       
  4760         {
       
  4761         TMceSrvStreamIterator streams( 
       
  4762             aStream.Session()->MccStreams(), aStream );
       
  4763         CMceSrvStream* stream = NULL;
       
  4764         while( streams.Next( stream ) )
       
  4765             {
       
  4766             CMceComVideoCodec& videoCodec = 
       
  4767                 reinterpret_cast<CMceComVideoCodec&>( stream->Codec() );
       
  4768             
       
  4769             MCEMM_DEBUG_STREAM( "updating config key", *stream );
       
  4770 
       
  4771              if ( videoCodec.SetConfigKeyL( aConfigKey ) )
       
  4772                 {
       
  4773                 // Synchronize codec only
       
  4774                 SynchronizeMccStreamL( *stream, 
       
  4775                                        aStream.Session()->NegotiationState().Role(),
       
  4776                                        ETrue );
       
  4777                 }
       
  4778             }
       
  4779         }
       
  4780         
       
  4781     MCEMM_DEBUG("CMceMediaManager::DoConfigKeyUpdateL(), Exit ");
       
  4782     }
       
  4783         
       
  4784 // End of File