vtuis/lcvtplugin/src/base/clcvtsession.cpp
branchRCL_3
changeset 35 779871d1e4f4
parent 34 f15ac8e65a02
child 37 590f6f022902
equal deleted inserted replaced
34:f15ac8e65a02 35:779871d1e4f4
     1 /*
       
     2 * Copyright (c) 2008 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:  LiveComm Videotelephony Plugin session Class
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32base.h>
       
    19 #include <e32std.h>
       
    20 #include <e32cmn.h>
       
    21 #include <featmgr.h>
       
    22  
       
    23 #include <w32std.h>
       
    24 #include <coecntrl.h>
       
    25 #include <eikenv.h>
       
    26 #include <eikappui.h>
       
    27 #include <apgcli.h>
       
    28 #include <centralrepository.h> 
       
    29 
       
    30 #include "clcvtsession.h"
       
    31 
       
    32 #include "cvtengmodel.h"
       
    33 
       
    34 #include "clcvtvideoplayerbase.h"
       
    35 #include "clcvtlocalvideoplayer.h"
       
    36 #include "clcvtremotevideoplayer.h"
       
    37 #include "tlcvtstates.h"
       
    38 #include "clcvtcmdexecutor.h"
       
    39 #include "mlcvtenginecommandmanager.h"
       
    40 #include "lcvtplugincommand.h"
       
    41 #include "lcvtutility.h"
       
    42 
       
    43 // User selectable Call answer status values
       
    44 const TInt KAllwaysQuery = 0;
       
    45 const TInt KAllwaysAllow = 2;
       
    46 
       
    47 // Default call index.
       
    48 const TInt KVtUiDefaultCallId = 1;
       
    49 
       
    50 // Granularity of command observer array.
       
    51 const TInt KLcVtCommandObserverArrayGranularity = 5;
       
    52 
       
    53 
       
    54 
       
    55 // Enumerates states for CLcVtActiveExec.
       
    56 enum
       
    57     {    
       
    58     // Operation finished. Must equal to zero.
       
    59     EVtSessionNone,
       
    60     
       
    61     // Active execution states for iActiveExec:
       
    62     
       
    63     //     Startup (prepare engine):
       
    64     EVtSessionStartup = 100,                                    // 100
       
    65     //     Initialise engine.
       
    66     EVtSessionStartupInitEngine = EVtSessionStartup,            // 100
       
    67     //     Prepare viewfinder.
       
    68     EVtSessionStartupPrepareViewfinder,                         // 101
       
    69     //     Prepare remote render.
       
    70     EVtSessionStartupPrepareRemoteRender,                       // 102
       
    71     //     Startup Finish 
       
    72     EVtSessionStartupFinish,                                    // 103
       
    73     
       
    74     //     Shutdown (reset engine):
       
    75     EVtSessionShutdown = 300,                                   // 300
       
    76     //     Hide application.
       
    77     EVtSessionShutdownHideApplication = EVtSessionShutdown,     // 300
       
    78     //     Reset engine.
       
    79     EVtSessionShutdownResetEngine,                              // 301
       
    80     
       
    81         
       
    82     //     Answered:
       
    83     EVtSessionAnswered = 500,                                   // 500    
       
    84     //     Start remote render.
       
    85     EVtSessionAnsweredStartRemoteRender = EVtSessionAnswered,   // 500    
       
    86     //     Prepare Camere
       
    87     EVtSessionAnsweredDoPrepareCamera,                          // 501
       
    88     //     Select camera as source.
       
    89     EVtSessionAnsweredSetlectCamera,                            // 502
       
    90     //     Select blank image as source.
       
    91     EVtSessionAnsweredSetlectNone,
       
    92     //     Start view finder
       
    93     EVtSessionAnsweredStartViewFinder,                          // 504
       
    94     //     Show Application 
       
    95     EVtSessionAnsweredBringToForeground,                        // 505
       
    96     
       
    97     //EVtSessionAnswered = 500,                                   // 500
       
    98     //EVtSessionAnsweredBringToForeground = EVtSessionAnswered,                        // 505
       
    99     
       
   100     //     Finish.
       
   101     EVtSessionAnsweredFinish                                    // 506    
       
   102     };
       
   103 
       
   104 
       
   105 /**
       
   106  * Encapsulates event handling.
       
   107  * @since Series 60 2.6
       
   108  */    
       
   109 class CLcVtSession::CEventObserver
       
   110     : public CBase,
       
   111       public MLcVtEngineCommandManager,
       
   112       public MVtEngEventObserver,
       
   113 #ifndef NGA_VIDEO_RENDER
       
   114       public MVtEngFrameObserver,
       
   115 #endif
       
   116       public MVtEngCommandObserver
       
   117     {    
       
   118     public: // Constructors and destructors
       
   119      
       
   120         /**
       
   121         * Two-phased constructor.
       
   122         * @param aSession plugin session.
       
   123         */        
       
   124         static CEventObserver* NewL(CLcVtSession& aSession);
       
   125         
       
   126         /**
       
   127         * Destructor.
       
   128         */        
       
   129         ~CEventObserver();
       
   130 
       
   131     public: // Functions from base classes
       
   132 
       
   133         /**
       
   134         * @see MLcVtEngineCommandManager::AddObserverL.
       
   135         */
       
   136         void AddObserverL( MVtEngCommandObserver& aObserver );
       
   137 
       
   138         /**
       
   139         * @see MLcVtEngineCommandManager::RemoveObserver.
       
   140         */
       
   141         void RemoveObserver( MVtEngCommandObserver& aObserver );
       
   142         
       
   143         /**
       
   144         * @see MVtEngEventObserver::HandleVtEventL.
       
   145         */        
       
   146         void HandleVtEventL( TInt aEvent );
       
   147         
       
   148         /**
       
   149         * @see MVtEngCommandObserver::HandleVTCommandPerformedL.
       
   150         */        
       
   151         void HandleVTCommandPerformedL(
       
   152                 TVtEngCommandId aCommand,
       
   153                 const TInt aError );
       
   154 #ifndef NGA_VIDEO_RENDER        
       
   155         /**
       
   156         * @see MVtEngFrameObserver::vtHandleFrameL.
       
   157         */        
       
   158         void vtHandleFrameL( TFrameType aType, CFbsBitmap* aBitmap );
       
   159         
       
   160         /**
       
   161         * @see MVtEngFrameObserver::vtSetFrame
       
   162         */        
       
   163         void vtSetFrame( TFrameType aType, CFbsBitmap* aBitmap );                 
       
   164 #endif                                       
       
   165     private:
       
   166         
       
   167         /**
       
   168         * Constructor.
       
   169         * @param aSession plugin session.
       
   170         */
       
   171         CEventObserver(CLcVtSession& aSession );
       
   172         
       
   173         /**
       
   174         * Symbian OS constructor.
       
   175         */        
       
   176         void ConstructL();        
       
   177           
       
   178     private:        
       
   179         
       
   180         // Ref to plugin session.
       
   181         CLcVtSession& iSession;    
       
   182         
       
   183         // ETrue when command events are being sent.
       
   184         TBool iInCommandPerformed;
       
   185 
       
   186         // Owned array of observers.
       
   187         RPointerArray< MVtEngCommandObserver > iCommandObservers;
       
   188         
       
   189     };
       
   190 
       
   191          
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 // -----------------------------------------------------------------------------
       
   195 //
       
   196 CLcVtSession* CLcVtSession::NewL()
       
   197     {
       
   198     CLcVtSession* self = new ( ELeave ) CLcVtSession();
       
   199     CleanupStack::PushL( self );
       
   200     self->ConstructL();
       
   201     CleanupStack::Pop( self );
       
   202     return self;
       
   203     }     
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 CLcVtSession::CLcVtSession( ) 
       
   210     {
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 void CLcVtSession::ConstructL()
       
   218     {
       
   219     
       
   220     __VTPRINTENTER( "CLcVtSession.ConstructL" )  
       
   221       
       
   222     __VTPRINT( DEBUG_MEDIA , "FeatureManager::InitializeLibL()" )
       
   223     FeatureManager::InitializeLibL(); 
       
   224         
       
   225     __VTPRINT( DEBUG_MEDIA , "iCameraHandler.SetSession(this)" )
       
   226     iCameraHandler.SetSession(this);
       
   227     __VTPRINT( DEBUG_MEDIA , "iRemoteVideoPlayer = CLcVtRemoteVideoPlayer_NewL" )
       
   228     iRemoteVideoPlayer = CLcVtRemoteVideoPlayer::NewL(this, *this);
       
   229     __VTPRINT( DEBUG_MEDIA , "iLocalVideoPlayer  = CLcVtLocalVideoPlayer_NewL" )
       
   230     iLocalVideoPlayer  = CLcVtLocalVideoPlayer::NewL(this, *this, iCameraHandler);  
       
   231 
       
   232 #ifndef NGA_VIDEO_RENDER 
       
   233     iFbsStarted = EFalse;   
       
   234             
       
   235     __VTPRINT( DEBUG_MEDIA , "iWsSession = &(CCoeEnv::Static()->WsSession())" )
       
   236     iWsSession = &(CCoeEnv::Static()->WsSession());
       
   237     __VTPRINT( DEBUG_MEDIA , "iWsSessionScreenDev = CCoeEnv::Static()->ScreenDevice()" )
       
   238     iWsSessionScreenDev = CCoeEnv::Static()->ScreenDevice();
       
   239     __VTPRINT( DEBUG_MEDIA , "iRootWin = &(CCoeEnv::Static()->RootWin())" )
       
   240     iRootWin = &(CCoeEnv::Static()->RootWin());
       
   241     
       
   242     __VTPRINT( DEBUG_MEDIA , "ConnectFbsServerL()" )
       
   243     ConnectFbsServerL();    
       
   244 #endif
       
   245     __VTPRINT( DEBUG_MEDIA , "iEventObserver = CEventObserver_NewL" )
       
   246     iEventObserver = CEventObserver::NewL( *this );
       
   247 
       
   248     iModel = CVtEngModel::NewL( *iEventObserver, *iEventObserver );
       
   249 
       
   250     __VTPRINT( DEBUG_MEDIA , "iLcVtStates_new" )
       
   251     iLcVtStates = new ( ELeave ) TLcVtStates( *iModel );
       
   252     __VTPRINT( DEBUG_MEDIA , "iLcVtStates->Update()" )
       
   253     iLcVtStates->Update();    
       
   254     
       
   255     __VTPRINT( DEBUG_MEDIA , "new_iActiveExec" )
       
   256     iActiveExec =
       
   257         new ( ELeave ) CLcVtActiveExec( CActive::EPriorityHigh );  
       
   258         
       
   259     __VTPRINT( DEBUG_MEDIA , "SetCallIdL( KVtUiDefaultCallId )" )
       
   260     SetCallIdL( KVtUiDefaultCallId );
       
   261     
       
   262     __VTPRINT( DEBUG_MEDIA , "iAsyncCallback" )
       
   263     iAsyncCallback =
       
   264         new ( ELeave ) CAsyncCallBack (
       
   265             TCallBack( &DoExit, this ),
       
   266             CActive::EPriorityStandard );   
       
   267 #if 0    
       
   268     __VTPRINT( DEBUG_MEDIA , "iLayoutChangeCallback" )
       
   269     iLayoutChangeCallback =
       
   270         new ( ELeave ) CAsyncCallBack(
       
   271             TCallBack( &DelayedHandleLayoutChanged, this ),
       
   272             CActive::EPriorityStandard );   
       
   273 #endif    
       
   274     CRepository* repository = CRepository::NewL( KCRUidTelephonySettings );
       
   275 
       
   276     if ( repository->Get( KSettingsVTVideoSending, VideoSendingKey ) == KErrNone )
       
   277         {
       
   278         __VTPRINT2( DEBUG_GEN, "CLcVtSession.IsFeatureSupported get key=%d", VideoSendingKey )
       
   279         }
       
   280     else
       
   281         {
       
   282         __VTPRINT( DEBUG_GEN, "CLcVtSession.IsFeatureSupported set key to default KAllwaysAllow" )
       
   283         VideoSendingKey = KAllwaysAllow;
       
   284         }
       
   285     delete repository;
       
   286     
       
   287     iIndicatorCtr = new  ( ELeave ) LcVtIndicatorController();
       
   288     __VTPRINTEXIT( "CLcVtSession.ConstructL" )
       
   289     
       
   290     }
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 // -----------------------------------------------------------------------------
       
   295 //
       
   296 CLcVtSession::~CLcVtSession()
       
   297     {
       
   298     __VTPRINTENTER( "CLcVtSession.~CLcVtSession" )  
       
   299 
       
   300     //delete iLayoutChangeCallback;
       
   301     delete iAsyncCallback;
       
   302 
       
   303 #ifndef NGA_VIDEO_RENDER    
       
   304     DisconnectFbsServer();
       
   305 #endif
       
   306     delete iActiveExec;
       
   307     delete iLcVtStates;
       
   308 
       
   309     delete iModel;
       
   310     
       
   311     delete iEventObserver;
       
   312     iEventObserver = NULL;
       
   313     
       
   314 #ifdef NGA_VIDEO_RENDER
       
   315     DestroyVideoWindows();
       
   316 #endif
       
   317 
       
   318     delete iLocalVideoPlayer;
       
   319     delete iRemoteVideoPlayer;
       
   320     
       
   321     delete iRemoteDisplayName;
       
   322     delete iRemoteDetails;
       
   323     if (iIndicatorCtr) {
       
   324         iIndicatorCtr->disableActiveCallIndicator();
       
   325         delete iIndicatorCtr;
       
   326     }    
       
   327     __VTPRINTEXIT( "CLcVtSession.~CLcVtSession" )
       
   328     FeatureManager::UnInitializeLib();  
       
   329     }
       
   330 
       
   331 #ifndef NGA_VIDEO_RENDER
       
   332 void CLcVtSession::ConnectFbsServerL()
       
   333     {
       
   334     // VT use bitmaps viewfinder now, So we start FBS server for proto demo  
       
   335     // and later we will use Qt image object to implement bitmaps view finder or we will use direct view finder    
       
   336     TInt err( KErrNone );
       
   337     // Start Font&Bitmap server    
       
   338     err = FbsStartup();
       
   339     if ( err == KErrNone )
       
   340         {
       
   341        err = RFbsSession::Connect();
       
   342        if( err == KErrNone )
       
   343            {
       
   344            iFbsStarted = ETrue;
       
   345            }            
       
   346         }
       
   347     
       
   348     iDummy = new ( ELeave ) CFbsBitmap();  
       
   349     //CleanupStack::PushL( iDummy );
       
   350     User::LeaveIfError( iDummy->Create( TSize( 4096, 1 ), EColor64K ) );      
       
   351     
       
   352     iGc = new (ELeave) CWindowGc( iWsSessionScreenDev );
       
   353     //CleanupStack::PushL( iGc );
       
   354     User::LeaveIfError( iGc->Construct());
       
   355     
       
   356     //CleanupStack::Pop(2);
       
   357     }
       
   358 
       
   359 
       
   360 void CLcVtSession::DisconnectFbsServer()
       
   361     {
       
   362     delete iGc;
       
   363     delete iDummy;    
       
   364     if ( iFbsStarted )
       
   365         {
       
   366         RFbsSession::Disconnect();
       
   367         iFbsStarted = EFalse;        
       
   368         }    
       
   369     }
       
   370 #endif
       
   371 #ifdef NGA_VIDEO_RENDER
       
   372 
       
   373 _LIT(KVTWindowGroupName,"32VTPluginVideoWindow");
       
   374 
       
   375 void CLcVtSession::CreateVideoWindowsL()
       
   376     {
       
   377     __VTPRINTENTER( "CLcVtSession.CreateVideoWindowsL" ) 
       
   378     User::LeaveIfError( iRwSession.Connect() );  
       
   379 
       
   380     iRwGroup = new (ELeave) RWindowGroup( iRwSession ) ;        
       
   381     iRwGroup->Construct( (TUint32)iRwGroup, EFalse );
       
   382     
       
   383     iRwGroup->SetName( KVTWindowGroupName );
       
   384     iRwGroup->SetOrdinalPosition( 1 , ECoeWinPriorityNeverAtFront );
       
   385     iRwGroup->AutoForeground(EFalse);
       
   386     
       
   387     iDev = new (ELeave) CWsScreenDevice( iRwSession );
       
   388     iDev->Construct( ); 
       
   389     
       
   390     iRemoteVideoWindow = new (ELeave) RWindow( iRwSession );
       
   391     iRemoteVideoWindow->Construct( *iRwGroup, (TUint32)iRemoteVideoWindow );
       
   392     
       
   393     TRect RMRect = RemoteVideoPlayer()->LcWindow()->LcWindowRect();
       
   394     iRemoteVideoWindow->SetExtent( RMRect.iTl, RMRect.Size() );
       
   395     iRemoteVideoWindow->SetOrdinalPosition( 1, ECoeWinPriorityNeverAtFront );
       
   396     iRemoteVideoWindow->Activate();
       
   397     
       
   398     iLocalVideoWindow = new (ELeave) RWindow( iRwSession );
       
   399     iLocalVideoWindow->Construct( *iRwGroup, (TUint32)iLocalVideoWindow );
       
   400     
       
   401     TRect VFRect = LocalVideoPlayer()->LcWindow()->LcWindowRect();
       
   402     iLocalVideoWindow->SetExtent( VFRect.iTl, VFRect.Size() );
       
   403     iLocalVideoWindow->SetOrdinalPosition( 1, ECoeWinPriorityNeverAtFront );
       
   404     iLocalVideoWindow->Activate();   
       
   405         
       
   406     iRwSession.Flush();  
       
   407 
       
   408     __VTPRINTEXIT( "CLcVtSession.CreateVideoWindowsL" )
       
   409     }
       
   410 
       
   411 void CLcVtSession::DestroyVideoWindows()
       
   412     {
       
   413     
       
   414     delete iDev;
       
   415     iDev = NULL;
       
   416     delete iRemoteVideoWindow;
       
   417     iRemoteVideoWindow = NULL;
       
   418     delete iLocalVideoWindow;
       
   419     iLocalVideoWindow = NULL;
       
   420     delete iRwGroup;
       
   421     iRwGroup = NULL;
       
   422     iRwSession.Close();
       
   423     }
       
   424 
       
   425 #endif
       
   426 
       
   427 
       
   428 void CLcVtSession::SetLcSessionObserver( MLcSessionObserver* aObserver )
       
   429     {
       
   430     iObserver = aObserver;
       
   431     }
       
   432 
       
   433 void CLcVtSession::SetLcUiProvider( MLcUiProvider* aUiProvider )
       
   434     {
       
   435     iUiProvider = aUiProvider;
       
   436     }
       
   437     
       
   438 TBool CLcVtSession::IsBackgroundStartup()
       
   439     {
       
   440     return ETrue;
       
   441     }
       
   442   
       
   443 TBool CLcVtSession::SendDialTone( TChar aKey )
       
   444     {
       
   445     iDtmfTone = aKey;
       
   446     __VTPRINT2( DEBUG_GEN, "CLcVtSession.SendDialTone: %d", iDtmfTone() )
       
   447     if ( Execute( KVtEngStartDtmfTone, &iDtmfTone ) != KErrNone )
       
   448         {
       
   449         return EFalse;
       
   450         }
       
   451     else
       
   452         {
       
   453         return ETrue;
       
   454         }
       
   455     }
       
   456 
       
   457 void CLcVtSession::EstablishLcSessionL()
       
   458     {
       
   459     __VTPRINTENTER( "CLcVtSession.EstablishLcSessionL" )
       
   460     
       
   461     TLcVtStateBase::SetInitialStateL( *this, *iLcVtStates );
       
   462     
       
   463     __VTPRINTEXIT( "CLcVtSession.EstablishLcSessionL" )
       
   464     }
       
   465 
       
   466 void CLcVtSession::TerminateLcSessionL()
       
   467     {
       
   468     __VTPRINTENTER( "CLcVtSession.TerminateLcSessionL" )    
       
   469     HandleCommandL( EPluginCmdEndActiveCall );
       
   470     __VTPRINTEXIT( "CLcVtSession.TerminateLcSessionL" )
       
   471     }
       
   472 
       
   473 MLcVideoPlayer* CLcVtSession::RemoteVideoPlayer()
       
   474     {
       
   475     return iRemoteVideoPlayer;
       
   476     }
       
   477 
       
   478 MLcVideoPlayer* CLcVtSession::LocalVideoPlayer()
       
   479     {
       
   480     return iLocalVideoPlayer;
       
   481     }
       
   482 
       
   483 MLcSession::TLcSessionState CLcVtSession::LcSessionState() const
       
   484     {
       
   485     return iSessionState;
       
   486     }
       
   487 
       
   488 const TDesC& CLcVtSession::LocalDisplayName()
       
   489     {
       
   490     return KNullDesC;
       
   491     }
       
   492 const TDesC& CLcVtSession::RemoteDisplayName()
       
   493     {
       
   494     if ( iRemoteDisplayName )
       
   495         {
       
   496         return *iRemoteDisplayName;
       
   497         }
       
   498     return KNullDesC;
       
   499     }
       
   500     
       
   501 TInt CLcVtSession::SetParameter( TInt aId, TInt aValue )
       
   502     {
       
   503      if (aId == 0)
       
   504          iMainWindow = reinterpret_cast<RWindow*>(aValue);
       
   505          
       
   506     return 0;
       
   507     }
       
   508 
       
   509 TInt CLcVtSession::ParameterValue( TInt aId )
       
   510     {
       
   511     return 0;
       
   512     }
       
   513 
       
   514 const TDesC& CLcVtSession::RemoteDetails()
       
   515     {
       
   516     if ( iRemoteDetails )
       
   517         {
       
   518         return *iRemoteDetails;
       
   519         }
       
   520     return KNullDesC;
       
   521     }
       
   522 
       
   523 void CLcVtSession::UpdateLcSessionL()
       
   524     {     
       
   525     __VTPRINTENTER( "CLcVtSession.UpdateLcSessionL" )
       
   526     
       
   527     if(iLcVtStates->ExecState() != TLcVtStates::EExecStateRunning )
       
   528         {
       
   529         __VTPRINTEXIT( "CLcVtSession.UpdateLcSessionL -- State Not OK" )
       
   530         return;
       
   531         }
       
   532 #if 0    
       
   533     if(iLocalVideoPlayer->IsOrientationChanged())
       
   534         HandleLayoutChanged();
       
   535     else
       
   536         UpdateRenderingParametersL();
       
   537 #endif
       
   538     UpdateRenderingParametersL();
       
   539     __VTPRINTEXIT( "CLcVtSession.UpdateLcSessionL" )
       
   540     }
       
   541     
       
   542 // -----------------------------------------------------------------------------
       
   543 // From MLcAudioControl
       
   544 // -----------------------------------------------------------------------------
       
   545 //
       
   546 TBool CLcVtSession::IsLcAudioMutedL()
       
   547     {
       
   548     return EFalse;
       
   549     }
       
   550 
       
   551 // -----------------------------------------------------------------------------
       
   552 // From MLcAudioControl
       
   553 // -----------------------------------------------------------------------------
       
   554 //
       
   555 void CLcVtSession::MuteLcAudioL( TBool aMute )
       
   556     {
       
   557     }
       
   558 
       
   559 // -----------------------------------------------------------------------------
       
   560 // From MLcAudioControl
       
   561 // -----------------------------------------------------------------------------
       
   562 //
       
   563 TBool CLcVtSession::IsLcMicMutedL()
       
   564     {    
       
   565     TBool result = !(iLcVtStates->AudioState().IsAudio());
       
   566     __VTPRINT2( DEBUG_GEN, "CLcVtSession.IsLcMicMutedL = %d", result )
       
   567     return result;  
       
   568     }
       
   569 
       
   570 // -----------------------------------------------------------------------------
       
   571 // From MLcAudioControl
       
   572 // -----------------------------------------------------------------------------
       
   573 //
       
   574 void CLcVtSession::MuteLcMicL( TBool aMute )
       
   575     {   
       
   576     __VTPRINT2( DEBUG_GEN, "CLcVtSession.MuteLcMicL aMute =  %d", aMute )
       
   577 
       
   578     if(aMute)
       
   579         {      
       
   580         HandleCommandL(EPluginCmdDisableAudio);
       
   581         }
       
   582     else
       
   583         {
       
   584         HandleCommandL(EPluginCmdEnableAudio);     
       
   585         }
       
   586     }
       
   587 
       
   588 // -----------------------------------------------------------------------------
       
   589 // From MLcAudioControl
       
   590 // -----------------------------------------------------------------------------
       
   591 //
       
   592 TBool CLcVtSession::IsEnablingLcLoudspeakerAllowed()
       
   593     {
       
   594     return ETrue;
       
   595     }
       
   596 
       
   597 // -----------------------------------------------------------------------------
       
   598 // From MLcAudioControl
       
   599 // -----------------------------------------------------------------------------
       
   600 //
       
   601 void CLcVtSession::EnableLcLoudspeakerL( TBool aEnabled )
       
   602     {
       
   603     __VTPRINT2( DEBUG_GEN, "CLcVtSession.EnableLcLoudspeakerL aEnabled =  %d", aEnabled )    
       
   604     
       
   605     if(aEnabled)
       
   606         {
       
   607         HandleCommandL(EPluginCmdActivateLoudspeaker);
       
   608         }
       
   609     else
       
   610         {
       
   611         HandleCommandL(EPluginCmdDeactivateLoudspeaker);
       
   612         }
       
   613     }
       
   614 
       
   615 // -----------------------------------------------------------------------------
       
   616 // From MLcAudioControl
       
   617 // -----------------------------------------------------------------------------
       
   618 //
       
   619 TBool CLcVtSession::IsLcLoudspeakerEnabled()
       
   620     {
       
   621     TBool result = !(iLcVtStates->AudioState().CanActivateLoudspeaker());
       
   622     __VTPRINT2( DEBUG_GEN, "CLcVtSession.IsLcLoudspeakerEnabled = %d", result )
       
   623     return result;    
       
   624     }
       
   625 
       
   626 // -----------------------------------------------------------------------------
       
   627 // From MLcAudioControl
       
   628 // -----------------------------------------------------------------------------
       
   629 //
       
   630 TInt CLcVtSession::LcVolumeL()
       
   631     {
       
   632     MVtEngAudio& audio = iModel->Audio();
       
   633     MVtEngAudio::TAudioRoutingState audioRouting;
       
   634     User::LeaveIfError( audio.GetRoutingState( audioRouting ) );
       
   635     const TInt volume( audio.OutputVolume(
       
   636         !( audioRouting == MVtEngAudio::EAudioLoudspeaker ) ) );
       
   637     
       
   638     return volume;
       
   639     }
       
   640 
       
   641 // -----------------------------------------------------------------------------
       
   642 // From MLcAudioControl
       
   643 // -----------------------------------------------------------------------------
       
   644 //
       
   645 void CLcVtSession::SetLcVolumeL( TInt aValue )
       
   646     {   
       
   647     __VTPRINTENTER( "CLcVtSession.SetLcVolumeL" )
       
   648     MVtEngAudio& audio = iModel->Audio();
       
   649     const TInt HandsetVolume( audio.OutputVolume(ETrue) );    
       
   650     const TInt HandsfreeVolume( audio.OutputVolume(EFalse) );    
       
   651     MVtEngAudio::TVtEngOutputVolume volume;
       
   652     volume.iHandsetVolume = HandsetVolume;
       
   653     volume.iHandsfreeVolume = HandsfreeVolume;
       
   654 
       
   655     MVtEngAudio::TAudioRoutingState audioRouting;
       
   656     User::LeaveIfError( audio.GetRoutingState( audioRouting ) );    
       
   657     if(audioRouting == MVtEngAudio::EAudioHandset)
       
   658         volume.iHandsetVolume = aValue;
       
   659     else
       
   660         volume.iHandsfreeVolume = aValue;    
       
   661     
       
   662     ExecuteCmdL( KVtEngSetAudioVolume, volume );
       
   663     __VTPRINTEXIT( "CLcVtSession.SetLcVolumeL" )
       
   664     }
       
   665 
       
   666 // -----------------------------------------------------------------------------
       
   667 // From MLcAudioControl
       
   668 // -----------------------------------------------------------------------------
       
   669 //
       
   670 void CLcVtSession::IncreaseLcVolumeL()
       
   671     {
       
   672     ExecuteCmdL( KVtEngIncreaseAudioVolume );
       
   673     }
       
   674 
       
   675 // -----------------------------------------------------------------------------
       
   676 // From MLcAudioControl
       
   677 // -----------------------------------------------------------------------------
       
   678 //
       
   679 void CLcVtSession::DecreaseLcVolumeL()
       
   680     {
       
   681     ExecuteCmdL( KVtEngDecreaseAudioVolume );
       
   682     }
       
   683 
       
   684 CVtEngModel& CLcVtSession::Model()
       
   685     {
       
   686     return *iModel;
       
   687     }
       
   688 
       
   689 
       
   690 void CLcVtSession::HandleCommandL(const TInt aCommand)
       
   691     {
       
   692     
       
   693     __VTPRINTENTER( "CLcVtSession.HandleCommandL" )
       
   694     
       
   695     if ( iLcVtStates->ExecState() != TLcVtStates::EExecStateRunning )
       
   696         {
       
   697         __VTPRINTEXIT( "CLcVtSession.HandleCommandL NOT ready" )
       
   698         return;
       
   699         }
       
   700     
       
   701     if (  iState->HandleCommandL( aCommand ) == TLcVtStateBase::EEventHandled )
       
   702         {
       
   703         __VTPRINTEXIT( "CLcVtSession.HandleCommandL <silently ignoring> 0" )
       
   704         return;
       
   705         }   
       
   706         
       
   707     __VTPRINT2( DEBUG_GEN, "CLcVtSession.HandleCommandL command =  %d", aCommand )
       
   708     
       
   709     switch ( aCommand )
       
   710         {
       
   711         case EPluginCmdEnableAudio:
       
   712             CmdEnableAudioL();
       
   713             break;
       
   714             
       
   715         case EPluginCmdDisableAudio:
       
   716             CmdDisableAudioL();
       
   717             break;
       
   718             
       
   719         case EPluginCmdUsePrimaryCamera:
       
   720             CmdUseCameraL( ETrue );
       
   721             break;
       
   722             
       
   723         case EPluginCmdUseSecondaryCamera:
       
   724             CmdUseCameraL( EFalse );
       
   725             break;
       
   726             
       
   727         case EPluginCmdEnableVideo:
       
   728             CmdEnableVideoL();
       
   729             break;
       
   730             
       
   731         case EPluginCmdDisableVideo:
       
   732             CmdDisableVideoL();
       
   733             break;
       
   734             
       
   735         case EPluginCmdActivateLoudspeaker:
       
   736             CmdActivateLoudspeakerL();
       
   737             break;
       
   738             
       
   739         case EPluginCmdDeactivateLoudspeaker:
       
   740             CmdDeactivateLoudspeakerL();
       
   741             break;
       
   742             
       
   743         }
       
   744     
       
   745     __VTPRINTEXIT( "CLcVtSession.HandleCommandL" )
       
   746     
       
   747     iLcVtStates->Update();
       
   748     }
       
   749 
       
   750 // -----------------------------------------------------------------------------
       
   751 // CLcVtSession::CmdEnableAudioL
       
   752 // -----------------------------------------------------------------------------
       
   753 //
       
   754 void CLcVtSession::CmdEnableAudioL()
       
   755     {
       
   756     ExecuteCmdL( KVtEngUnmuteOutgoingAudio );
       
   757     iLcVtStates->Update();
       
   758     }
       
   759 
       
   760 
       
   761 // -----------------------------------------------------------------------------
       
   762 // CLcVtSession::CmdDisableAudioL
       
   763 // -----------------------------------------------------------------------------
       
   764 //
       
   765 void CLcVtSession::CmdDisableAudioL()
       
   766     {
       
   767     ExecuteCmdL( KVtEngMuteOutgoingAudio );
       
   768     iLcVtStates->Update();
       
   769     }
       
   770 
       
   771 
       
   772 // -----------------------------------------------------------------------------
       
   773 // CLcVtSession::CmdUseCameraL
       
   774 // -----------------------------------------------------------------------------
       
   775 //
       
   776 void CLcVtSession::CmdUseCameraL( const TBool aPrimaryCamera )
       
   777     {
       
   778 
       
   779     MVtEngMedia& media = iModel->Media();
       
   780 
       
   781     MVtEngMedia::TMediaSource selectedSource =
       
   782         ( aPrimaryCamera ) ?
       
   783             MVtEngMedia::EMediaCameraPri : MVtEngMedia::EMediaCameraSec;
       
   784 
       
   785     TInt available = 0;
       
   786     LcVtUtility::GetOutgoingMediaState( media, available );
       
   787     if ( available & MVtEngMedia::EMediaVideo )
       
   788         {
       
   789         ExecuteCmdL( KVtEngStopViewFinder );
       
   790         
       
   791         TRAPD( err, ExecuteCmdL( KVtEngSetSource, selectedSource ) );
       
   792 
       
   793         if ( err == KErrNone )
       
   794             {
       
   795             ExecuteCmdL( KVtEngStartViewFinder );
       
   796             }
       
   797         else
       
   798             {
       
   799             //ShowOtherCameraNotUsableNoteL();
       
   800             }
       
   801         }
       
   802     else
       
   803         {
       
   804         /*
       
   805         MVtEngMedia::TPrepareCameraParams params;
       
   806         params.iMediaSource = selectedSource;
       
   807         params.iInitialize = EFalse;
       
   808         TRAPD( err, ExecuteCmdL( KVtEngPrepareCamera, params ) );
       
   809         if ( err != KErrNone )
       
   810             {
       
   811             ShowOtherCameraNotUsableNoteL();
       
   812             }
       
   813             */
       
   814         }
       
   815     
       
   816     }
       
   817 
       
   818 
       
   819 // -----------------------------------------------------------------------------
       
   820 // CLcVtSession::CmdEnableVideoL
       
   821 // -----------------------------------------------------------------------------
       
   822 //
       
   823 void CLcVtSession::CmdEnableVideoL()
       
   824     {
       
   825     // if outgoing video is frozen
       
   826     MVtEngMedia& media = iModel->Media();
       
   827     if ( LcVtUtility::GetFreezeState( media ) )
       
   828         {
       
   829         ExecuteCmdL( KVtEngUnfreeze );
       
   830         // swap images if needed
       
   831         //RestoreViewFinderL();
       
   832         }
       
   833     else
       
   834         {
       
   835         ExecuteCmdL( KVtEngStopViewFinder );
       
   836         //iUplinkWindow->SetStreamBitmap( NULL );
       
   837         MVtEngMedia::TMediaSource source = MVtEngMedia::EMediaCamera;
       
   838         ExecuteCmdL( KVtEngSetSource, source );
       
   839         MVtEngMedia::TCameraId id;
       
   840         if ( iModel->Media().GetCurrentCameraId( id ) == KErrInUse )
       
   841             {
       
   842             //ShowCameraInUseNoteL();
       
   843             }
       
   844         ExecuteCmdL( KVtEngStartViewFinder );
       
   845         }
       
   846     // update VB settings
       
   847     //UpdateVBSettingL();
       
   848     iLcVtStates->Update();
       
   849     }
       
   850 
       
   851 // -----------------------------------------------------------------------------
       
   852 // CLcVtSession::CmdDisableVideoL
       
   853 // -----------------------------------------------------------------------------
       
   854 //
       
   855 void CLcVtSession::CmdDisableVideoL()
       
   856     {
       
   857     ExecuteCmdL( KVtEngStopViewFinder );
       
   858 
       
   859     //iUplinkWindow->SetStreamBitmap( NULL );
       
   860 
       
   861     TInt err = KErrNotFound;
       
   862     if ( LcVtUtility::HasStillImage( iModel->Media() ) )
       
   863         {
       
   864         __VTPRINT( DEBUG_GEN, "CLcVtSession.CmdDisableVideoL.HasStill" )
       
   865         MVtEngMedia::TMediaSource source = MVtEngMedia::EMediaStillImage;
       
   866         TRAP( err, ExecuteCmdL( KVtEngSetSource, source ) );
       
   867         }
       
   868     if ( ( err != KErrNone ) )
       
   869         {
       
   870         __VTPRINT( DEBUG_GEN, "CLcVtSession.CmdDisableVideoL.MediaNone" )
       
   871         MVtEngMedia::TMediaSource source = MVtEngMedia::EMediaNone;
       
   872         ExecuteCmdL( KVtEngSetSource, source );
       
   873         }
       
   874 
       
   875     ExecuteCmdL( KVtEngStartViewFinder );
       
   876     iLcVtStates->Update();
       
   877     }
       
   878 
       
   879 // -----------------------------------------------------------------------------
       
   880 // CLcVtSession::CmdActivateLoudspeakerL
       
   881 // -----------------------------------------------------------------------------
       
   882 //
       
   883 void CLcVtSession::CmdActivateLoudspeakerL()
       
   884     {
       
   885     MVtEngAudio::TVtEngRoutingSetting audioSetting =
       
   886         MVtEngAudio::EActivateHandsfree;
       
   887     ExecuteCmdL( KVtEngSetAudioRouting, audioSetting );
       
   888     iLcVtStates->Update();
       
   889     }
       
   890 
       
   891 // -----------------------------------------------------------------------------
       
   892 // CLcVtSession::CmdDeactivateLoudspeakerL
       
   893 // -----------------------------------------------------------------------------
       
   894 //
       
   895 void CLcVtSession::CmdDeactivateLoudspeakerL()
       
   896     {
       
   897     MVtEngAudio::TVtEngRoutingSetting audioSetting =
       
   898         MVtEngAudio::EDeactivateHansfree;
       
   899     ExecuteCmdL( KVtEngSetAudioRouting, audioSetting );
       
   900     iLcVtStates->Update();
       
   901     }
       
   902 
       
   903 
       
   904 // -----------------------------------------------------------------------------
       
   905 // CLcVtSession::SetZoomFactorL
       
   906 // -----------------------------------------------------------------------------
       
   907 //
       
   908 void CLcVtSession::SetZoomFactorL( TInt aZoomStep )
       
   909     {
       
   910     __VTPRINTENTER( "CLcVtSessionCLcVtSession.SetZoomFactorL" )
       
   911     MVtEngMedia& media = iModel->Media();
       
   912     if ( LcVtUtility::IsZoomAllowed( media ) )
       
   913         {
       
   914         ExecuteCmdL( KVtEngSetZoomStep, aZoomStep );
       
   915         }
       
   916     __VTPRINTEXIT( "CLcVtSession.SetZoomFactorL" )
       
   917     }
       
   918 
       
   919 #ifndef NGA_VIDEO_RENDER
       
   920 //local video display, VT use bitmaps vf now, and maybe replace by direct vf later
       
   921 void CLcVtSession::vtHandleFrameL( CFbsBitmap* aBitmap )
       
   922     {
       
   923     __VTPRINTENTER( "CLcVtSession.vtHandleFrameL" )   
       
   924     
       
   925     /*    
       
   926     TRect VFRect = LocalVideoPlayer()->LcWindow()->LcWindowRect();
       
   927     const TPoint KVFcordinate( VFRect.iTl.iX,  VFRect.iTl.iY );    
       
   928     iMainWindow->Invalidate();
       
   929     iMainWindow->BeginRedraw();
       
   930     iGc->Activate( *iMainWindow );
       
   931     aBitmap->BeginDataAccess();
       
   932     aBitmap->EndDataAccess();
       
   933     iGc->BitBlt( KVFcordinate , aBitmap );
       
   934     iGc->Deactivate();
       
   935     iMainWindow->EndRedraw();
       
   936     */
       
   937     
       
   938     /*
       
   939     TRect VFRect = LocalVideoPlayer()->LcWindow()->LcWindowRect();    
       
   940     const TPoint KVFcordinate( VFRect.iTl.iX -2 ,  VFRect.iTl.iY - 168 );
       
   941     iLocalVideoWindow->Invalidate();
       
   942     iLocalVideoWindow->BeginRedraw();
       
   943     iGc->Activate( *iLocalVideoWindow );
       
   944     iGc->BitBlt( KVFcordinate , aBitmap );
       
   945     iGc->Deactivate();
       
   946     iLocalVideoWindow->EndRedraw();
       
   947     */   
       
   948         
       
   949     __VTPRINTEXIT("CLcVtSession.vtHandleFrameL")     
       
   950     }
       
   951 #endif
       
   952 
       
   953 TInt CLcVtSession::SetForegroundStatus( TBool aIsForeground )
       
   954 {
       
   955     __VTPRINTENTER( "CLcVtSession.SetForegroundStatus" )
       
   956     __VTPRINT2( DEBUG_MEDIA , "    foreground: %d", aIsForeground )
       
   957 
       
   958     if ( iRwGroup )
       
   959         {
       
   960         TInt priority = aIsForeground ? ECoeWinPriorityNormal : ECoeWinPriorityNeverAtFront;
       
   961         iRwGroup->SetOrdinalPosition( 1 , priority );
       
   962         iRemoteVideoWindow->SetOrdinalPosition( 1 , priority );
       
   963         iLocalVideoWindow->SetOrdinalPosition( 1 , priority );
       
   964         iRwSession.Flush();
       
   965         }
       
   966     if ( aIsForeground )
       
   967        {
       
   968        iIndicatorCtr->disableActiveCallIndicator();
       
   969        }
       
   970     else {
       
   971        iIndicatorCtr->enableActiveCallIndicator();
       
   972        }
       
   973 
       
   974     __VTPRINTEXIT( "CLcVtSession.SetForegroundStatus" )
       
   975     
       
   976     return KErrNone;   
       
   977 }
       
   978 
       
   979 // -----------------------------------------------------------------------------
       
   980 // CLcVtSession::ShutdownL
       
   981 // -----------------------------------------------------------------------------
       
   982 //
       
   983 void CLcVtSession::ShutdownL()
       
   984     {
       
   985     __VTPRINTENTER( "CLcVtSession.ShutdownL" )
       
   986     iActiveExec->Start( EVtSessionShutdown, *this );
       
   987     __VTPRINTEXIT( "CLcVtSession.ShutdownL" )
       
   988     }
       
   989 
       
   990 // -----------------------------------------------------------------------------
       
   991 // CLcVtSession::StartupPhase1L
       
   992 // -----------------------------------------------------------------------------
       
   993 //
       
   994 void CLcVtSession::StartupPhase1L()
       
   995     {
       
   996     __VTPRINTENTER( "CLcVtSession.StartupPhase1L" )
       
   997     iActiveExec->Start( EVtSessionStartup, *this );
       
   998     __VTPRINTEXIT( "CLcVtSession.StartupPhase1L" )
       
   999     }
       
  1000 
       
  1001 
       
  1002 // -----------------------------------------------------------------------------
       
  1003 // CLcVtSession::StartupPhase2L
       
  1004 // -----------------------------------------------------------------------------
       
  1005 //
       
  1006 void CLcVtSession::StartupPhase2L()
       
  1007     {
       
  1008     __VTPRINTENTER( "CLcVtSession.StartupPhase2L" )
       
  1009     iActiveExec->Start( EVtSessionAnswered, *this );
       
  1010     __VTPRINTEXIT( "CLcVtSession.StartupPhase2L" )
       
  1011     }
       
  1012 
       
  1013 // -----------------------------------------------------------------------------
       
  1014 // CLcVtSession::ActiveExecExecuteL
       
  1015 // -----------------------------------------------------------------------------
       
  1016 //
       
  1017 TBool CLcVtSession::ActiveExecExecuteL(
       
  1018         CLcVtActiveExec& /*aActiveExec*/,
       
  1019         const TInt aState,
       
  1020         TInt& aNextState,
       
  1021         TRequestStatus& aRequest )
       
  1022     {
       
  1023     return ActiveExecInitExecuteL(
       
  1024             aState,
       
  1025             aNextState,
       
  1026             aRequest );
       
  1027     }
       
  1028 
       
  1029 // -----------------------------------------------------------------------------
       
  1030 // CLcVtSession::ActiveExecContinue
       
  1031 // -----------------------------------------------------------------------------
       
  1032 //
       
  1033 TBool CLcVtSession::ActiveExecContinue(
       
  1034         CLcVtActiveExec& /*aActiveExec*/,
       
  1035         TInt& aState,
       
  1036         const TInt aError )
       
  1037     {
       
  1038     return ActiveExecInitContinue( aState, aError );
       
  1039     }
       
  1040 
       
  1041 // -----------------------------------------------------------------------------
       
  1042 // CLcVtSession::ActiveExecCancel
       
  1043 // -----------------------------------------------------------------------------
       
  1044 //
       
  1045 void CLcVtSession::ActiveExecCancel(
       
  1046         CLcVtActiveExec& /*aActiveExec*/,
       
  1047         TInt aState )
       
  1048     {
       
  1049     ActiveExecInitCancel( aState );
       
  1050     }
       
  1051 
       
  1052 // -----------------------------------------------------------------------------
       
  1053 // CLcVtSession::ActiveExecDone
       
  1054 // -----------------------------------------------------------------------------
       
  1055 //
       
  1056 void CLcVtSession::ActiveExecDone(
       
  1057         CLcVtActiveExec& /*aActiveExec*/,
       
  1058         const TInt aInitialState )
       
  1059     {    
       
  1060     ActiveExecInitDone( aInitialState );
       
  1061     }
       
  1062 
       
  1063 
       
  1064 // -----------------------------------------------------------------------------
       
  1065 // CLcVtSession::ActiveExecInitCancel
       
  1066 // -----------------------------------------------------------------------------
       
  1067 //
       
  1068 void CLcVtSession::ActiveExecInitCancel(
       
  1069         const TInt /*aState*/ )
       
  1070     {
       
  1071     __VTPRINTENTER( "CLcVtSession.InitExecCancel" )
       
  1072     
       
  1073     delete iCmdExecutor;
       
  1074 
       
  1075     if ( iShutdownRequest )
       
  1076         {
       
  1077         User::RequestComplete( iShutdownRequest, KErrCancel );
       
  1078         iShutdownRequest = NULL;
       
  1079         }
       
  1080     __VTPRINTEXIT( "CLcVtSession.InitExecCancel" )
       
  1081     }
       
  1082 
       
  1083 // -----------------------------------------------------------------------------
       
  1084 // CLcVtSession::ActiveExecInitDone
       
  1085 // -----------------------------------------------------------------------------
       
  1086 //
       
  1087 void CLcVtSession::ActiveExecInitDone(
       
  1088         const TInt aInitialState )
       
  1089     {
       
  1090     __VTPRINTENTER( "CLcVtSession.ExecInitDone" )
       
  1091     __VTPRINT2( DEBUG_GEN, "CLcVtSession.InitExecDone.ini=%d", aInitialState )
       
  1092     // Operation succeeded
       
  1093     
       
  1094     // Now we have finished.
       
  1095     if ( iState )
       
  1096         {
       
  1097         if ( aInitialState == EVtSessionAnswered )
       
  1098             {
       
  1099             TRAP_IGNORE( iState->LcVtStartupPhase2DoneL() );
       
  1100 			iSessionState = EOpen;
       
  1101             iObserver->StateChanged( *this );             
       
  1102             }
       
  1103         else if ( aInitialState == EVtSessionShutdown )
       
  1104             {
       
  1105             TRAP_IGNORE( iState->ShutdownDoneL() );
       
  1106             }
       
  1107         else // EVtSessionStartup
       
  1108             {
       
  1109             TRAP_IGNORE( iState->LcVtStartupPhase1DoneL() );
       
  1110             }
       
  1111         }
       
  1112     __VTPRINTEXIT( "CLcVtSession.ExecInitDone" )
       
  1113     }
       
  1114 
       
  1115 
       
  1116 // -----------------------------------------------------------------------------
       
  1117 // CLcVtSession::ActiveExecInitExecuteL
       
  1118 // -----------------------------------------------------------------------------
       
  1119 //
       
  1120 TBool CLcVtSession::ActiveExecInitExecuteL(
       
  1121         const TInt aState,
       
  1122         TInt& aNextState,
       
  1123         TRequestStatus& aRequest )
       
  1124     {
       
  1125     __VTPRINTENTER( "CLcVtSession.ActiveExecInitExecuteL" )
       
  1126     __VTPRINT2( DEBUG_GEN, "CLcVtSession.ActiveExecInitExecuteL.st=%d", aState )
       
  1127 
       
  1128     TBool synch = EFalse;
       
  1129 
       
  1130     switch ( aState )
       
  1131         {
       
  1132         // Startup chain:
       
  1133         case EVtSessionStartupInitEngine:
       
  1134             //ChangeApplicationFocus(ETrue);
       
  1135 #if defined (__WINS__)
       
  1136             ActiveExecInitExecuteCommandL( KVtEngInitializeEngineDiag, aRequest );
       
  1137 #else            
       
  1138             ActiveExecInitExecuteCommandL( KVtEngInitializeEngine, aRequest );
       
  1139 #endif            
       
  1140             aNextState = EVtSessionStartupPrepareViewfinder; 
       
  1141             //aNextState = EVtSessionStartupFinish;            
       
  1142             break;
       
  1143             
       
  1144         case EVtSessionStartupPrepareViewfinder:
       
  1145             //iSessionState = EOpen;
       
  1146             //iObserver->StateChanged( *this );          
       
  1147                         
       
  1148 #ifdef NGA_VIDEO_RENDER
       
  1149             CreateVideoWindowsL();
       
  1150 #endif           
       
  1151             ActiveExecInitPrepareViewFinderL( aRequest );            
       
  1152             aNextState = EVtSessionStartupPrepareRemoteRender;
       
  1153             break;
       
  1154 
       
  1155         case EVtSessionStartupPrepareRemoteRender:
       
  1156             ActiveExecInitPrepareRemoteRenderL( aRequest );
       
  1157             aNextState = EVtSessionStartupFinish;
       
  1158             break;
       
  1159             
       
  1160         case EVtSessionStartupFinish:
       
  1161             aNextState = EVtSessionNone;
       
  1162             synch = ETrue;
       
  1163             break;
       
  1164             
       
  1165             
       
  1166         // Shutdown chain:    
       
  1167         case EVtSessionShutdownHideApplication:
       
  1168             ChangeApplicationFocus( EFalse );
       
  1169             synch = ETrue;
       
  1170             aNextState = EVtSessionShutdownResetEngine;            
       
  1171             break;
       
  1172         case EVtSessionShutdownResetEngine:
       
  1173             {
       
  1174             aRequest = KRequestPending;
       
  1175 
       
  1176             MVtEngCommandHandler& command = iModel->CommandHandler();
       
  1177             // There should not be any commands ongoing because
       
  1178             // we have canceled all dialogs (and this should
       
  1179             // be the only command without dialog).
       
  1180             command.CancelCommand( command.PendingCommand() ); // ignore error
       
  1181             command.ExecuteL( KVtEngResetEngine, NULL );
       
  1182             iShutdownRequest = &aRequest;
       
  1183 
       
  1184             aNextState = EVtSessionNone;
       
  1185             }            
       
  1186             break;
       
  1187         
       
  1188         
       
  1189             
       
  1190         // Answered chain:  
       
  1191         case EVtSessionAnsweredStartRemoteRender:            
       
  1192             {
       
  1193             ActiveExecInitExecuteCommandL( KVtEngStartRenderRemote, aRequest );
       
  1194             //TRequestStatus* status = &aRequest;
       
  1195             //User::RequestComplete( status, KErrNone );            
       
  1196 
       
  1197             MVtEngSessionInfo::TDirection direction;
       
  1198             if ( iModel->Session().GetDirection( direction ) != KErrNone )
       
  1199                 {
       
  1200                 direction = MVtEngSessionInfo::EDirectionMT;
       
  1201                 }
       
  1202             
       
  1203             MVtEngMedia& media = iModel->Media();    
       
  1204             if ( LcVtUtility::HasCameras( media ) )
       
  1205                 {
       
  1206                 if ( direction == MVtEngSessionInfo::EDirectionMT )
       
  1207                     {
       
  1208                         if ( VideoSendingKey == KAllwaysAllow)
       
  1209                             {
       
  1210                             aNextState = EVtSessionAnsweredDoPrepareCamera;
       
  1211                             }
       
  1212                         else
       
  1213                             {
       
  1214                             aNextState = EVtSessionAnsweredSetlectNone;
       
  1215                             }
       
  1216                     }
       
  1217                 else
       
  1218                     {
       
  1219                     //MVtEngSessionInfo::EDirectionMO
       
  1220                     aNextState = EVtSessionAnsweredDoPrepareCamera;
       
  1221                     }
       
  1222                 }
       
  1223             else
       
  1224                 {
       
  1225                 aNextState = EVtSessionAnsweredSetlectNone;
       
  1226                 }
       
  1227             }
       
  1228             break;
       
  1229             
       
  1230         case EVtSessionAnsweredSetlectNone:
       
  1231             {
       
  1232             ActiveExecInitSetSourceL( MVtEngMedia::EMediaNone, aRequest );
       
  1233             aNextState = EVtSessionAnsweredStartViewFinder;            
       
  1234             }
       
  1235             break;
       
  1236         case EVtSessionAnsweredDoPrepareCamera:
       
  1237             {
       
  1238             MVtEngMedia& media = iModel->Media();
       
  1239             MVtEngMedia::TMediaSource source = MVtEngMedia::EMediaCamera;
       
  1240             ActiveExecInitPrepareCameraL( source, aRequest );
       
  1241             aNextState = EVtSessionAnsweredSetlectCamera;
       
  1242             }
       
  1243             break;
       
  1244             
       
  1245         case EVtSessionAnsweredSetlectCamera:
       
  1246             ActiveExecInitSetSourceL( MVtEngMedia::EMediaCamera, aRequest );
       
  1247             aNextState = EVtSessionAnsweredStartViewFinder;
       
  1248             break;
       
  1249             
       
  1250         case EVtSessionAnsweredStartViewFinder:
       
  1251             ActiveExecInitExecuteCommandL( KVtEngStartViewFinder, aRequest );
       
  1252             aNextState = EVtSessionAnsweredBringToForeground;            
       
  1253             break;
       
  1254             
       
  1255         case EVtSessionAnsweredBringToForeground:
       
  1256             {
       
  1257             //CreateVideoWindowsL();
       
  1258             
       
  1259             ChangeApplicationFocus(ETrue);
       
  1260             TRequestStatus* status = &aRequest;
       
  1261             User::RequestComplete( status, KErrNone );            
       
  1262             aNextState = EVtSessionAnsweredFinish;
       
  1263             }
       
  1264             break;
       
  1265             
       
  1266         case EVtSessionAnsweredFinish:
       
  1267             {          
       
  1268             //iRwGroup->SetOrdinalPosition( 1 , ECoeWinPriorityNormal );
       
  1269             
       
  1270             TBool handleAsForeground( ETrue );
       
  1271             TPtrC8 params( reinterpret_cast< TUint8* >( &handleAsForeground ), sizeof( TBool ) );
       
  1272             MVtEngCommandHandler& command = iModel->CommandHandler();            
       
  1273             TRAPD( err, command.ExecuteL( KVtEngSetUIForeground, &params ));
       
  1274             if(err != KErrNone)
       
  1275                 {
       
  1276                 err = KErrNone;
       
  1277                 }
       
  1278             
       
  1279             iLcVtStates->Update();
       
  1280             
       
  1281             iObserver->StateChanged( *iLocalVideoPlayer );
       
  1282             iObserver->StateChanged( *iRemoteVideoPlayer );            
       
  1283             
       
  1284             synch = ETrue;
       
  1285             aNextState = EVtSessionNone;
       
  1286             }
       
  1287             break;
       
  1288         }
       
  1289     
       
  1290     __VTPRINT2( DEBUG_GEN, "CLcVtSession.ActiveExecInitExecuteL.sync=%d", synch )
       
  1291     __VTPRINT2( DEBUG_GEN, "CLcVtSession.ActiveExecInitExecuteL.next=%d", aNextState )
       
  1292     __VTPRINTEXITR( "CLcVtSession.ActiveExecInitExecuteL %d", synch )
       
  1293     return synch;
       
  1294     
       
  1295     }
       
  1296 
       
  1297 
       
  1298 // -----------------------------------------------------------------------------
       
  1299 // CLcVtSession::ActiveExecInitContinue
       
  1300 // -----------------------------------------------------------------------------
       
  1301 //
       
  1302 TBool CLcVtSession::ActiveExecInitContinue(
       
  1303         TInt& aState,
       
  1304         const TInt /*aError*/ )
       
  1305     {
       
  1306     __VTPRINTENTER( "CLcVtSession.InitExecCont" )
       
  1307     __VTPRINT2( DEBUG_GEN, "CLcVtSession.InitExecCont.st=%d", aState ) 
       
  1308 
       
  1309     const TBool cont = EFalse;
       
  1310     __VTPRINT2( DEBUG_GEN, "VtUi.InitExecCont.cont=%d", cont )
       
  1311 
       
  1312     if ( !cont )
       
  1313         {
       
  1314         // Operation failed.
       
  1315         if ( iState )
       
  1316             {
       
  1317             TRAP_IGNORE( iState->LcVtStartupFailedL() );
       
  1318             }
       
  1319         }
       
  1320     __VTPRINTEXITR( "VtUi.InitExecCont %d", cont )
       
  1321     return cont;
       
  1322     }
       
  1323 
       
  1324 
       
  1325 // -----------------------------------------------------------------------------
       
  1326 // CLcVtSession::ActiveExecInitExecuteCommandL
       
  1327 // -----------------------------------------------------------------------------
       
  1328 //
       
  1329 void CLcVtSession::ActiveExecInitExecuteCommandL(
       
  1330         const TVtEngCommandId aCommand,
       
  1331         TRequestStatus& aRequest )
       
  1332     {
       
  1333     iCmdExecutor =
       
  1334         ExecuteCmdAsyncL(
       
  1335         &iCmdExecutor,
       
  1336         aCommand,
       
  1337         aRequest );
       
  1338     }
       
  1339 
       
  1340 
       
  1341 // -----------------------------------------------------------------------------
       
  1342 // CLcVtSession::ActiveExecInitPrepareViewFinderL
       
  1343 // -----------------------------------------------------------------------------
       
  1344 //
       
  1345 void CLcVtSession::ActiveExecInitPrepareViewFinderL(
       
  1346         TRequestStatus& aRequest )
       
  1347     {
       
  1348     
       
  1349     __VTPRINTENTER( "CLcVtSession.ActiveExecInitPrepareViewFinderL" )
       
  1350         
       
  1351     TRect VFRect = LocalVideoPlayer()->LcWindow()->LcWindowRect();    
       
  1352     TSize size (VFRect.Size());
       
  1353     
       
  1354 #ifdef NGA_VIDEO_RENDER  
       
  1355     
       
  1356     __VTPRINT3(DEBUG_GEN,  "CLcVtSession.ActiveExecInitPrepareViewFinderL size(%d,%d)", size.iWidth, size.iHeight )    
       
  1357     
       
  1358     iLocalVideoWindow->SetPosition( VFRect.iTl );    
       
  1359     iLocalVideoWindow->SetSize( VFRect.Size() ); 
       
  1360     
       
  1361     iRwSession.Flush(); 
       
  1362         
       
  1363     __VTPRINT2( DEBUG_MEDIA , "    LocalVideoPlayer.VFRect.iTl.iX: %d", VFRect.iTl.iX )
       
  1364     __VTPRINT2( DEBUG_MEDIA , "    LocalVideoPlayer.VFRect.iTl.iY: %d", VFRect.iTl.iY )
       
  1365     __VTPRINT2( DEBUG_MEDIA , "    LocalVideoPlayer.VFRect.iWidth: %d", VFRect.Width() )
       
  1366     __VTPRINT2( DEBUG_MEDIA , "    LocalVideoPlayer.VFRect.iHeight: %d", VFRect.Height() )  
       
  1367                    
       
  1368     TVtEngRenderingOptionsNGA configViewfinder( *iLocalVideoWindow, iRwSession );
       
  1369     iCmdExecutor =
       
  1370           ExecuteCmdAsyncL(
       
  1371               &iCmdExecutor,
       
  1372               KVtEngPrepareViewFinder,
       
  1373               configViewfinder,
       
  1374               aRequest );   
       
  1375     
       
  1376     
       
  1377     /*
       
  1378     TPoint point( 0, 0 );
       
  1379     TRect vfRect( point, size ); 
       
  1380      
       
  1381     TVtEngRenderingOptionsDSA configViewfinder(*iEventObserver, iRwSession ,*iDev, *iLocalVideoWindow, vfRect, vfRect);    
       
  1382 
       
  1383     iCmdExecutor =
       
  1384           ExecuteCmdAsyncL(
       
  1385               &iCmdExecutor,
       
  1386               KVtEngPrepareViewFinderDSA,
       
  1387               configViewfinder,
       
  1388               aRequest );
       
  1389               */                  
       
  1390     
       
  1391 #else
       
  1392     
       
  1393     __VTPRINT3(DEBUG_GEN,  "CLcVtSession.ActiveExecInitPrepareViewFinderL size(%d,%d)", size.iWidth, size.iHeight )    
       
  1394     
       
  1395     TVtEngRenderingOptions configViewfinder(*iEventObserver, size);
       
  1396 
       
  1397     iCmdExecutor =
       
  1398           ExecuteCmdAsyncL(
       
  1399               &iCmdExecutor,
       
  1400               KVtEngPrepareViewFinder,
       
  1401               configViewfinder,
       
  1402               aRequest );   
       
  1403     
       
  1404 #endif    
       
  1405     }
       
  1406 
       
  1407 
       
  1408 // -----------------------------------------------------------------------------
       
  1409 // CLcVtSession::ActiveExecInitPrepareRemoteRenderL
       
  1410 // -----------------------------------------------------------------------------
       
  1411 //
       
  1412 void CLcVtSession::ActiveExecInitPrepareRemoteRenderL(
       
  1413         TRequestStatus& aRequest )
       
  1414     {
       
  1415     
       
  1416     TRect RMRect = RemoteVideoPlayer()->LcWindow()->LcWindowRect();    
       
  1417     const TSize KRMsize( RMRect.Size());
       
  1418     TRect screen( KRMsize );
       
  1419     TRect clip( KRMsize );        
       
  1420     
       
  1421 #ifdef NGA_VIDEO_RENDER 
       
  1422         
       
  1423     iRemoteVideoWindow->SetPosition( RMRect.iTl );
       
  1424     iRemoteVideoWindow->SetSize( RMRect.Size() );    
       
  1425     
       
  1426     iRwSession.Flush(); 
       
  1427     
       
  1428     __VTPRINT2( DEBUG_MEDIA , "    RemoteVideoPlayer.RMRect.iTl.iX: %d", RMRect.iTl.iX )
       
  1429     __VTPRINT2( DEBUG_MEDIA , "    RemoteVideoPlayer.RMRect.iTl.iY: %d", RMRect.iTl.iY )
       
  1430     __VTPRINT2( DEBUG_MEDIA , "    RemoteVideoPlayer.RMRect.iWidth: %d", RMRect.Width() )
       
  1431     __VTPRINT2( DEBUG_MEDIA , "    RemoteVideoPlayer.RMRect.iHeight: %d", RMRect.Height() )   
       
  1432        
       
  1433        
       
  1434     TVtEngRenderingOptionsNGA configRemoteRender( *iRemoteVideoWindow, iRwSession );    
       
  1435     iCmdExecutor =
       
  1436         ExecuteCmdAsyncL(
       
  1437             &iCmdExecutor,
       
  1438             KVtEngPrepareRemoteRenderNGA,
       
  1439             configRemoteRender,
       
  1440             aRequest );
       
  1441     
       
  1442 #else
       
  1443 
       
  1444     const TPoint KRMcordinate( RMRect.iTl.iX,  RMRect.iTl.iY );
       
  1445     
       
  1446     TVtEngRenderingOptionsDP configRemoteRender(*iEventObserver, *iWsSession ,*iWsSessionScreenDev, *iMainWindow, screen, clip, KRMcordinate );  
       
  1447 
       
  1448     iCmdExecutor =
       
  1449         ExecuteCmdAsyncL(
       
  1450             &iCmdExecutor,
       
  1451             KVtEngPrepareRemoteRenderDP,
       
  1452             configRemoteRender,
       
  1453             aRequest );
       
  1454     
       
  1455 #endif
       
  1456     
       
  1457     }
       
  1458 
       
  1459 
       
  1460 // -----------------------------------------------------------------------------
       
  1461 // CLcVtSession::ActiveExecInitPrepareCameraL
       
  1462 // -----------------------------------------------------------------------------
       
  1463 //
       
  1464 void CLcVtSession::ActiveExecInitPrepareCameraL(
       
  1465         const MVtEngMedia::TMediaSource aSource,
       
  1466         TRequestStatus& aRequest )
       
  1467     {
       
  1468     MVtEngMedia::TPrepareCameraParams params;
       
  1469     params.iMediaSource = aSource;
       
  1470     params.iInitialize = ETrue;
       
  1471     iCmdExecutor =
       
  1472         ExecuteCmdAsyncL(
       
  1473             &iCmdExecutor,
       
  1474             KVtEngPrepareCamera,
       
  1475             params,
       
  1476             aRequest );
       
  1477     }
       
  1478 
       
  1479 // -----------------------------------------------------------------------------
       
  1480 // CLcVtSession::ActiveExecInitSetSourceL
       
  1481 // -----------------------------------------------------------------------------
       
  1482 //
       
  1483 void CLcVtSession::ActiveExecInitSetSourceL(
       
  1484         const MVtEngMedia::TMediaSource aSource,
       
  1485         TRequestStatus& aRequest )
       
  1486     {
       
  1487     MVtEngMedia::TMediaSource source =
       
  1488         aSource;
       
  1489     iCmdExecutor =
       
  1490         ExecuteCmdAsyncL(
       
  1491             &iCmdExecutor,
       
  1492             KVtEngSetSource,
       
  1493             source,
       
  1494             aRequest );
       
  1495     }
       
  1496 
       
  1497 
       
  1498 // -----------------------------------------------------------------------------
       
  1499 // CLcVtSession::ExecuteCmdAsyncL
       
  1500 // -----------------------------------------------------------------------------
       
  1501 //
       
  1502 CLcVtCmdExecutor* CLcVtSession::ExecuteCmdAsyncL(
       
  1503         CLcVtCmdExecutor** aDialogPtr,
       
  1504         const TVtEngCommandId aCommand,
       
  1505         TRequestStatus& aStatus )
       
  1506     {
       
  1507     return DoExecuteCmdAsyncL( aDialogPtr, aCommand, NULL, aStatus );
       
  1508     }
       
  1509 
       
  1510 // -----------------------------------------------------------------------------
       
  1511 // CLcVtSession::ExecuteCmdAsyncL
       
  1512 // -----------------------------------------------------------------------------
       
  1513 //
       
  1514 template< class T >
       
  1515 CLcVtCmdExecutor* CLcVtSession::ExecuteCmdAsyncL(
       
  1516         CLcVtCmdExecutor** aDialogPtr,
       
  1517         const TVtEngCommandId aCommand,
       
  1518         T& aParam,
       
  1519         TRequestStatus& aStatus )
       
  1520     {
       
  1521     TPtrC8 params( reinterpret_cast< TUint8* >( &aParam ), sizeof( T ) );
       
  1522     return DoExecuteCmdAsyncL( aDialogPtr, aCommand, &params, aStatus );
       
  1523     }
       
  1524 
       
  1525 // -----------------------------------------------------------------------------
       
  1526 // CLcVtSession::DoExecuteCmdAsyncL
       
  1527 // -----------------------------------------------------------------------------
       
  1528 //
       
  1529 CLcVtCmdExecutor* CLcVtSession::DoExecuteCmdAsyncL(
       
  1530         CLcVtCmdExecutor** aDialogPtr,
       
  1531         const TVtEngCommandId aCommand,
       
  1532         TDesC8* aParams,
       
  1533         TRequestStatus& aStatus )
       
  1534     {
       
  1535     __VTPRINT2( DEBUG_GEN, "CLcVtSession.DoExecAsync.cmd=%d", aCommand )
       
  1536     MVtEngCommandHandler& command = iModel->CommandHandler();
       
  1537     const TInt caps = command.GetCommandCaps( aCommand );
       
  1538 
       
  1539     if ( caps >= KErrNone )
       
  1540         {
       
  1541         const TBool asynchronous =
       
  1542             ( caps & MVtEngCommandHandler::EAttribAsync );
       
  1543 
       
  1544         if ( asynchronous  )
       
  1545             {
       
  1546             CLcVtCmdExecutor* executor =
       
  1547                 new ( ELeave ) CLcVtCmdExecutor(
       
  1548                     aDialogPtr,
       
  1549                     iModel->CommandHandler(),
       
  1550                     *iEventObserver );
       
  1551             executor->ExecuteCmdL( aCommand, aParams, &aStatus );
       
  1552             return executor;
       
  1553             }
       
  1554         else
       
  1555             {
       
  1556             command.ExecuteL( aCommand, aParams );
       
  1557             RefreshStatesL();
       
  1558             TRequestStatus* status = &aStatus;
       
  1559             User::RequestComplete( status, KErrNone );
       
  1560             }
       
  1561         }
       
  1562     else
       
  1563         {
       
  1564         // Failed.
       
  1565         User::Leave( caps );
       
  1566         }
       
  1567     
       
  1568     return NULL;
       
  1569     }
       
  1570 
       
  1571 // -----------------------------------------------------------------------------
       
  1572 // CLcVtSession::ExecuteCmdL
       
  1573 // -----------------------------------------------------------------------------
       
  1574 //
       
  1575 void CLcVtSession::ExecuteCmdL( const TVtEngCommandId aCommand )
       
  1576     {
       
  1577     DoExecuteCmdL( aCommand, NULL );
       
  1578     }
       
  1579 
       
  1580 // -----------------------------------------------------------------------------
       
  1581 // CLcVtSession::ExecuteCmdL
       
  1582 // -----------------------------------------------------------------------------
       
  1583 //
       
  1584 template< class T >
       
  1585 void CLcVtSession::ExecuteCmdL(
       
  1586         const TVtEngCommandId aCommand,
       
  1587         T& aParam )
       
  1588     {
       
  1589     TPtrC8 params( reinterpret_cast< TUint8* >( &aParam ), sizeof( T ) );
       
  1590     DoExecuteCmdL( aCommand, &params );
       
  1591     }
       
  1592 
       
  1593 // -----------------------------------------------------------------------------
       
  1594 // CLcVtSession::DoExecuteCmdL
       
  1595 // -----------------------------------------------------------------------------
       
  1596 //
       
  1597 void CLcVtSession::DoExecuteCmdL(
       
  1598         const TVtEngCommandId aCommand,
       
  1599         TDesC8* aParams )
       
  1600     {
       
  1601     __VTPRINT2( DEBUG_GEN, "CLcVtSession.DoExec.cmd=%d", aCommand )
       
  1602     MVtEngCommandHandler& command = iModel->CommandHandler();
       
  1603     const TInt caps = command.GetCommandCaps( aCommand );
       
  1604 
       
  1605     if ( caps >= KErrNone )
       
  1606         {
       
  1607         const TBool asynchronous =
       
  1608             ( caps & MVtEngCommandHandler::EAttribAsync );
       
  1609 
       
  1610         if ( asynchronous  )
       
  1611             {            
       
  1612             CLcVtCmdExecutor* executor =
       
  1613                 new ( ELeave ) CLcVtCmdExecutor(
       
  1614                     NULL,
       
  1615                     iModel->CommandHandler(),
       
  1616                     *iEventObserver );
       
  1617             iUiProvider->BlockUi(ETrue);
       
  1618             //executor->ExecuteCmdL( aCommand, aParams, NULL );
       
  1619             TRAPD( err, executor->ExecuteCmdL( aCommand, aParams, NULL ) );
       
  1620             iUiProvider->BlockUi(EFalse);
       
  1621             if(err != KErrNone)
       
  1622                 User::Leave(err);
       
  1623             
       
  1624             }
       
  1625         else
       
  1626             {
       
  1627             command.ExecuteL( aCommand, aParams );
       
  1628             RefreshStatesL();
       
  1629             }
       
  1630         }
       
  1631     else
       
  1632         {
       
  1633         // Failed.
       
  1634         User::Leave( caps );
       
  1635         }
       
  1636     }
       
  1637 
       
  1638 
       
  1639 // -----------------------------------------------------------------------------
       
  1640 // CLcVtSession::Execute
       
  1641 // -----------------------------------------------------------------------------
       
  1642 //
       
  1643 TInt CLcVtSession::Execute( const TVtEngCommandId aCommand, TDesC8* aParam )
       
  1644     {
       
  1645     MVtEngCommandHandler& command = iModel->CommandHandler();
       
  1646     TRAPD( err, command.ExecuteL( aCommand, aParam ) );
       
  1647 #ifdef VTDEBUG
       
  1648     if ( err != KErrNone )
       
  1649         {
       
  1650         __VTPRINT3( DEBUG_GEN, "CLcVtSession.Execute.Nok.cmd=%d,err=%d", aCommand, err )
       
  1651         }
       
  1652 #endif // VTDEBUG
       
  1653     return err;
       
  1654     }
       
  1655 
       
  1656 
       
  1657 // -----------------------------------------------------------------------------
       
  1658 // CLcVtSession::ChangeApplicationFocus
       
  1659 // -----------------------------------------------------------------------------
       
  1660 //
       
  1661 void CLcVtSession::ChangeApplicationFocus( const TBool aForeground )
       
  1662     {
       
  1663     __VTPRINTENTER( "CLcVtSession.ChangeApplicationFocus" )
       
  1664     if ( iUiProvider ){
       
  1665         iUiProvider->HandleForegroundStatus(aForeground);
       
  1666     }
       
  1667     __VTPRINTEXIT( "CLcVtSession.ChangeApplicationFocus" )
       
  1668     }
       
  1669 
       
  1670 
       
  1671 // -----------------------------------------------------------------------------
       
  1672 // CLcVtSession::ChangeState
       
  1673 // -----------------------------------------------------------------------------
       
  1674 //
       
  1675 void CLcVtSession::ChangeState( TLcVtStateBase* aState )
       
  1676     {
       
  1677     __VTPRINTENTER( "CLcVtSession.ChangeState" )
       
  1678     iState = aState;
       
  1679     __VTPRINTEXIT( "CLcVtSession.ChangeState" )
       
  1680     }
       
  1681 
       
  1682 #if 0
       
  1683 // -----------------------------------------------------------------------------
       
  1684 // CLcVtSession::StartDtmfTone
       
  1685 // -----------------------------------------------------------------------------
       
  1686 //
       
  1687 void CLcVtSession::StartDtmfTone( const TChar& aTone )
       
  1688     {
       
  1689     // should be called only through current application state
       
  1690     iDtmfTone = aTone;
       
  1691     __VTPRINT2( DEBUG_GEN, "CLcVtSession.DTMF.Start.%d", iDtmfTone() )
       
  1692     if ( Execute( KVtEngStartDtmfTone, &iDtmfTone ) != KErrNone )
       
  1693         {
       
  1694         iDtmfTone = 0;
       
  1695         }
       
  1696     }
       
  1697 
       
  1698 // -----------------------------------------------------------------------------
       
  1699 // CLcVtSession::StopDtmfTone
       
  1700 // -----------------------------------------------------------------------------
       
  1701 //
       
  1702 void CLcVtSession::StopDtmfTone()
       
  1703     {
       
  1704     // should be called only through current application state
       
  1705     if ( iDtmfTone() )
       
  1706         {
       
  1707         __VTPRINT( DEBUG_GEN, "CLcVtSession.DTMF.STOP" )
       
  1708         (void) Execute( KVtEngStopDtmfTone, NULL );
       
  1709         iDtmfTone = 0;
       
  1710         }
       
  1711     }
       
  1712 #endif
       
  1713 // -----------------------------------------------------------------------------
       
  1714 // CLcVtSession::SetCallIdL
       
  1715 // -----------------------------------------------------------------------------
       
  1716 //
       
  1717 void CLcVtSession::SetCallIdL( const TInt aCallId )
       
  1718     {
       
  1719     }
       
  1720 
       
  1721 // -----------------------------------------------------------------------------
       
  1722 // CLcVtSession::SetCallNameL
       
  1723 // -----------------------------------------------------------------------------
       
  1724 //
       
  1725 TBool CLcVtSession::SetCallNameL( const TDesC& aName )
       
  1726     {
       
  1727     HBufC* name = aName.AllocL();
       
  1728     delete iRemoteDisplayName;
       
  1729     iRemoteDisplayName = name;
       
  1730     return ETrue;
       
  1731     }
       
  1732 
       
  1733 // -----------------------------------------------------------------------------
       
  1734 // CLcVtSession::SetCallNameL
       
  1735 // -----------------------------------------------------------------------------
       
  1736 //
       
  1737 void CLcVtSession::SetCallNumberL( const TDesC& aNumber )
       
  1738     {
       
  1739     HBufC* number = aNumber.AllocL();
       
  1740     delete iRemoteDetails;
       
  1741     iRemoteDetails = number;
       
  1742     }
       
  1743 
       
  1744 
       
  1745 // -----------------------------------------------------------------------------
       
  1746 // CLcVtSession::StartShutdown
       
  1747 // -----------------------------------------------------------------------------
       
  1748 //
       
  1749 void CLcVtSession::StartShutdown()
       
  1750     {
       
  1751     __VTPRINTENTER( "CLcVtSession.StartShutdown" )
       
  1752     iSessionState = EClosing;
       
  1753     if ( iObserver != NULL )
       
  1754         {
       
  1755         iObserver->StateChanged( *this ); 
       
  1756         }
       
  1757     //iUiProvider->BlockUi(ETrue);
       
  1758     __VTPRINTEXIT( "CLcVtSession.StartShutdown" )
       
  1759     }
       
  1760 
       
  1761 // -----------------------------------------------------------------------------
       
  1762 // CLcVtSession::NumberSource
       
  1763 // -----------------------------------------------------------------------------
       
  1764 //
       
  1765 TDesC* CLcVtSession::NumberSource() const
       
  1766     {
       
  1767     return NULL;
       
  1768     }
       
  1769 
       
  1770 
       
  1771 // -----------------------------------------------------------------------------
       
  1772 // CLcVtSession::RefreshL
       
  1773 // -----------------------------------------------------------------------------
       
  1774 //
       
  1775 void CLcVtSession::RefreshL( const TInt aRefreshFlags )
       
  1776     {
       
  1777     }
       
  1778 
       
  1779 
       
  1780 // -----------------------------------------------------------------------------
       
  1781 // CLcVtSession::RefreshStatesL
       
  1782 // -----------------------------------------------------------------------------
       
  1783 //
       
  1784 void CLcVtSession::RefreshStatesL()
       
  1785     {
       
  1786     __VTPRINTENTER( "CLcVtSession.RefreshStatesL" )
       
  1787     // If transaction (set of commands) is pending refresh in delayed until
       
  1788     // all of them are processed.
       
  1789     __VTPRINTEXIT( "CLcVtSession.RefreshStatesL" )
       
  1790     }
       
  1791 
       
  1792 #if 0
       
  1793 // -----------------------------------------------------------------------------
       
  1794 // CLcVtSession::HandleLayoutChanged
       
  1795 // -----------------------------------------------------------------------------
       
  1796 //
       
  1797 TInt CLcVtSession::HandleLayoutChanged()
       
  1798     {
       
  1799     __VTPRINTENTER( "CLcVtSession.HandleLayoutChanged" )
       
  1800     iLayoutChangeCallback->CallBack();
       
  1801     __VTPRINTEXIT( "CLcVtSession.HandleLayoutChanged" )
       
  1802     return KErrNone;
       
  1803     }
       
  1804 
       
  1805 
       
  1806 // -----------------------------------------------------------------------------
       
  1807 // CLcVtSession::DelayedHandleLayoutChanged
       
  1808 // -----------------------------------------------------------------------------
       
  1809 //
       
  1810 TInt CLcVtSession::DelayedHandleLayoutChanged( TAny* aPtr )
       
  1811     {
       
  1812     __VTPRINTENTER( "CLcVtSession.DelayedHandleLayoutChanged" )
       
  1813     CLcVtSession* self = reinterpret_cast< CLcVtSession* > ( aPtr );
       
  1814     //self->iUiStates->SetDisableBlindSetting( ETrue );
       
  1815     TRAPD( err, self->HandleLayoutChangedL() );
       
  1816     //self->iUiStates->SetDisableBlindSetting( EFalse );
       
  1817     //self->RefreshBlind();
       
  1818     __VTPRINTENTER( "CLcVtSession.DelayedHandleLayoutChanged" )
       
  1819     return err;
       
  1820     }
       
  1821 
       
  1822 // -----------------------------------------------------------------------------
       
  1823 // CLcVtSession::HandleLayoutChangedL
       
  1824 // -----------------------------------------------------------------------------
       
  1825 //
       
  1826 void CLcVtSession::HandleLayoutChangedL()
       
  1827     {
       
  1828     __VTPRINTENTER( "CLcVtSession.LayoutChg" )
       
  1829     
       
  1830     if ( iState )
       
  1831     {
       
  1832     iState->HandleLayoutChangedL();
       
  1833     }
       
  1834     
       
  1835     /*
       
  1836     if ( !iAllowVideoDlgShowed )
       
  1837         {
       
  1838         if ( iState )
       
  1839             {
       
  1840             iState->HandleLayoutChangedL();
       
  1841             }
       
  1842         }
       
  1843     else
       
  1844         {
       
  1845         iUiStates->SetLayoutChangeNeeded( EFalse );
       
  1846         DoHandleLayoutChangedL();
       
  1847         }
       
  1848         */
       
  1849     __VTPRINTEXIT( "CLcVtSession.LayoutChg" )
       
  1850     }
       
  1851 
       
  1852 // -----------------------------------------------------------------------------
       
  1853 // CLcVtSession::DoHandleLayoutChangedL
       
  1854 // -----------------------------------------------------------------------------
       
  1855 //
       
  1856 void CLcVtSession::DoHandleLayoutChangedL()
       
  1857     {
       
  1858     __VTPRINTENTER( "CLcVtSession.DoLayoutChg" )
       
  1859     
       
  1860     // Fully update rendering parameters
       
  1861     UpdateRenderingParametersL();
       
  1862     // Notify engine about layout change
       
  1863     //iLayoutChg = ETrue;
       
  1864     TRAPD( error, ExecuteCmdL( KVtEngHandleLayoutChange ) );
       
  1865     //iLayoutChg = EFalse;
       
  1866 
       
  1867     // Not ready error is allowed to happen (e.g. when sharing)
       
  1868     if ( error && ( error != KErrNotReady ) )
       
  1869         {
       
  1870         User::Leave( error );
       
  1871         }
       
  1872     else
       
  1873         {
       
  1874         __VTPRINT( DEBUG_GEN,
       
  1875             "CLcVtSession.DoLayoutChg KVtEngHandleLayoutChange == KErrNotReady (ok)" )
       
  1876         }
       
  1877         
       
  1878     __VTPRINTEXIT( "CLcVtSession.DoLayoutChg" )
       
  1879     }
       
  1880 #endif
       
  1881 
       
  1882 // -----------------------------------------------------------------------------
       
  1883 // CLcVtSession::UpdateRenderingParametersL
       
  1884 // -----------------------------------------------------------------------------
       
  1885 //
       
  1886 #ifdef NGA_VIDEO_RENDER
       
  1887 
       
  1888 void CLcVtSession::UpdateRenderingParametersL()
       
  1889     {
       
  1890     __VTPRINTENTER( "CLcVtSession.UpdateRenderingParametersL" )
       
  1891     
       
  1892     iRwGroup->SetOrdinalPosition( 1 , ECoeWinPriorityNormal );
       
  1893     
       
  1894     TRect RMRect = RemoteVideoPlayer()->LcWindow()->LcWindowRect();
       
  1895     iRemoteVideoWindow->SetExtent( RMRect.iTl, RMRect.Size() ); 
       
  1896     iRemoteVideoWindow->SetOrdinalPosition( 1 , ECoeWinPriorityNeverAtFront );
       
  1897     iRemoteVideoWindow->SetTransparencyAlphaChannel();
       
  1898     
       
  1899     __VTPRINT2( DEBUG_MEDIA , "    RemoteVideoPlayer.RMRect.iTl.iX: %d", RMRect.iTl.iX )
       
  1900     __VTPRINT2( DEBUG_MEDIA , "    RemoteVideoPlayer.RMRect.iTl.iY: %d", RMRect.iTl.iY )
       
  1901     __VTPRINT2( DEBUG_MEDIA , "    RemoteVideoPlayer.RMRect.iWidth: %d", RMRect.Width() )
       
  1902     __VTPRINT2( DEBUG_MEDIA , "    RemoteVideoPlayer.RMRect.iHeight: %d", RMRect.Height() )    
       
  1903     
       
  1904     
       
  1905     TRect VFRect = LocalVideoPlayer()->LcWindow()->LcWindowRect();
       
  1906     iLocalVideoWindow->SetExtent( VFRect.iTl, VFRect.Size() );
       
  1907     iLocalVideoWindow->SetOrdinalPosition( 1, ECoeWinPriorityNeverAtFront );
       
  1908     iLocalVideoWindow->SetTransparencyAlphaChannel();
       
  1909     
       
  1910     __VTPRINT2( DEBUG_MEDIA , "    LocalVideoPlayer.VFRect.iTl.iX: %d", VFRect.iTl.iX )
       
  1911     __VTPRINT2( DEBUG_MEDIA , "    LocalVideoPlayer.VFRect.iTl.iY: %d", VFRect.iTl.iY )
       
  1912     __VTPRINT2( DEBUG_MEDIA , "    LocalVideoPlayer.VFRect.iWidth: %d", VFRect.Width() )
       
  1913     __VTPRINT2( DEBUG_MEDIA , "    LocalVideoPlayer.VFRect.iHeight: %d", VFRect.Height() )    
       
  1914     
       
  1915     iRwSession.Flush();    
       
  1916 
       
  1917     __VTPRINTEXIT( "CLcVtSession.UpdateRenderingParametersL" )
       
  1918     
       
  1919     }
       
  1920 
       
  1921 
       
  1922 #else
       
  1923 
       
  1924 void CLcVtSession::UpdateRenderingParametersL()
       
  1925     {
       
  1926     
       
  1927     __VTPRINTENTER( "CLcVtSession.UpdateRenderingParametersL" )
       
  1928     
       
  1929     MVtEngMedia& media = iModel->Media();
       
  1930     const TBool viewFinderStarted =
       
  1931         media.RenderingStarted( MVtEngMedia::EMediaOutgoing );
       
  1932     const TBool remoteRenderStarted =
       
  1933         media.RenderingStarted( MVtEngMedia::EMediaIncoming );
       
  1934 
       
  1935     // Stop viewfinder & remote render.
       
  1936     if( viewFinderStarted )
       
  1937         {
       
  1938         ExecuteCmdL( KVtEngStopViewFinder );
       
  1939         }
       
  1940     ExecuteCmdL( KVtEngStopRenderRemote );
       
  1941 
       
  1942     TRect VFRect = LocalVideoPlayer()->LcWindow()->LcWindowRect();    
       
  1943     TSize size (VFRect.Size());  
       
  1944     
       
  1945     TVtEngRenderingOptions configViewfinder(*iEventObserver,size);
       
  1946 
       
  1947     ExecuteCmdL( KVtEngPrepareViewFinder, configViewfinder );
       
  1948 
       
  1949     // Prepare remote render.
       
  1950     TRect RMRect = RemoteVideoPlayer()->LcWindow()->LcWindowRect();    
       
  1951     const TSize KRMsize( RMRect.Size());
       
  1952     TRect screen( KRMsize );
       
  1953     TRect clip( KRMsize );
       
  1954     const TPoint KRMcordinate( RMRect.iTl.iX,  RMRect.iTl.iY );   
       
  1955     
       
  1956     TVtEngRenderingOptionsDP configRemoteRender(*iEventObserver, *iWsSession ,*iWsSessionScreenDev, *iMainWindow, screen, clip, KRMcordinate );  
       
  1957 
       
  1958     TRAPD ( err, ExecuteCmdL(
       
  1959         KVtEngPrepareRemoteRenderDP,
       
  1960         configRemoteRender ) );    
       
  1961     
       
  1962      if ( err != KErrNone )
       
  1963         {
       
  1964         if ( viewFinderStarted )
       
  1965             {
       
  1966             // Start viewfinder.
       
  1967             ExecuteCmdL( KVtEngStartViewFinder );
       
  1968             }
       
  1969         User::Leave ( err );
       
  1970         } 
       
  1971 
       
  1972     // Start remote render.
       
  1973     TRAP_IGNORE( ExecuteCmdL( KVtEngStartRenderRemote ) );
       
  1974 
       
  1975     if ( viewFinderStarted )
       
  1976         {
       
  1977         // Start viewfinder.
       
  1978         ExecuteCmdL( KVtEngStartViewFinder );
       
  1979         }
       
  1980 
       
  1981     __VTPRINTEXIT( "CLcVtSession.UpdateRenderingParametersL" )
       
  1982     
       
  1983     }
       
  1984 
       
  1985 #endif
       
  1986 
       
  1987 // -----------------------------------------------------------------------------
       
  1988 // CLcVtSession::HandleEngineResetL
       
  1989 // -----------------------------------------------------------------------------
       
  1990 //
       
  1991 void CLcVtSession::HandleEngineResetL()
       
  1992     {
       
  1993     __VTPRINTENTER( "CLcVtSession.HandleEngineResetL" )
       
  1994     if ( iShutdownRequest )
       
  1995         {
       
  1996         __VTPRINT( DEBUG_GEN, "  CLcVtSession.HandleEngineResetL shutdown" )
       
  1997         User::RequestComplete( iShutdownRequest, KErrNone );
       
  1998         iShutdownRequest = NULL;
       
  1999         }
       
  2000     __VTPRINTEXIT( "CLcVtSession.HandleEngineResetL" )
       
  2001     }
       
  2002 
       
  2003 
       
  2004 // -----------------------------------------------------------------------------
       
  2005 // CLcVtSession::HandleShutdownReady
       
  2006 // -----------------------------------------------------------------------------
       
  2007 //
       
  2008 void CLcVtSession::HandleShutdownReady()
       
  2009     {
       
  2010     __VTPRINTENTER( "CLcVtSession.HandleShutdownReady" )
       
  2011 
       
  2012     if(iAsyncCallback->IsActive())
       
  2013         {
       
  2014         iAsyncCallback->Cancel();
       
  2015         }
       
  2016 
       
  2017     iAsyncCallback->Set(
       
  2018         TCallBack( &DoExit, this ) );
       
  2019     iAsyncCallback->CallBack();
       
  2020     __VTPRINTEXIT( "CLcVtSession.HandleShutdownReady" )
       
  2021     }
       
  2022 
       
  2023 
       
  2024 // -----------------------------------------------------------------------------
       
  2025 // CLcVtSession::DoExit
       
  2026 // -----------------------------------------------------------------------------
       
  2027 //
       
  2028 TInt CLcVtSession::DoExit( TAny* aSession )
       
  2029     {
       
  2030     __VTPRINTENTER( "CLcVtSession.DoExit" )
       
  2031     CLcVtSession* self = static_cast< CLcVtSession* >( aSession );
       
  2032     self->iAsyncCallback->Cancel();
       
  2033     // Before exiting ensure there are no pending actions.
       
  2034     self->ActiveExecInitCancel( 0 );  
       
  2035     self->CloseApp();    
       
  2036     __VTPRINTEXIT( "CLcVtSession.DoExit" )
       
  2037     return KErrNone;
       
  2038     }
       
  2039 
       
  2040 // -----------------------------------------------------------------------------
       
  2041 // CLcVtSession::CloseApp
       
  2042 // -----------------------------------------------------------------------------
       
  2043 //
       
  2044 void CLcVtSession::CloseApp()
       
  2045     {
       
  2046     __VTPRINTENTER( "CLcVtSession.CloseApp" )
       
  2047     //iUiProvider->BlockUi(EFalse);
       
  2048 #if 0
       
  2049     if(iEventObserver)
       
  2050         {
       
  2051          delete iEventObserver;
       
  2052          iEventObserver = NULL;
       
  2053         }
       
  2054 #endif
       
  2055     iSessionState = EClosed;
       
  2056     iObserver->StateChanged( *this ); 
       
  2057     __VTPRINTEXIT( "CLcVtSession.CloseApp" )
       
  2058     }
       
  2059 
       
  2060 // Implementation of CLcVtSession::CEventObserver
       
  2061 
       
  2062 // -----------------------------------------------------------------------------
       
  2063 // CLcVtSession::CEventObserver::CEventObserver
       
  2064 // -----------------------------------------------------------------------------
       
  2065 //
       
  2066 CLcVtSession::CEventObserver::CEventObserver( CLcVtSession& aSession )
       
  2067     :iSession(aSession),
       
  2068     iCommandObservers( KLcVtCommandObserverArrayGranularity )
       
  2069     {        
       
  2070     }
       
  2071 
       
  2072 // -----------------------------------------------------------------------------
       
  2073 // CLcVtSession::CEventObserver::ConstructL
       
  2074 // -----------------------------------------------------------------------------
       
  2075 //
       
  2076 void CLcVtSession::CEventObserver::ConstructL()
       
  2077     {                
       
  2078     }
       
  2079 
       
  2080 // -----------------------------------------------------------------------------
       
  2081 // CLcVtSession::CEventObserver::NewL
       
  2082 // -----------------------------------------------------------------------------
       
  2083 //
       
  2084 CLcVtSession::CEventObserver* CLcVtSession::CEventObserver::NewL( CLcVtSession& aSession )
       
  2085    {
       
  2086    CEventObserver* self = new ( ELeave ) CEventObserver(aSession  );
       
  2087    CleanupStack::PushL( self );
       
  2088    self->ConstructL();
       
  2089    CleanupStack::Pop( self );
       
  2090    return self;
       
  2091    }
       
  2092 
       
  2093 // -----------------------------------------------------------------------------
       
  2094 // CLcVtSession::CEventObserver::~CEventObserver
       
  2095 // -----------------------------------------------------------------------------
       
  2096 //
       
  2097 CLcVtSession::CEventObserver::~CEventObserver()
       
  2098    {
       
  2099    iCommandObservers.Close();        
       
  2100    }
       
  2101 
       
  2102 // -----------------------------------------------------------------------------
       
  2103 // CLcVtSession::CEventObserver::AddObserverL
       
  2104 // -----------------------------------------------------------------------------
       
  2105 //
       
  2106 void CLcVtSession::CEventObserver::AddObserverL(
       
  2107        MVtEngCommandObserver& aObserver )
       
  2108     {
       
  2109     User::LeaveIfError(
       
  2110     iCommandObservers.Append( &aObserver ) );
       
  2111     }
       
  2112 
       
  2113 // -----------------------------------------------------------------------------
       
  2114 // CLcVtSession::CEventObserver::RemoveObserver
       
  2115 // -----------------------------------------------------------------------------
       
  2116 //
       
  2117 void CLcVtSession::CEventObserver::RemoveObserver(
       
  2118         MVtEngCommandObserver& aObserver )
       
  2119     {
       
  2120     const TInt pos = iCommandObservers.Find( &aObserver );
       
  2121     if ( pos != KErrNotFound )
       
  2122         {
       
  2123         if ( !iInCommandPerformed )
       
  2124             {
       
  2125             iCommandObservers.Remove( pos );
       
  2126             }
       
  2127         else
       
  2128             {
       
  2129             iCommandObservers[ pos ] = NULL;
       
  2130             }
       
  2131         }
       
  2132     }
       
  2133     
       
  2134 
       
  2135 void CLcVtSession::CEventObserver::HandleVtEventL( TInt aEvent )
       
  2136     {
       
  2137     __VTPRINTENTER( "CEventObserver.HandleVtEventL" )
       
  2138     __VTPRINT2( DEBUG_GEN, "CEventObserver.HandleVtEventL event=%d ",aEvent );
       
  2139     
       
  2140     /** Allow application state to handle event first. It may also deny further
       
  2141       * handling by indicating the event was handled */
       
  2142     if ( iSession.iState &&
       
  2143             iSession.iState->HandleVtEventL( aEvent )
       
  2144             == TLcVtStateBase::EEventHandled )
       
  2145         {
       
  2146         __VTPRINTEXITR( "CEventObserver.HandleVtEventL %d", 0 )
       
  2147         return;
       
  2148         }
       
  2149     
       
  2150     iSession.iLcVtStates->Update();
       
  2151     
       
  2152     iSession.iObserver->Updated(*(iSession.iLocalVideoPlayer));
       
  2153     iSession.iObserver->Updated(*(iSession.iRemoteVideoPlayer));    
       
  2154     
       
  2155     __VTPRINTEXIT( "CEventObserver.HandleVtEventL" )
       
  2156     }
       
  2157         
       
  2158 void CLcVtSession::CEventObserver::HandleVTCommandPerformedL(
       
  2159         TVtEngCommandId aCommand,
       
  2160         const TInt aError )
       
  2161     {         
       
  2162      __VTPRINTENTER( "CEventObserver.HandleVTCommandPerformedL" )
       
  2163      __VTPRINT3( DEBUG_GEN, "CEventObserver.HandleVTCommandPerformedL cmd=%d , result=%d",aCommand, aError );   
       
  2164      
       
  2165      if ( iSession.iState &&
       
  2166              iSession.iState->HandleVTCommandPerformedL( aCommand, aError ) ==
       
  2167           TLcVtStateBase::EEventHandled )
       
  2168          {
       
  2169          // state didn't allow further processing of command completion
       
  2170          __VTPRINTEXITR( "CEventObserver.HandleVTCommandPerformedL %d", 0 )
       
  2171          return;
       
  2172          }
       
  2173      
       
  2174      iSession.RefreshStatesL();
       
  2175 
       
  2176      iSession.iLcVtStates->Update();
       
  2177      
       
  2178      const TInt count = iCommandObservers.Count();
       
  2179      TInt nullPosition = KErrNotFound;
       
  2180 
       
  2181      iInCommandPerformed = ETrue;
       
  2182 
       
  2183      // iInCommandPerformed equals ETrue while inside the following loop;
       
  2184      // Exceptions must not be raised.
       
  2185      for ( TInt index = 0; index < count; index++ )
       
  2186          {
       
  2187          MVtEngCommandObserver* obs = iCommandObservers[ index ];
       
  2188          if ( obs )
       
  2189              {
       
  2190              TRAP_IGNORE( obs->HandleVTCommandPerformedL( aCommand, aError ) );
       
  2191              }
       
  2192          else
       
  2193              {
       
  2194              // We store only one position; eventually all NULL elements of the
       
  2195              // array will be removed.
       
  2196              nullPosition = index;
       
  2197              }
       
  2198          }
       
  2199      iInCommandPerformed = EFalse;
       
  2200 
       
  2201      if ( nullPosition != KErrNotFound )
       
  2202          {
       
  2203          iCommandObservers.Remove( nullPosition );
       
  2204          }
       
  2205 
       
  2206      
       
  2207      // Specific handling of some commands:
       
  2208      if ( aCommand == KVtEngResetEngine ) // Engine has been reset
       
  2209          {
       
  2210          //__ASSERT_ALWAYS( !aError, VtUiPanic::Panic( EVtUiPanicResetFailed ) );
       
  2211          iSession.HandleEngineResetL();
       
  2212          }
       
  2213          
       
  2214      
       
  2215      __VTPRINTEXITR( "CEventObserver.HandleVTCommandPerformedL %d", 1 )
       
  2216                   
       
  2217     }
       
  2218 
       
  2219 #ifndef NGA_VIDEO_RENDER
       
  2220 void CLcVtSession::CEventObserver::vtHandleFrameL(
       
  2221          TFrameType aType,
       
  2222          CFbsBitmap* aBitmap )
       
  2223     {
       
  2224     iSession.vtHandleFrameL( aBitmap);
       
  2225     }
       
  2226 
       
  2227 void CLcVtSession::CEventObserver::vtSetFrame(
       
  2228         TFrameType aType,
       
  2229         CFbsBitmap* aBitmap )
       
  2230     {
       
  2231     }
       
  2232 #endif
       
  2233 
       
  2234 TBool CLcVtSession::IsFeatureSupported( CLcEngine::TLcFeature aLcFeature )
       
  2235 {
       
  2236     __VTPRINT2( DEBUG_GEN, "CLcVtSession.IsFeatureSupported feature=%d", aLcFeature)
       
  2237     TBool flag = EFalse;
       
  2238 
       
  2239     switch ( aLcFeature )
       
  2240         {
       
  2241         case CLcEngine::ELcSendVideoQuery:
       
  2242             {
       
  2243             //MO call: return false; MT call: return true if key = Ask first, return false if key = No or Yes.
       
  2244             MVtEngSessionInfo::TDirection direction;
       
  2245             if ( iModel->Session().GetDirection( direction ) != KErrNone )
       
  2246                 {
       
  2247                 direction = MVtEngSessionInfo::EDirectionMT;
       
  2248                 }
       
  2249             __VTPRINT2( DEBUG_GEN, "CLcVtSession.IsFeatureSupported direction=%d", direction )
       
  2250 
       
  2251             if ( direction == MVtEngSessionInfo::EDirectionMT 
       
  2252                  && VideoSendingKey == KAllwaysQuery )
       
  2253                 {
       
  2254                 flag = ETrue;
       
  2255                 }
       
  2256             }
       
  2257             break;
       
  2258 
       
  2259         default:
       
  2260             break;
       
  2261         }
       
  2262 
       
  2263     // return feature not supported if not handled
       
  2264     return flag;
       
  2265 }
       
  2266 
       
  2267 // End of file
       
  2268 
       
  2269 /*
       
  2270  * 
       
  2271 // -----------------------------------------------------------------------------
       
  2272 // CLcVtSession::UpdateLocalVideoRenderParamL
       
  2273 // -----------------------------------------------------------------------------
       
  2274 //
       
  2275 void CLcVtSession::UpdateLocalVideoRenderParamL()
       
  2276     { 
       
  2277     __VTPRINTENTER( "CLcVtSession.UpdateLocalVideoRenderParamL" )
       
  2278     
       
  2279     if(iLcVtStates->ExecState() != TLcVtStates::EExecStateRunning )
       
  2280         {
       
  2281         __VTPRINTEXIT( "CLcVtSession.UpdateLocalVideoRenderParamL -- not running state" )
       
  2282         return;
       
  2283         }
       
  2284     
       
  2285     MVtEngMedia& media = Model().Media();                
       
  2286     const TBool viewFinderStarted =
       
  2287         media.RenderingStarted( MVtEngMedia::EMediaOutgoing );
       
  2288     
       
  2289     if( viewFinderStarted )
       
  2290         {
       
  2291         ExecuteCmdL( KVtEngStopViewFinder );
       
  2292         }  
       
  2293     
       
  2294     TRect VFRect = LocalVideoPlayer()->LcWindow()->LcWindowRect();    
       
  2295     TSize size (VFRect.Size());  
       
  2296     
       
  2297     TVtEngRenderingOptions configViewfinder(*iEventObserver,size);
       
  2298 
       
  2299     ExecuteCmdL( KVtEngPrepareViewFinder, configViewfinder );
       
  2300     
       
  2301     if ( viewFinderStarted )
       
  2302         {
       
  2303         // Start viewfinder.
       
  2304         ExecuteCmdL( KVtEngStartViewFinder );
       
  2305         }    
       
  2306     
       
  2307     __VTPRINTEXIT( "CLcVtSession.UpdateLocalVideoRenderParamL" )    
       
  2308     }
       
  2309 
       
  2310 // -----------------------------------------------------------------------------
       
  2311 // CLcVtSession::UpdateRemoteVideoRenderParamL
       
  2312 // -----------------------------------------------------------------------------
       
  2313 //
       
  2314 void CLcVtSession::UpdateRemoteVideoRenderParamL()
       
  2315     {    
       
  2316     __VTPRINTENTER( "CLcVtSession.UpdateRemoteVideoRenderParamL" )
       
  2317     
       
  2318     if(iLcVtStates->ExecState() != TLcVtStates::EExecStateRunning )
       
  2319         {
       
  2320         __VTPRINTEXIT( "CLcVtSession.UpdateRemoteVideoRenderParamL -- not running state" )
       
  2321         return;
       
  2322         }    
       
  2323     
       
  2324     MVtEngMedia& media = Model().Media();
       
  2325     const TBool remoteRenderStarted =
       
  2326         media.RenderingStarted( MVtEngMedia::EMediaIncoming );
       
  2327     
       
  2328     ExecuteCmdL( KVtEngStopRenderRemote );
       
  2329     
       
  2330     TRect RMRect = RemoteVideoPlayer()->LcWindow()->LcWindowRect();    
       
  2331     const TSize KRMsize( RMRect.Size());
       
  2332     TRect screen( KRMsize );
       
  2333     TRect clip( KRMsize );
       
  2334     const TPoint KRMcordinate( RMRect.iTl.iX,  RMRect.iTl.iY );    
       
  2335     
       
  2336     __VTPRINT2( DEBUG_MEDIA , "    RMRect.iTl.iX: %d", RMRect.iTl.iX)
       
  2337     __VTPRINT2( DEBUG_MEDIA , "    RMRect.iTl.iY: %d", RMRect.iTl.iY )
       
  2338     __VTPRINT2( DEBUG_MEDIA , "    RMRect.iWidth: %d", RMRect.Width() )
       
  2339     __VTPRINT2( DEBUG_MEDIA , "    RMRect.iHeight: %d", RMRect.Height() )    
       
  2340     
       
  2341     TVtEngRenderingOptionsDP configRemoteRender(*iEventObserver, *iWsSession ,*iWsSessionScreenDev, *iMainWindow, screen, clip, KRMcordinate );  
       
  2342 
       
  2343     ExecuteCmdL(
       
  2344         KVtEngPrepareRemoteRenderDP,
       
  2345         configRemoteRender );    
       
  2346     
       
  2347     TRAP_IGNORE( ExecuteCmdL( KVtEngStartRenderRemote ) );
       
  2348     
       
  2349     __VTPRINTEXIT( "CLcVtSession.UpdateRemoteVideoRenderParamL" )
       
  2350 
       
  2351     }
       
  2352 
       
  2353 // -----------------------------------------------------------------------------
       
  2354 // CLcVtSession::LayoutChangedL
       
  2355 // -----------------------------------------------------------------------------
       
  2356 //
       
  2357 void CLcVtSession::LayoutChangedL()
       
  2358     {    
       
  2359     __VTPRINTENTER( "CLcVtSession.LayoutChangedL" )
       
  2360     
       
  2361     if(iLcVtStates->ExecState() != TLcVtStates::EExecStateRunning )
       
  2362         {
       
  2363         __VTPRINTEXIT( "CLcVtSession.LayoutChangedL -- not running state" )
       
  2364         return;
       
  2365         }    
       
  2366     
       
  2367     TRAPD( error, ExecuteCmdL( KVtEngHandleLayoutChange ) );
       
  2368     
       
  2369     __VTPRINTEXIT( "CLcVtSession.LayoutChangedL" )
       
  2370     }
       
  2371  
       
  2372  */