multimediacommsengine/tsrc/MCETestUI/MCETestUIEngine/src/CMCETestUIEngineSession.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 
       
    23 #include <MCEManager.h>
       
    24 #include <MCESession.h>
       
    25 #include <MCEMediaStream.h>
       
    26 //#include <MCEOneWayStream.h>
       
    27 #include <MCEAudioStream.h>
       
    28 #include <MCEVideoStream.h>
       
    29 #include <MCEMediaSource.h>
       
    30 #include <MCEMicSource.h>
       
    31 #include <MCEMediaSink.h>
       
    32 #include <MCERtpSink.h>
       
    33 #include <MCERtpSource.h>
       
    34 #include <MCESpeakerSink.h>
       
    35 #include <mcesecuresession.h>
       
    36 
       
    37 #include "MCETestUIEngineDefaultValues.h"
       
    38 
       
    39 #include "CMCETestUIEngine.h"
       
    40 #include "CMCETestUIEngineSession.h"
       
    41 
       
    42 #include "TMCETestUIEngineCmdTerminateSession.h"
       
    43 #include "TMCETestUIEngineCmdUpdateSession.h"
       
    44 #include "TMCETestUIEngineCmdDeleteSession.h"
       
    45 #include "TMCETestUIEngineCmdFloorControlSession.h"
       
    46 #include "TMCETestUIEngineCmdWriteSdpToFile.h"
       
    47 #include "TMCETestUIEngineCmdCryptoHandling.h"
       
    48 #include "TMCETestUIEngineCmdCreateEvent.h"
       
    49 #include "TMCETestUIEngineCmdSRReqRes.h"
       
    50 #include "CMCETestUIEngineAudioStream.h"
       
    51 #include "CMCETestUIEngineVideoStream.h"
       
    52 
       
    53 
       
    54 // ============================ MEMBER FUNCTIONS ===============================
       
    55 
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CMCETestUIEngineSession::CMCETestUIEngineSession
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CMCETestUIEngineSession::CMCETestUIEngineSession( 
       
    62                 CMCETestUIEngine& aEngine,
       
    63                 TDirection aDirection,
       
    64                 TVideoDirection aVideoDirection )
       
    65     : iEngine( aEngine ),
       
    66       iDirection( aDirection ),
       
    67       iVideoDirection( aVideoDirection ),
       
    68       iHold( EFalse ),
       
    69       iHoldInProgress( EFalse )
       
    70     {
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CMCETestUIEngineSession::BaseConstructL()
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 void CMCETestUIEngineSession::BaseConstructL()
       
    78     {
       
    79     }
       
    80 
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CMCETestUIEngineSession::~CMCETestUIEngineSession
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 EXPORT_C CMCETestUIEngineSession::~CMCETestUIEngineSession()
       
    87     {
       
    88     iCommands.ResetAndDestroy();
       
    89     iAudioStreams.ResetAndDestroy();
       
    90     iVideoStreams.ResetAndDestroy();
       
    91     }
       
    92 /*
       
    93 // -----------------------------------------------------------------------------
       
    94 // CMCETestUIEngineSession::StatusCode
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 EXPORT_C TInt CMCETestUIEngineSession::StatusCode()
       
    98 	{
       
    99 	return iStatusCode;
       
   100 	}
       
   101 */	
       
   102 // -----------------------------------------------------------------------------
       
   103 // CMCETestUIEngineSession::GetCommands
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 const RPointerArray<TMCETestUIEngineCmdBase>& 
       
   107             CMCETestUIEngineSession::GetCommandsL()
       
   108     {
       
   109     User::LeaveIfError( iSession ? KErrNone : KErrNotReady );
       
   110 
       
   111     TInt state = iSession->State();
       
   112     
       
   113 
       
   114 	switch( state ) 
       
   115 		{
       
   116 		case CMceSession::EIdle: 
       
   117 		    {	
       
   118 		         
       
   119 		    break;
       
   120 		    }
       
   121 		    
       
   122 		case CMceSession::EAnswering: 
       
   123 		    {	
       
   124 		    iCommands.Append( new (ELeave) 
       
   125 		        TMCETestUIEngineCmdDeleteSession( iEngine, *this ) );	    
       
   126 			
       
   127 			iCommands.Append( new (ELeave) 
       
   128 		        TMCETestUIEngineCmdSendInfo( iEngine, *this ) );
       
   129 			iCommands.Append( new (ELeave) 
       
   130 		        TMCETestUIEngineCmdDTMFInfo( iEngine, *this ) );
       
   131 		    iCommands.Append( new ( ELeave )
       
   132 		    	TMCETestUIEngineCmdSendInfoResponse( iEngine, *this ) );		        
       
   133 		   
       
   134 		    break;
       
   135 		    }
       
   136 		    
       
   137 		case CMceSession::ETerminating: 
       
   138 		    {	
       
   139 		    iCommands.Append( new (ELeave) 
       
   140 		        TMCETestUIEngineCmdDeleteSession( iEngine, *this ) );	    
       
   141 		    break;
       
   142 		    }
       
   143 	    case CMceSession::EIncoming:
       
   144 	        {	            
       
   145 		    iCommands.Append( new (ELeave) 
       
   146 		        TMCETestUIEngineCmdUpdateSession( iEngine, *this ) );
       
   147 		    iCommands.Append( new (ELeave) 
       
   148 		        TMCETestUIEngineCmdUpdateSessionWithValues( iEngine, *this ) );
       
   149 
       
   150 			iCommands.Append( new (ELeave) 
       
   151 		        TMCETestUIEngineCmdSendInfo( iEngine, *this ) );
       
   152 			iCommands.Append( new (ELeave) 
       
   153 		        TMCETestUIEngineCmdDTMFInfo( iEngine, *this ) );
       
   154 		    iCommands.Append( new ( ELeave )
       
   155 		    	TMCETestUIEngineCmdSendInfoResponse( iEngine, *this ) );		        
       
   156 		    break;
       
   157 	        }
       
   158 		case CMceSession::EEstablished:
       
   159 		    {		         
       
   160 		    iCommands.Append( new (ELeave) 
       
   161 		        TMCETestUIEngineCmdUpdateSession( iEngine, *this ) );
       
   162 		    iCommands.Append( new (ELeave) 
       
   163 		        TMCETestUIEngineCmdUpdateSessionWithValues( iEngine, *this ) );
       
   164 		    iCommands.Append( new (ELeave) TMCETestUIEngineCmdFCSendSession( 
       
   165                                 iEngine, *this ) );
       
   166 		    iCommands.Append( new (ELeave) 
       
   167 		        TMCETestUIEngineCmdTerminateSession( iEngine, *this ) );
       
   168 		    iCommands.Append( new (ELeave) 
       
   169 		        TMCETestUIEngineCmdDeleteSession( iEngine, *this ) ); 
       
   170 		    iCommands.Append( new (ELeave) 
       
   171 		        TMCETestUIEngineCmdHoldCall( iEngine, *this ) );     
       
   172 		    iCommands.Append( new (ELeave) 
       
   173 		        TMCETestUIEngineCmdCreateReferSession( iEngine, *this ) );
       
   174 		    iCommands.Append( new (ELeave) 
       
   175 		        TMCETestUIEngineCmdWriteSdpToFile( iEngine, *this ) );
       
   176 		    
       
   177 			iCommands.Append( new (ELeave) 
       
   178 		        TMCETestUIEngineCmdSendInfo( iEngine, *this ) );
       
   179 			iCommands.Append( new (ELeave) 
       
   180 		        TMCETestUIEngineCmdDTMFInfo( iEngine, *this ) );
       
   181 		    iCommands.Append( new ( ELeave )
       
   182 		    	TMCETestUIEngineCmdSendInfoResponse( iEngine, *this ) );		        
       
   183 		    		    	        
       
   184 		    if(iSession->Type() == KMceSessionSecure) 
       
   185 		    	{
       
   186 		    	iCommands.Append( new (ELeave) 
       
   187 		        	TMCETestUIEngineCmdCurrentCryptoContext( iEngine, *this ) );
       
   188 		        iCommands.Append( new (ELeave) 
       
   189 		        	TMCETestUIEngineCmdSupportedCryptoContext( iEngine, *this ) );
       
   190 		        iCommands.Append( new (ELeave) 
       
   191 		        	TMCETestUIEngineCmdSetCryptoContext( iEngine, *this ) );
       
   192 		       	}
       
   193 		     
       
   194 		    break;
       
   195 		    }
       
   196 		case CMceSession::ETerminated: 
       
   197 		    {	
       
   198 		    iCommands.Append( new (ELeave) 
       
   199 		        TMCETestUIEngineCmdDeleteSession( iEngine, *this ) );
       
   200 		    if(iSession->Type() == KMceSessionSecure) 
       
   201 		    	{
       
   202 		    	iCommands.Append( new (ELeave) 
       
   203 		        	TMCETestUIEngineCmdCurrentCryptoContext( iEngine, *this ) );
       
   204 		        iCommands.Append( new (ELeave) 
       
   205 		        	TMCETestUIEngineCmdSupportedCryptoContext( iEngine, *this ) );
       
   206 		        break;
       
   207 		    	}
       
   208 		     	    
       
   209 		    break;
       
   210 		    }
       
   211 		default: 
       
   212 		    {    
       
   213 		    break;
       
   214 		    }
       
   215 		}  
       
   216 		  
       
   217     return iCommands; 
       
   218     }
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CMCETestUIEngineSession::State
       
   222 // -----------------------------------------------------------------------------
       
   223 //
       
   224 EXPORT_C const TDesC& CMCETestUIEngineSession::State() 
       
   225     {
       
   226     if ( !iSession ) 
       
   227         {
       
   228         User::Panic( _L16("CMCETestUIEngine"), 0 );
       
   229         }
       
   230         
       
   231     TInt state = iSession->State();
       
   232 
       
   233 	switch( state ) 
       
   234 		{
       
   235 		case CMceSession::EIdle: 
       
   236 		    return KSessionStateIdle; 
       
   237 		    break;
       
   238 		case CMceSession::EOffering: 
       
   239 		    return KSessionStateOffering; 
       
   240 		    break;
       
   241 		case CMceSession::EIncoming: 
       
   242 		    return KSessionStateIncoming; 
       
   243 		    break;
       
   244 		case CMceSession::EReserving: 
       
   245 		    return KSessionStateReserving; 
       
   246 		    break;
       
   247 		case CMceSession::EAnswering: 
       
   248 		    return KSessionStateAnswering; 
       
   249 		    break;
       
   250 		case CMceSession::EProceeding: 
       
   251 		    return KSessionStateProceeding; 
       
   252 		    break;
       
   253 		case CMceSession::EEstablished: 
       
   254 		    return KSessionStateEstablished; 
       
   255 		    break;
       
   256 		case CMceSession::ECancelling: 
       
   257 		    return KSessionStateCancelling; 
       
   258 		    break;
       
   259 		case CMceSession::ETerminating: 
       
   260 		    return KSessionStateTerminating; 
       
   261 		    break;
       
   262 		case CMceSession::ETerminated: 
       
   263 		    return KSessionStateTerminated; 
       
   264 		    break;
       
   265 		default: 
       
   266 		    return KSessionStateUnknown; 
       
   267 		    break;
       
   268 		}    
       
   269     }
       
   270 
       
   271 // -----------------------------------------------------------------------------
       
   272 // CMCETestUIEngineSession::Direction
       
   273 // -----------------------------------------------------------------------------
       
   274 //
       
   275 EXPORT_C TDirection CMCETestUIEngineSession::Direction() const
       
   276     {
       
   277     return iDirection;    
       
   278     }
       
   279 // -----------------------------------------------------------------------------
       
   280 // CMCETestUIEngineSession::VideoDirection
       
   281 // -----------------------------------------------------------------------------
       
   282 //
       
   283 EXPORT_C TVideoDirection CMCETestUIEngineSession::VideoDirection() const
       
   284     {
       
   285     return iVideoDirection;    
       
   286     }
       
   287 // -----------------------------------------------------------------------------
       
   288 // CMCETestUIEngineSession::TextualDirection
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 EXPORT_C const TDesC16& CMCETestUIEngineSession::TextualDirection() const
       
   292     {
       
   293     switch ( Direction() )
       
   294         {
       
   295         case ESendRecv :
       
   296             {
       
   297             return KSessionDirectionSendRecv;
       
   298             break;
       
   299             }
       
   300         case ERecvOnly :
       
   301             {
       
   302             return KSessionDirectionRecvOnly;
       
   303             break;
       
   304             }
       
   305         case ESendOnly :
       
   306             {
       
   307             return KSessionDirectionSendOnly;
       
   308             break;
       
   309             }                        
       
   310         default:
       
   311             {
       
   312             break;
       
   313             }
       
   314         }
       
   315         
       
   316     return KSessionDirectionNotSpesified;
       
   317     }
       
   318 
       
   319 // -----------------------------------------------------------------------------
       
   320 // CMCETestUIEngineSession::TextualVideoDirection
       
   321 // -----------------------------------------------------------------------------
       
   322 //
       
   323 EXPORT_C const TDesC16& CMCETestUIEngineSession::TextualVideoDirection() const
       
   324     {
       
   325     switch ( VideoDirection() )
       
   326         {
       
   327         case EVideoSendRecv :
       
   328             {
       
   329             return KSessionDirectionSendRecv;
       
   330             break;
       
   331             }
       
   332         case EVideoRecvOnly :
       
   333             {
       
   334             return KSessionDirectionRecvOnly;
       
   335             break;
       
   336             }
       
   337         case EVideoSendOnly :
       
   338             {
       
   339             return KSessionDirectionSendOnly;
       
   340             break;
       
   341             }                        
       
   342         default:
       
   343             {
       
   344             break;
       
   345             }
       
   346         }
       
   347         
       
   348     return KSessionDirectionNotSpesified;
       
   349     }
       
   350 // -----------------------------------------------------------------------------
       
   351 // CMCETestUIEngineSession::AudioStreamsL
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 EXPORT_C const RPointerArray<CMCETestUIEngineAudioStream>& 
       
   355                 CMCETestUIEngineSession::AudioStreamsL()
       
   356     {
       
   357     // Wrapped audiostreams are owned by session so we have to reconstruct 
       
   358     // audiostream wrappers to be sure that they are in valid state 
       
   359     iAudioStreams.ResetAndDestroy();
       
   360     
       
   361     const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
   362     
       
   363     for ( TInt i = 0; i < streams.Count(); ++i )
       
   364         {
       
   365         if ( streams[i]->Type() == KMceAudio )
       
   366             {
       
   367             CMceAudioStream* audioStream = 
       
   368                                     static_cast<CMceAudioStream*>(streams[i]);
       
   369             CMCETestUIEngineAudioStream* engineAudioStream =
       
   370                 CMCETestUIEngineAudioStream::NewL( iEngine, *audioStream );
       
   371             CleanupStack::PushL( engineAudioStream );
       
   372             iAudioStreams.Append( engineAudioStream );
       
   373             CleanupStack::Pop( engineAudioStream );
       
   374             //// code changed for MCE 2.0
       
   375             if(streams[i]->BoundStream())
       
   376             	{
       
   377             	if ( streams[i]->Type() == KMceAudio )
       
   378             		{
       
   379             		CMceAudioStream* boundStream = 
       
   380                                     static_cast<CMceAudioStream*>(&streams[i]->BoundStreamL());
       
   381 		            CMCETestUIEngineAudioStream* engineBoundStream =
       
   382 		                CMCETestUIEngineAudioStream::NewL( iEngine, *boundStream );
       
   383 		            CleanupStack::PushL( engineBoundStream );
       
   384 		            iAudioStreams.Append( engineBoundStream );
       
   385 		            CleanupStack::Pop( engineBoundStream );
       
   386             		}
       
   387             	}
       
   388             //// code changed for MCE 2.0	
       
   389           /*  if ( audioStream->BoundStream() )
       
   390                 {
       
   391                 CMCEOneWayStream& oneWayStream = audioStream->BoundStreamL();
       
   392                 if ( oneWayStream.Type() == KMCEAudio )
       
   393                     {
       
   394                     CMCEAudioStream& boundStream =
       
   395                             static_cast<CMCEAudioStream&>(oneWayStream); 
       
   396                     CMCETestUIEngineAudioStream* engineBoundStream =
       
   397                             CMCETestUIEngineAudioStream::NewL( iEngine, 
       
   398                                                                boundStream );
       
   399                     CleanupStack::PushL( engineBoundStream );
       
   400                     iAudioStreams.Append( engineBoundStream );
       
   401                     CleanupStack::Pop( engineBoundStream );        
       
   402                     }
       
   403                 }
       
   404             */}
       
   405         }
       
   406     
       
   407     return iAudioStreams;
       
   408     }                
       
   409  
       
   410  // -----------------------------------------------------------------------------
       
   411 // CMCETestUIEngineSession::VideoStreamsL
       
   412 // -----------------------------------------------------------------------------
       
   413 //
       
   414 EXPORT_C const RPointerArray<CMCETestUIEngineVideoStream>& 
       
   415                 CMCETestUIEngineSession::VideoStreamsL()
       
   416     {
       
   417     // Wrapped audiostreams are owned by session so we have to reconstruct 
       
   418     // audiostream wrappers to be sure that they are in valid state 
       
   419     iVideoStreams.ResetAndDestroy();
       
   420     
       
   421     const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
   422     
       
   423     for ( TInt i = 0; i < streams.Count(); ++i )
       
   424         {
       
   425         if ( streams[i]->Type() == KMceVideo )
       
   426             {
       
   427             CMceVideoStream* videoStream = 
       
   428                                     static_cast<CMceVideoStream*>(streams[i]);
       
   429             CMCETestUIEngineVideoStream* engineVideoStream =
       
   430                 CMCETestUIEngineVideoStream::NewL( iEngine, *videoStream );
       
   431             CleanupStack::PushL( engineVideoStream );
       
   432             iVideoStreams.Append( engineVideoStream );
       
   433             CleanupStack::Pop( engineVideoStream );
       
   434             //// code changed for MCE 2.0
       
   435             if(streams[i]->BoundStream())
       
   436             	{
       
   437             	if ( streams[i]->Type() == KMceVideo )
       
   438             		{
       
   439             		CMceVideoStream* boundStream = 
       
   440                                     static_cast<CMceVideoStream*>(&streams[i]->BoundStreamL());
       
   441 		            CMCETestUIEngineVideoStream* engineBoundStream =
       
   442 		                CMCETestUIEngineVideoStream::NewL( iEngine, *boundStream );
       
   443 		            CleanupStack::PushL( engineBoundStream );
       
   444 		            iVideoStreams.Append( engineBoundStream );
       
   445 		            CleanupStack::Pop( engineBoundStream );
       
   446             		}
       
   447             	}
       
   448             //// code changed for MCE 2.0	
       
   449           /*  if ( audioStream->BoundStream() )
       
   450                 {
       
   451                 CMCEOneWayStream& oneWayStream = audioStream->BoundStreamL();
       
   452                 if ( oneWayStream.Type() == KMCEAudio )
       
   453                     {
       
   454                     CMCEAudioStream& boundStream =
       
   455                             static_cast<CMCEAudioStream&>(oneWayStream); 
       
   456                     CMCETestUIEngineAudioStream* engineBoundStream =
       
   457                             CMCETestUIEngineAudioStream::NewL( iEngine, 
       
   458                                                                boundStream );
       
   459                     CleanupStack::PushL( engineBoundStream );
       
   460                     iAudioStreams.Append( engineBoundStream );
       
   461                     CleanupStack::Pop( engineBoundStream );        
       
   462                     }
       
   463                 }
       
   464             */}
       
   465         }
       
   466     
       
   467     return iVideoStreams;
       
   468     }                
       
   469                         
       
   470                       
       
   471 // -----------------------------------------------------------------------------
       
   472 // CMCETestUIEngineSession::Session
       
   473 // -----------------------------------------------------------------------------
       
   474 //
       
   475 CMceSession& CMCETestUIEngineSession::Session()
       
   476     {
       
   477     return *iSession;
       
   478     }
       
   479 
       
   480 // -----------------------------------------------------------------------------
       
   481 // CMCETestUIEngineSession::ProfileId()
       
   482 // -----------------------------------------------------------------------------
       
   483 //
       
   484 EXPORT_C TUint32 CMCETestUIEngineSession::ProfileId()
       
   485     {
       
   486     return iSession->Profile();
       
   487     }
       
   488 // -----------------------------------------------------------------------------
       
   489 // CMCETestUIEngineSession::SolveDirection
       
   490 // -----------------------------------------------------------------------------
       
   491 //
       
   492 TDirection CMCETestUIEngineSession::SolveDirection()
       
   493     {
       
   494     
       
   495     /////////////////////
       
   496     //
       
   497     // TODO: This function should be refactored to use stream wrappers. 
       
   498     //       That will also simplify the function quite much.
       
   499     //
       
   500     //////////////////////
       
   501     
       
   502     TBool hasUpLink = EFalse;
       
   503     TBool hasDownLink = EFalse;
       
   504     
       
   505     const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
   506 
       
   507     for ( TInt i = 0; i < streams.Count(); ++i )
       
   508         {        
       
   509         if ( streams[i]->Type() == KMceAudio )
       
   510             {
       
   511             CMceAudioStream* audioStream = 
       
   512                                     static_cast<CMceAudioStream*>(streams[i]);
       
   513             if ( audioStream->Source() )
       
   514                 {
       
   515                 if ( audioStream->Source()->Type() == KMceRTPSource )
       
   516                     {
       
   517                     hasDownLink = ETrue;
       
   518                     }
       
   519                 }
       
   520             const RPointerArray<CMceMediaSink>& sinks = audioStream->Sinks();
       
   521             for ( TInt j = 0; j < sinks.Count(); ++j )
       
   522                 {
       
   523                 if ( sinks[j]->Type() == KMceRTPSink )
       
   524                     {
       
   525                     hasUpLink = ETrue;
       
   526                     }
       
   527                 }
       
   528               //// code changed for MCE 2.0  
       
   529               if(audioStream->BoundStream())
       
   530               	{
       
   531               	CMceMediaStream& boundStream = audioStream->BoundStreamL();
       
   532               	 if ( boundStream.Source() )
       
   533                     {
       
   534                     if ( boundStream.Source()->Type() == KMceRTPSource )
       
   535                         {
       
   536                         hasDownLink = ETrue;
       
   537                         }
       
   538                     }
       
   539                   const RPointerArray<CMceMediaSink>& boundStreamSinks = 
       
   540                                                         boundStream.Sinks();
       
   541                   for ( TInt x = 0; x < boundStreamSinks.Count(); ++x )
       
   542                     {
       
   543                     if ( boundStreamSinks[x]->Type() == KMceRTPSink )
       
   544                         {
       
   545                         hasUpLink = ETrue;
       
   546                         }
       
   547                     }
       
   548                                                         
       
   549               	}
       
   550               //// code changed for MCE 2.0	
       
   551     /*        if ( audioStream->BoundStream() )
       
   552                 {
       
   553                 CMCEOneWayStream& boundStream = audioStream->BoundStreamL();
       
   554                 if ( boundStream.Source() )
       
   555                     {
       
   556                     if ( boundStream.Source()->Type() == KMCERTPSource )
       
   557                         {
       
   558                         hasDownLink = ETrue;
       
   559                         }
       
   560                     }
       
   561                 const RPointerArray<CMCEMediaSink>& boundStreamSinks = 
       
   562                                                         boundStream.Sinks();
       
   563                                                         
       
   564                 for ( TInt x = 0; x < boundStreamSinks.Count(); ++x )
       
   565                     {
       
   566                     if ( boundStreamSinks[x]->Type() == KMCERTPSink )
       
   567                         {
       
   568                         hasUpLink = ETrue;
       
   569                         }
       
   570                     }
       
   571                 }*/
       
   572             }
       
   573         }  
       
   574         
       
   575     if ( hasUpLink && hasDownLink )
       
   576         {
       
   577         iDirection = ESendRecv;
       
   578         }
       
   579     else if ( hasUpLink )
       
   580         {
       
   581         iDirection = ESendOnly;
       
   582         }
       
   583     else if ( hasDownLink )
       
   584         {
       
   585         iDirection = ERecvOnly;
       
   586         }  
       
   587     else
       
   588         {
       
   589         iDirection = ENotSpesified;
       
   590         }
       
   591         
       
   592     return iDirection;   
       
   593     }
       
   594 
       
   595 // -----------------------------------------------------------------------------
       
   596 // CMCETestUIEngineSession::CurrentAudioStreams
       
   597 // -----------------------------------------------------------------------------
       
   598 
       
   599 EXPORT_C RPointerArray<CMCETestUIEngineAudioStream>&
       
   600 		CMCETestUIEngineSession::CurrentAudioStreams()
       
   601 	{
       
   602 	return iAudioStreams;	
       
   603 	}
       
   604 	
       
   605 
       
   606 // -----------------------------------------------------------------------------
       
   607 // CMCETestUIEngineSession::CurrentVideoStreams
       
   608 // -----------------------------------------------------------------------------
       
   609 
       
   610 EXPORT_C RPointerArray<CMCETestUIEngineVideoStream>&
       
   611 		CMCETestUIEngineSession::CurrentVideoStreams()
       
   612 	{
       
   613 	return iVideoStreams;	
       
   614 	}
       
   615 	
       
   616 // -----------------------------------------------------------------------------
       
   617 // CMCETestUIEngineSession::SolveVideoDirection
       
   618 // -----------------------------------------------------------------------------
       
   619 //
       
   620 TVideoDirection CMCETestUIEngineSession::SolveVideoDirection()
       
   621     {
       
   622     
       
   623     /////////////////////
       
   624     //
       
   625     // TODO: This function should be refactored to use stream wrappers. 
       
   626     //       That will also simplify the function quite much.
       
   627     //
       
   628     //////////////////////
       
   629     
       
   630     TBool hasUpLink = EFalse;
       
   631     TBool hasDownLink = EFalse;
       
   632     
       
   633     const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
   634 
       
   635     for ( TInt i = 0; i < streams.Count(); ++i )
       
   636         {        
       
   637         if ( streams[i]->Type() == KMceVideo )
       
   638             {
       
   639             CMceVideoStream* videoStream = 
       
   640                                     static_cast<CMceVideoStream*>(streams[i]);
       
   641             if ( videoStream->Source() )
       
   642                 {
       
   643                 if ( videoStream->Source()->Type() == KMceRTPSource )
       
   644                     {
       
   645                     hasDownLink = ETrue;
       
   646                     }
       
   647                 }
       
   648             const RPointerArray<CMceMediaSink>& sinks = videoStream->Sinks();
       
   649             for ( TInt j = 0; j < sinks.Count(); ++j )
       
   650                 {
       
   651                 if ( sinks[j]->Type() == KMceRTPSink )
       
   652                     {
       
   653                     hasUpLink = ETrue;
       
   654                     }
       
   655                 }
       
   656               //// code changed for MCE 2.0  
       
   657               if(videoStream->BoundStream())
       
   658               	{
       
   659               	CMceMediaStream& boundStream = videoStream->BoundStreamL();
       
   660               	 if ( boundStream.Source() )
       
   661                     {
       
   662                     if ( boundStream.Source()->Type() == KMceRTPSource )
       
   663                         {
       
   664                         hasDownLink = ETrue;
       
   665                         }
       
   666                     }
       
   667                   const RPointerArray<CMceMediaSink>& boundStreamSinks = 
       
   668                                                         boundStream.Sinks();
       
   669                   for ( TInt x = 0; x < boundStreamSinks.Count(); ++x )
       
   670                     {
       
   671                     if ( boundStreamSinks[x]->Type() == KMceRTPSink )
       
   672                         {
       
   673                         hasUpLink = ETrue;
       
   674                         }
       
   675                     }
       
   676                                                         
       
   677               	}
       
   678               //// code changed for MCE 2.0	
       
   679     /*        if ( audioStream->BoundStream() )
       
   680                 {
       
   681                 CMCEOneWayStream& boundStream = audioStream->BoundStreamL();
       
   682                 if ( boundStream.Source() )
       
   683                     {
       
   684                     if ( boundStream.Source()->Type() == KMCERTPSource )
       
   685                         {
       
   686                         hasDownLink = ETrue;
       
   687                         }
       
   688                     }
       
   689                 const RPointerArray<CMCEMediaSink>& boundStreamSinks = 
       
   690                                                         boundStream.Sinks();
       
   691                                                         
       
   692                 for ( TInt x = 0; x < boundStreamSinks.Count(); ++x )
       
   693                     {
       
   694                     if ( boundStreamSinks[x]->Type() == KMCERTPSink )
       
   695                         {
       
   696                         hasUpLink = ETrue;
       
   697                         }
       
   698                     }
       
   699                 }*/
       
   700            }
       
   701         }  
       
   702         
       
   703     if ( hasUpLink && hasDownLink )
       
   704         {
       
   705         iVideoDirection = EVideoSendRecv;
       
   706         }
       
   707     else if ( hasUpLink )
       
   708         {
       
   709         iVideoDirection = EVideoSendOnly;
       
   710         }
       
   711     else if ( hasDownLink )
       
   712         {
       
   713         iVideoDirection = EVideoRecvOnly;
       
   714         }  
       
   715     else
       
   716         {
       
   717         iVideoDirection = EVideoNotSpesified;
       
   718         }
       
   719         
       
   720     return iVideoDirection;   
       
   721     }
       
   722     
       
   723  // ---------------------------------------------------------------------------
       
   724 // CSVPHoldMediaHandler::EnableAudioL
       
   725 // ---------------------------------------------------------------------------
       
   726 //
       
   727  void CMCETestUIEngineSession::EnableAudioL( )
       
   728     {
       
   729     const RPointerArray< CMceMediaStream >& streams = iSession->Streams();
       
   730     TInt streamCount = streams.Count();
       
   731     for ( TInt i = 0; i < streamCount; i++ )
       
   732         {
       
   733         CMceMediaStream* mediaStream = streams[ i ];
       
   734         TMceMediaType mediaType = mediaStream->Type();
       
   735         if ( KMceAudio == mediaType )
       
   736             {
       
   737             // Now enable the audio streams.
       
   738             EnableAudioStreamL( mediaStream->BoundStreamL() );
       
   739             EnableAudioStreamL( *mediaStream );
       
   740             }
       
   741         }
       
   742     }
       
   743 
       
   744 // ---------------------------------------------------------------------------
       
   745 // CSVPHoldMediaHandler::EnableAudioStreamL
       
   746 // ---------------------------------------------------------------------------
       
   747 //
       
   748  void CMCETestUIEngineSession::EnableAudioStreamL( CMceMediaStream& aAudioStream )
       
   749     {
       
   750     
       
   751     if ( aAudioStream.Source() &&
       
   752          ( KMceMicSource == aAudioStream.Source()->Type() ||
       
   753            KMceRTPSource == aAudioStream.Source()->Type() ) )
       
   754         {
       
   755         CMceMediaSource* source = aAudioStream.Source();
       
   756         if ( !source->IsEnabled() )
       
   757             {
       
   758             // Enable source
       
   759             source->EnableL();
       
   760             }
       
   761         }
       
   762         
       
   763     if ( aAudioStream.Sinks().Count()  )
       
   764         {
       
   765         const RPointerArray< CMceMediaSink >& sinks =
       
   766              aAudioStream.Sinks();
       
   767         for ( TInt z = 0; z < sinks.Count(); z++ )
       
   768             {
       
   769             if ( KMceSpeakerSink == sinks[ z ]->Type() )
       
   770                 {
       
   771                 CMceSpeakerSink* speakerSink = 
       
   772                     ( CMceSpeakerSink* )  sinks[ z ];
       
   773                 if ( !speakerSink->IsEnabled() )
       
   774                     {
       
   775                     // unmute speaker sink
       
   776                     speakerSink->EnableL();
       
   777                     }
       
   778                 }
       
   779             } 
       
   780         }                                        
       
   781 
       
   782     }	
       
   783 
       
   784 // ---------------------------------------------------------------------------
       
   785 // CMCETestUIEngineSession::AdjustVideoCodecsL
       
   786 // ---------------------------------------------------------------------------
       
   787 //    
       
   788 void CMCETestUIEngineSession::AdjustVideoCodecsL( 
       
   789     const RPointerArray<CMceVideoCodec>& aCodecs )
       
   790     {
       
   791     for ( TInt i = 0; i < aCodecs.Count(); i++ )
       
   792         {
       
   793         if ( aCodecs[ i ]->SdpName().Compare( KMceSDPNameH264 ) == 0 )
       
   794             {
       
   795             TUid encDecUid;
       
   796             encDecUid.iUid = KMceTestUiAvcEncoderUid;
       
   797             // Trapped as method is not supported at the moment
       
   798             TRAP_IGNORE( aCodecs[ i ]->SetPreferredEncodingDecodingDeviceL( encDecUid ) )
       
   799             }
       
   800         }
       
   801     }
       
   802 
       
   803 // ---------------------------------------------------------------------------
       
   804 // CMCETestUIEngineSession::AdjustVideoCodecsL
       
   805 // ---------------------------------------------------------------------------
       
   806 // 
       
   807 CMceMediaStream* CMCETestUIEngineSession::FindStreamForSourceL(
       
   808     CMceMediaStream& aStream, 
       
   809     TMceSourceType aSourceType )
       
   810     {
       
   811     CMceMediaStream* streamForSource = NULL;
       
   812     
       
   813     CMceMediaSource* source = aStream.Source();
       
   814     if ( source && source->Type() == aSourceType )
       
   815 	    {
       
   816 	    streamForSource = &aStream;
       
   817 	    }
       
   818 	else
       
   819 	    {
       
   820 	    CMceMediaSource* boundStreamSource = 
       
   821 	        aStream.BoundStream() ? aStream.BoundStreamL().Source() : NULL;
       
   822     	if ( boundStreamSource && boundStreamSource->Type() == aSourceType )
       
   823     	    {
       
   824     	    streamForSource = &aStream.BoundStreamL();
       
   825     	    }
       
   826 	    }
       
   827 	return streamForSource;
       
   828     }
       
   829     
       
   830 // End of file
       
   831