multimediacommsengine/tsrc/MCETestUI/MCETestUIEngine/src/CMCETestUIEngine.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 #include <sip.h>
       
    19 #include <MceManager.h>
       
    20 #include <MceFCMsgExchange.h>
       
    21 #include <Mcedefs.h>
       
    22 #include <commdbconnpref.h>
       
    23 #include <f32file.h>
       
    24 #include <BADESCA.H>
       
    25 #include "CMCETestUIEngine.h"
       
    26 #include "CMCETestUIEngineMultimediaObserver.h"
       
    27 #include "CMCETestUIEngineProfileContainer.h"
       
    28 #include "CMCETestUIEngineProfile.h"
       
    29 #include "CMCETestUIEngineRefer.h"
       
    30 #include "CMCETestUIEngineOutSession.h"
       
    31 #include "CMCETestUIEngineSipObserver.h"
       
    32 #include "MMCETestUIUserInterface.h"
       
    33 #include "CMCETestUIQuestionSingleSelection.h"
       
    34 #include "CMCETestUIEngineOutEvent.h"
       
    35 #include "CMCETestUIEngineOutRefer.h"
       
    36 #include "CMCETestUIEngineCodec.h"
       
    37 #include "CMCETestUIEngineVideoCodec.h"
       
    38 #include "CMCETestUIEngineAudioStream.h"
       
    39 #include "CMCETestUIEngineVideoStream.h"
       
    40 #include "CMCETestUIEngineVideoSink.h"
       
    41 #include "CMCETestUIEngineVideoSource.h"
       
    42 #include "TMCETestUIEngineCmdUpdateSession.h"
       
    43 #include "TMCETestUIEngineCmdAcceptSession.h"
       
    44 #include "CMCETestUIEngineInSession.h"
       
    45 #include "MCETestUIDebug.h"
       
    46 #include "CMCETestUIEngineRefer.h"
       
    47 #include "CMCETestUIEngineOutSession.h"
       
    48 #include "CMCETestUIEngineInSession.h"
       
    49 #include "CMCETestUIEngineOutEvent.h"
       
    50 #include "CMCETestUIEngineInEvent.h"
       
    51 #include "CMCETestUIEngineOutRefer.h"
       
    52 #include "CMCETestUIEngineInRefer.h"
       
    53 
       
    54 // MCE Interface
       
    55 #include <MceOutSession.h>
       
    56 #include <MceInSession.h>
       
    57 #include <MceAudioStream.h>
       
    58 #include <MceVideoStream.h>
       
    59 #include <MceOutEvent.h>
       
    60 #include <MceOutRefer.h>
       
    61 #include <MceAudioCodec.h>
       
    62 #include <MCEDisplaySink.h>
       
    63 #include <MCECameraSource.h>
       
    64 #include <MCERtpSource.h>
       
    65 #include <MCEAudioCodec.h>
       
    66 #include <MCEVideoCodec.h>
       
    67 #include <MCEAMRCodec.h>
       
    68 #include <MCEMicSource.h>
       
    69 #include <MCERtpSink.h>
       
    70 #include <MCERtpSource.h>
       
    71 #include <MCESpeakerSink.h>
       
    72 #include <MCEStreamBundle.h>
       
    73 #include <mcedefs.h>
       
    74 #include <mcerefer.h>
       
    75 // Applicaple commands
       
    76 #include "TMCETestUIEngineCmdBase.h"
       
    77 #include "TMCETestUIEngineCmdCreateSession.h"
       
    78 #include "TMCETestUIEngineCmdSelectProfile.h"
       
    79 #include "TMCETestUIEngineCmdCreateEvent.h"
       
    80 
       
    81 
       
    82 // PoC priority
       
    83 const TUint KAudioPriorityPocAudioUplink                  = 95;
       
    84 const TUint KAudioPriorityPocAudioDownlink                = 95;
       
    85 const TUint KAudioPrefPocAudioUplink                      = 0x05130001;
       
    86 const TUint KAudioPrefPocAudioDownlink                    = 0x05120001;
       
    87 
       
    88 // VoIP priority
       
    89 const TUint KSVPAudioPriorityAudioUplink                  = 100;
       
    90 const TUint KSVPAudioPriorityAudioDownlink                = 100;
       
    91 const TUint KSVPAudioPrefAudioUplink                      = 0x05220001; 
       
    92 const TUint KSVPAudioPrefAudioDownlink                    = 0x05210001; 
       
    93 
       
    94 
       
    95 //SWIS Playback
       
    96 const TUint KAudioPrioritySwisPlayback                    = 74;
       
    97 const TUint KAudioPrefSwisPlayback                        = 0x05330001;
       
    98 
       
    99 
       
   100 const TUint KJitterBufferInactTimeout 					  = 10000;
       
   101 const TUint KJitterBufferSize							  = 200;
       
   102 const TUint KJitterBufferTreshold						  = 100;
       
   103 const TUint KJitterBufferTresholdRealTimeVideoVideo	      = 20;
       
   104 const TUint KJitterBufferTresholdRealTimeVideoAudio	      = 2;
       
   105 const TUint KJitterBufferSizeRealTimeVideoAudio	          = 30;
       
   106 //const TUint KJitterBufferSize							  = 1000;
       
   107 //const TUint KJitterBufferTreshold						  = 500;
       
   108 //const TUint KAudioPrefAudioUplink                      = 0x05220001;
       
   109 //const TUint KAudioPrefAudioDownlink                    = 0x05210001;
       
   110 
       
   111 // DTMF
       
   112 const TUint KDtmfAudioPriority                           = 45;
       
   113 const TUint KDtmfAudioPref                               = 0x00150001; 
       
   114 
       
   115 
       
   116 #define IS_DOWNLINK( a ) ( a->Source()->Type() == KMceRTPSource )
       
   117 
       
   118 // CONSTANTS
       
   119 
       
   120 // Experimental Uid for UI engine, reserve own if needed
       
   121 const TUid KUIEngineUid = { 0x10281F9B };  
       
   122 const TUid KUIOptionsUid = { 0x10123F9E };
       
   123 
       
   124 _LIT8( KFCTypeTBCP, "TBCP" ); 
       
   125 _LIT8( KMCERtpSinkIdentity, "RtpSink@multimedia.engine.com" ); 
       
   126 _LIT8( KMCERtpSourceIdentity, "RtpSource@multimedia.engine.com" ); 
       
   127 // ============================ MEMBER FUNCTIONS ===============================
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CMCETestUIEngine::NewL
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 EXPORT_C CMCETestUIEngine* CMCETestUIEngine::NewL() 
       
   134     {
       
   135 
       
   136     CMCETestUIEngine* self = new (ELeave) CMCETestUIEngine();
       
   137     CleanupStack::PushL( self );
       
   138     self->ConstructL( );
       
   139     CleanupStack::Pop( self );
       
   140     return self;  
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CMCETestUIEngine::CMCETestUIEngine
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 CMCETestUIEngine::CMCETestUIEngine()
       
   148     : iNextOutSessionId( 0 ),iNextInSessionId( 0 ),
       
   149       iNextOutEventId(0),iNextInEventId(0),
       
   150       iNextOutReferId(0),iNextInReferId(0),
       
   151       iFCSession(EFalse), iRtcpFlag(EFalse),iKoppaFlag(ETrue), 
       
   152       iBundle(EFalse), iSdp(EFalse),i180PreCondition(EFalse),iSecureSessionAVP(EFalse),
       
   153 	  iSecPreconditions(EFalse),iAutoResponse(EFalse),
       
   154       iVoIPFlag(EFalse), iHoldWithAddress( ETrue ),iPriorityType( KVoIPPriority ),
       
   155       iJitterBufTreshold( KJitterBufferTreshold ), iJitterBufSize( KJitterBufferSize ),
       
   156       iJitterBufTimeout(KJitterBufferInactTimeout), iMultiCodecSupport(ETrue)
       
   157      {
       
   158      }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CMCETestUIEngine::ConstructL
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 void CMCETestUIEngine::ConstructL()
       
   165     {
       
   166     iSipObserver = CMCETestUIEngineSipObserver::NewL();
       
   167   //  iSip = CSIP::NewL( KUIEngineUid, *iSipObserver );
       
   168   //	  iSip = CSIP::NewL( KUIOptionsUid, *iSipObserver );
       
   169 	iSip = iSipObserver->GetSipInstance();
       
   170     iProfiles = CMCETestUIEngineProfileContainer::NewL( *this, *iSip );
       
   171 
       
   172     iManager = CMceManager::NewL( KUIEngineUid, &iDataContainer );
       
   173 
       
   174     iMMObserver = CMCETestUIEngineMultimediaObserver::NewL( *this );
       
   175 	iManager->SetSessionObserver( iMMObserver );
       
   176 	iManager->SetTransactionObserver( iMMObserver ); 
       
   177 	iManager->SetInTransactionObserver( iMMObserver ); 
       
   178 	iManager->SetInSessionObserver( iMMObserver );
       
   179 	iManager->SetMediaObserver( iMMObserver );
       
   180 	iManager->SetRtpObserver( iMMObserver );	
       
   181 	iManager->SetEventObserver( iMMObserver );	
       
   182 	iManager->SetInEventObserver( iMMObserver );
       
   183 	iManager->SetReferObserver(iMMObserver);
       
   184 	iManager->SetInReferObserver(iMMObserver);
       
   185 	iManager->SetDtmfObserver( iMMObserver );
       
   186 		
       
   187 	iCallWatcher = CMCEPoCOmaCSCallWatcher::NewL( iMMObserver );
       
   188 	iCallWatcher->Subscribe();	
       
   189 
       
   190     iFC = CMceFcMsgExchange::NewL( *iManager, KFCTypeTBCP );
       
   191     
       
   192     iOutSessionWithProfile = EFalse;        
       
   193     iOutSessionWithAPList = EFalse;
       
   194     iOutSessionWithAPNumber = EFalse;
       
   195     }
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // CMCETestUIEngine::~CMCETestUIEngine
       
   199 // -----------------------------------------------------------------------------
       
   200 //
       
   201 EXPORT_C CMCETestUIEngine::~CMCETestUIEngine()
       
   202     {
       
   203     iCommands.ResetAndDestroy();
       
   204     iOutSessions.ResetAndDestroy();
       
   205     iInSessions.ResetAndDestroy();
       
   206     iOutEvents.ResetAndDestroy();
       
   207     iInEvents.ResetAndDestroy();
       
   208     iOutRefers.ResetAndDestroy();
       
   209     iInRefers.ResetAndDestroy();
       
   210     iTransactionIds.Close();
       
   211     delete iCallWatcher;
       
   212     delete iFC;
       
   213     delete iManager;
       
   214     delete iMMObserver;
       
   215     delete iProfiles;
       
   216     delete iSip;
       
   217     delete iSipObserver;
       
   218     }
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CMCETestUIEngine::GetCommandsL
       
   222 // -----------------------------------------------------------------------------
       
   223 //
       
   224 EXPORT_C const RPointerArray<TMCETestUIEngineCmdBase>& 
       
   225         CMCETestUIEngine::GetCommandsL()
       
   226     {
       
   227     iCommands.ResetAndDestroy();
       
   228 
       
   229     iCommands.Append( new (ELeave) TMCETestUIEngineCmdSelectProfile( *this ) );
       
   230 
       
   231     TBool canCreateOutSession = EFalse;
       
   232     
       
   233     const RPointerArray<CMCETestUIEngineProfile> profiles = UsedProfiles();
       
   234     
       
   235     // OutSession can be created with profile
       
   236     for ( TInt i = 0; i < profiles.Count(); ++i )
       
   237         {
       
   238         if ( profiles[i]->IsRegistered() )
       
   239             {
       
   240             canCreateOutSession = ETrue;
       
   241             }
       
   242         }
       
   243     
       
   244       // TODO: OutSession can be created also with event or refer.
       
   245     //       Add check for those.    
       
   246 
       
   247     
       
   248     // Provide caller with ability to create an outsession.
       
   249     if ( canCreateOutSession )
       
   250         {    
       
   251      iCommands.Append( 
       
   252                     new (ELeave) TMCETestUIEngineCmdCreateSession( *this ) );
       
   253      
       
   254         }
       
   255     iCommands.Append( 
       
   256                     new (ELeave) TMCETestUIEngineCmdCreateSessionUsingAPList( *this ) );
       
   257     iCommands.Append( 
       
   258                     new (ELeave) TMCETestUIEngineCmdCreateSessionUsingAPNumber( *this ) );
       
   259     if ( canCreateOutSession )
       
   260         {    
       
   261         iCommands.Append( 
       
   262                     new (ELeave) TMCETestUIEngineCmdCreateEvent( *this ) );
       
   263         iCommands.Append( 
       
   264                     new (ELeave) TMCETestUIEngineCmdCreateRefer( *this ) );
       
   265         
       
   266         }
       
   267     
       
   268      
       
   269         
       
   270     return iCommands;    
       
   271     }
       
   272             
       
   273 
       
   274 // -----------------------------------------------------------------------------
       
   275 // CMCETestUIEngine::SetUserInterface
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 EXPORT_C void CMCETestUIEngine::SetUserInterface(
       
   279         MMCETestUIUserInterface* aUserInterface )
       
   280     {
       
   281     iUserInterface = aUserInterface;
       
   282     }
       
   283 
       
   284 // -----------------------------------------------------------------------------
       
   285 // CMCETestUIEngine::AvailableProfiles
       
   286 // -----------------------------------------------------------------------------
       
   287 //
       
   288 EXPORT_C const RPointerArray<CMCETestUIEngineProfile>& 
       
   289         CMCETestUIEngine::AvailableProfiles( )
       
   290     {
       
   291     return iProfiles->AvailableProfiles();
       
   292     }
       
   293 
       
   294 // -----------------------------------------------------------------------------
       
   295 // CMCETestUIEngine::UsedProfiles
       
   296 // -----------------------------------------------------------------------------
       
   297 //
       
   298 EXPORT_C const RPointerArray<CMCETestUIEngineProfile>& 
       
   299         CMCETestUIEngine::UsedProfiles( )
       
   300     {
       
   301     return iProfiles->UsedProfiles();
       
   302     }
       
   303 
       
   304 // -----------------------------------------------------------------------------
       
   305 // CMCETestUIEngine::DeleteSession
       
   306 // -----------------------------------------------------------------------------
       
   307 //
       
   308 EXPORT_C void CMCETestUIEngine::DeleteSession( 
       
   309         CMCETestUIEngineSession& aSession )
       
   310     {
       
   311     for ( TInt i = 0; i < iOutSessions.Count(); ++i )
       
   312         {
       
   313         if ( iOutSessions[i] == &aSession )
       
   314             {
       
   315             delete iOutSessions[i];
       
   316             iOutSessions.Remove( i );
       
   317             iOutSessions.Compress();
       
   318             EngineStateChangedL();
       
   319             return;
       
   320             }
       
   321         }
       
   322     for ( TInt i = 0; i < iInSessions.Count(); ++i )
       
   323         {
       
   324         if ( iInSessions[i] == &aSession )
       
   325             {
       
   326          	delete iInSessions[i];
       
   327             iInSessions.Remove( i );
       
   328             iInSessions.Compress();
       
   329             EngineStateChangedL();
       
   330             return;
       
   331             }
       
   332         }
       
   333     }
       
   334 
       
   335 // -----------------------------------------------------------------------------
       
   336 // CMCETestUIEngine::CreateOutSession
       
   337 // -----------------------------------------------------------------------------
       
   338 //
       
   339 EXPORT_C CMCETestUIEngineOutSession& CMCETestUIEngine::CreateOutSessionL( 
       
   340         CMCETestUIEngineProfile& aProfile,
       
   341         TDirection aDirection ,
       
   342         TVideoDirection aVideoDirection ,
       
   343         TSessionType aSessionType)
       
   344     {
       
   345     SetPriorities();
       
   346     
       
   347     CMCETestUIEngineOutSession* outSession = CMCETestUIEngineOutSession::NewL( 
       
   348             *this, aProfile, aDirection,aVideoDirection,aSessionType );
       
   349     CleanupStack::PushL ( outSession );
       
   350     iOutSessions.Append( outSession );
       
   351 	NotifyUser( KUserNotificationSessionCreated );
       
   352 	EngineStateChangedL();	    
       
   353     CleanupStack::Pop( outSession );
       
   354     
       
   355     return *outSession;
       
   356     }
       
   357 
       
   358 // -----------------------------------------------------------------------------
       
   359 // CMCETestUIEngine::CreateOutSession
       
   360 // -----------------------------------------------------------------------------
       
   361 //
       
   362 EXPORT_C CMCETestUIEngineOutSession& CMCETestUIEngine::CreateOutSessionL( 
       
   363         TUint32 aIAPId,
       
   364         TDirection aDirection ,
       
   365         TVideoDirection aVideoDirection ,
       
   366         TSessionType aSessionType)
       
   367     {
       
   368     SetPriorities();
       
   369     
       
   370     CMCETestUIEngineOutSession* outSession = CMCETestUIEngineOutSession::NewL( 
       
   371             *this, aIAPId, aDirection,aVideoDirection,aSessionType );
       
   372     CleanupStack::PushL ( outSession );
       
   373     iOutSessions.Append( outSession );
       
   374 	NotifyUser( KUserNotificationSessionCreated );
       
   375 	EngineStateChangedL();	    
       
   376     CleanupStack::Pop( outSession );
       
   377     
       
   378     return *outSession;
       
   379     }
       
   380  // -----------------------------------------------------------------------------
       
   381 // CMCETestUIEngine::CreateOutSession
       
   382 // -----------------------------------------------------------------------------
       
   383 //
       
   384 EXPORT_C CMCETestUIEngineOutSession& CMCETestUIEngine::CreateOutSessionL( CMceRefer& aRefer)
       
   385     {
       
   386     SetPriorities();
       
   387     TSessionType sessionType = ECustomSession;	
       
   388 	        
       
   389 	TDirection direction = ENotSpesified;
       
   390 	        
       
   391 	TVideoDirection videoDirection = EVideoNotSpesified;
       
   392     CMCETestUIEngineOutSession* outSession = CMCETestUIEngineOutSession::NewL( 
       
   393             *this, aRefer ,direction,videoDirection,sessionType);
       
   394     CleanupStack::PushL ( outSession );
       
   395     iOutSessions.Append( outSession );
       
   396 	NotifyUser( KUserNotificationSessionCreated );
       
   397 	EngineStateChangedL();	    
       
   398     CleanupStack::Pop( outSession );
       
   399     
       
   400     return *outSession;
       
   401     }
       
   402     
       
   403 // -----------------------------------------------------------------------------
       
   404 // CMCETestUIEngine::CreateInSession
       
   405 // -----------------------------------------------------------------------------
       
   406 //
       
   407 EXPORT_C CMCETestUIEngineInSession& CMCETestUIEngine::CreateInSessionL(
       
   408         CMceInSession* aSession )
       
   409     {
       
   410     if ( aSession->Streams().Count()  == 0)
       
   411     	{
       
   412     	AddSendRecvDefaultAudioStreamsL(aSession);
       
   413     	}
       
   414     
       
   415     UpdateWithPriorityCodecValues(aSession);
       
   416     if( i180PreCondition )
       
   417     	{
       
   418     	aSession->SetModifierL( KMce100Rel, KMce100RelRequired );
       
   419     	}
       
   420    	
       
   421    	if( iHoldWithAddress )
       
   422     	{
       
   423     	aSession->SetModifierL( KMceMediaDirection, KMceMediaDirectionWithAddress );
       
   424     	} 
       
   425     if (iSecureSessionAVP )
       
   426 		{
       
   427 		aSession->SetModifierL( KMceSecureSession, KMceSecurePlainAVP );
       
   428 		} 	
       
   429 
       
   430     if(IsFCSession())
       
   431     	{
       
   432     	UpdatePoCValues( aSession );
       
   433     	}
       
   434     else 
       
   435     	{
       
   436     	UpdateInactivitytimeValues(aSession);
       
   437     	}
       
   438     if( iBundle )
       
   439         {
       
   440         BundleStreamsL( aSession );
       
   441         }
       
   442     UpdateRtpSink(aSession);
       
   443     
       
   444     CMCETestUIEngineInSession* inSession = CMCETestUIEngineInSession::NewL(
       
   445             *this, aSession );
       
   446     CleanupStack::PushL( inSession );
       
   447     iInSessions.Append( inSession );
       
   448 	NotifyUser( KMiscIncomingSession );
       
   449 	
       
   450 	EngineStateChangedL();	
       
   451 	CleanupStack::Pop( inSession );
       
   452 	
       
   453 	return *inSession;   
       
   454     }
       
   455 
       
   456 
       
   457 // -----------------------------------------------------------------------------
       
   458 // CMCETestUIEngine::AddSendRecvDefaultAudioStreamsL
       
   459 // -----------------------------------------------------------------------------
       
   460 //
       
   461 
       
   462 void CMCETestUIEngine::AddSendRecvDefaultAudioStreamsL(CMceInSession* aSession)
       
   463 	{
       
   464 	
       
   465 	//create stream, boundstream with micsource - rtpsink and rtpsource and speaker sink
       
   466 	    CMceAudioStream* audioOutStream = NULL;
       
   467 	    CMceAudioStream* audioOutStreamLocal = NULL;
       
   468 	 
       
   469 	    // Create outstream (== uplink)
       
   470        audioOutStream = CMceAudioStream::NewLC();
       
   471 	   CMceMicSource* mic = NULL;
       
   472 	   mic = CMceMicSource::NewLC();
       
   473 	   audioOutStream->SetSourceL( mic );	
       
   474 	   CleanupStack::Pop( mic );
       
   475 			
       
   476 	   CMceRtpSink* rtpSink;
       
   477 	  
       
   478 	   if(iRtcpFlag)
       
   479 			{
       
   480 			rtpSink = CMceRtpSink::NewL(ETrue);	
       
   481 			CleanupStack::PushL(rtpSink);
       
   482 			}
       
   483 		else
       
   484 			{
       
   485 			rtpSink = CMceRtpSink::NewLC();	
       
   486 			}
       
   487 		audioOutStream->AddSinkL( rtpSink );
       
   488 		CleanupStack::Pop( rtpSink );
       
   489 			
       
   490 	
       
   491 
       
   492 	    // Create instream (== downlink)
       
   493 	    CMceAudioStream* audioInStream = NULL;
       
   494 	    audioInStream = CMceAudioStream::NewLC();
       
   495 		CMceRtpSource* rtpSource = CMceRtpSource::NewLC( iJitterBufSize, 
       
   496                                 	                         iJitterBufTreshold, 
       
   497                                 	                         iJitterBufTimeout, 0);
       
   498 		audioInStream->SetSourceL( rtpSource );
       
   499 		CleanupStack::Pop( rtpSource );
       
   500 			
       
   501 		CMceSpeakerSink* speaker = CMceSpeakerSink::NewLC();
       
   502 		audioInStream->AddSinkL( speaker );
       
   503 		CleanupStack::Pop( speaker );
       
   504 		
       
   505 	   
       
   506 		audioOutStream->BindL( audioInStream ); 
       
   507 	    CleanupStack::Pop( audioInStream );     
       
   508 	
       
   509 	   // Add streams to OutSession    
       
   510 	    aSession->AddStreamL( audioOutStream );
       
   511 	    CleanupStack::Pop( audioOutStream );
       
   512 	
       
   513  	}
       
   514 
       
   515 // -----------------------------------------------------------------------------
       
   516 // CMCETestUIEngine::UpdateIncomingSessionVoIPData
       
   517 // -----------------------------------------------------------------------------
       
   518 //
       
   519 void CMCETestUIEngine::UpdateIncomingSessionVoIPDataL(CMceInSession* aSession)
       
   520 	{
       
   521 	
       
   522 	// modify codecs and codec settings if streams found
       
   523     if ( aSession->Streams().Count() )
       
   524         {
       
   525        	const RPointerArray< CMceMediaStream >& streams = aSession->Streams();
       
   526        for ( TInt i = 0; i < streams.Count(); i++ )
       
   527             {
       
   528             CMceMediaStream* stream1 = ( CMceMediaStream* ) streams[i];
       
   529             if ( KMceVideo == stream1->Type() )
       
   530                 {
       
   531                 aSession->RemoveStreamL( *streams[ i ] );
       
   532                 }
       
   533             
       
   534             if ( stream1->Source() && stream1->Source()->Type() == KMceRTPSource )
       
   535                 {
       
   536                	CMceRtpSource* rtpSource = ( CMceRtpSource* ) stream1->Source();
       
   537                	rtpSource->UpdateL( 16, 11, 1100 ); // magic numbers
       
   538                	rtpSource->DisableL();
       
   539                 }
       
   540                 
       
   541             if ( stream1->Sinks().Count()  )
       
   542                 {
       
   543                 const RPointerArray< CMceMediaSink >& sinks = stream1->Sinks();
       
   544                 
       
   545                  for ( TInt z = 0; z < sinks.Count(); z++ )
       
   546                     {
       
   547                     if ( sinks[ z ]->Type() == KMceSpeakerSink )
       
   548                         {
       
   549                         CMceSpeakerSink* speakerSink = ( CMceSpeakerSink* )  sinks[ z ];
       
   550                         speakerSink->DisableL();                       
       
   551                         }
       
   552                     } 
       
   553                 }
       
   554             
       
   555             if ( stream1->Source() && stream1->Source()->Type() == KMceMicSource )
       
   556                 {
       
   557                	CMceMicSource* micSource = ( CMceMicSource* ) stream1->Source();
       
   558                	micSource->DisableL();
       
   559                 }
       
   560             }
       
   561         }
       
   562   //  CheckStreamsL( *aSession );   
       
   563    const RPointerArray< CMceMediaStream >& streamArray = aSession->Streams();
       
   564    for ( TInt i = 0; i < streamArray.Count(); i++ )
       
   565         {
       
   566         CMceAudioStream* audioStream = ( CMceAudioStream* ) streamArray[ i ];
       
   567         
       
   568         TUint priority = IS_DOWNLINK( audioStream ) ? 
       
   569                 KSVPAudioPriorityAudioDownlink : 
       
   570                 KSVPAudioPriorityAudioUplink;
       
   571                 
       
   572         TUint preference = IS_DOWNLINK( audioStream ) ?
       
   573                 KSVPAudioPrefAudioDownlink :
       
   574                 KSVPAudioPrefAudioUplink;
       
   575             
       
   576         SetMMFPriorityForCodecsL( audioStream->Codecs(),
       
   577                                   priority, 
       
   578                                   preference );
       
   579         
       
   580         if ( audioStream->BoundStream() )
       
   581             {
       
   582             CMceAudioStream* audioStream2 = ( CMceAudioStream* ) &audioStream->BoundStreamL();
       
   583 
       
   584             priority = IS_DOWNLINK( audioStream2 ) ? 
       
   585                 KSVPAudioPriorityAudioDownlink : 
       
   586                 KSVPAudioPriorityAudioUplink;
       
   587                 
       
   588             preference = IS_DOWNLINK( audioStream2 ) ?
       
   589                 KSVPAudioPrefAudioDownlink :
       
   590                 KSVPAudioPrefAudioUplink;
       
   591                 
       
   592             SetMMFPriorityForCodecsL( audioStream2->Codecs(),
       
   593                                       priority, 
       
   594                                       preference );
       
   595             }
       
   596         }
       
   597         
       
   598 	aSession->SetModifierL( KMcePreconditions, KMcePreconditionsNotUsed  );
       
   599     aSession->UpdateL();
       
   600  //   aSession->RingL();
       
   601  //   aSession->AcceptL();
       
   602     
       
   603     
       
   604 	}
       
   605 
       
   606 // -----------------------------------------------------------------------------
       
   607 // CMCETestUIEngine::SetMMFPriorityForCodecsL
       
   608 // -----------------------------------------------------------------------------
       
   609 //	
       
   610 void CMCETestUIEngine::SetMMFPriorityForCodecsL( 
       
   611     const RPointerArray<CMceAudioCodec>& aCodecs, 
       
   612     TUint aAudioPriority, 
       
   613     TUint aAudioPreference )
       
   614     {
       
   615     for ( TInt z = 0; z < aCodecs.Count(); z++ )
       
   616         {
       
   617         if ( !aCodecs[ z ]->SdpName().Compare( KMceSDPNameDtmf ) )
       
   618             {
       
   619             aCodecs[ z ]->SetMMFPriorityL( KDtmfAudioPriority );
       
   620             aCodecs[ z ]->SetMMFPriorityPreferenceL( KDtmfAudioPref );    
       
   621             }
       
   622         else
       
   623             {
       
   624             aCodecs[ z ]->SetMMFPriorityL( aAudioPriority );
       
   625             aCodecs[ z ]->SetMMFPriorityPreferenceL( aAudioPreference );    
       
   626             }
       
   627         }
       
   628     }
       
   629 
       
   630 // -----------------------------------------------------------------------------
       
   631 // CMCETestUIEngine::SetMMFPriorityForCodecsL
       
   632 // -----------------------------------------------------------------------------
       
   633 //	
       
   634 void CMCETestUIEngine::SetMMFPriorityForCodecsL( 
       
   635     const RPointerArray<CMceVideoCodec>& aCodecs, 
       
   636     TUint aPriority, 
       
   637     TUint aPreference )
       
   638     {
       
   639     for ( TInt z = 0; z < aCodecs.Count(); z++ )
       
   640         {
       
   641         aCodecs[ z ]->SetMMFPriorityL( aPriority );
       
   642         aCodecs[ z ]->SetMMFPriorityPreferenceL( aPreference );    
       
   643         }
       
   644     }
       
   645         
       
   646 // -----------------------------------------------------------------------------
       
   647 // CMCETestUIEngine::UpdateIncomingSessionVoIPDataAfterAnswerL
       
   648 // -----------------------------------------------------------------------------
       
   649 //
       
   650 void CMCETestUIEngine::UpdateIncomingSessionVoIPDataAfterAnswerL(CMceInSession& aSession)
       
   651 	{
       
   652 	const RPointerArray<CMceMediaStream>& streams = aSession.Streams();
       
   653     
       
   654     for ( TInt i = 0; i < streams.Count(); i++ )
       
   655         {
       
   656         CMceMediaStream* stream1 = ( CMceMediaStream* ) streams[i];
       
   657         
       
   658         if ( stream1->Source() && stream1->Source()->Type() == KMceRTPSource )
       
   659             {
       
   660             CMceRtpSource* rtpSource = ( CMceRtpSource* ) stream1->Source();
       
   661            	rtpSource->EnableL();
       
   662             }
       
   663             
       
   664         if ( stream1->Sinks().Count()  )
       
   665             {
       
   666             const RPointerArray< CMceMediaSink >& sinks = stream1->Sinks();
       
   667             
       
   668              for ( TInt z = 0; z < sinks.Count(); z++ )
       
   669                 {
       
   670                 if ( sinks[ z ]->Type() == KMceSpeakerSink )
       
   671                     {
       
   672                     CMceSpeakerSink* speakerSink = 
       
   673                         ( CMceSpeakerSink* )  sinks[ z ];
       
   674                     speakerSink->EnableL();
       
   675                     }
       
   676                 } 
       
   677             }
       
   678         
       
   679         if ( stream1->Source() && stream1->Source()->Type() == KMceMicSource )
       
   680             {
       
   681            	CMceMicSource* micSource = ( CMceMicSource* ) stream1->Source();
       
   682            	micSource->EnableL();
       
   683             }  
       
   684         } 	
       
   685 	}
       
   686 // -----------------------------------------------------------------------------
       
   687 // CMCETestUIEngine::IncomingUpdateL
       
   688 // -----------------------------------------------------------------------------
       
   689 //
       
   690 EXPORT_C void CMCETestUIEngine::IncomingUpdateL(CMceSession& aOrigSession, 
       
   691 					CMceInSession* aUpdatedSession)
       
   692 	{
       
   693 	 for ( TInt i = 0; i < iOutSessions.Count(); ++i )
       
   694         {
       
   695         CMceOutSession& wrappedSession = iOutSessions[i]->OutSession();
       
   696         if ( &wrappedSession == &aOrigSession )
       
   697             {
       
   698          	delete iOutSessions[i];
       
   699             iOutSessions.Remove( i );
       
   700             iOutSessions.Compress();
       
   701             CMCETestUIEngineInSession& inSession = CreateInSessionL(aUpdatedSession);
       
   702             return;
       
   703             }
       
   704         }
       
   705 
       
   706 	 for ( TInt i = 0; i < iInSessions.Count(); ++i )
       
   707         {
       
   708         CMceInSession& wrappedSession = iInSessions[i]->InSession();
       
   709         if ( &wrappedSession == &aOrigSession )
       
   710             {
       
   711          	delete iInSessions[i];
       
   712             iInSessions.Remove( i );
       
   713             iInSessions.Compress();
       
   714             CMCETestUIEngineInSession& inSession = CreateInSessionL(aUpdatedSession);
       
   715             return;
       
   716             }
       
   717         }
       
   718 	}
       
   719 
       
   720 // -----------------------------------------------------------------------------
       
   721 // CMCETestUIEngine::OutSessions
       
   722 // -----------------------------------------------------------------------------
       
   723 //
       
   724 EXPORT_C const RPointerArray<CMCETestUIEngineOutSession>& 
       
   725         CMCETestUIEngine::OutSessions( )
       
   726     {
       
   727     return iOutSessions;
       
   728     }
       
   729 
       
   730 // -----------------------------------------------------------------------------
       
   731 // CMCETestUIEngine::InSessions
       
   732 // -----------------------------------------------------------------------------
       
   733 //
       
   734 EXPORT_C const RPointerArray<CMCETestUIEngineInSession>& 
       
   735         CMCETestUIEngine::InSessions( )
       
   736     {
       
   737     return iInSessions;
       
   738     }
       
   739 
       
   740 // -----------------------------------------------------------------------------
       
   741 // CMCETestUIEngine::ProfileContainer
       
   742 // -----------------------------------------------------------------------------
       
   743 //
       
   744 CMCETestUIEngineProfileContainer& CMCETestUIEngine::ProfileContainer()
       
   745     {
       
   746     return *iProfiles;
       
   747     }
       
   748 
       
   749 // -----------------------------------------------------------------------------
       
   750 // CMCETestUIEngine::MCEManager
       
   751 // -----------------------------------------------------------------------------
       
   752 //
       
   753 CMceManager& CMCETestUIEngine::MCEManager()
       
   754     {
       
   755     return *iManager;
       
   756     }
       
   757 
       
   758 // -----------------------------------------------------------------------------
       
   759 // CMCETestUIEngine::MMObserver
       
   760 // -----------------------------------------------------------------------------
       
   761 //  
       
   762     
       
   763 CMCETestUIEngineMultimediaObserver& CMCETestUIEngine::MMObserver()
       
   764 	{
       
   765 	return *iMMObserver;
       
   766 	}
       
   767 
       
   768 // -----------------------------------------------------------------------------
       
   769 // CMCETestUIEngine::FloorControl
       
   770 // -----------------------------------------------------------------------------
       
   771 //
       
   772 CMceFcMsgExchange& CMCETestUIEngine::FloorControl()
       
   773 	{
       
   774 	return *iFC;
       
   775 	}
       
   776 
       
   777 // -----------------------------------------------------------------------------
       
   778 // CMCETestUIEngine::EngineStateChanged
       
   779 // -----------------------------------------------------------------------------
       
   780 //
       
   781 void CMCETestUIEngine::EngineStateChangedL()
       
   782     {
       
   783     if ( iUserInterface )
       
   784         {
       
   785         iUserInterface->EngineStateChangedL();
       
   786         }
       
   787     }
       
   788 // -----------------------------------------------------------------------------
       
   789 // CMCETestUIEngine::NotifyUser
       
   790 // -----------------------------------------------------------------------------
       
   791 //
       
   792 void CMCETestUIEngine::NotifyUser( const TDesC& aMessage )
       
   793     {
       
   794     if ( iUserInterface )
       
   795         {
       
   796         iUserInterface->NotifyUser( aMessage );
       
   797         }
       
   798     }
       
   799     
       
   800 void CMCETestUIEngine::NotifyUserWaitL ( const TDesC& aMessage )
       
   801   {
       
   802   if ( iUserInterface )
       
   803      {
       
   804      iUserInterface->NotifyUserWaitL ( aMessage );
       
   805      }
       
   806   }
       
   807 
       
   808 // -----------------------------------------------------------------------------
       
   809 // CMCETestUIEngine::AskQuestion
       
   810 // -----------------------------------------------------------------------------
       
   811 //
       
   812 TInt CMCETestUIEngine::AskQuestionL( 
       
   813         const CMCETestUIQuestionSingleSelection& aQuestion )
       
   814     {
       
   815     if ( iUserInterface )
       
   816         {
       
   817         return iUserInterface->AskQuestionL( aQuestion );
       
   818         }    
       
   819     return KErrNotReady;
       
   820     }
       
   821 
       
   822 // -----------------------------------------------------------------------------
       
   823 // CMCETestUIEngine::AskQuestion
       
   824 // -----------------------------------------------------------------------------
       
   825 //
       
   826 void CMCETestUIEngine::AskQuestionL( CMCETestUIQuestionDataQuery& aQuestion )
       
   827     {
       
   828     if ( iUserInterface )
       
   829         {
       
   830         iUserInterface->AskQuestionL( aQuestion );
       
   831         }     
       
   832     }
       
   833 // -----------------------------------------------------------------------------
       
   834 // CMCETestUIEngine::SessionParams
       
   835 // -----------------------------------------------------------------------------
       
   836 //
       
   837 
       
   838 TBool CMCETestUIEngine::SessionParamsL(TSessionParams &aSessionParams, TSessionType aSessionType)
       
   839 {
       
   840 	if ( iUserInterface )
       
   841         {
       
   842         return iUserInterface->SessionParamsL( aSessionParams,aSessionType );
       
   843         }     
       
   844     return EFalse;    
       
   845 }
       
   846 
       
   847 // -----------------------------------------------------------------------------
       
   848 // CMCETestUIEngine::SessionEstablishValues
       
   849 // -----------------------------------------------------------------------------
       
   850 //
       
   851 
       
   852 TBool CMCETestUIEngine::SessionEstablishValues(TSessionEstablishValues &sessionValues)
       
   853 	{
       
   854 	if ( iUserInterface )
       
   855         {
       
   856         return iUserInterface->SessionEstablishValues( sessionValues);
       
   857         }     
       
   858     return EFalse;
       
   859 	}
       
   860 	
       
   861 // -----------------------------------------------------------------------------
       
   862 // CMCETestUIEngine::SessionResponseValues
       
   863 // -----------------------------------------------------------------------------
       
   864 //
       
   865 
       
   866 TBool CMCETestUIEngine::SessionResponseValues(TSessionResponseValues &responseValues)
       
   867 	{
       
   868 	if ( iUserInterface )
       
   869         {
       
   870         return iUserInterface->SessionResponseValues( responseValues);
       
   871         }     
       
   872     return EFalse;
       
   873 	}
       
   874 
       
   875 // -----------------------------------------------------------------------------
       
   876 // CMCETestUIEngine::SessionEstablishValues
       
   877 // -----------------------------------------------------------------------------
       
   878 //
       
   879 
       
   880 TBool CMCETestUIEngine::NotifyValues(TNotifyValues &notifyValues)
       
   881 	{
       
   882 	if ( iUserInterface )
       
   883         {
       
   884         return iUserInterface->NotifyValues( notifyValues);
       
   885         }     
       
   886     return EFalse;
       
   887 	}		
       
   888 // -----------------------------------------------------------------------------
       
   889 // CMCETestUIEngine::NextOutSessionId
       
   890 // -----------------------------------------------------------------------------
       
   891 //
       
   892 TInt CMCETestUIEngine::NextOutSessionId()
       
   893     {
       
   894     return iNextOutSessionId++;
       
   895     }
       
   896 
       
   897 // -----------------------------------------------------------------------------
       
   898 // CMCETestUIEngine::NextInSessionId
       
   899 // -----------------------------------------------------------------------------
       
   900 //
       
   901 TInt CMCETestUIEngine::NextInSessionId()
       
   902     {
       
   903     return iNextInSessionId++;
       
   904     }
       
   905 
       
   906 // -----------------------------------------------------------------------------
       
   907 // CMCETestUIEngine::UpdateWithPoCValues
       
   908 // -----------------------------------------------------------------------------
       
   909 //
       
   910 void CMCETestUIEngine::UpdatePoCValues(CMceInSession* aSession)
       
   911 	{
       
   912 	RDebug::Print( _L( "*MCE Test UI* UpdatePoCValues-Entry" ));
       
   913 	const RPointerArray<CMceMediaStream>& streams = aSession->Streams();
       
   914 
       
   915     if ( streams.Count() == 0 )
       
   916         {
       
   917         User::Leave( KErrNoMemory );
       
   918         }
       
   919     
       
   920     CMceMediaStream* inStream = (CMceAudioStream*) streams[0]; 
       
   921     CMceAudioStream* audioIn = NULL;
       
   922     if( inStream->Type() == KMceAudio )
       
   923         {
       
   924         audioIn = (CMceAudioStream*) inStream;
       
   925         }
       
   926     else
       
   927         {
       
   928         User::Leave( KErrArgument );
       
   929         }
       
   930     
       
   931     CMceMediaStream& outStream = inStream->BoundStreamL();
       
   932     CMceAudioStream* audioOut = (CMceAudioStream*) &outStream;
       
   933 	
       
   934 	const RPointerArray<CMceAudioCodec>& codecs = audioIn->Codecs();
       
   935 	
       
   936 	for( int i = 0; i < codecs.Count(); i++ )
       
   937 	    {
       
   938 	    CMceAudioCodec* codec = codecs[i];
       
   939 	    // Search for AMR codec and delete others
       
   940 	    if( codec->SdpName().Find( KMceSDPNameAMR ) == KErrNotFound )
       
   941 	        {
       
   942 	        audioIn->RemoveCodecL( *codec );
       
   943 	        --i;
       
   944 	        }
       
   945 	    }
       
   946 	    
       
   947 	if( ( codecs.Count() != 1 ) || 
       
   948 	    ( codecs[0]->SdpName().Find( KMceSDPNameAMR ) == KErrNotFound ))
       
   949 	    {
       
   950 	    // AMR codec not found
       
   951 	    User::Leave( KErrArgument );
       
   952 	    }
       
   953 	
       
   954 	CMceRtpSource* rtpSource = (CMceRtpSource*) inStream->Source();
       
   955 	HBufC8* rtpSourceIdentity = KMCERtpSourceIdentity().AllocLC();
       
   956 	rtpSource->UpdateL( iJitterBufSize, 
       
   957 					    iJitterBufTreshold, 
       
   958 					    iJitterBufTimeout,
       
   959 					    rtpSourceIdentity );	
       
   960 	CleanupStack::PopAndDestroy(rtpSourceIdentity);
       
   961 	CMceMicSource* micSource = (CMceMicSource*)audioOut->Source();
       
   962 	micSource->DisableL();
       
   963 	CMceMediaSink* rtpOutSink = (CMceMediaSink*) audioOut->Sinks()[0];
       
   964 //	rtpOutSink->DisableL();  
       
   965 	// disabling RTCP sending
       
   966 	HBufC8* rtpSinkIdentity = KMCERtpSinkIdentity().AllocLC();
       
   967 	((CMceRtpSink*)rtpOutSink)->UpdateL( ETrue,rtpSinkIdentity ); 
       
   968 	RDebug::Print( _L( "*MCE Test UI* UpdatePoCValues-Exit" )); 
       
   969 	CleanupStack::PopAndDestroy(rtpSinkIdentity);
       
   970 
       
   971 	}
       
   972 // -----------------------------------------------------------------------------
       
   973 // CMCETestUIEngine::UpdateInactivitytimeValues
       
   974 // -----------------------------------------------------------------------------
       
   975 //
       
   976 void CMCETestUIEngine::UpdateInactivitytimeValues(CMceInSession* aSession)
       
   977 	{	
       
   978 	const RPointerArray<CMceMediaStream>& streams = aSession->Streams();
       
   979 
       
   980     if ( streams.Count() == 0 )
       
   981         {
       
   982         User::Leave( KErrNoMemory );
       
   983         }
       
   984         
       
   985     TBool sendRecvVideo = IsSendRecvVideo( aSession );
       
   986 	for ( TInt i = 0; i < streams.Count(); ++i )
       
   987 		{
       
   988 		TInt jitbufSize( iJitterBufSize );
       
   989     	TInt jitbufThreshold( iJitterBufTreshold );
       
   990     	TInt jitbufTimeout( iJitterBufTimeout );
       
   991 	
       
   992 		CMceMediaStream* mediaStream = 
       
   993                                     static_cast<CMceMediaStream*>(streams[i]);
       
   994 
       
   995     	GetJitterBufferValues( 
       
   996     	    mediaStream, jitbufSize, jitbufThreshold, jitbufTimeout, sendRecvVideo );
       
   997 
       
   998         HBufC8* rtpSourceIdentity = KMCERtpSourceIdentity().AllocLC();
       
   999         if ( mediaStream->Source()->Type() == KMceRTPSource )
       
  1000         	{
       
  1001         
       
  1002         	CMceRtpSource* rtpSource = (CMceRtpSource*) mediaStream->Source();
       
  1003 			rtpSource->UpdateL( jitbufSize, 
       
  1004 					            jitbufThreshold, 
       
  1005 					            jitbufTimeout,
       
  1006 					            rtpSourceIdentity);
       
  1007         	}
       
  1008         if( mediaStream->BoundStream() )
       
  1009             {
       
  1010             CMceMediaSource* boundsource = mediaStream->BoundStreamL().Source();
       
  1011             if( boundsource->Type() == KMceRTPSource )
       
  1012                 {
       
  1013                 CMceRtpSource* boundRtpSource = (CMceRtpSource*) boundsource;
       
  1014                 boundRtpSource->UpdateL( jitbufSize, 
       
  1015 					                  jitbufThreshold, 
       
  1016 					                  jitbufTimeout,
       
  1017 					                  rtpSourceIdentity );
       
  1018                 }
       
  1019             }
       
  1020          CleanupStack::PopAndDestroy(rtpSourceIdentity);
       
  1021 		}
       
  1022     }
       
  1023 // -----------------------------------------------------------------------------
       
  1024 // CMCETestUIEngine::UpdateRtpSink
       
  1025 // -----------------------------------------------------------------------------
       
  1026 //
       
  1027 void CMCETestUIEngine::UpdateRtpSink(CMceInSession* aSession)
       
  1028 	{
       
  1029 	if ( IsSendRecvVideo( aSession ) )
       
  1030 	    {
       
  1031 	    // Don't use rtcp in sendrecv video session
       
  1032 	    iRtcpFlag = ETrue;
       
  1033 	    }
       
  1034 	
       
  1035 	const RPointerArray<CMceMediaStream>& streams = aSession->Streams();
       
  1036 
       
  1037     if ( streams.Count() == 0 )
       
  1038         {
       
  1039         User::Leave( KErrNoMemory );
       
  1040         }
       
  1041 	for ( TInt i = 0; i < streams.Count(); ++i )
       
  1042 		{
       
  1043 		CMceMediaStream* mediaStream = 
       
  1044                                     static_cast<CMceMediaStream*>(streams[i]);
       
  1045         const RPointerArray<CMceMediaSink>& sinks = mediaStream->Sinks();
       
  1046         for ( TInt j = 0; j < sinks.Count(); ++j )
       
  1047         	{
       
  1048         	if(sinks[j]->Type() == KMceRTPSink)
       
  1049         		{
       
  1050         		CMceRtpSink* rtpSink = (CMceRtpSink*)(sinks[j]);
       
  1051         		HBufC8* rtpSinkIdentity = KMCERtpSinkIdentity().AllocLC();
       
  1052         		rtpSink->UpdateL( iRtcpFlag, rtpSinkIdentity );
       
  1053         		CleanupStack::PopAndDestroy(rtpSinkIdentity);
       
  1054         		}
       
  1055         	}
       
  1056         if( mediaStream->BoundStream() )
       
  1057             {
       
  1058             const RPointerArray<CMceMediaSink>& boundsinks = mediaStream->BoundStreamL().Sinks();
       
  1059             for ( TInt j = 0; j < boundsinks.Count(); ++j )
       
  1060             	{
       
  1061             	if(boundsinks[j]->Type() == KMceRTPSink)
       
  1062             		{
       
  1063             		CMceRtpSink* rtpSink = (CMceRtpSink*)(boundsinks[j]);
       
  1064             		HBufC8* rtpSinkIdentity = KMCERtpSinkIdentity().AllocLC();
       
  1065         			rtpSink->UpdateL( iRtcpFlag, rtpSinkIdentity );
       
  1066         			CleanupStack::PopAndDestroy(rtpSinkIdentity);
       
  1067             		}
       
  1068             	}
       
  1069             }
       
  1070       	}
       
  1071     }
       
  1072     
       
  1073 // -----------------------------------------------------------------------------
       
  1074 // CMCETestUIEngine::BundleStreamsL
       
  1075 // -----------------------------------------------------------------------------
       
  1076 //
       
  1077 void CMCETestUIEngine::BundleStreamsL( CMceInSession* aSession )
       
  1078 	{
       
  1079 	const RPointerArray<CMceMediaStream>& streams = aSession->Streams();
       
  1080 
       
  1081     if ( streams.Count() == 0 )
       
  1082         {
       
  1083         User::Leave( KErrNoMemory );
       
  1084         }
       
  1085         
       
  1086     CMceMediaStream* audioStream = NULL;
       
  1087     CMceMediaStream* videoStream = NULL;
       
  1088         
       
  1089 	for ( TInt i = 0; i < streams.Count(); ++i )
       
  1090 		{
       
  1091 		CMceMediaStream* mediaStream = 
       
  1092                                     static_cast<CMceMediaStream*>(streams[i]);
       
  1093         
       
  1094         CMceMediaSource* source = mediaStream->Source();
       
  1095         User::LeaveIfNull( source );
       
  1096         if( mediaStream->Type() == KMceAudio && source->Type() == KMceRTPSource )
       
  1097             {
       
  1098             audioStream = mediaStream;
       
  1099             }
       
  1100         else if( mediaStream->Type() == KMceVideo && source->Type() == KMceRTPSource )
       
  1101             {
       
  1102             videoStream = mediaStream;
       
  1103             }      
       
  1104         if( mediaStream->BoundStream() )
       
  1105             {
       
  1106             CMceMediaStream* boundStream = &mediaStream->BoundStreamL();
       
  1107             
       
  1108             CMceMediaSource* boundsource = boundStream->Source();
       
  1109             User::LeaveIfNull( boundsource );
       
  1110             
       
  1111             if( boundStream->Type() == KMceAudio && boundsource->Type() == KMceRTPSource )
       
  1112                 {
       
  1113                 audioStream = mediaStream;
       
  1114                 }
       
  1115              else if( boundStream->Type() == KMceVideo && boundsource->Type() == KMceRTPSource )
       
  1116                 {
       
  1117                 videoStream = mediaStream;
       
  1118                 }     
       
  1119             }
       
  1120       	}
       
  1121     if( audioStream && videoStream )
       
  1122         {
       
  1123         CMceStreamBundle* bundle = CMceStreamBundle::NewLC( CMceStreamBundle::ELS );
       
  1124         bundle->AddStreamL( *audioStream );
       
  1125         bundle->AddStreamL( *videoStream );
       
  1126         CleanupStack::Pop( bundle );
       
  1127         aSession->AddBundleL( bundle );
       
  1128         }
       
  1129     }
       
  1130     
       
  1131       
       
  1132 // -----------------------------------------------------------------------------
       
  1133 // CMCETestUIEngine::UpdateWithPocPriorityCodecValues
       
  1134 // -----------------------------------------------------------------------------
       
  1135 //
       
  1136 // -----------------------------------------------------------------------------
       
  1137 // CMCETestUIEngine::SetPriorities
       
  1138 // -----------------------------------------------------------------------------
       
  1139 //
       
  1140 void CMCETestUIEngine::SetPriorities()
       
  1141 	{
       
  1142     if( iPriorityType == KPoCPriority )
       
  1143         {
       
  1144         iPriorityUplink = KAudioPriorityPocAudioUplink;
       
  1145         iPriorityDownlink = KAudioPriorityPocAudioDownlink;
       
  1146         iPrefUplink = KAudioPrefPocAudioUplink;
       
  1147         iPrefDownlink = KAudioPrefPocAudioDownlink;
       
  1148         }
       
  1149     else if( iPriorityType == KVoIPPriority )
       
  1150         {
       
  1151         iPriorityUplink = KSVPAudioPriorityAudioUplink;
       
  1152         iPriorityDownlink = KSVPAudioPriorityAudioDownlink;
       
  1153         iPrefUplink = KSVPAudioPrefAudioUplink;
       
  1154         iPrefDownlink = KSVPAudioPrefAudioDownlink;
       
  1155         }
       
  1156     else
       
  1157         {
       
  1158         iPriorityUplink = KAudioPrioritySwisPlayback;
       
  1159         iPriorityDownlink = KAudioPrioritySwisPlayback;
       
  1160         iPrefUplink = KAudioPrefSwisPlayback;
       
  1161         iPrefDownlink = KAudioPrefSwisPlayback;
       
  1162         }
       
  1163 	}
       
  1164 
       
  1165 
       
  1166 // -----------------------------------------------------------------------------
       
  1167 // CMCETestUIEngine::UpdateWithPriorityCodecValues
       
  1168 // -----------------------------------------------------------------------------
       
  1169 //
       
  1170 void CMCETestUIEngine::UpdateWithPriorityCodecValues(CMceInSession* aSession)
       
  1171 	{
       
  1172 	
       
  1173 	SetPriorities();
       
  1174 	
       
  1175 	const RPointerArray<CMceMediaStream>& streams = aSession->Streams();
       
  1176 	
       
  1177 	for ( TInt i = 0; i < streams.Count(); ++i )
       
  1178         {        
       
  1179         if ( streams[i]->Type() == KMceAudio )
       
  1180             {
       
  1181             CMceAudioStream* audioStream = ( CMceAudioStream* ) streams[ i ];
       
  1182             
       
  1183             TUint priority = IS_DOWNLINK( audioStream ) ? 
       
  1184                     iPriorityDownlink : 
       
  1185                     iPriorityUplink;
       
  1186                     
       
  1187             TUint preference = IS_DOWNLINK( audioStream ) ?
       
  1188                     iPrefDownlink :
       
  1189                     iPrefUplink;
       
  1190                 
       
  1191             SetMMFPriorityForCodecsL( audioStream->Codecs(),
       
  1192                                       priority, 
       
  1193                                       preference );
       
  1194             
       
  1195             if ( audioStream->BoundStream() )
       
  1196                 {
       
  1197                 CMceAudioStream* audioStream2 = ( CMceAudioStream* ) &audioStream->BoundStreamL();
       
  1198 
       
  1199                 priority = IS_DOWNLINK( audioStream2 ) ? 
       
  1200                     iPriorityDownlink : 
       
  1201                     iPriorityUplink;
       
  1202                     
       
  1203                 preference = IS_DOWNLINK( audioStream2 ) ?
       
  1204                     iPrefDownlink :
       
  1205                     iPrefUplink;
       
  1206                     
       
  1207                 SetMMFPriorityForCodecsL( audioStream2->Codecs(),
       
  1208                                           priority, 
       
  1209                                           preference );
       
  1210                 }
       
  1211             }
       
  1212         else if ( streams[i]->Type() == KMceVideo )
       
  1213             {
       
  1214             // Direction does not matter in video case
       
  1215             CMceVideoStream* videoStream = ( CMceVideoStream* ) streams[ i ];
       
  1216             SetMMFPriorityForCodecsL( videoStream->Codecs(),
       
  1217                                       iPriorityDownlink, 
       
  1218                                       iPrefDownlink );
       
  1219             if ( videoStream->BoundStream() )
       
  1220                 {
       
  1221                 CMceVideoStream* videoStream2 = ( CMceVideoStream* ) &videoStream->BoundStreamL();
       
  1222                 SetMMFPriorityForCodecsL( videoStream2->Codecs(),
       
  1223                                           iPriorityDownlink, 
       
  1224                                           iPrefDownlink );
       
  1225                 }
       
  1226             }
       
  1227         else
       
  1228             {
       
  1229             // NOP
       
  1230             }
       
  1231         }
       
  1232 	}
       
  1233 	
       
  1234 // -----------------------------------------------------------------------------
       
  1235 // CMCETestUIEngine::DeleteEvent
       
  1236 // -----------------------------------------------------------------------------
       
  1237 //
       
  1238 EXPORT_C void CMCETestUIEngine::DeleteEvent( 
       
  1239         CMCETestUIEngineEvent& aEvent )
       
  1240     {
       
  1241     for ( TInt i = 0; i < iOutEvents.Count(); ++i )
       
  1242         {
       
  1243         if ( iOutEvents[i] == &aEvent )
       
  1244             {
       
  1245             delete iOutEvents[i];
       
  1246             iOutEvents.Remove( i );
       
  1247             iOutEvents.Compress();
       
  1248             EngineStateChangedL();
       
  1249             return;
       
  1250             }
       
  1251         }
       
  1252     for ( TInt i = 0; i < iInEvents.Count(); ++i )
       
  1253         {
       
  1254         if ( iInEvents[i] == &aEvent )
       
  1255             {
       
  1256          	delete iInEvents[i];
       
  1257             iInEvents.Remove( i );
       
  1258             iInEvents.Compress();
       
  1259             EngineStateChangedL();
       
  1260             return;
       
  1261             }
       
  1262         }
       
  1263     }
       
  1264 
       
  1265 // -----------------------------------------------------------------------------
       
  1266 // CMCETestUIEngine::CreateOutEvent
       
  1267 // -----------------------------------------------------------------------------
       
  1268 //
       
  1269 EXPORT_C CMCETestUIEngineOutEvent& CMCETestUIEngine::CreateOutEventL( 
       
  1270         CMCETestUIEngineProfile& aProfile)
       
  1271     {
       
  1272     
       
  1273     CMCETestUIEngineOutEvent* outEvent = CMCETestUIEngineOutEvent::NewL( 
       
  1274             *this, aProfile);
       
  1275     CleanupStack::PushL ( outEvent);
       
  1276     iOutEvents.Append( outEvent );
       
  1277 	NotifyUser( KUserNotificationEventCreated );
       
  1278 	EngineStateChangedL();	    
       
  1279     CleanupStack::Pop( outEvent );
       
  1280     
       
  1281     return *outEvent;
       
  1282     }
       
  1283 
       
  1284 // -----------------------------------------------------------------------------
       
  1285 // CMCETestUIEngine::CreateOutEvent
       
  1286 // -----------------------------------------------------------------------------
       
  1287 //
       
  1288 EXPORT_C CMCETestUIEngineOutEvent& CMCETestUIEngine::CreateOutEventL( 
       
  1289         CMceOutEvent* aEvent)
       
  1290     {
       
  1291     
       
  1292     CMCETestUIEngineOutEvent* outEvent = CMCETestUIEngineOutEvent::NewL( 
       
  1293             *this, aEvent);
       
  1294     CleanupStack::PushL ( outEvent);
       
  1295     iOutEvents.Append( outEvent );
       
  1296 	NotifyUser( KUserNotificationEventCreated );
       
  1297 	EngineStateChangedL();	    
       
  1298     CleanupStack::Pop( outEvent );
       
  1299     
       
  1300     return *outEvent;
       
  1301     }
       
  1302 // -----------------------------------------------------------------------------
       
  1303 // CMCETestUIEngine::CreateInEvent
       
  1304 // -----------------------------------------------------------------------------
       
  1305 //
       
  1306 EXPORT_C CMCETestUIEngineInEvent& CMCETestUIEngine::CreateInEventL(
       
  1307         CMceInEvent* aEvent )
       
  1308     {
       
  1309     CMCETestUIEngineInEvent* inEvent = CMCETestUIEngineInEvent::NewL(
       
  1310             *this, aEvent );
       
  1311     CleanupStack::PushL( inEvent );
       
  1312     iInEvents.Append( inEvent );
       
  1313 	NotifyUser( KMiscIncomingEvent );
       
  1314 	EngineStateChangedL();	
       
  1315 	CleanupStack::Pop( inEvent );
       
  1316 	
       
  1317 	return *inEvent;   
       
  1318     }
       
  1319 
       
  1320 // -----------------------------------------------------------------------------
       
  1321 // CMCETestUIEngine::OutEvents
       
  1322 // -----------------------------------------------------------------------------
       
  1323 //
       
  1324 EXPORT_C const RPointerArray<CMCETestUIEngineOutEvent>& 
       
  1325         CMCETestUIEngine::OutEvents( )
       
  1326     {
       
  1327     return iOutEvents;
       
  1328     }
       
  1329 
       
  1330 // -----------------------------------------------------------------------------
       
  1331 // CMCETestUIEngine::InEvents
       
  1332 // -----------------------------------------------------------------------------
       
  1333 //
       
  1334 EXPORT_C const RPointerArray<CMCETestUIEngineInEvent>& 
       
  1335         CMCETestUIEngine::InEvents( )
       
  1336     {
       
  1337     return iInEvents;
       
  1338     }
       
  1339 // -----------------------------------------------------------------------------
       
  1340 // CMCETestUIEngine::EventParams
       
  1341 // -----------------------------------------------------------------------------
       
  1342 //
       
  1343 
       
  1344 TBool CMCETestUIEngine::EventParamsL(TEventParams &aEventParams)
       
  1345 {
       
  1346 	if ( iUserInterface )
       
  1347         {
       
  1348         return iUserInterface->EventParamsL( aEventParams);
       
  1349         }     
       
  1350     return EFalse;    
       
  1351 }
       
  1352 // -----------------------------------------------------------------------------
       
  1353 // CMCETestUIEngine::NextOutEventId
       
  1354 // -----------------------------------------------------------------------------
       
  1355 //
       
  1356 TInt CMCETestUIEngine::NextOutEventId()
       
  1357     {
       
  1358     return iNextOutEventId++;
       
  1359     }
       
  1360 
       
  1361 // -----------------------------------------------------------------------------
       
  1362 // CMCETestUIEngine::NextInEventId
       
  1363 // -----------------------------------------------------------------------------
       
  1364 //
       
  1365 TInt CMCETestUIEngine::NextInEventId()
       
  1366     {
       
  1367     return iNextInEventId++;
       
  1368     }
       
  1369 
       
  1370 // -----------------------------------------------------------------------------
       
  1371 // CMCETestUIEngine::DeleteRefer
       
  1372 // -----------------------------------------------------------------------------
       
  1373 //
       
  1374 EXPORT_C void CMCETestUIEngine::DeleteRefer( 
       
  1375         CMCETestUIEngineRefer& aRefer )
       
  1376     {
       
  1377     for ( TInt i = 0; i < iOutRefers.Count(); ++i )
       
  1378         {
       
  1379         if ( iOutRefers[i] == &aRefer )
       
  1380             {
       
  1381             delete iOutRefers[i];
       
  1382             iOutRefers.Remove( i );
       
  1383             iOutRefers.Compress();
       
  1384             EngineStateChangedL();
       
  1385             return;
       
  1386             }
       
  1387         }
       
  1388     for ( TInt i = 0; i < iInRefers.Count(); ++i )
       
  1389         {
       
  1390         if ( iInRefers[i] == &aRefer )
       
  1391             {
       
  1392          	delete iInRefers[i];
       
  1393             iInRefers.Remove( i );
       
  1394             iInRefers.Compress();
       
  1395             EngineStateChangedL();
       
  1396             return;
       
  1397             }
       
  1398         }
       
  1399     }
       
  1400 
       
  1401 // -----------------------------------------------------------------------------
       
  1402 // CMCETestUIEngine::CreateOutReferL
       
  1403 // -----------------------------------------------------------------------------
       
  1404 //
       
  1405 EXPORT_C CMCETestUIEngineOutRefer& CMCETestUIEngine::CreateOutReferL( 
       
  1406         CMCETestUIEngineProfile& aProfile)
       
  1407     {
       
  1408     
       
  1409     CMCETestUIEngineOutRefer* outRefer = CMCETestUIEngineOutRefer::NewL( 
       
  1410             *this, aProfile);
       
  1411     CleanupStack::PushL ( outRefer);
       
  1412     iOutRefers.Append( outRefer );
       
  1413 	NotifyUser( KUserNotificationReferCreated );
       
  1414 	EngineStateChangedL();	    
       
  1415     CleanupStack::Pop( outRefer );
       
  1416     
       
  1417     return *outRefer;
       
  1418     }
       
  1419 // -----------------------------------------------------------------------------
       
  1420 // CMCETestUIEngine::CreateOutReferL
       
  1421 // -----------------------------------------------------------------------------
       
  1422 //
       
  1423 EXPORT_C CMCETestUIEngineOutRefer& CMCETestUIEngine::CreateOutReferL( 
       
  1424         CMCETestUIEngineSession& aSession)
       
  1425     {
       
  1426     
       
  1427     CMCETestUIEngineOutRefer* outRefer = CMCETestUIEngineOutRefer::NewL( 
       
  1428             *this, aSession);
       
  1429     CleanupStack::PushL ( outRefer);
       
  1430     iOutRefers.Append( outRefer );
       
  1431 	NotifyUser( KUserNotificationReferCreated );
       
  1432 	EngineStateChangedL();	    
       
  1433     CleanupStack::Pop( outRefer );
       
  1434     
       
  1435     return *outRefer;
       
  1436     }
       
  1437 
       
  1438 // -----------------------------------------------------------------------------
       
  1439 // CMCETestUIEngine::CreateOutReferL
       
  1440 // -----------------------------------------------------------------------------
       
  1441 //
       
  1442 EXPORT_C CMCETestUIEngineOutRefer& CMCETestUIEngine::CreateOutReferL( 
       
  1443         CMCETestUIEngineEvent& aEvent)
       
  1444     {
       
  1445     
       
  1446     CMCETestUIEngineOutRefer* outRefer = CMCETestUIEngineOutRefer::NewL( 
       
  1447             *this, aEvent);
       
  1448     CleanupStack::PushL ( outRefer);
       
  1449     iOutRefers.Append( outRefer );
       
  1450 	NotifyUser( KUserNotificationReferCreated );
       
  1451 	EngineStateChangedL();	    
       
  1452     CleanupStack::Pop( outRefer );
       
  1453     
       
  1454     return *outRefer;
       
  1455     }
       
  1456 
       
  1457 
       
  1458 // -----------------------------------------------------------------------------
       
  1459 // CMCETestUIEngine::CreateInReferL
       
  1460 // -----------------------------------------------------------------------------
       
  1461 //
       
  1462 EXPORT_C CMCETestUIEngineInRefer& CMCETestUIEngine::CreateInReferL(
       
  1463         CMceInRefer* aRefer )
       
  1464     {
       
  1465     CMCETestUIEngineInRefer* inRefer = CMCETestUIEngineInRefer::NewL(
       
  1466             *this, aRefer);
       
  1467     CleanupStack::PushL( inRefer);
       
  1468     iInRefers.Append( inRefer );
       
  1469 	NotifyUser( KMiscIncomingRefer );
       
  1470 	EngineStateChangedL();	
       
  1471 	CleanupStack::Pop( inRefer );
       
  1472 	
       
  1473 	return *inRefer;   
       
  1474     }
       
  1475 
       
  1476 // -----------------------------------------------------------------------------
       
  1477 // CMCETestUIEngine::OutRefers
       
  1478 // -----------------------------------------------------------------------------
       
  1479 //
       
  1480 EXPORT_C const RPointerArray<CMCETestUIEngineOutRefer>& 
       
  1481         CMCETestUIEngine::OutRefers( )
       
  1482     {
       
  1483     return iOutRefers;
       
  1484     }
       
  1485 
       
  1486 // -----------------------------------------------------------------------------
       
  1487 // CMCETestUIEngine::InRefers
       
  1488 // -----------------------------------------------------------------------------
       
  1489 //
       
  1490 EXPORT_C const RPointerArray<CMCETestUIEngineInRefer>& 
       
  1491         CMCETestUIEngine::InRefers( )
       
  1492     {
       
  1493     return iInRefers;
       
  1494     }
       
  1495 // -----------------------------------------------------------------------------
       
  1496 // CMCETestUIEngine::ReferParams
       
  1497 // -----------------------------------------------------------------------------
       
  1498 //
       
  1499 
       
  1500 TBool CMCETestUIEngine::ReferParamsL(TReferParams &aReferParams)
       
  1501 {
       
  1502 	if ( iUserInterface )
       
  1503         {
       
  1504         return iUserInterface->ReferParamsL( aReferParams);
       
  1505         }     
       
  1506     return EFalse;    
       
  1507 }
       
  1508 
       
  1509 // -----------------------------------------------------------------------------
       
  1510 // CMCETestUIEngine::ReferToParams
       
  1511 // -----------------------------------------------------------------------------
       
  1512 //
       
  1513 
       
  1514 TBool CMCETestUIEngine::ReferToParamsL(TReferParams &aReferParams)
       
  1515 {
       
  1516 	if ( iUserInterface )
       
  1517         {
       
  1518         return iUserInterface->ReferToParamsL( aReferParams);
       
  1519         }     
       
  1520     return EFalse;    
       
  1521 }
       
  1522 // -----------------------------------------------------------------------------
       
  1523 // CMCETestUIEngine::NextOutReferId
       
  1524 // -----------------------------------------------------------------------------
       
  1525 //
       
  1526 TInt CMCETestUIEngine::NextOutReferId()
       
  1527     {
       
  1528     return iNextOutReferId++;
       
  1529     }
       
  1530 
       
  1531 // -----------------------------------------------------------------------------
       
  1532 // CMCETestUIEngine::NextInReferId
       
  1533 // -----------------------------------------------------------------------------
       
  1534 //
       
  1535 TInt CMCETestUIEngine::NextInReferId()
       
  1536     {
       
  1537     return iNextInReferId++;
       
  1538     }
       
  1539 
       
  1540 
       
  1541 // -----------------------------------------------------------------------------
       
  1542 // CMCETestUIEngine::DeleteAudioCodec
       
  1543 // -----------------------------------------------------------------------------
       
  1544 //
       
  1545 
       
  1546 EXPORT_C void CMCETestUIEngine::DeleteAudioCodec( CMCETestUIEngineCodec& aAudioCodec)
       
  1547 	{
       
  1548 
       
  1549 	 for ( TInt k = 0; k < iOutSessions.Count(); ++k )
       
  1550         {
       
  1551          const RPointerArray<CMCETestUIEngineAudioStream>& audioStreams = 
       
  1552             iOutSessions[k]->CurrentAudioStreams();
       
  1553             
       
  1554          for ( TInt i = 0; i < audioStreams.Count(); ++i )
       
  1555         	{
       
  1556         	 RPointerArray<CMCETestUIEngineCodec>& codecs = 
       
  1557             	audioStreams[i]->CurrentCodecs();
       
  1558             	
       
  1559          	for ( TInt j = 0; j < codecs.Count(); ++j )
       
  1560 				{
       
  1561 					if ( codecs[j] == &aAudioCodec )
       
  1562 		            {
       
  1563 		            audioStreams[i]->AudioStream().RemoveCodecL(codecs[j]->Codec());
       
  1564 		            delete codecs[j];
       
  1565 		            codecs.Remove( j );
       
  1566 		            codecs.Compress();
       
  1567 		            EngineStateChangedL();
       
  1568 		            return;
       
  1569 		            }
       
  1570 				}
       
  1571         	}
       
  1572          
       
  1573             
       
  1574         }
       
  1575 
       
  1576 	 for ( TInt k = 0; k < iInSessions.Count(); ++k )
       
  1577         {
       
  1578          const RPointerArray<CMCETestUIEngineAudioStream>& audioStreams = 
       
  1579             iInSessions[k]->CurrentAudioStreams();
       
  1580             
       
  1581         for ( TInt i = 0; i < audioStreams.Count(); ++i )
       
  1582         	{
       
  1583         	 RPointerArray<CMCETestUIEngineCodec>& codecs = 
       
  1584             	audioStreams[i]->CurrentCodecs();
       
  1585             
       
  1586 			for ( TInt j = 0; j < codecs.Count(); ++j )
       
  1587 				{
       
  1588 					if ( codecs[j] == &aAudioCodec )
       
  1589 		            {
       
  1590 		            audioStreams[i]->AudioStream().RemoveCodecL(codecs[j]->Codec());
       
  1591 		            delete codecs[j];
       
  1592 		            codecs.Remove( j );
       
  1593 		            codecs.Compress();
       
  1594 		            EngineStateChangedL();
       
  1595 		            return;
       
  1596 		            }
       
  1597 				}
       
  1598         	}
       
  1599          
       
  1600             
       
  1601         }
       
  1602 		
       
  1603 	}
       
  1604  
       
  1605 // -----------------------------------------------------------------------------
       
  1606 // CMCETestUIEngine::DeleteVideoCodec
       
  1607 // -----------------------------------------------------------------------------
       
  1608 //
       
  1609 
       
  1610 EXPORT_C void CMCETestUIEngine::DeleteVideoCodec( CMCETestUIEngineVideoCodec& aVideoCodec)
       
  1611 	{
       
  1612 
       
  1613 	 for ( TInt k = 0; k < iOutSessions.Count(); ++k )
       
  1614         {
       
  1615          const RPointerArray<CMCETestUIEngineVideoStream>& videoStreams = 
       
  1616             iOutSessions[k]->CurrentVideoStreams();
       
  1617             
       
  1618          for ( TInt i = 0; i < videoStreams.Count(); ++i )
       
  1619         	{
       
  1620         	 RPointerArray<CMCETestUIEngineVideoCodec>& codecs = 
       
  1621             	videoStreams[i]->CurrentCodecs();
       
  1622             	
       
  1623          	for ( TInt j = 0; j < codecs.Count(); ++j )
       
  1624 				{
       
  1625 					if ( codecs[j] == &aVideoCodec )
       
  1626 		            {
       
  1627 		            videoStreams[i]->VideoStream().RemoveCodecL(codecs[j]->Codec());
       
  1628 		            delete codecs[j];
       
  1629 		            codecs.Remove( j );
       
  1630 		            codecs.Compress();
       
  1631 		            EngineStateChangedL();
       
  1632 		            return;
       
  1633 		            }
       
  1634 				}
       
  1635         	}
       
  1636          
       
  1637             
       
  1638         }
       
  1639 
       
  1640 	 for ( TInt k = 0; k < iInSessions.Count(); ++k )
       
  1641         {
       
  1642          const RPointerArray<CMCETestUIEngineVideoStream>& videoStreams = 
       
  1643             iInSessions[k]->CurrentVideoStreams();
       
  1644             
       
  1645         for ( TInt i = 0; i < videoStreams.Count(); ++i )
       
  1646         	{
       
  1647         	 RPointerArray<CMCETestUIEngineVideoCodec>& codecs = 
       
  1648             	videoStreams[i]->CurrentCodecs();
       
  1649             
       
  1650 			for ( TInt j = 0; j < codecs.Count(); ++j )
       
  1651 				{
       
  1652 					if ( codecs[j] == &aVideoCodec )
       
  1653 		            {
       
  1654 		            videoStreams[i]->VideoStream().RemoveCodecL(codecs[j]->Codec());
       
  1655 		            delete codecs[j];
       
  1656 		            codecs.Remove( j );
       
  1657 		            codecs.Compress();
       
  1658 		            EngineStateChangedL();
       
  1659 		            return;
       
  1660 		            }
       
  1661 				}
       
  1662         	}
       
  1663          
       
  1664             
       
  1665         }
       
  1666 		
       
  1667 	}
       
  1668        
       
  1669 // -----------------------------------------------------------------------------
       
  1670 // CMCETestUIEngine::IsFCSession
       
  1671 // -----------------------------------------------------------------------------
       
  1672 //
       
  1673 EXPORT_C TBool CMCETestUIEngine::IsFCSession()
       
  1674 	{
       
  1675 	return iFCSession;
       
  1676 	}
       
  1677 
       
  1678 
       
  1679 // -----------------------------------------------------------------------------
       
  1680 // CMCETestUIEngine::SetFCSession
       
  1681 // -----------------------------------------------------------------------------
       
  1682 //
       
  1683 EXPORT_C void CMCETestUIEngine::SetFCSession(TBool aFCSession)
       
  1684 	{
       
  1685 	iFCSession = aFCSession;
       
  1686 	}
       
  1687 	
       
  1688 // -----------------------------------------------------------------------------
       
  1689 // CMCETestUIEngine::CreateMceSettingsL
       
  1690 // -----------------------------------------------------------------------------
       
  1691 //	
       
  1692 
       
  1693 EXPORT_C void CMCETestUIEngine::CreateMceSettingsL()
       
  1694 	{
       
  1695 	if ( iUserInterface )
       
  1696         {
       
  1697         return iUserInterface->CreateMceSettingsL();
       
  1698         }
       
  1699 	}
       
  1700 // -----------------------------------------------------------------------------
       
  1701 // CMCETestUIEngine::CreateMceValueSettingsL
       
  1702 // -----------------------------------------------------------------------------
       
  1703 //	
       
  1704 
       
  1705 EXPORT_C void CMCETestUIEngine::CreateMceValueSettingsL()
       
  1706 	{
       
  1707 	if ( iUserInterface )
       
  1708         {
       
  1709         return iUserInterface->CreateMceValueSettingsL();
       
  1710         }
       
  1711 	}
       
  1712 
       
  1713 // -----------------------------------------------------------------------------
       
  1714 // CMCETestUIEngine::CreateMceSettingsL
       
  1715 // -----------------------------------------------------------------------------
       
  1716 //	
       
  1717 
       
  1718 EXPORT_C TBool CMCETestUIEngine::StartDTMFToneL( TChar& aChar )
       
  1719 	{
       
  1720 	if ( iUserInterface )
       
  1721         {
       
  1722         return iUserInterface->StartDTMFToneL( aChar );
       
  1723         }
       
  1724     return EFalse;
       
  1725 	}
       
  1726 
       
  1727 // -----------------------------------------------------------------------------
       
  1728 // CMCETestUIEngine::CreateMceSettingsL
       
  1729 // -----------------------------------------------------------------------------
       
  1730 //	
       
  1731 
       
  1732 EXPORT_C TBool CMCETestUIEngine::SendDTMFToneL( TChar& aChar, TInt& aInterval )
       
  1733 	{
       
  1734 	if ( iUserInterface )
       
  1735         {
       
  1736         return iUserInterface->SendDTMFToneL( aChar, aInterval );
       
  1737         }
       
  1738     return EFalse;
       
  1739 	}
       
  1740 
       
  1741 // -----------------------------------------------------------------------------
       
  1742 // CMCETestUIEngine::GetCodecTypeL
       
  1743 // -----------------------------------------------------------------------------
       
  1744 //	
       
  1745 
       
  1746 EXPORT_C TBool CMCETestUIEngine::GetCodecTypeL(TInt& aCodecIndex )
       
  1747 	{
       
  1748 	if ( iUserInterface )
       
  1749         {
       
  1750         return iUserInterface->GetCodecTypeL( aCodecIndex );
       
  1751         }
       
  1752     return EFalse;
       
  1753 	}	
       
  1754 // -----------------------------------------------------------------------------
       
  1755 // CMCETestUIEngine::GetIapIdL
       
  1756 // -----------------------------------------------------------------------------
       
  1757 //	
       
  1758 
       
  1759 EXPORT_C TBool CMCETestUIEngine::GetIapIdL(TInt& aIapid )
       
  1760 	{
       
  1761 	if ( iUserInterface )
       
  1762         {
       
  1763         return iUserInterface->GetIapIdL( aIapid );
       
  1764         }
       
  1765     return EFalse;
       
  1766 	}
       
  1767 	
       
  1768 // -----------------------------------------------------------------------------
       
  1769 // CMCETestUIEngine::GetIapIdL
       
  1770 // -----------------------------------------------------------------------------
       
  1771 //	
       
  1772 
       
  1773 void CMCETestUIEngine::GetIapIdFromAPList()
       
  1774 	{
       
  1775   
       
  1776     iIapId = -1;
       
  1777     TCommDbConnPref prefs;
       
  1778   
       
  1779     TInt error( PrepareConnection( prefs, iIapId ) );
       
  1780  	 if ( error != KErrNone )
       
  1781         {
       
  1782         return ;
       
  1783         }
       
  1784     error = iConn.Start( prefs );
       
  1785     if ( error != KErrNone )
       
  1786         {
       
  1787         iConn.Close();
       
  1788         iSocketServ.Close();
       
  1789    
       
  1790         }
       
  1791     TUint32 aValue;
       
  1792     
       
  1793     error = iConn.GetIntSetting(_L("IAP\\Id"), aValue);
       
  1794 	
       
  1795 	if ( error != KErrNone )
       
  1796 	    {
       
  1797 	    iConn.Close();
       
  1798 	    iSocketServ.Close();
       
  1799 	    }
       
  1800    	else
       
  1801        {
       
  1802        iIapId = aValue;
       
  1803        }
       
  1804     }
       
  1805 	
       
  1806 // ---------------------------------------------------------------------------
       
  1807 // TInt CMCETestUIEngine::PrepareConnection()
       
  1808 // ---------------------------------------------------------------------------
       
  1809 //
       
  1810 TInt CMCETestUIEngine::PrepareConnection( TCommDbConnPref& aPrefs,
       
  1811 										  TInt /*aIapId*/ )
       
  1812     {
       
  1813     TInt err( KErrCouldNotConnect );
       
  1814 
       
  1815     aPrefs.SetDirection( ECommDbConnectionDirectionOutgoing );
       
  1816 
       
  1817     err = iSocketServ.Connect();
       
  1818 
       
  1819     if ( err != KErrNone )
       
  1820         {
       
  1821         iSocketServ.Close();
       
  1822         return err;
       
  1823         }
       
  1824 
       
  1825     err = iConn.Open( iSocketServ );
       
  1826 
       
  1827     if ( err != KErrNone )
       
  1828         {
       
  1829         iConn.Close(); 
       
  1830         iSocketServ.Close();
       
  1831         return err;
       
  1832         }
       
  1833 
       
  1834     return KErrNone;
       
  1835     }
       
  1836     
       
  1837 // -----------------------------------------------------------------------------
       
  1838 // CMCETestUIEngine::GetRect
       
  1839 // -----------------------------------------------------------------------------
       
  1840 //	
       
  1841 
       
  1842 EXPORT_C TRect CMCETestUIEngine::GetRect()
       
  1843 	{
       
  1844 	if ( iUserInterface )
       
  1845     	{
       
  1846     	return iUserInterface->GetRect();
       
  1847     	}
       
  1848     return TRect();
       
  1849 	}
       
  1850 // -----------------------------------------------------------------------------
       
  1851 // CMCETestUIEngine::ShowCurrentCryptoContexts
       
  1852 // -----------------------------------------------------------------------------
       
  1853 //	
       
  1854 
       
  1855 EXPORT_C void CMCETestUIEngine::ShowCurrentCryptoContextsL(TBool aCrypto32,TBool aCrypto80)
       
  1856 	{
       
  1857 	if ( iUserInterface )
       
  1858     	{
       
  1859     	return iUserInterface->ShowCurrentCryptoContextsL(aCrypto32, aCrypto80 );
       
  1860     	}
       
  1861 	}
       
  1862 // -----------------------------------------------------------------------------
       
  1863 // CMCETestUIEngine::ShowCurrentCryptoContexts
       
  1864 // -----------------------------------------------------------------------------
       
  1865 //	
       
  1866 
       
  1867 EXPORT_C void CMCETestUIEngine::ShowSupportedCryptoContextsL(TBool aCrypto32,TBool aCrypto80)
       
  1868 	{
       
  1869 	if ( iUserInterface )
       
  1870     	{
       
  1871     	return iUserInterface->ShowSupportedCryptoContextsL(aCrypto32, aCrypto80 );
       
  1872     	}
       
  1873 	}
       
  1874 // -----------------------------------------------------------------------------
       
  1875 // CMCETestUIEngine::ShowCurrentCryptoContexts
       
  1876 // -----------------------------------------------------------------------------
       
  1877 //	
       
  1878 
       
  1879 EXPORT_C void CMCETestUIEngine::GetCryptoContextsL(TBool& aCrypto32,TBool& aCrypto80)
       
  1880 	{
       
  1881 	if ( iUserInterface )
       
  1882     	{
       
  1883     	return iUserInterface->GetCryptoContextsL(aCrypto32, aCrypto80 );
       
  1884     	}
       
  1885 	}
       
  1886 // -----------------------------------------------------------------------------
       
  1887 // CMCETestUIEngine::CreateMceSettingsL
       
  1888 // -----------------------------------------------------------------------------
       
  1889 //	
       
  1890 
       
  1891 EXPORT_C TBool CMCETestUIEngine::SendDTMFToneSequenceL( TDes& aSequence  )
       
  1892 	{
       
  1893 	if ( iUserInterface )
       
  1894         {
       
  1895         return iUserInterface->SendDTMFToneSequenceL( aSequence );
       
  1896         }
       
  1897     return EFalse;
       
  1898 	}
       
  1899 	
       
  1900 // -----------------------------------------------------------------------------
       
  1901 // CMCETestUIEngine::IsVideoEnabled
       
  1902 // -----------------------------------------------------------------------------
       
  1903 //	
       
  1904 
       
  1905 EXPORT_C TBool CMCETestUIEngine::IsVideoEnabled()
       
  1906 	{
       
  1907 	if ( iUserInterface )
       
  1908         {
       
  1909         return iUserInterface->IsVideoEnabled();
       
  1910         }
       
  1911     return EFalse;
       
  1912 	}
       
  1913 	
       
  1914 // -----------------------------------------------------------------------------
       
  1915 // CMCETestUIEngine::EnableVideo
       
  1916 // -----------------------------------------------------------------------------
       
  1917 //	
       
  1918 
       
  1919 EXPORT_C void CMCETestUIEngine::EnableVideo(CMCETestUIEngineSession& aSession)
       
  1920 	{
       
  1921 	const RPointerArray<CMCETestUIEngineVideoStream>& streams = aSession.VideoStreamsL();
       
  1922 
       
  1923     for (TInt i = 0; i < streams.Count(); i ++)
       
  1924         {
       
  1925 	 //   CMceMediaStream* stream = (CMceMediaStream*) streams[i];  
       
  1926 	     CMCETestUIEngineVideoStream* stream = (CMCETestUIEngineVideoStream*) streams[i];  
       
  1927 	//	const RPointerArray<CMceMediaSink>& sinks = stream->Sinks();
       
  1928 	    const RPointerArray<CMCETestUIEngineVideoSink>& sinks = stream->SinksL();
       
  1929 	    const RPointerArray<CMCETestUIEngineVideoSource>& sources = stream->SourcesL();
       
  1930 
       
  1931 		if (sinks[0]->Type() == KMceDisplaySink &&
       
  1932 		    sources[0]->Type() == KMceCameraSource )
       
  1933     		{
       
  1934 		    sinks[0]->EnableL();
       
  1935 		  	}
       
  1936 	    }
       
  1937 
       
  1938 	if ( iUserInterface )
       
  1939         {
       
  1940         return iUserInterface->EnableVideo();
       
  1941         }
       
  1942 	}
       
  1943 	
       
  1944 // -----------------------------------------------------------------------------
       
  1945 // CMCETestUIEngine::DisableVideo
       
  1946 // -----------------------------------------------------------------------------
       
  1947 //	
       
  1948 
       
  1949 EXPORT_C void CMCETestUIEngine::DisableVideo(CMCETestUIEngineSession& aSession)
       
  1950 	{
       
  1951 	
       
  1952 	const RPointerArray<CMCETestUIEngineVideoStream>& streams = aSession.VideoStreamsL();
       
  1953 
       
  1954     for (TInt i = 0; i < streams.Count(); i ++)
       
  1955         {
       
  1956 	  //  CMceMediaStream* stream = (CMceMediaStream*) streams[i];  
       
  1957 	    CMCETestUIEngineVideoStream* stream = (CMCETestUIEngineVideoStream*) streams[i];  
       
  1958 	//	const RPointerArray<CMceMediaSink>& sinks = stream->Sinks();
       
  1959 
       
  1960 		 const RPointerArray<CMCETestUIEngineVideoSink>& sinks = stream->SinksL();
       
  1961 		 const RPointerArray<CMCETestUIEngineVideoSource>& sources = stream->SourcesL();
       
  1962 		if (sinks[0]->Type() == KMceDisplaySink &&
       
  1963 		    sources[0]->Type() == KMceCameraSource )
       
  1964     		{
       
  1965 		    sinks[0]->DisableL();
       
  1966 		  	}
       
  1967 	       
       
  1968 		  }
       
  1969 	if ( iUserInterface )
       
  1970         {
       
  1971         return iUserInterface->DisableVideo();
       
  1972         }
       
  1973 	}
       
  1974 	
       
  1975 // -----------------------------------------------------------------------------
       
  1976 // CMCETestUIEngine::EnableReceivingVideo
       
  1977 // -----------------------------------------------------------------------------
       
  1978 //	
       
  1979 
       
  1980 EXPORT_C void CMCETestUIEngine::EnableReceivingVideo(CMCETestUIEngineSession& aSession)
       
  1981 	{
       
  1982 	const RPointerArray<CMCETestUIEngineVideoStream>& streams = aSession.VideoStreamsL();
       
  1983 
       
  1984     for (TInt i = 0; i < streams.Count(); i ++)
       
  1985         {
       
  1986 	 //   CMceMediaStream* stream = (CMceMediaStream*) streams[i];  
       
  1987 	     CMCETestUIEngineVideoStream* stream = (CMCETestUIEngineVideoStream*) streams[i];  
       
  1988 	//	const RPointerArray<CMceMediaSink>& sinks = stream->Sinks();
       
  1989 	    const RPointerArray<CMCETestUIEngineVideoSink>& sinks = stream->SinksL();
       
  1990 	    const RPointerArray<CMCETestUIEngineVideoSource>& sources = stream->SourcesL();
       
  1991 
       
  1992 		if (sinks[0]->Type() == KMceDisplaySink &&
       
  1993 		    sources[0]->Type() == KMceRTPSource )
       
  1994     		{
       
  1995 		    sinks[0]->EnableL();
       
  1996 		  	}
       
  1997 	    }
       
  1998 
       
  1999 	if ( iUserInterface )
       
  2000         {
       
  2001         return iUserInterface->EnableVideo();
       
  2002         }
       
  2003 	}
       
  2004 	
       
  2005 // -----------------------------------------------------------------------------
       
  2006 // CMCETestUIEngine::DisableReceivingVideo
       
  2007 // -----------------------------------------------------------------------------
       
  2008 //	
       
  2009 
       
  2010 EXPORT_C void CMCETestUIEngine::DisableReceivingVideo(CMCETestUIEngineSession& aSession)
       
  2011 	{
       
  2012 	
       
  2013 	const RPointerArray<CMCETestUIEngineVideoStream>& streams = aSession.VideoStreamsL();
       
  2014 
       
  2015     for (TInt i = 0; i < streams.Count(); i ++)
       
  2016         {
       
  2017 	  //  CMceMediaStream* stream = (CMceMediaStream*) streams[i];  
       
  2018 	    CMCETestUIEngineVideoStream* stream = (CMCETestUIEngineVideoStream*) streams[i];  
       
  2019 	//	const RPointerArray<CMceMediaSink>& sinks = stream->Sinks();
       
  2020 
       
  2021 		 const RPointerArray<CMCETestUIEngineVideoSink>& sinks = stream->SinksL();
       
  2022 		 const RPointerArray<CMCETestUIEngineVideoSource>& sources = stream->SourcesL();
       
  2023 		if (sinks[0]->Type() == KMceDisplaySink &&
       
  2024 		    sources[0]->Type() == KMceRTPSource )
       
  2025     		{
       
  2026 		    sinks[0]->DisableL();
       
  2027 		  	}
       
  2028 	       
       
  2029 		  }
       
  2030 	if ( iUserInterface )
       
  2031         {
       
  2032         return iUserInterface->DisableVideo();
       
  2033         }
       
  2034 	}
       
  2035 // -----------------------------------------------------------------------------
       
  2036 // CMCETestUIEngine::CsStatusChangedL
       
  2037 // -----------------------------------------------------------------------------
       
  2038 //	
       
  2039 
       
  2040 void CMCETestUIEngine::CsStatusChangedL( TPoCOmaCsState aStatus )
       
  2041     {   
       
  2042     MCE_TESTUI_DEBUG3( "CsStatusChangedL, Status: ", aStatus );
       
  2043     switch ( aStatus )
       
  2044         {
       
  2045         case EPoCOmaCallStateDialling:
       
  2046         case EPoCOmaCallStateRinging:
       
  2047         case EPoCOmaCallStateAnswering:
       
  2048             // do hold
       
  2049             //NotifyUser( KCallStateActivated );
       
  2050             //EngineStateChangedL();
       
  2051             TRAPD( err, DoHoldUnholdL( ETrue ) );
       
  2052             if( err != KErrNone )
       
  2053                 {
       
  2054                 MCE_TESTUI_DEBUG3( "Error in doing hold", err );
       
  2055                 }
       
  2056             break;
       
  2057         case EPoCOmaCallStateDisconnecting:
       
  2058         case EPoCOmaCallStateNone:
       
  2059             // do unhold
       
  2060             //NotifyUser( KCallStateDeActivated );
       
  2061             //EngineStateChangedL();
       
  2062             TRAPD( err2, DoHoldUnholdL( EFalse ));
       
  2063             if( err2 != KErrNone )
       
  2064                 {
       
  2065                 MCE_TESTUI_DEBUG3( "Error in doing unhold", err2 );
       
  2066                 }
       
  2067             break;
       
  2068         default:
       
  2069             break;
       
  2070         
       
  2071         }
       
  2072     
       
  2073     }
       
  2074 // -----------------------------------------------------------------------------
       
  2075 // CMCETestUIEngine::DoHoldUnholdL
       
  2076 // -----------------------------------------------------------------------------
       
  2077 //	
       
  2078 	
       
  2079 void CMCETestUIEngine::DoHoldUnholdL( TBool aHold )
       
  2080     {
       
  2081     MCE_TESTUI_DEBUG3( "DoHoldUnholdL, Hold or Unhold: ", aHold );
       
  2082 
       
  2083     for ( TInt k = 0; k < iOutSessions.Count(); ++k )
       
  2084         {
       
  2085         DoEnableDisableL( iOutSessions[k]->OutSession(), aHold );
       
  2086         }
       
  2087 	for ( TInt k = 0; k < iInSessions.Count(); ++k )
       
  2088         {
       
  2089         DoEnableDisableL( iInSessions[k]->InSession(), aHold );
       
  2090         }
       
  2091     }
       
  2092     
       
  2093 // -----------------------------------------------------------------------------
       
  2094 // CMCETestUIEngine::DoHoldUnholdL
       
  2095 // -----------------------------------------------------------------------------
       
  2096 //	   
       
  2097 void CMCETestUIEngine::DoEnableDisableL( CMceSession& aSession, TBool aHold ) 
       
  2098     {
       
  2099     const RPointerArray<CMceMediaStream>& streams = aSession.Streams();
       
  2100      
       
  2101     for ( TInt i = 0; i < streams.Count(); ++i )
       
  2102 		{
       
  2103 		CMceMediaStream* mediaStream = 
       
  2104                                     static_cast<CMceMediaStream*>(streams[i]);
       
  2105         
       
  2106         CMceMediaSource* source = mediaStream->Source();
       
  2107         User::LeaveIfNull( source );
       
  2108         
       
  2109         if( mediaStream->Type() == KMceAudio && source->Type() == KMceRTPSource )
       
  2110             {
       
  2111             if( aHold )
       
  2112                 {
       
  2113                 MCE_TESTUI_DEBUG1(" Disabling downlink " );
       
  2114                 mediaStream->DisableL();
       
  2115                 }
       
  2116             else
       
  2117                 {
       
  2118                 MCE_TESTUI_DEBUG1(" Enabling downlink " );
       
  2119                 mediaStream->EnableL();
       
  2120                 }
       
  2121             }
       
  2122             
       
  2123         if( mediaStream->BoundStream() )
       
  2124             {
       
  2125             CMceMediaStream* boundStream = &mediaStream->BoundStreamL();
       
  2126             
       
  2127             CMceMediaSource* boundsource = boundStream->Source();
       
  2128             User::LeaveIfNull( boundsource );
       
  2129             
       
  2130             if( boundStream->Type() == KMceAudio && boundsource->Type() == KMceRTPSource )
       
  2131                 {
       
  2132                 if( aHold )
       
  2133                     {
       
  2134                     MCE_TESTUI_DEBUG1(" Disabling downlink " );
       
  2135                     boundStream->DisableL();
       
  2136                     }
       
  2137                 else
       
  2138                     {
       
  2139                     MCE_TESTUI_DEBUG1(" Enabling downlink " );
       
  2140                     boundStream->EnableL();
       
  2141                     }
       
  2142                 }
       
  2143             }
       
  2144 		}   
       
  2145     aSession.UpdateL();
       
  2146     }
       
  2147     
       
  2148 // -----------------------------------------------------------------------------
       
  2149 // CMCETestUIEngine::NotifyStreamStateChangeL
       
  2150 // -----------------------------------------------------------------------------
       
  2151 //
       
  2152 void CMCETestUIEngine::NotifyStreamStateChangeL( CMceMediaStream& aStream ) 
       
  2153     {
       
  2154     TInt state = aStream.State();
       
  2155 
       
  2156 	TBuf16<100> buf16;
       
  2157 	buf16.Append(KUserNotificationStreamStateChanged );
       
  2158 	buf16.Append(KLeftParenthesis);
       
  2159 		
       
  2160 	switch( state ) 
       
  2161 		{
       
  2162 		case CMceMediaStream::EUninitialized: 
       
  2163 		   	buf16.Append(KStreamUninitialized); 
       
  2164 		    break;
       
  2165 		case CMceMediaStream::EInitialized: 
       
  2166 		    buf16.Append(KStreamInitialized); 
       
  2167 		    break;
       
  2168 		case CMceMediaStream::EBuffering: 
       
  2169 		    buf16.Append(KStreamBuffering); 
       
  2170 		    break;
       
  2171 		case CMceMediaStream::EIdle: 
       
  2172 		    buf16.Append(KStreamIdle); 
       
  2173 		    break;
       
  2174 		case CMceMediaStream::EStreaming: 
       
  2175 		    buf16.Append(KStreamStreaming); 
       
  2176 		    break;
       
  2177 		case CMceMediaStream::EDisabled: 
       
  2178 		    buf16.Append(KStreamDisabled); 
       
  2179 		    break;
       
  2180 		case CMceMediaStream::ENoResources: 
       
  2181 		    buf16.Append(KStreamNoResources); 
       
  2182 		    break;
       
  2183 		case CMceMediaStream::ETranscodingRequired: 
       
  2184 		    buf16.Append(KStreamTranscodingRequired); 
       
  2185 		    break;
       
  2186 		case CMceMediaStream::ETranscoding: 
       
  2187 		    buf16.Append(KStreamTranscoding); 
       
  2188 		    break;
       
  2189 		default: 
       
  2190 		    buf16.Append(KSessionStateUnknown); 
       
  2191 		}
       
  2192 	buf16.Append(KRightParenthesis);
       
  2193 	NotifyUser(buf16);
       
  2194     }
       
  2195 
       
  2196 
       
  2197 
       
  2198 // -----------------------------------------------------------------------------
       
  2199 // CMCETestUIEngine::AddTransactionIdL
       
  2200 // -----------------------------------------------------------------------------
       
  2201 //
       
  2202 void CMCETestUIEngine::AddTransactionIdL( TMceTransactionId aId )
       
  2203 	{
       
  2204 	if ( iTransactionIds.Find( aId ) == KErrNotFound )
       
  2205 		{
       
  2206 		iTransactionIds.AppendL( aId );
       
  2207 		}
       
  2208 	}
       
  2209 	
       
  2210 // -----------------------------------------------------------------------------
       
  2211 // CMCETestUIEngine::TransactionIds
       
  2212 // -----------------------------------------------------------------------------
       
  2213 //
       
  2214 const RArray< TMceTransactionId >& CMCETestUIEngine::TransactionIds() const
       
  2215 	{
       
  2216 	return iTransactionIds;
       
  2217 	}
       
  2218 
       
  2219 
       
  2220 // -----------------------------------------------------------------------------
       
  2221 // CMCETestUIEngine::RemoveTransactionId
       
  2222 // -----------------------------------------------------------------------------
       
  2223 //
       
  2224 void CMCETestUIEngine::RemoveTransactionId( TMceTransactionId aId )
       
  2225 	{
       
  2226 	TInt index = iTransactionIds.Find( aId );
       
  2227 	if ( index != KErrNotFound )
       
  2228 		{
       
  2229 		iTransactionIds.Remove( index );
       
  2230 		}
       
  2231 	}
       
  2232 
       
  2233 // -----------------------------------------------------------------------------
       
  2234 // CMCETestUIEngine::GetJitterBufferValues
       
  2235 // Default values are converted to more suitable in case of video session
       
  2236 // -----------------------------------------------------------------------------
       
  2237 //
       
  2238 void CMCETestUIEngine::GetJitterBufferValues( 
       
  2239     CMceMediaStream* aMediaStream, 
       
  2240     TInt& aJitbufSize, 
       
  2241     TInt& aJitbufThreshold, 
       
  2242     TInt& aJitbufTimeout, 
       
  2243     TBool aSessionTypeKnownToBeVideo )
       
  2244     {
       
  2245     TBool defaultValues( ETrue );
       
  2246     TBool videoSession( aSessionTypeKnownToBeVideo );
       
  2247     if ( aMediaStream && !videoSession )
       
  2248         {
       
  2249         videoSession = ( aMediaStream->Type() == KMceVideo );
       
  2250         }
       
  2251     
       
  2252     // If two way video session, default value for jitterbuffer is altered    
       
  2253     if ( videoSession && aJitbufThreshold == KJitterBufferTreshold )
       
  2254         {
       
  2255         if ( aMediaStream && aMediaStream->Type() == KMceVideo )
       
  2256             {
       
  2257             aJitbufThreshold = KJitterBufferTresholdRealTimeVideoVideo;
       
  2258             aJitbufSize = iJitterBufSize;  
       
  2259             }
       
  2260         else
       
  2261             {
       
  2262             aJitbufThreshold = KJitterBufferTresholdRealTimeVideoAudio;
       
  2263             aJitbufSize = KJitterBufferSizeRealTimeVideoAudio;  
       
  2264             }     
       
  2265         aJitbufTimeout = iJitterBufTimeout; 
       
  2266         defaultValues = EFalse;
       
  2267         }
       
  2268             
       
  2269     if ( defaultValues )
       
  2270         {
       
  2271         aJitbufSize = iJitterBufSize;
       
  2272 	    aJitbufThreshold = iJitterBufTreshold;
       
  2273 	    aJitbufTimeout = iJitterBufTimeout;
       
  2274         }
       
  2275     }
       
  2276 
       
  2277 // -----------------------------------------------------------------------------
       
  2278 // CMCETestUIEngine::IsSendRecvVideo
       
  2279 // -----------------------------------------------------------------------------
       
  2280 //
       
  2281 TBool CMCETestUIEngine::IsSendRecvVideo( CMceSession* aSession )
       
  2282     {
       
  2283     TBool sendRecvVideo( EFalse );
       
  2284     if ( aSession )
       
  2285         {
       
  2286         const RPointerArray<CMceMediaStream>& streams = aSession->Streams();
       
  2287         for ( TInt i = 0; i < streams.Count() && !sendRecvVideo; i++ )
       
  2288             {
       
  2289             if ( streams[ i ]->Type() == KMceVideo )
       
  2290                 {
       
  2291                 sendRecvVideo = streams[ i ]->BoundStream();
       
  2292                 }
       
  2293             }
       
  2294         }
       
  2295     return sendRecvVideo;
       
  2296     }
       
  2297     
       
  2298 // End of file