multimediacommsengine/tsrc/MCETestUI/MCETestUIEngine/src/CMCETestUIEngineOutSession.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // MCE API
       
    22 #include <ecam.h>
       
    23 #include <MCEManager.h>
       
    24 #include <Mcedefs.h>
       
    25 #include <MCEOutSession.h>
       
    26 #include <mcerefer.h>
       
    27 #include <MCEAudioStream.h>
       
    28 #include <MCEAudioStream.h>
       
    29 #include <mcevideostream.h>
       
    30 #include <MCEMicSource.h>
       
    31 #include <MCERtpSink.h>
       
    32 #include <MCERtpSource.h>
       
    33 #include <MCESpeakerSink.h>
       
    34 #include <mcecamerasource.h>
       
    35 #include <mcedisplaysink.h>
       
    36 #include <MCEmediaSink.h>
       
    37 #include <MCEFileSource.h>
       
    38 #include <Uri8.h>
       
    39 #include <mcefilesink.h>
       
    40 #include <MCEAudioCodec.h>
       
    41 #include <MCEVideoCodec.h>
       
    42 #include <MCEAMRCodec.h>
       
    43 #include <MCEFCMsgExchange.h>
       
    44 #include <mcestreambundle.h>
       
    45 #include <mcesecureoutsession.h>
       
    46 #include <mcesecuresession.h>
       
    47 #include <aknutils.h>
       
    48 #include <mceavccodec.h>
       
    49 #include "MCETestUIEngineDefaultValues.h"
       
    50 #include "CMCETestUIQuestionDataQuery.h"
       
    51 #include "CMCETestUIEngine.h"
       
    52 #include "CMCETestUIEngineProfileContainer.h"
       
    53 #include "CMCETestUIEngineProfile.h"
       
    54 #include "CMCETestUIEngineOutSession.h"
       
    55 #include "TMCETestUIEngineCmdEstablish.h"
       
    56 #include "TMCETestUIEngineCmdCancelSession.h"
       
    57 #include "TMCETestUIEngineCmdDeleteSession.h"
       
    58 #include "TMCETestUIEngineCmdFloorControlSession.h"
       
    59 #include "CMCETestUIEngineMultimediaObserver.h"
       
    60 #include "TMCETestUIEngineCmdCryptoHandling.h"
       
    61 
       
    62 #include "TMCETestUIEngineCmdSRReqRes.h"
       
    63 
       
    64 
       
    65 
       
    66 //const TUint KAudioPrefAudioUplink                      = 0x05220001;
       
    67 //const TUint KAudioPrefAudioDownlink                    = 0x05210001;
       
    68 
       
    69 
       
    70 const TUint KJitterBufferInactTimeout 					  = 10000;
       
    71 
       
    72 _LIT8( KMCERtpSinkIdentity, "RtpSink@multimedia.engine.com" ); 
       
    73 _LIT8( KMCERtpSourceIdentity, "RtpSource@multimedia.engine.com" ); 
       
    74 
       
    75 // ============================ MEMBER FUNCTIONS ===============================
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CMCETestUIEngineOutSession::NewL()
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CMCETestUIEngineOutSession* CMCETestUIEngineOutSession::NewL(
       
    82             CMCETestUIEngine& aEngine,
       
    83             CMCETestUIEngineProfile& aProfile,
       
    84             TDirection aDirection,
       
    85             TVideoDirection aVideoDirection,
       
    86             TSessionType aSessionType ) 
       
    87     {
       
    88 
       
    89     CMCETestUIEngineOutSession* self = 
       
    90         new (ELeave) CMCETestUIEngineOutSession( aEngine, 
       
    91                                                  aProfile,
       
    92                                                  aDirection,
       
    93                                                  aVideoDirection,
       
    94                                                  aSessionType );
       
    95     CleanupStack::PushL( self );
       
    96     self->ConstructL();
       
    97     CleanupStack::Pop( self );
       
    98     return self;  
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CMCETestUIEngineOutSession::NewL()
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 CMCETestUIEngineOutSession* CMCETestUIEngineOutSession::NewL(
       
   106             CMCETestUIEngine& aEngine,
       
   107             TUint32 aIAPId,
       
   108             TDirection aDirection,
       
   109             TVideoDirection aVideoDirection,
       
   110             TSessionType aSessionType ) 
       
   111     {
       
   112 
       
   113     CMCETestUIEngineOutSession* self = 
       
   114         new (ELeave) CMCETestUIEngineOutSession( aEngine, 
       
   115                                                  aIAPId,
       
   116                                                  aDirection,
       
   117                                                  aVideoDirection,
       
   118                                                  aSessionType );
       
   119     CleanupStack::PushL( self );
       
   120     self->ConstructL();
       
   121     CleanupStack::Pop( self );
       
   122     return self;  
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CMCETestUIEngineOutSession::NewL()
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 CMCETestUIEngineOutSession* CMCETestUIEngineOutSession::NewL(
       
   130             CMCETestUIEngine& aEngine,
       
   131             CMceRefer &aRefer,
       
   132             TDirection aDirection,
       
   133             TVideoDirection aVideoDirection,
       
   134             TSessionType aSessionType ) 
       
   135     {
       
   136 
       
   137     CMCETestUIEngineOutSession* self = 
       
   138         new (ELeave) CMCETestUIEngineOutSession( aEngine, 
       
   139                                                  aRefer,
       
   140                                                  aDirection,
       
   141                                                  aVideoDirection,
       
   142                                                  aSessionType );
       
   143     CleanupStack::PushL( self );
       
   144     self->ConstructL(aRefer);
       
   145     CleanupStack::Pop( self );
       
   146     return self;  
       
   147     }
       
   148 // -----------------------------------------------------------------------------
       
   149 // CMCETestUIEngineOutSession::CMCETestUIEngineOutSession
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 CMCETestUIEngineOutSession::CMCETestUIEngineOutSession( 
       
   153                 CMCETestUIEngine& aEngine,
       
   154                 CMCETestUIEngineProfile& aProfile,
       
   155                 TDirection aDirection,
       
   156                 TVideoDirection aVideoDirection,
       
   157                 TSessionType aSessionType )
       
   158     : CMCETestUIEngineSession( aEngine, aDirection,aVideoDirection ),
       
   159       iProfile( &aProfile ),
       
   160       iId( 0 ),
       
   161       iSessionType(aSessionType),
       
   162       iIapId ( 0xFF )
       
   163     {
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CMCETestUIEngineOutSession::CMCETestUIEngineOutSession
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 CMCETestUIEngineOutSession::CMCETestUIEngineOutSession( 
       
   171                 CMCETestUIEngine& aEngine,
       
   172                 TUint32 aIAPId,
       
   173                 TDirection aDirection,
       
   174                 TVideoDirection aVideoDirection,
       
   175                 TSessionType aSessionType )
       
   176     : CMCETestUIEngineSession( aEngine, aDirection,aVideoDirection ),
       
   177       iIapId( aIAPId ),
       
   178       iId( 0 ),
       
   179       iSessionType(aSessionType),
       
   180       iProfile ( NULL )
       
   181     {
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CMCETestUIEngineOutSession::CMCETestUIEngineOutSession
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 CMCETestUIEngineOutSession::CMCETestUIEngineOutSession( 
       
   189                 CMCETestUIEngine& aEngine,
       
   190                 CMceRefer &aRefer,
       
   191                 TDirection aDirection,
       
   192                 TVideoDirection aVideoDirection,
       
   193                 TSessionType /*aSessionType*/ )
       
   194     : CMCETestUIEngineSession( aEngine, aDirection,aVideoDirection ),
       
   195       iId( 0 ),
       
   196       iRefer(&aRefer)
       
   197       
       
   198     {
       
   199     }
       
   200 // -----------------------------------------------------------------------------
       
   201 // CMCETestUIEngineOutSession::ConstructL()
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 void CMCETestUIEngineOutSession::ConstructL()
       
   205     {
       
   206  
       
   207      /////////////////////
       
   208     //
       
   209     // TODO: After implementing wrappers for streams, sinks and sources 
       
   210     //       this function should be refactored to make use of them. That will 
       
   211     //       also simplify the function to some extent.
       
   212     //
       
   213     //////////////////////
       
   214     BaseConstructL();
       
   215     FillProfileRegistrar();   
       
   216     FillPoCOrigAddress();
       
   217     if( SessionParamsL(iSessionParams,iSessionType) )
       
   218         {
       
   219     	// set rtcp flag
       
   220     	 if(iEngine.iRtcpFlag == EFalse)
       
   221     	 	{
       
   222     	 	iEngine.iSRCount = 0;
       
   223     		iEngine.iRRCount = 0;	
       
   224     	 	}
       
   225        		
       
   226      
       
   227     	 // Solve recipient
       
   228 	    CMCETestUIQuestionDataQuery* question = 
       
   229 		    CMCETestUIQuestionDataQuery::NewLC();
       
   230 		    
       
   231         question->SetCaptionL( KUserQuestionInputRecipient );
       
   232     	question->SetDefaultValueL(iSessionParams.iRecipentAddress  );
       
   233     	question->SetAnswerL( iSessionParams.iRecipentAddress  );
       
   234     	TBufC8<300> recipient( question->Answer8() );
       
   235     	
       
   236     	CleanupStack::PopAndDestroy( question );
       
   237 	  
       
   238 		//////
       
   239 		// solve originator
       
   240 	    CMceOutSession* outSession = NULL;
       
   241 	    
       
   242 	    if( iSessionParams.originator.Compare(KNone) )//if there is originator
       
   243 	   	    {
       
   244 		   	HBufC8* orig8 = HBufC8::NewL(iSessionParams.originator.Length());
       
   245 		   	TPtr8 ptr = orig8->Des();
       
   246 		    ptr.Copy(iSessionParams.originator);
       
   247 		    // Create Outsession
       
   248 		    if(iEngine.iOutSessionWithProfile)// thru profile
       
   249 		    	{
       
   250 		    	
       
   251 		    	if( iSessionParams.iSecureSession )
       
   252 		    		{
       
   253 		    		iOutSession = 
       
   254 		    				CMceSecureOutSession::NewL( iEngine.MCEManager(),
       
   255 		                                                iProfile->Profile(),
       
   256 		                                                recipient ,orig8);
       
   257 		            if( iEngine.iSecureSessionAVP )
       
   258 			    		{
       
   259 			    		iOutSession->SetModifierL( KMceSecureSession, 
       
   260 			    								   KMceSecurePlainAVP );
       
   261 			    		} 
       
   262 			    		
       
   263 			        if ( iEngine.iSecPreconditions )
       
   264 			    		{			    		
       
   265 					    iOutSession->SetModifierL( KMceSecPreconditions, 
       
   266 											   KMcePreconditionsE2ESupported );
       
   267 			    		}	
       
   268 
       
   269 		    		}
       
   270 		    	else
       
   271 		    		{
       
   272 		    		iOutSession = CMceOutSession::NewL( iEngine.MCEManager(),
       
   273 		                                            iProfile->Profile(),
       
   274 		                                            recipient ,orig8);	
       
   275 		    		}
       
   276 		    	
       
   277 		    	}
       
   278 		    else ///thru accesspoint , it can be  done only with originator
       
   279 		    	{
       
   280 		    	iOutSession = CMceOutSession::NewL( iEngine.MCEManager(),
       
   281 		                                           iIapId,ptr,recipient);
       
   282 		    			    	
       
   283 		    	}
       
   284 			    
       
   285 	   	    }
       
   286 	   	else  // if there is only recipent and no originator 
       
   287 	   	    {
       
   288 	   	    if ( iSessionParams.iSecureSession )
       
   289 		    	{
       
   290 		    	iOutSession = 
       
   291 		    		CMceSecureOutSession::NewL( iEngine.MCEManager(), 
       
   292 	                                            iProfile->Profile(),
       
   293 	                                            recipient );
       
   294 	            if ( iEngine.iSecureSessionAVP )
       
   295 			    		{
       
   296 			    		iOutSession->SetModifierL( KMceSecureSession, 
       
   297 			    								   KMceSecurePlainAVP );
       
   298 			    		} 
       
   299 		    	if ( iEngine.iSecPreconditions )
       
   300 			    		{			    		
       
   301 						iOutSession->SetModifierL( KMceSecPreconditions, 
       
   302 										KMcePreconditionsE2ESupported );
       
   303 			    		}
       
   304 	
       
   305 		    	}
       
   306 		    else
       
   307 		    	{
       
   308 		    	iOutSession = CMceOutSession::NewL( iEngine.MCEManager(), 
       
   309 	                                            iProfile->Profile(),
       
   310 	                                            recipient );
       
   311 		    	}
       
   312 	   	    
       
   313 	   	    }
       
   314 	    
       
   315 	    iSession = iOutSession;
       
   316 
       
   317         if ( iSessionType == EPoCSession)
       
   318 			{
       
   319 		 	FillPoCSessionData(iOutSession);
       
   320 			}
       
   321 		else if (iSessionType == EVoIPSession)
       
   322 			{
       
   323 			FillVoIPSessionData(iOutSession);
       
   324 			}
       
   325 	    else if (iSessionType == E2WayVideoSession)
       
   326 	        {
       
   327 	        Fill2WayVideoSessionDataL(iOutSession);
       
   328 	        }
       
   329 		else if (iSessionType == ECustomSession)
       
   330 			{
       
   331 			FillCustomSessionData(iOutSession);
       
   332 			}
       
   333 		if ( iEngine.iHoldWithAddress )
       
   334     		{
       
   335     		iOutSession->SetModifierL( KMceMediaDirection, KMceMediaDirectionWithAddress );
       
   336     		} 
       
   337 		if ( iEngine.IsFCSession() ) 
       
   338 			{
       
   339 			TRAP_IGNORE(iEngine.FloorControl().InitializeL(
       
   340 												*iOutSession,0,iEngine.MMObserver()));
       
   341 			CDesC8Array* array = NULL;
       
   342 		
       
   343 			array = new (ELeave) CDesC8ArrayFlat(1);	
       
   344 		    array->AppendL(_L8("a=fmtp:TBCP queuing=1; tb_priority=0; timestamp=1; tb_granted=1; poc_sess_priority=1; poc_lock=1\r\n"));
       
   345 			iEngine.FloorControl().UpdateL(*iOutSession, array);
       
   346 				
       
   347 			}
       
   348 		
       
   349 		if ( iEngine.iSdp )
       
   350 			    {
       
   351 			    CDesC8Array* array = new (ELeave) CDesC8ArrayFlat(3);
       
   352 			    array->AppendL(_L8("a=OutgoingSession1:20\r\n"));
       
   353                 array->AppendL(_L8("a=OutgoingSession2:40\r\n"));
       
   354                 array->AppendL(_L8("b=AS:64\r\n"));
       
   355 			    iOutSession->SetSessionSDPLinesL( array );
       
   356 			    }
       
   357         }
       
   358 		
       
   359 		    // Get identity
       
   360 	    iId = iEngine.NextOutSessionId();
       
   361     	iType = KMceOutSession;
       
   362    
       
   363     }
       
   364 
       
   365 // -----------------------------------------------------------------------------
       
   366 // CMCETestUIEngineOutSession::ConstructSessionFromReferL()
       
   367 // -----------------------------------------------------------------------------
       
   368 //
       
   369 void CMCETestUIEngineOutSession::ConstructL(CMceRefer& /*aRefer*/)
       
   370     {
       
   371  
       
   372      /////////////////////
       
   373     //
       
   374     // TODO: After implementing wrappers for streams, sinks and sources 
       
   375     //       this function should be refactored to make use of them. That will 
       
   376     //       also simplify the function to some extent.
       
   377     //
       
   378     //////////////////////
       
   379     BaseConstructL();
       
   380     
       
   381 	    CMceOutSession* outSession = NULL;
       
   382 	    iOutSession = CMceOutSession::NewL( *iRefer );
       
   383 		   
       
   384 	    iSession = iOutSession;
       
   385 
       
   386         if ( iSessionType == ECustomSession)
       
   387 			{
       
   388 		//	FillCustomSessionData(iOutSession);
       
   389 			FillVoIPSessionData(iOutSession);
       
   390 			}
       
   391 		if( iEngine.iHoldWithAddress )
       
   392     		{
       
   393     		iOutSession->SetModifierL( KMceMediaDirection, KMceMediaDirectionWithAddress );
       
   394     		} 
       
   395 		if( iEngine.IsFCSession() ) 
       
   396 			{
       
   397 			TRAP_IGNORE(iEngine.FloorControl().InitializeL(
       
   398 												*iOutSession,0,iEngine.MMObserver()));
       
   399 			CDesC8Array* array = NULL;
       
   400 		
       
   401 			array = new (ELeave) CDesC8ArrayFlat(1);	
       
   402 		    array->AppendL(_L8("a=fmtp:TBCP queuing=1; tb_priority=0; timestamp=1; tb_granted=1; poc_sess_priority=1; poc_lock=1\r\n"));
       
   403 			iEngine.FloorControl().UpdateL(*iOutSession, array);
       
   404 				
       
   405 			}
       
   406 		if( iEngine.iSdp )
       
   407 		    {
       
   408 		    CDesC8Array* array = new (ELeave) CDesC8ArrayFlat(2);
       
   409 		    array->AppendL(_L8("a=OutgoingSession1:20\r\n"));
       
   410             array->AppendL(_L8("a=OutgoingSession2:40\r\n"));
       
   411 		    iOutSession->SetSessionSDPLinesL( array );
       
   412 		    }
       
   413 	
       
   414 		
       
   415 		    // Get identity
       
   416 	    iId = iEngine.NextOutSessionId();
       
   417     	iType = KMceOutSession;
       
   418    
       
   419     }
       
   420 
       
   421 // -----------------------------------------------------------------------------
       
   422 // CMCETestUIEngineOutSession::~CMCETestUIEngineOutSession
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 EXPORT_C CMCETestUIEngineOutSession::~CMCETestUIEngineOutSession()
       
   426     {
       
   427     delete iOutSession;
       
   428     }
       
   429 
       
   430 // -----------------------------------------------------------------------------
       
   431 // CMCETestUIEngineOutSession::GetCommands
       
   432 // -----------------------------------------------------------------------------
       
   433 //
       
   434 const RPointerArray<TMCETestUIEngineCmdBase>& 
       
   435             CMCETestUIEngineOutSession::GetCommandsL()
       
   436     {
       
   437     iCommands.ResetAndDestroy();
       
   438 
       
   439     // Get base class commands
       
   440     CMCETestUIEngineSession::GetCommandsL();
       
   441         
       
   442     // Get own commands       
       
   443     TInt state = iOutSession->State();
       
   444 
       
   445 	switch( state ) 
       
   446 		{
       
   447 		case CMceSession::EIdle: 
       
   448 		    iCommands.Append( new (ELeave) TMCETestUIEngineCmdEstablish( 
       
   449                                 iEngine, *this ) );
       
   450             iCommands.Append( new (ELeave) TMCETestUIEngineCmdEstablishWithValues( 
       
   451                                 iEngine, *this ) );
       
   452             iCommands.Append( new (ELeave) TMCETestUIEngineCmdFCSendSession( 
       
   453                                 iEngine, *this ) );
       
   454                
       
   455             iCommands.Append( new (ELeave) 
       
   456 		        TMCETestUIEngineCmdDeleteSession( iEngine, *this ) );
       
   457 		    if(iSession->Type() == KMceSessionSecure) 
       
   458 		    	{
       
   459 		    	iCommands.Append( new (ELeave) 
       
   460 		        	TMCETestUIEngineCmdCurrentCryptoContext( iEngine, *this ) );
       
   461 		        iCommands.Append( new (ELeave) 
       
   462 		        	TMCETestUIEngineCmdSupportedCryptoContext( iEngine, *this ) );
       
   463 		        iCommands.Append( new (ELeave) 
       
   464 		        	TMCETestUIEngineCmdSetCryptoContext( iEngine, *this ) );
       
   465 		       	}
       
   466 		    break;
       
   467 		case CMceSession::EOffering: 
       
   468 		    iCommands.Append( new (ELeave) TMCETestUIEngineCmdCancelSession( 
       
   469                                 iEngine, *this ) );
       
   470             iCommands.Append( new (ELeave) TMCETestUIEngineCmdFCSendSession( 
       
   471                                 iEngine, *this ) );
       
   472 			iCommands.Append( new (ELeave) 
       
   473 		        TMCETestUIEngineCmdDeleteSession( iEngine, *this ) );     
       
   474 			
       
   475 		    iCommands.Append( new (ELeave) 
       
   476 		        TMCETestUIEngineCmdSendInfo( iEngine, *this ) );
       
   477 			iCommands.Append( new (ELeave) 
       
   478 		        TMCETestUIEngineCmdDTMFInfo( iEngine, *this ) );
       
   479 		    iCommands.Append( new ( ELeave )
       
   480 		    	TMCETestUIEngineCmdSendInfoResponse( iEngine, *this ) );
       
   481 
       
   482 		        
       
   483 		        
       
   484 		    if(iSession->Type() == KMceSessionSecure) 
       
   485 		    	{
       
   486 		    	iCommands.Append( new (ELeave) 
       
   487 		        	TMCETestUIEngineCmdCurrentCryptoContext( iEngine, *this ) );
       
   488 		        iCommands.Append( new (ELeave) 
       
   489 		        	TMCETestUIEngineCmdSupportedCryptoContext( iEngine, *this ) );
       
   490 		        }
       
   491 		                              
       
   492 		    break;
       
   493 		case CMceSession::EEstablished:
       
   494 			if(VideoDirection() != EVideoNotSpesified)    
       
   495 		    	{
       
   496 		    	if(iEngine.IsVideoEnabled())
       
   497 		    	{
       
   498 		    	iCommands.Append( new (ELeave) 
       
   499 		        TMCETestUIEngineCmdDisableVideoSession( iEngine, *this ) );
       
   500 		    	}
       
   501 		    	else
       
   502 		    	{
       
   503 		    	iCommands.Append( new (ELeave) 
       
   504 		        TMCETestUIEngineCmdEnableVideoSession( iEngine, *this ) );     		        
       
   505 		    	}
       
   506 		    	}
       
   507 		    break;		
       
   508 		default: 
       
   509 		    break;
       
   510 		}  
       
   511 		  
       
   512     return iCommands; 
       
   513     }
       
   514 
       
   515 // -----------------------------------------------------------------------------
       
   516 // CMCETestUIEngineOutSession::Id
       
   517 // -----------------------------------------------------------------------------
       
   518 //
       
   519 EXPORT_C TInt CMCETestUIEngineOutSession::Id() const
       
   520     {
       
   521     return iId;
       
   522     }
       
   523 
       
   524 // -----------------------------------------------------------------------------
       
   525 // CMCETestUIEngineOutSession::OutSession
       
   526 // -----------------------------------------------------------------------------
       
   527 //
       
   528 CMceOutSession& CMCETestUIEngineOutSession::OutSession()
       
   529     {
       
   530     return *iOutSession;
       
   531     }
       
   532 
       
   533 // -----------------------------------------------------------------------------
       
   534 // CMCETestUIEngineOutSession::SessionParams
       
   535 // -----------------------------------------------------------------------------
       
   536 //
       
   537 
       
   538 TBool CMCETestUIEngineOutSession::SessionParamsL(TSessionParams &aSessionParams,
       
   539 									TSessionType aSessionType)
       
   540 	{
       
   541   	return iEngine.SessionParamsL( aSessionParams,aSessionType );
       
   542  	}
       
   543 
       
   544 // -----------------------------------------------------------------------------
       
   545 // CMCETestUIEngineOutSession::FillPoCSessionData
       
   546 // -----------------------------------------------------------------------------
       
   547 //
       
   548 
       
   549 void CMCETestUIEngineOutSession::FillProfileRegistrar()
       
   550 	{
       
   551 	// trying to get profile registrar 
       
   552     if(iEngine.iOutSessionWithProfile)
       
   553     	{
       
   554     	TUriParser8 parser;
       
   555 	    const TDesC8& aor = iProfile->Aor();
       
   556 	    parser.Parse( aor ) ; 
       
   557 	    CUri8* uri8 = CUri8::NewLC( parser );
       
   558 	    const TDesC8& registrar =  uri8->Uri().Extract( EUriHost ) ;
       
   559 	    
       
   560 	    HBufC*registrar16 = HBufC16::NewLC( KRecipent().Length() + registrar.Length() );
       
   561 	    TPtr registrarPtr = registrar16->Des();
       
   562 	    registrarPtr.Copy( registrar );
       
   563 	    
       
   564 	    iSessionParams.iRecipentAddress.Append(KRecipent) ;
       
   565 	    iSessionParams.iRecipentAddress.Append(*registrar16)  ;
       
   566 	    
       
   567 	    CleanupStack::PopAndDestroy( registrar16 );
       
   568 	    registrar16 = NULL;
       
   569 	    
       
   570 	    CleanupStack::PopAndDestroy( uri8 );
       
   571 	    uri8 = NULL; 
       
   572     	}
       
   573        else
       
   574        	{
       
   575        	iSessionParams.iRecipentAddress.Append(KRecipent) ;
       
   576        	}
       
   577     
       
   578     // profile registrar end .....
       
   579 	}
       
   580 
       
   581 // -----------------------------------------------------------------------------
       
   582 // CMCETestUIEngineOutSession::FillPoCorigAddress
       
   583 // -----------------------------------------------------------------------------
       
   584 //
       
   585 
       
   586 void CMCETestUIEngineOutSession::FillPoCOrigAddress()
       
   587 	{
       
   588  
       
   589     if(iEngine.IsFCSession())
       
   590     	{
       
   591     	const TDesC8& aor = iProfile->Aor();
       
   592     	HBufC*aor16 = HBufC16::NewLC( aor.Length() );
       
   593     	TPtr aorPtr = aor16->Des();
       
   594     	aorPtr.Copy(aor);
       
   595     	iSessionParams.originator.Append(*aor16)  ;
       
   596 	    CleanupStack::PopAndDestroy( aor16 );
       
   597 	    aor16 = NULL;
       
   598 	   	}
       
   599        
       
   600    	}
       
   601 
       
   602 // -----------------------------------------------------------------------------
       
   603 // CMCETestUIEngineOutSession::FillVoIPSessionData
       
   604 // -----------------------------------------------------------------------------
       
   605 //
       
   606 
       
   607 void CMCETestUIEngineOutSession::FillVoIPSessionData(CMceOutSession* outSession)
       
   608 	{
       
   609    
       
   610     // OUT STREAM
       
   611     // create "audio out" stream first, puts audioOutStream to cleanupstack
       
   612     CMceAudioStream* audioOutStream = CMceAudioStream::NewLC();
       
   613    
       
   614     // create mic source
       
   615     CMceMicSource* mic = CMceMicSource::NewLC();
       
   616    
       
   617     // set source for "audio out" stream, in this case it's microphone
       
   618     // there can be only one source at a time.
       
   619     audioOutStream->SetSourceL( mic );
       
   620     
       
   621     // pop mic from cleanupstack
       
   622     CleanupStack::Pop( mic );
       
   623     
       
   624     // create rtp sink for mic
       
   625     CMceRtpSink* rtpSink = CMceRtpSink::NewL();
       
   626 	CleanupStack::PushL( rtpSink );
       
   627 	audioOutStream->AddSinkL( rtpSink );
       
   628 	CleanupStack::Pop( rtpSink );
       
   629    
       
   630     // IN STREAM
       
   631     // create "audio in" stream
       
   632     CMceAudioStream* audioInStream = CMceAudioStream::NewLC();
       
   633       
       
   634     // create rtp source for "audio in" stream
       
   635 	CMceRtpSource* rtpSource = CMceRtpSource::NewLC( iEngine.iJitterBufSize, 
       
   636                                 	                 iEngine.iJitterBufTreshold, 0 );
       
   637 	audioInStream->SetSourceL( rtpSource );
       
   638 	// pop rtp source from cleanupstack
       
   639 	CleanupStack::Pop( rtpSource );
       
   640 	
       
   641 	// create speaker sink for "audio in" stream
       
   642 	CMceSpeakerSink* speaker = CMceSpeakerSink::NewLC();	
       
   643 	audioInStream->AddSinkL( speaker );
       
   644 	// pop speaker from cleanupstack
       
   645 	CleanupStack::Pop( speaker );
       
   646 	
       
   647 	// bind "audio out" stream to "audio in" stream
       
   648 	// audioInStream->BindL( audioOutStream );
       
   649 	audioOutStream->BindL( audioInStream );
       
   650     // iSession->AddStreamL( audioInStream );
       
   651     outSession->AddStreamL( audioOutStream );
       
   652     
       
   653     // modify QoS preconditions off
       
   654     outSession->SetModifierL( KMcePreconditions, KMcePreconditionsNotUsed  );
       
   655 
       
   656         
       
   657     // add codecs to audiostream 
       
   658     // some default voip values to be still added
       
   659     
       
   660     // set MMF priorities and preferences to codecs
       
   661     // set MMF codec priorities  for all codecs in both streams
       
   662     
       
   663     iEngine.SetMMFPriorityForCodecsL( audioInStream->Codecs(),
       
   664                               iEngine.iPriorityDownlink, 
       
   665                               iEngine.iPrefDownlink );
       
   666     
       
   667     iEngine.SetMMFPriorityForCodecsL( audioOutStream->Codecs(),
       
   668                               iEngine.iPriorityUplink, 
       
   669                               iEngine.iPrefUplink );                                
       
   670     
       
   671     // pop audioInStream from cleanupstack
       
   672     CleanupStack::Pop( audioInStream );
       
   673     
       
   674     // pop audioOutStream from cleanupstack
       
   675 	CleanupStack::Pop( audioOutStream );
       
   676    
       
   677     
       
   678 	}
       
   679 // -----------------------------------------------------------------------------
       
   680 // CMCETestUIEngineOutSession::FillPoCSessionData
       
   681 // -----------------------------------------------------------------------------
       
   682 //
       
   683 
       
   684 void CMCETestUIEngineOutSession::FillPoCSessionData(CMceOutSession* outSession)
       
   685 	{
       
   686 	iDirection = ESendRecv;
       
   687 	const TInt KStartLocalPort = 6688;
       
   688     const TInt AMRDefOfferPTime = 160;
       
   689     
       
   690     // Maximum ptime
       
   691     const TInt AMRDefOfferMaxPTime = 400;
       
   692     
       
   693     // Allowed bitrates
       
   694     const TInt AMRDefOfferAllowedBitrates = KMceAllowedAmrNbBitrate475 | 
       
   695 								  KMceAllowedAmrNbBitrate515 | 
       
   696 								  KMceAllowedAmrNbBitrate590;
       
   697 								  
       
   698     // Bitrate
       
   699     const TInt AMRDefOfferBitrate = KMceAmrNbBitrate515;
       
   700     
       
   701     // Codec mode
       
   702     const TInt AMRDefOfferCodingMode = EMceOctetAligned;
       
   703     
       
   704     
       
   705 	 CMceAudioStream* audioOutStream = NULL;
       
   706 	 	// audio in stream
       
   707 	CMceAudioStream* audioStreamIn = CMceAudioStream::NewLC();
       
   708 
       
   709 	TInt locPort( KStartLocalPort );
       
   710 	locPort = locPort + ( 128 * 2 );
       
   711 	
       
   712 	audioStreamIn->SetLocalMediaPortL( locPort );
       
   713 		
       
   714 	CMceSpeakerSink* speakerSink = CMceSpeakerSink::NewLC();
       
   715 	audioStreamIn->AddSinkL(speakerSink);
       
   716 	CleanupStack::Pop();
       
   717 	
       
   718 	// TODO:
       
   719 	HBufC8* rtpSourceIdentity = KMCERtpSourceIdentity().AllocLC();
       
   720 	CMceRtpSource* rtpSource = CMceRtpSource::NewLC( iEngine.iJitterBufSize, 
       
   721                                 	                 iEngine.iJitterBufTreshold, 
       
   722                                 	                 iEngine.iJitterBufTimeout,
       
   723                                 	                 rtpSourceIdentity);
       
   724 	audioStreamIn->SetSourceL(rtpSource);
       
   725 	//rtpSource->EnableInactivityTimerL(10000);
       
   726 	CleanupStack::Pop();	
       
   727 	CleanupStack::PopAndDestroy(rtpSourceIdentity);
       
   728 	
       
   729 	CMceAudioStream* audioStreamOut = CMceAudioStream::NewLC();
       
   730 	HBufC8* rtpSinkIdentity = KMCERtpSinkIdentity().AllocLC();
       
   731 	CMceRtpSink* rtpSink = CMceRtpSink::NewL( ETrue, rtpSinkIdentity);
       
   732 	audioStreamOut->AddSinkL(rtpSink);
       
   733 	CleanupStack::PopAndDestroy(rtpSinkIdentity);
       
   734 	
       
   735 	CMceMicSource* micSource = CMceMicSource::NewLC();
       
   736 	audioStreamOut->SetSourceL(micSource);
       
   737 	micSource->DisableL();
       
   738 	CleanupStack::Pop();	
       
   739 	
       
   740 	audioStreamIn->BindL(audioStreamOut);
       
   741 	CleanupStack::Pop(audioStreamOut);
       
   742 	// floor control
       
   743 
       
   744 	outSession->AddStreamL( audioStreamIn );
       
   745 	CleanupStack::Pop(audioStreamIn);
       
   746 	// 
       
   747 	// TODO: Currently MMComms supports only the first codec of the stream
       
   748 	//
       
   749 	const RPointerArray<CMceAudioCodec>& codecs =  audioStreamIn->Codecs();
       
   750 	
       
   751 	for( int i = 0; i < codecs.Count(); i++ )
       
   752 	    {
       
   753 	    CMceAudioCodec* codec = codecs[i];
       
   754 	    
       
   755 	    // Search for AMR codec and delete others
       
   756 		if( codec->SdpName() != KMceSDPNameAMR )
       
   757 	        {
       
   758 	    	audioStreamIn->RemoveCodecL( *codec );
       
   759 	    	--i;
       
   760 	    	}
       
   761 	    }
       
   762 
       
   763     if( codecs.Count() != 1 )
       
   764         {
       
   765         User::Leave( KErrArgument );
       
   766         }
       
   767         
       
   768 	CMceAmrCodec* amrcodec = ( CMceAmrCodec* ) codecs[0];
       
   769 	
       
   770 	const RPointerArray<CMceAudioCodec>& codecsOut =  audioStreamOut->Codecs();
       
   771 	CMceAmrCodec* amrcodecOut = (CMceAmrCodec*)codecsOut[0];
       
   772 	
       
   773 	
       
   774 	// set prioirity for uplink
       
   775 	amrcodecOut->SetMMFPriorityL( iEngine.iPriorityUplink );
       
   776     amrcodecOut->SetMMFPriorityPreferenceL( iEngine.iPrefUplink );
       
   777     
       
   778 	// set prioirity for downlink
       
   779 	amrcodec->SetMMFPriorityL( iEngine.iPriorityDownlink );
       
   780     amrcodec->SetMMFPriorityPreferenceL( iEngine.iPrefDownlink );
       
   781 	
       
   782 	//
       
   783 	// Set initial parameters for codec
       
   784 	//
       
   785 	// Allowed bitrates
       
   786 	amrcodec->SetAllowedBitrates( AMRDefOfferAllowedBitrates );
       
   787 	
       
   788 	// Bitrate should be 5150
       
   789 	amrcodec->SetBitrate( AMRDefOfferBitrate );
       
   790 
       
   791     // AMR narrow band, sampling rate 8000
       
   792 	amrcodec->SetSamplingFreq( KMceAmrNbSamplingFreq );
       
   793 	
       
   794 	// Use bandwith effient coding
       
   795 	amrcodec->SetCodecMode( AMRDefOfferCodingMode );
       
   796 	amrcodecOut->SetCodecMode( AMRDefOfferCodingMode );
       
   797 	
       
   798 	// Default packet ratio is 8 AMR packets per one RTP packet
       
   799 	// -> ptime = 8 * 20 = 160. Lower value is not good with GPRS bearer
       
   800 	amrcodec->SetPTime(AMRDefOfferPTime );
       
   801 	
       
   802 	// Allowable maximum ptime, 400 should be OK
       
   803 	amrcodec->SetMaxPTime( AMRDefOfferMaxPTime );
       
   804 	
       
   805 	// 106 seems to be common payload type
       
   806 	amrcodec->SetPayloadType( 106 );
       
   807 	
       
   808 
       
   809 	// Disabled here due to audio server crash
       
   810 //	CMceRtpSink* rtpOutSink = (CMceRtpSink*) audioStreamOut->Sinks()[0];
       
   811 //	rtpOutSink->DisableL();
       
   812 	}
       
   813 
       
   814 // -----------------------------------------------------------------------------
       
   815 // CMCETestUIEngineOutSession::FillCustomSessionData	
       
   816 // -----------------------------------------------------------------------------
       
   817 //
       
   818 void CMCETestUIEngineOutSession::FillCustomSessionData(CMceOutSession* outSession)
       
   819 	{
       
   820 	
       
   821 	// setmodifier for the session, by default preconditions are present, if no preconditions then setthis
       
   822 	if( iSessionParams.iNoPrecondtion) 
       
   823 		{
       
   824 		outSession->SetModifierL(KMcePreconditions,KMcePreconditionsNotUsed);
       
   825 		}
       
   826 	outSession->SetServiceTypeL(iSessionParams.iServiceType);
       
   827 	switch (iSessionParams.index )
       
   828 	    {
       
   829 	    case 0: 
       
   830 	        iDirection = ESendRecv;
       
   831 	        break;
       
   832 	    case 1: 
       
   833 	        iDirection = ESendOnly;
       
   834 	        break;
       
   835 	    case 2: 
       
   836 	        iDirection = ERecvOnly;
       
   837 	        break;
       
   838 	    default:
       
   839 	        iDirection = ENotSpesified;
       
   840 	        break;
       
   841 	    }
       
   842 	    
       
   843 	    CMceFileSource* fileSource = NULL;
       
   844 	    CMceAudioStream* audioOutStream = NULL;
       
   845 	    CMceAudioStream* audioOutStreamLocal = NULL;
       
   846 	 	if ( iDirection != ENotSpesified )
       
   847 	    {
       
   848 	    // Create outstream (== uplink)
       
   849 
       
   850 	    if ( iDirection == ESendOnly ||  
       
   851 	         iDirection == ESendRecv )
       
   852 	        {
       
   853 	        audioOutStream = CMceAudioStream::NewLC();
       
   854 	        CMceMicSource* mic = NULL;
       
   855 	        
       
   856 			if(iSessionParams.sourceType)
       
   857 				{
       
   858 				fileSource = CMceFileSource::NewL(iEngine.MCEManager(), iSessionParams.sourceFile );
       
   859             	CleanupStack::PushL( fileSource );
       
   860             	audioOutStream->SetSourceL(fileSource);
       
   861             	CleanupStack::Pop( fileSource );
       
   862 				}
       
   863 			else
       
   864 				{
       
   865 				mic = CMceMicSource::NewLC();
       
   866 				audioOutStream->SetSourceL( mic );	
       
   867 				CleanupStack::Pop( mic );
       
   868 				}
       
   869 			
       
   870 			
       
   871 			CMceRtpSink* rtpSink;
       
   872 			CMceSpeakerSink* speakerSink;
       
   873 			
       
   874 			if(iSessionParams.audioSinkType)			
       
   875 				{
       
   876 				speakerSink = CMceSpeakerSink::NewLC();
       
   877 				audioOutStream->AddSinkL( speakerSink );
       
   878 				speakerSink->SetRoutingL( KMceAudioRoutePrivate );
       
   879 				CleanupStack::Pop( speakerSink );
       
   880 				}
       
   881 			else
       
   882 				{
       
   883 				HBufC8* rtpSinkIdentity = KMCERtpSinkIdentity().AllocLC();
       
   884 				if(iEngine.iRtcpFlag)
       
   885 					{
       
   886 					rtpSink = CMceRtpSink::NewL(ETrue, rtpSinkIdentity);	
       
   887 					CleanupStack::PushL(rtpSink);
       
   888 					}
       
   889 				else
       
   890 					{
       
   891 					rtpSink = CMceRtpSink::NewL( EFalse, rtpSinkIdentity );
       
   892 					CleanupStack::PushL(rtpSink);	
       
   893 					}
       
   894 				audioOutStream->AddSinkL( rtpSink );
       
   895 				CleanupStack::Pop( rtpSink );
       
   896 				CleanupStack::PopAndDestroy(rtpSinkIdentity);
       
   897 				}
       
   898 				
       
   899 		    // Create stream for local playing of the audio
       
   900 		    if ( fileSource && iEngine.iBundle )
       
   901 				{
       
   902 				audioOutStreamLocal = CMceAudioStream::NewLC();
       
   903             	audioOutStreamLocal->SetSourceL(fileSource);
       
   904             	speakerSink = 0;
       
   905             	speakerSink = CMceSpeakerSink::NewLC();	
       
   906 				audioOutStreamLocal->AddSinkL( speakerSink );
       
   907 				CleanupStack::Pop( speakerSink );
       
   908 				}
       
   909 
       
   910 			if( iEngine.iSdp )
       
   911 			    {
       
   912 			    CDesC8Array* array = new (ELeave) CDesC8ArrayFlat(3);
       
   913 			    array->AppendL(_L8("a=OutgoingStream1UL:20\r\n"));
       
   914                 array->AppendL(_L8("a=OutgoingStream2UL:40\r\n"));
       
   915                 array->AppendL(_L8("b=AS:64\r\n"));
       
   916 			    audioOutStream->SetMediaAttributeLinesL( array );
       
   917 			    
       
   918 			    }    
       
   919 	        }
       
   920 
       
   921 	    // Create instream (== downlink)
       
   922 	    CMceAudioStream* audioInStream = NULL;
       
   923 	    
       
   924 	    if ( iDirection == ERecvOnly ||
       
   925 	         iDirection == ESendRecv )
       
   926 	        {
       
   927 			audioInStream = CMceAudioStream::NewLC();
       
   928 			HBufC8* rtpSourceIdentity = KMCERtpSourceIdentity().AllocLC();
       
   929 			CMceRtpSource* rtpSource = CMceRtpSource::NewL( iEngine.iJitterBufSize, 
       
   930                                 	                         iEngine.iJitterBufTreshold, 
       
   931                                 	                         iEngine.iJitterBufTimeout,
       
   932                                 	                         rtpSourceIdentity);
       
   933 			CleanupStack::PushL( rtpSource );
       
   934 			audioInStream->SetSourceL( rtpSource );
       
   935 			CleanupStack::Pop( rtpSource );
       
   936 			CleanupStack::PopAndDestroy(rtpSourceIdentity);
       
   937 			
       
   938 			CMceSpeakerSink* speaker = CMceSpeakerSink::NewLC();
       
   939 			speaker->SetRoutingL( KMceAudioRoutePrivate );	
       
   940 			audioInStream->AddSinkL( speaker );
       
   941 			CleanupStack::Pop( speaker );
       
   942 			
       
   943 			if( iEngine.iSdp )
       
   944 			    {
       
   945 			    CDesC8Array* array = new (ELeave) CDesC8ArrayFlat(3);
       
   946 			    array->AppendL(_L8("a=OutgoingStream1DL:20\r\n"));
       
   947                 array->AppendL(_L8("a=BoundStream:40\r\n"));
       
   948                 array->AppendL(_L8("b=AS:64\r\n"));	
       
   949 			    audioInStream->SetMediaAttributeLinesL( array );
       
   950 			    }    
       
   951 			    
       
   952 	        }
       
   953             
       
   954 	    // Bound streams     
       
   955 	    if ( iDirection == ESendRecv )
       
   956 	        {
       
   957 			audioOutStream->BindL( audioInStream ); 
       
   958 			
       
   959 			if ( audioInStream )
       
   960 			    {
       
   961 			    CleanupStack::Pop( audioInStream );     
       
   962 			    }
       
   963 	        }
       
   964 
       
   965 	    // Add streams to OutSession    
       
   966 	    if ( iDirection != ERecvOnly )
       
   967 	        {
       
   968 	        if ( audioOutStreamLocal )
       
   969 	            {
       
   970 	            outSession->AddStreamL( audioOutStreamLocal );
       
   971 	            CleanupStack::Pop( audioOutStreamLocal );
       
   972 	            
       
   973 	            iEngine.SetMMFPriorityForCodecsL( audioOutStreamLocal->Codecs(),
       
   974                                       iEngine.iPriorityUplink, 
       
   975                                       iEngine.iPrefUplink );
       
   976 	            }
       
   977 
       
   978 	        outSession->AddStreamL( audioOutStream );
       
   979 	        CleanupStack::Pop( audioOutStream );
       
   980 
       
   981                 
       
   982             iEngine.SetMMFPriorityForCodecsL( audioOutStream->Codecs(),
       
   983                                       iEngine.iPriorityUplink, 
       
   984                                       iEngine.iPrefUplink );
       
   985             
       
   986             if ( audioInStream )
       
   987                 {  
       
   988                 iEngine.SetMMFPriorityForCodecsL( audioInStream->Codecs(),
       
   989                                           iEngine.iPriorityDownlink, 
       
   990                                           iEngine.iPrefDownlink );
       
   991                 }
       
   992 	        }
       
   993 	    else
       
   994 	        {
       
   995 	        outSession->AddStreamL( audioInStream );
       
   996 	        CleanupStack::Pop( audioInStream );
       
   997 	        
       
   998 	        iEngine.SetMMFPriorityForCodecsL( audioInStream->Codecs(),
       
   999                                       iEngine.iPriorityDownlink, 
       
  1000                                       iEngine.iPrefDownlink );
       
  1001 	        }    
       
  1002 	    
       
  1003 	    }
       
  1004 	  switch (iSessionParams.videoIndex )
       
  1005 	    {
       
  1006 	    case 0: 
       
  1007 	        iVideoDirection = EVideoSendRecv;
       
  1008 	        break;
       
  1009 	    case 1: 
       
  1010 	        iVideoDirection = EVideoSendOnly;
       
  1011 	        break;
       
  1012 	    case 2: 
       
  1013 	        iVideoDirection = EVideoRecvOnly;
       
  1014 	        break;
       
  1015 	    default:
       
  1016 	        iVideoDirection = EVideoNotSpesified;
       
  1017 	        break;
       
  1018 	    }
       
  1019 	    
       
  1020 	    CMceVideoStream* videoOutStreamRTP = NULL;
       
  1021 	    CMceVideoStream* videoOutStreamDisplay = NULL;
       
  1022 	    CMceVideoStream* videoOutStreamFile = NULL;
       
  1023 	    CMceVideoStream* vidStreamLocal = NULL;
       
  1024 	    CMceCameraSource* cam =NULL;
       
  1025 	    CMceFileSource* videoFileSource = NULL;
       
  1026 	    
       
  1027 	 	if ( iVideoDirection != EVideoNotSpesified )
       
  1028 	    {
       
  1029 	    // Create outstream (== uplink)
       
  1030 	    
       
  1031 
       
  1032 	    if ( iVideoDirection == EVideoSendOnly ||  
       
  1033 	         iVideoDirection == EVideoSendRecv )
       
  1034 	        {
       
  1035 	        // UL stream present
       
  1036 			CMceRtpSink* rtpSink = NULL;
       
  1037 			CMceDisplaySink* dispSink = NULL;
       
  1038 			CMceFileSink* fileSink = NULL;
       
  1039 			
       
  1040 			if(iSessionParams.videoSinkDisplay)
       
  1041 				{
       
  1042 				dispSink = CMceDisplaySink::NewLC( iEngine.MCEManager());
       
  1043 			//	TRect viewFinder(0, 83, 352, 378);
       
  1044 				TRect viewFinder(32, 88, 208, 232);
       
  1045 			//    TRect viewFinder(iEngine.GetRect());
       
  1046 	        	dispSink->SetDisplayRectL( viewFinder );
       
  1047 				videoOutStreamDisplay = CMceVideoStream::NewL();
       
  1048 				CleanupStack::Pop( dispSink );
       
  1049 				CleanupStack::PushL( videoOutStreamDisplay );
       
  1050 				videoOutStreamDisplay->AddSinkL( dispSink );
       
  1051 				if(iSessionParams.sourceType)
       
  1052 					{
       
  1053 					//check for filesource if it is already there --- start
       
  1054 					if(fileSource)
       
  1055 						{
       
  1056 						videoOutStreamDisplay->SetSourceL( fileSource );	
       
  1057 						}
       
  1058 					else
       
  1059 						{
       
  1060 						fileSource = CMceFileSource::NewL(iEngine.MCEManager(), iSessionParams.sourceFile );
       
  1061 		            	CleanupStack::PushL( fileSource );
       
  1062 		            	videoOutStreamDisplay->SetSourceL(fileSource);
       
  1063 		            	CleanupStack::Pop( fileSource );
       
  1064 						}
       
  1065 					}
       
  1066 				else
       
  1067 					{
       
  1068 					cam = CMceCameraSource::NewL(iEngine.MCEManager());
       
  1069 					CleanupStack::PushL( cam  );
       
  1070 					videoOutStreamDisplay->SetSourceL( cam );
       
  1071 					CleanupStack::Pop( cam );	
       
  1072 					}
       
  1073 			
       
  1074 				outSession->AddStreamL( videoOutStreamDisplay );
       
  1075 				CleanupStack::Pop( videoOutStreamDisplay );
       
  1076 				
       
  1077 				iEngine.SetMMFPriorityForCodecsL( videoOutStreamDisplay->Codecs(),
       
  1078                                                   iEngine.iPriorityUplink, 
       
  1079                                                   iEngine.iPrefUplink );
       
  1080 				}
       
  1081 			
       
  1082 			if(iSessionParams.videoSinkFile)
       
  1083 				{
       
  1084 				fileSink = CMceFileSink::NewLC( iSessionParams.sinkFile);
       
  1085 				videoOutStreamFile = CMceVideoStream::NewL();
       
  1086 				CleanupStack::Pop( fileSink );
       
  1087 				CleanupStack::PushL( videoOutStreamFile );
       
  1088 				videoOutStreamFile->AddSinkL( fileSink );
       
  1089 				if(iSessionParams.sourceType)
       
  1090 					{
       
  1091 					//check for filesource if it is already there --- start
       
  1092 					if(fileSource)
       
  1093 						{
       
  1094 						videoOutStreamFile->SetSourceL( fileSource );	
       
  1095 						}
       
  1096 					else
       
  1097 						{
       
  1098 						fileSource = CMceFileSource::NewL(iEngine.MCEManager(), iSessionParams.sourceFile );
       
  1099 		            	CleanupStack::PushL( fileSource );
       
  1100 		            	videoOutStreamFile->SetSourceL(fileSource);
       
  1101 		            	CleanupStack::Pop( fileSource );
       
  1102 						}
       
  1103 					}
       
  1104 				else
       
  1105 					{
       
  1106 					// need to check for camera ?????
       
  1107 					if(cam)
       
  1108 						{
       
  1109 						videoOutStreamFile->SetSourceL( cam );	
       
  1110 						}
       
  1111 					else
       
  1112 						{
       
  1113 						cam = CMceCameraSource::NewL(iEngine.MCEManager());
       
  1114 						CleanupStack::PushL( cam  );
       
  1115 						videoOutStreamFile->SetSourceL( cam );
       
  1116 						CleanupStack::Pop( cam );
       
  1117 						}
       
  1118 					
       
  1119 					}
       
  1120 				CleanupStack::Pop( videoOutStreamFile );
       
  1121 				outSession->AddStreamL( videoOutStreamFile );
       
  1122 				
       
  1123                 AdjustVideoCodecsL( videoOutStreamFile->Codecs() );
       
  1124 				}
       
  1125 			if( iSessionParams.videoSinkRtp )
       
  1126 				{
       
  1127 				
       
  1128 				videoOutStreamRTP = CMceVideoStream::NewL();
       
  1129 				CleanupStack::PushL( videoOutStreamRTP );
       
  1130 				
       
  1131 				HBufC8* rtpSinkIdentity = KMCERtpSinkIdentity().AllocLC();
       
  1132 				if(iEngine.iRtcpFlag)
       
  1133 					{
       
  1134 					rtpSink = CMceRtpSink::NewL(ETrue,rtpSinkIdentity );	
       
  1135 					CleanupStack::PushL( rtpSink );
       
  1136 					}
       
  1137 				else
       
  1138 					{
       
  1139 					rtpSink = CMceRtpSink::NewL(EFalse, rtpSinkIdentity);
       
  1140 					CleanupStack::PushL( rtpSink );	
       
  1141 					}
       
  1142 				
       
  1143 				videoOutStreamRTP->AddSinkL( rtpSink );
       
  1144 				CleanupStack::Pop( rtpSink );
       
  1145 				CleanupStack::PopAndDestroy(rtpSinkIdentity);
       
  1146 				if(iSessionParams.sourceType)
       
  1147 					{
       
  1148 					//check for filesource if it is already there --- start
       
  1149 					if(fileSource)
       
  1150 						{
       
  1151 						videoOutStreamRTP->SetSourceL( fileSource );	
       
  1152 						}
       
  1153 					else
       
  1154 						{
       
  1155 						fileSource = CMceFileSource::NewL(iEngine.MCEManager(), iSessionParams.sourceFile );
       
  1156 		            	CleanupStack::PushL( fileSource );
       
  1157 		            	videoOutStreamRTP->SetSourceL(fileSource);
       
  1158 		            	CleanupStack::Pop( fileSource );
       
  1159 						}
       
  1160 					}
       
  1161 				else
       
  1162 					{
       
  1163 					// need to check for camera ?????
       
  1164 					if(cam)
       
  1165 						{
       
  1166 						videoOutStreamRTP->SetSourceL( cam );	
       
  1167 						}
       
  1168 					else
       
  1169 						{
       
  1170 						cam = CMceCameraSource::NewL(iEngine.MCEManager());
       
  1171 						CleanupStack::PushL( cam  );
       
  1172 						videoOutStreamRTP->SetSourceL( cam );
       
  1173 						CleanupStack::Pop( cam );
       
  1174 						}
       
  1175 					
       
  1176 					}
       
  1177 				}
       
  1178 			
       
  1179 		     }   // uplink over
       
  1180 
       
  1181 	    // Create instream (== downlink)
       
  1182 	    CMceVideoStream* videoInStreamRTP = NULL;
       
  1183 	    
       
  1184 	    if ( iVideoDirection == EVideoRecvOnly ||
       
  1185 	         iVideoDirection == EVideoSendRecv )
       
  1186 	        {
       
  1187 			videoInStreamRTP = CMceVideoStream::NewLC();
       
  1188 			HBufC8* rtpSourceIdentity = KMCERtpSourceIdentity().AllocLC();
       
  1189 			
       
  1190 			TInt jitbufSize( iEngine.iJitterBufSize );
       
  1191             TInt jitbufThreshold( iEngine.iJitterBufTreshold );
       
  1192             TInt jitbufTimeout( iEngine.iJitterBufTimeout );
       
  1193             iEngine.GetJitterBufferValues( 
       
  1194         	    videoInStreamRTP, jitbufSize, jitbufThreshold, jitbufTimeout, ETrue );
       
  1195     	    
       
  1196 			CMceRtpSource* rtpSource = CMceRtpSource::NewLC( jitbufSize, 
       
  1197                                 	                         jitbufThreshold, 
       
  1198                                 	                         jitbufTimeout,
       
  1199                                 	                         rtpSourceIdentity);
       
  1200 			videoInStreamRTP->SetSourceL( rtpSource );
       
  1201 			CleanupStack::Pop( rtpSource );
       
  1202 			CleanupStack::PopAndDestroy(rtpSourceIdentity);
       
  1203 			CMceDisplaySink* display = CMceDisplaySink::NewLC(iEngine.MCEManager());	
       
  1204 			videoInStreamRTP->AddSinkL( display );
       
  1205 			//	
       
  1206 			if( iEngine.iSdp )
       
  1207 			    {
       
  1208 			    CDesC8Array* array = new (ELeave) CDesC8ArrayFlat(1);
       
  1209                 array->AppendL(_L8("b=AS:64\r\n"));
       
  1210 			    videoInStreamRTP->SetMediaAttributeLinesL( array );
       
  1211 			    }  	
       
  1212 					
       
  1213 			//	
       
  1214 			// TRect disp(32, 88, 208, 232);
       
  1215 			TRect disp(iEngine.GetRect());
       
  1216 		   	display->SetDisplayRectL( disp );
       
  1217         //	display->DisableL();
       
  1218 			CleanupStack::Pop( display );
       
  1219 	        }  
       
  1220 	        
       
  1221 	     // Bound streams     
       
  1222 	    if ( iVideoDirection == ESendRecv && 
       
  1223 	         videoOutStreamRTP  )
       
  1224 	        {
       
  1225 			videoOutStreamRTP->BindL( videoInStreamRTP ); 
       
  1226 			
       
  1227 			if ( videoInStreamRTP )
       
  1228 			    {
       
  1229 			    CleanupStack::Pop( videoInStreamRTP );     
       
  1230 			    }
       
  1231 			CleanupStack::Pop( videoOutStreamRTP );
       
  1232 			outSession->AddStreamL( videoOutStreamRTP );
       
  1233 			
       
  1234 			AdjustVideoCodecsL( videoOutStreamRTP->Codecs() );
       
  1235 	        }
       
  1236 	    
       
  1237 	    else // no bound streams present, either UL or DL 
       
  1238 	        {
       
  1239 	        if( iVideoDirection == EVideoRecvOnly ) // DL present
       
  1240 	            {
       
  1241 	            CleanupStack::Pop( videoInStreamRTP );
       
  1242 	            outSession->AddStreamL( videoInStreamRTP );
       
  1243 	            }
       
  1244 	        else if ( videoOutStreamRTP ) // RTP UL if present
       
  1245 	            {
       
  1246 	            CleanupStack::Pop( videoOutStreamRTP );
       
  1247 			    outSession->AddStreamL( videoOutStreamRTP );
       
  1248 			    
       
  1249 			    AdjustVideoCodecsL( videoOutStreamRTP->Codecs() );	 
       
  1250 			    
       
  1251 			    iEngine.SetMMFPriorityForCodecsL( videoOutStreamRTP->Codecs(),
       
  1252                                                   iEngine.iPriorityUplink, 
       
  1253                                                   iEngine.iPrefUplink );
       
  1254 	            }
       
  1255 	        }
       
  1256 	    }
       
  1257 	if( iEngine.iBundle /*iSessionParams.iBundle*/ ) 
       
  1258 	    {
       
  1259 	    if( audioOutStream && videoOutStreamDisplay && 
       
  1260 	        iSessionParams.sourceType  )
       
  1261 	        {
       
  1262 	        // audio and video from file present, bundle
       
  1263 	        CMceStreamBundle* bundle = CMceStreamBundle::NewLC( CMceStreamBundle::ELS );
       
  1264 	       // bundle->AddStreamL( *audioOutStream );
       
  1265 	        bundle->AddStreamL( *videoOutStreamDisplay );
       
  1266 	        if ( audioOutStreamLocal )
       
  1267 	            {
       
  1268 	            bundle->AddStreamL( *audioOutStreamLocal );
       
  1269 	            }
       
  1270 	        CleanupStack::Pop( bundle );
       
  1271 	        outSession->AddBundleL( bundle );
       
  1272 	        }
       
  1273 	    }
       
  1274 	     	    	
       
  1275 	}
       
  1276 
       
  1277 // -----------------------------------------------------------------------------
       
  1278 // CMCETestUIEngineOutSession::Fill2WayVideoSessionDataL	
       
  1279 // -----------------------------------------------------------------------------
       
  1280 //
       
  1281 void CMCETestUIEngineOutSession::Fill2WayVideoSessionDataL(CMceOutSession* aOutSession)
       
  1282     {
       
  1283     // Video
       
  1284     //
       
  1285     
       
  1286     aOutSession->SetModifierL( KMcePreconditions, KMcePreconditionsNotUsed );
       
  1287     
       
  1288     // Create video uplink
       
  1289     //
       
  1290     CMceVideoStream* videoOutStream = CMceVideoStream::NewL();
       
  1291     CleanupStack::PushL( videoOutStream );
       
  1292     
       
  1293     CMceRtpSink* rtpSink = CMceRtpSink::NewL( ETrue );
       
  1294     CleanupStack::PushL( rtpSink );	
       
  1295 	videoOutStream->AddSinkL( rtpSink );
       
  1296 	CleanupStack::Pop( rtpSink );
       
  1297 	
       
  1298     CMceCameraSource* cam = CMceCameraSource::NewL( iEngine.MCEManager() );
       
  1299 	CleanupStack::PushL( cam  );
       
  1300 	
       
  1301 	if ( iSessionParams.iCameraSetting == TSessionParams::EMceCameraSecondary )
       
  1302         {
       
  1303         if ( cam->CamerasAvailable() > 1 )
       
  1304             {
       
  1305             cam->SetCameraIndexL( 1 );
       
  1306             }
       
  1307         }
       
  1308 	
       
  1309 	videoOutStream->SetSourceL( cam );
       
  1310 	CleanupStack::Pop( cam );	
       
  1311 
       
  1312     CMceVideoStream* videoLocalStream = NULL;
       
  1313     if ( iSessionParams.videoSinkDisplay == TSessionParams::EMceViewFinderEnabled )
       
  1314         {
       
  1315         videoLocalStream = CMceVideoStream::NewL();
       
  1316         CleanupStack::PushL( videoLocalStream );
       
  1317         CMceDisplaySink* localDispSink = CMceDisplaySink::NewLC( iEngine.MCEManager() );
       
  1318     
       
  1319         TRect localDisplayRect(0, 0, 36, 44);
       
  1320         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, localDisplayRect );
       
  1321         localDispSink->SetDisplayRectL( localDisplayRect );
       
  1322         localDispSink->SetPriorityL( ECoeWinPriorityAlwaysAtFront );
       
  1323     	videoLocalStream->AddSinkL( localDispSink );
       
  1324     	CleanupStack::Pop( localDispSink );
       
  1325     	
       
  1326     	videoLocalStream->SetSourceL( cam );
       
  1327     	
       
  1328     	aOutSession->AddStreamL( videoLocalStream );
       
  1329     	CleanupStack::Pop( videoLocalStream );
       
  1330         }
       
  1331         
       
  1332     // Create video downlink
       
  1333     //
       
  1334     CMceVideoStream* videoInStream = CMceVideoStream::NewL();
       
  1335     CleanupStack::PushL( videoInStream );
       
  1336     
       
  1337     CMceDisplaySink* dispSink = CMceDisplaySink::NewLC( iEngine.MCEManager());
       
  1338     
       
  1339     TRect displayRect(32, 88, 208, 232);
       
  1340     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, displayRect );
       
  1341     dispSink->SetDisplayRectL( displayRect );
       
  1342 	videoInStream->AddSinkL( dispSink );
       
  1343 	CleanupStack::Pop( dispSink );
       
  1344 	
       
  1345 	TInt jitbufSize( iEngine.iJitterBufSize );
       
  1346     TInt jitbufThreshold( iEngine.iJitterBufTreshold );
       
  1347     TInt jitbufTimeout( iEngine.iJitterBufTimeout );
       
  1348 	
       
  1349 	iEngine.GetJitterBufferValues( 
       
  1350     	    videoInStream, jitbufSize, jitbufThreshold, jitbufTimeout, ETrue );
       
  1351     	    
       
  1352    	CMceRtpSource* rtpSource = CMceRtpSource::NewLC( jitbufSize, 
       
  1353    	                                                 jitbufThreshold, 
       
  1354    	                                                 jitbufTimeout );
       
  1355    	videoInStream->SetSourceL( rtpSource );
       
  1356 	CleanupStack::Pop( rtpSource );	
       
  1357                                 	                         
       
  1358     // Modify codecs and make sendrecv session
       
  1359     //
       
  1360     videoOutStream->BindL( videoInStream ); 
       
  1361     CleanupStack::Pop( videoInStream );
       
  1362     
       
  1363     aOutSession->AddStreamL( videoOutStream );
       
  1364     CleanupStack::Pop( videoOutStream );
       
  1365     
       
  1366     if ( iSessionParams.iVideoCodec == TSessionParams::EMceCodecSingle ||
       
  1367          iSessionParams.iVideoCodec == TSessionParams::EMceCodecMultipleModes )
       
  1368         {
       
  1369         // Remove all other codecs than first one
       
  1370         //
       
  1371         const RPointerArray<CMceVideoCodec>& videoCodecs = 
       
  1372             videoOutStream->Codecs();
       
  1373         
       
  1374         for ( TInt i = videoCodecs.Count() - 1; i > 0; i-- )
       
  1375             {
       
  1376             videoOutStream->RemoveCodecL( *videoCodecs[ i ] );
       
  1377             }
       
  1378             
       
  1379         if ( videoLocalStream )
       
  1380             {
       
  1381             const RPointerArray<CMceVideoCodec>& videoCodecs2 = 
       
  1382                 videoLocalStream->Codecs();
       
  1383         
       
  1384             for ( TInt i = videoCodecs2.Count() - 1; i > 0; i-- )
       
  1385                 {
       
  1386                 videoLocalStream->RemoveCodecL( *videoCodecs2[ i ] );
       
  1387                 }
       
  1388             }
       
  1389         } 
       
  1390     
       
  1391     if ( iSessionParams.iVideoCodec == TSessionParams::EMceCodecMultipleModes )
       
  1392         {
       
  1393         // Currently make only multiple modes offer for AVC
       
  1394         CMceVideoCodec* defaultAvcCodec = NULL;
       
  1395         const RPointerArray<CMceVideoCodec>& videoCodecs = 
       
  1396             videoOutStream->Codecs();
       
  1397         for ( TInt i = 0; i < videoCodecs.Count(); i++ )
       
  1398             {
       
  1399             if ( videoCodecs[ i ]->SdpName().CompareF( KMceSDPNameH264 ) == 0 )
       
  1400                 {
       
  1401                 defaultAvcCodec = videoCodecs[ i ];
       
  1402                 }
       
  1403             }
       
  1404         if ( defaultAvcCodec )
       
  1405             {
       
  1406             CMceVideoCodec* otherModeAvcCodec = defaultAvcCodec->CloneL();
       
  1407             CleanupStack::PushL( otherModeAvcCodec );
       
  1408             TInt codecMode = defaultAvcCodec->CodecMode();
       
  1409             TInt payloadType = defaultAvcCodec->PayloadType();
       
  1410             payloadType++;
       
  1411             if ( codecMode == KMceAvcModeSingleNal )
       
  1412                 {
       
  1413                 codecMode = KMceAvcModeNonInterleaved;
       
  1414                 }
       
  1415             else
       
  1416                 {
       
  1417                 codecMode = KMceAvcModeSingleNal;
       
  1418                 }
       
  1419             User::LeaveIfError( otherModeAvcCodec->SetCodecMode( codecMode ) );
       
  1420             User::LeaveIfError( otherModeAvcCodec->SetPayloadType( payloadType ) );
       
  1421             
       
  1422             videoOutStream->AddCodecL( otherModeAvcCodec );
       
  1423             CleanupStack::Pop( otherModeAvcCodec );
       
  1424             
       
  1425             CMceVideoCodec* otherModeAvcCodec2 = otherModeAvcCodec->CloneL();
       
  1426             CleanupStack::PushL( otherModeAvcCodec2 );
       
  1427             videoInStream->AddCodecL( otherModeAvcCodec2 );
       
  1428             CleanupStack::Pop( otherModeAvcCodec2 );
       
  1429             
       
  1430             if ( videoLocalStream )
       
  1431                 {
       
  1432                 CMceVideoCodec* otherModeAvcCodec3 = otherModeAvcCodec->CloneL();
       
  1433                 CleanupStack::PushL( otherModeAvcCodec3 );
       
  1434                 videoLocalStream->AddCodecL( otherModeAvcCodec3 );
       
  1435                 CleanupStack::Pop( otherModeAvcCodec3 ); 
       
  1436                 }
       
  1437             }
       
  1438         }
       
  1439         
       
  1440     AdjustVideoCodecsL( videoOutStream->Codecs() );   
       
  1441     
       
  1442     // Audio
       
  1443     //
       
  1444     if ( iSessionParams.iAudioCodec != TSessionParams::EMceCodecNone )
       
  1445         {
       
  1446         // Create audio uplink
       
  1447         //
       
  1448       	CMceAudioStream* audioStreamOut = CMceAudioStream::NewLC();
       
  1449     	CMceRtpSink* rtpSink = CMceRtpSink::NewL( ETrue );
       
  1450     	audioStreamOut->AddSinkL( rtpSink );
       
  1451     	
       
  1452     	CMceMicSource* micSource = CMceMicSource::NewLC();
       
  1453     	audioStreamOut->SetSourceL( micSource );
       
  1454     	CleanupStack::Pop();	
       
  1455         
       
  1456         // Create audio downlink
       
  1457         //
       
  1458         CMceAudioStream* audioStreamIn = CMceAudioStream::NewLC();
       
  1459         
       
  1460         TInt jitbufSize2( iEngine.iJitterBufSize );
       
  1461         TInt jitbufThreshold2( iEngine.iJitterBufTreshold );
       
  1462         TInt jitbufTimeout2( iEngine.iJitterBufTimeout );
       
  1463         iEngine.GetJitterBufferValues( 
       
  1464     	    audioStreamIn, jitbufSize2, jitbufThreshold2, jitbufTimeout2, ETrue );
       
  1465     	    
       
  1466     	CMceRtpSource* rtpSource = CMceRtpSource::NewLC( jitbufSize2, 
       
  1467    	                                                     jitbufThreshold2, 
       
  1468    	                                                     jitbufTimeout2 );
       
  1469     	audioStreamIn->SetSourceL( rtpSource );
       
  1470     	CleanupStack::Pop();
       
  1471     	
       
  1472     	CMceSpeakerSink* speakerSink = CMceSpeakerSink::NewLC();
       
  1473     	speakerSink->SetRoutingL( KMceAudioRoutePrivate );	
       
  1474     	audioStreamIn->AddSinkL( speakerSink );
       
  1475     	CleanupStack::Pop();	
       
  1476         
       
  1477         // Make them sendrecv
       
  1478         //
       
  1479         audioStreamOut->BindL( audioStreamIn ); 
       
  1480         CleanupStack::Pop( audioStreamIn );
       
  1481         
       
  1482         aOutSession->AddStreamL( audioStreamOut );
       
  1483         CleanupStack::Pop( audioStreamOut );
       
  1484         
       
  1485         iEngine.SetMMFPriorityForCodecsL( audioStreamOut->Codecs(),
       
  1486                                           iEngine.iPriorityUplink, 
       
  1487                                           iEngine.iPrefUplink );
       
  1488         
       
  1489         iEngine.SetMMFPriorityForCodecsL( audioStreamIn->Codecs(),
       
  1490                                           iEngine.iPriorityDownlink, 
       
  1491                                           iEngine.iPrefDownlink );
       
  1492                                                                         
       
  1493         if ( iSessionParams.iAudioCodec == TSessionParams::EMceCodecSingle )
       
  1494             {
       
  1495             const TDesC8& singleCodec = KMceSDPNamePCMU();
       
  1496             const RPointerArray<CMceAudioCodec>& audioCodecs = audioStreamOut->Codecs();
       
  1497             for( int i = 0; i < audioCodecs.Count(); i++ )
       
  1498         	    {
       
  1499         	    CMceAudioCodec* codec = audioCodecs[i];
       
  1500         	    
       
  1501         	    // Search for AMR codec and delete others
       
  1502         	    if ( codec->SdpName().CompareF( singleCodec ) != 0 )
       
  1503         	        {
       
  1504         	    	audioStreamOut->RemoveCodecL( *codec );
       
  1505         	    	--i;
       
  1506         	    	}
       
  1507         	    }
       
  1508         	    
       
  1509             __ASSERT_ALWAYS( audioCodecs.Count() == 1, User::Leave( KErrArgument ) );
       
  1510             }
       
  1511         }
       
  1512     
       
  1513     }
       
  1514     
       
  1515 // -----------------------------------------------------------------------------
       
  1516 // CMCETestUIEngineOutSession::GetVideoCodec	
       
  1517 // -----------------------------------------------------------------------------
       
  1518 //	
       
  1519 CMceVideoCodec* CMCETestUIEngineOutSession::GetVideoCodec( 
       
  1520     CMceVideoStream& aStream, const TDesC8& aSdpName )
       
  1521     {
       
  1522     const RPointerArray<CMceVideoCodec>& videoCodecs = aStream.Codecs();
       
  1523     for ( TInt i = 0; i < videoCodecs.Count(); i++ )
       
  1524         {
       
  1525         if ( videoCodecs[ i ]->SdpName().CompareF( aSdpName ) == 0 )
       
  1526             {
       
  1527             return videoCodecs[ i ];
       
  1528             }
       
  1529         }
       
  1530     return NULL;
       
  1531     }
       
  1532