mmsharing/mmshui/src/musuilivesharingcontroller.cpp
branchRCL_3
changeset 33 bc78a40cd63c
child 41 755f0370535b
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Application's UI class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "musuilivesharingcontroller.h"
       
    21 #include "musuicallbackservice.h"
       
    22 #include "musuieventobserver.h"
       
    23 #include "musuisharingobserver.h"
       
    24 #include "musuisendobserver.h"
       
    25 #include "musuilivesharingobserver.h"
       
    26 #include "musuidialogutil.h"
       
    27 #include "musenglivesession.h"
       
    28 #include "musuiresourcehandler.h"
       
    29 #include "musui.hrh"
       
    30 #include "mussettings.h"
       
    31 #include "mussettingskeys.h"
       
    32 #include "muslogger.h" // debug logging
       
    33 #include "musuigeneralview.h"
       
    34 #include "musuiactivetimer.h"
       
    35 
       
    36 #include <musui.rsg>
       
    37 #include <avkon.hrh>
       
    38 #include <StringLoader.h>
       
    39 
       
    40 #include <AknUtils.h>
       
    41 
       
    42 using namespace NMusResourceApi;
       
    43 using namespace MusSettingsKeys;
       
    44 
       
    45 const TInt KMusUiPauseResumeGuardPeriod = 500000;
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CMusUiLiveSharingController* CMusUiLiveSharingController::NewL(
       
    52                         MMusUiEventObserver& aEventObserver,
       
    53                         MMusUiSharingObserver& aSharingObserver,
       
    54 	                    MMusUiSendObserver& aSendObserver,
       
    55                         MMusUiLiveSharingObserver& aLiveObserver,
       
    56                         const TRect& aRect )
       
    57     {
       
    58     CMusUiLiveSharingController* self =
       
    59              new( ELeave ) CMusUiLiveSharingController( aEventObserver,
       
    60                                                         aSharingObserver,
       
    61                                                         aSendObserver,
       
    62                                                         aLiveObserver );
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL( aRect );
       
    65     CleanupStack::Pop( self );
       
    66     return self;
       
    67     }
       
    68 
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 CMusUiLiveSharingController::~CMusUiLiveSharingController()
       
    75     {
       
    76     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::~CMusUiLiveSharingController" );
       
    77     delete iSession;
       
    78     delete iPauseResumeGuardTimer;
       
    79     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::~CMusUiLiveSharingController" );
       
    80     }
       
    81 
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 CMusUiLiveSharingController::CMusUiLiveSharingController(
       
    88                             MMusUiEventObserver& aEventObserver,    
       
    89                         	MMusUiSharingObserver& aSharingObserver,
       
    90 	                        MMusUiSendObserver& aSendObserver,
       
    91 	                        MMusUiLiveSharingObserver& aLiveObserver )
       
    92 	: CMusUiSendController( aEventObserver, aSharingObserver, aSendObserver ),
       
    93 	  iLiveObserver( aLiveObserver )
       
    94     {
       
    95     }
       
    96     
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void CMusUiLiveSharingController::ConstructL( const TRect& aRect )
       
   103     {
       
   104     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::ConstructL" );
       
   105     
       
   106     CMusUiSendController::ConstructL(); // Base class construction
       
   107 
       
   108     iSession = CMusEngLiveSession::NewL( VideoFileNameL(),
       
   109                                          aRect,
       
   110                                          *this,
       
   111                                          *this,
       
   112                                          *this,
       
   113                                          iSipProfileId );
       
   114 
       
   115     iSession->SetAudioRoutingObserver( this );
       
   116     iSession->SetVolumeChangeObserver( this );
       
   117         
       
   118     if ( iSession->AudioRoutingCanBeChanged() && !iSession->IsAudioRoutingHeadset() )
       
   119         {
       
   120         iSession->EnableLoudspeakerL( ELoudspeakerEnabled, ETrue );
       
   121         }
       
   122         
       
   123     if ( iVideoCodec && iVideoCodec->Length() > 0 )
       
   124         {
       
   125         iSession->SetSupportedVideoCodecListL( *iVideoCodec );
       
   126         }
       
   127     
       
   128     iPauseResumeGuardTimer = CMusUiActiveTimer::NewL( NULL );
       
   129         
       
   130     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::ConstructL" );
       
   131     }
       
   132     
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void CMusUiLiveSharingController::PlayL()
       
   139     {
       
   140     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::PlayL" );
       
   141     
       
   142     CMusUiSendController::PlayL();
       
   143     iEventObserver.ShowNaviPaneIconL( 
       
   144                     (!iDiskFull) ? RecordIcon() : EMusUiNaviIconRecordNot );
       
   145     
       
   146     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::PlayL" );
       
   147     }
       
   148 
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // When orientation changed , Camera instances has to be recreated inorder
       
   152 // to receive proper orientated frames.
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void CMusUiLiveSharingController::RefreshCameraOrientationL()
       
   156     {
       
   157     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::RefreshCameraOrientationL" );
       
   158 
       
   159     if ( EngineSession() ){
       
   160         EngineSession()->RefreshOrientationL();
       
   161     }
       
   162     
       
   163     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::RefreshCameraOrientationL" );
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 void CMusUiLiveSharingController::PauseL()
       
   171     {
       
   172     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::PauseL" );
       
   173     
       
   174     CMusUiSendController::PauseL();
       
   175     iEventObserver.ShowNaviPaneIconL( EMusUiNaviIconPause );
       
   176     
       
   177     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::PauseL" );
       
   178     }
       
   179 
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 //
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 void CMusUiLiveSharingController::DeleteEngineSession()
       
   186     {
       
   187     CMusUiSendController::DeleteEngineSession();
       
   188     if ( iSession && iSession->IsAudioRoutingLoudSpeaker() )
       
   189 	    {
       
   190 	    iShowDialog = ETrue; 
       
   191 	    }
       
   192     delete iSession;
       
   193     iSession = NULL;
       
   194     }
       
   195 
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 // -----------------------------------------------------------------------------
       
   200 //
       
   201 CMusEngMceOutSession* CMusUiLiveSharingController::EngineOutSession()
       
   202     {
       
   203     return iSession; // Live session is CMusEngMceOutSession
       
   204     }
       
   205 
       
   206 
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 void CMusUiLiveSharingController::InviteL( const TDesC& aRecipient )
       
   212     {
       
   213     MUS_LOG_TDESC( "mus: [MUSUI ]    -> CMusUiLiveSharingController::InviteL:",
       
   214                             aRecipient );
       
   215 
       
   216     // Registration must not be pending in this phase
       
   217     __ASSERT_ALWAYS( !iSipRegistrationPending, 
       
   218                      iEventObserver.HandleError( KErrNotReady ) );
       
   219     
       
   220     delete iAddress;
       
   221     iAddress = NULL;
       
   222     iAddress = aRecipient.AllocL();
       
   223 
       
   224     
       
   225     TRAPD( err, iSession->InviteL( aRecipient ) );
       
   226     MUS_LOG( "mus: [MUSUI ]     CMusUiLiveSharingController::InviteL: After TRAPD" );
       
   227 
       
   228     // If address is in wrong format, Manual Address Entry Dialog
       
   229     // is displayed
       
   230     if ( err != KErrNone )
       
   231         {
       
   232         // Display the error message
       
   233         DismissWaitDialog();
       
   234         if ( !ExitOccured() )
       
   235             {
       
   236             MusUiDialogUtil::ShowGlobalErrorDialogL( 
       
   237                                 R_MUS_LIVE_SHARING_VIEW_NOTE_INVITE_ERROR );
       
   238             }
       
   239         if ( ( ++iTriedInvitations < 2 )  && ( err == KErrArgument ) )
       
   240             {
       
   241             MUS_LOG( "mus: [MUSUI ]     CMusUiLiveSharingController::InviteL: iTriedInvitations < 2" );
       
   242             iManualAddressTyped = ETrue;
       
   243             iResourceHandler->RequestKeypadL( ETrue );
       
   244             iSendObserver.ManualAddressEntryL( *iRemoteSipAddressProposal );
       
   245             return;
       
   246             }
       
   247         else
       
   248             {
       
   249             MUS_LOG( "mus: [MUSUI ]     CMusUiLiveSharingController::InviteL: ++iTriedInvitations > 1" );
       
   250             HandleExitL();
       
   251             return;
       
   252             }
       
   253         }
       
   254     
       
   255     SetConnectionInitialized( ETrue );
       
   256         
       
   257     ShowInvitingWaitDialogL();
       
   258     
       
   259         
       
   260     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::InviteL" );
       
   261     }
       
   262 
       
   263 
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 // -----------------------------------------------------------------------------
       
   267 //
       
   268 void CMusUiLiveSharingController::HandleSliderValueChangeL( TInt aNewLevel )
       
   269     {
       
   270     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiLiveSharingController::HandleSliderValueChangeL(%d)",
       
   271               aNewLevel )
       
   272 
       
   273     __ASSERT_ALWAYS( !ExitOccured(), User::Leave( KErrDied ) );
       
   274     __ASSERT_ALWAYS( iConnectionEstablished, User::Leave( KErrNotReady ) );
       
   275     
       
   276     if ( iToolbarZoomSelected )
       
   277         {
       
   278         iSession->SetZoomL( aNewLevel );
       
   279         iLiveObserver.SetZoomL( iSession->CurrentZoomL() );
       
   280         }
       
   281     else
       
   282         {
       
   283         iSession->SetBrightnessL( aNewLevel );
       
   284         iLiveObserver.SetBrightnessL( iSession->CurrentBrightnessL() );
       
   285         }
       
   286     
       
   287     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::HandleSliderValueChangeL" )
       
   288     }
       
   289 
       
   290 
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 // -----------------------------------------------------------------------------
       
   295 //
       
   296 void CMusUiLiveSharingController::OfferToolbarEventL( TInt aCommand )
       
   297     {
       
   298     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiLiveSharingController::OfferToolbarEventL [%d]",
       
   299                             aCommand );
       
   300     
       
   301     iLiveObserver.SetZoomVisible( EFalse );
       
   302     iLiveObserver.SetBrightnessVisible( EFalse );
       
   303                                                     
       
   304     switch ( aCommand )
       
   305         {
       
   306         case EMusuiCmdToolbarPauseLive:
       
   307             {
       
   308             HandleCommandL( EMusuiCmdViewPause );
       
   309             HandlePauseResumeInToolbar();
       
   310             break;
       
   311             }
       
   312             
       
   313         case EMusuiCmdToolbarUnPauseLive:
       
   314             {
       
   315             HandleCommandL( EMusuiCmdViewContinue );
       
   316             HandlePauseResumeInToolbar();
       
   317             break;
       
   318             }
       
   319         case EMusuiCmdToolbarZoom:
       
   320             {
       
   321             iToolbarZoomSelected = !iToolbarZoomSelected;
       
   322             
       
   323             if ( iToolbarZoomSelected )
       
   324                 {
       
   325                 iLiveObserver.SetZoomValues( iSession->MinZoomL(), 
       
   326                                              iSession->MaxZoomL() );
       
   327                 iLiveObserver.SetZoomL( iSession->CurrentZoomL() );
       
   328                 }
       
   329             
       
   330             iLiveObserver.SetZoomVisible( iToolbarZoomSelected );
       
   331             iSharingObserver.HighlightSelectedToolbarItem( EMusuiCmdToolbarZoom );
       
   332             
       
   333             break;
       
   334             }
       
   335         case EMusuiCmdToolbarBrightness:
       
   336             {
       
   337             iToolbarBrightnessSelected = !iToolbarBrightnessSelected;
       
   338             
       
   339             if ( iToolbarBrightnessSelected )
       
   340                 {
       
   341                 MUS_LOG1( "mus: [MUSUI ]     CMusUiLiveSharingController::OfferToolbarEventL: Brightness %d",
       
   342                                 iSession->CurrentBrightnessL() );
       
   343                                 
       
   344                 iLiveObserver.SetBrightnessValues( iSession->MinBrightnessL(),
       
   345                                                    iSession->MaxBrightnessL() );
       
   346                 
       
   347                 iLiveObserver.SetBrightnessL( iSession->CurrentBrightnessL() );
       
   348                 }
       
   349             
       
   350             iLiveObserver.SetBrightnessVisible( iToolbarBrightnessSelected );
       
   351             iSharingObserver.HighlightSelectedToolbarItem( EMusuiCmdToolbarBrightness );
       
   352             
       
   353             break;
       
   354             }        
       
   355         default:    // Not live specific, let the base class handle
       
   356             {
       
   357             CMusUiEventController::OfferToolbarEventL( aCommand );
       
   358             break;
       
   359             }
       
   360         }
       
   361     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::OfferToolbarEventL" );
       
   362     }
       
   363 
       
   364 
       
   365 // -----------------------------------------------------------------------------
       
   366 //
       
   367 // -----------------------------------------------------------------------------
       
   368 //
       
   369 void CMusUiLiveSharingController::HandleCommandL( TInt aCommand )
       
   370     {
       
   371     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiLiveSharingController::HandleCommandL [%d]",
       
   372                             aCommand );
       
   373 
       
   374     __ASSERT_ALWAYS( !ExitOccured(), User::Leave( KErrDied ) );
       
   375 
       
   376     switch ( aCommand )
       
   377         {
       
   378         case EMusuiCmdViewPause:
       
   379             {            
       
   380             UserInitiatedCameraStateChangeL(EFalse);
       
   381             break;
       
   382             }
       
   383         case EMusuiCmdViewContinue:
       
   384             {
       
   385             UserInitiatedCameraStateChangeL(ETrue);
       
   386             break;
       
   387             }
       
   388 
       
   389         case EMusuiCmdViewShareVideo:
       
   390             {
       
   391             PauseL();
       
   392             // TODO: Change to video sharing
       
   393             break;
       
   394             }
       
   395         case EMusuiCmdViewShareImage:
       
   396             {
       
   397             PauseL();
       
   398             // TODO: Change to image sharing
       
   399             break;
       
   400             }
       
   401 
       
   402         case EMusuiCmdToolbarZoom:
       
   403             {
       
   404             iToolbarZoomSelected = ETrue;
       
   405             iToolbarBrightnessSelected = EFalse;
       
   406             iLiveObserver.SetZoomValues( iSession->MinZoomL(), 
       
   407                                          iSession->MaxZoomL() );
       
   408             iLiveObserver.SetZoomL( iSession->CurrentZoomL() );
       
   409             
       
   410             iLiveObserver.SetZoomVisible( iToolbarZoomSelected );
       
   411             break;
       
   412             }
       
   413         case EMusuiCmdViewMiddleSoftkeyOk:
       
   414             {
       
   415             HandleMiddleSoftkeyOkL();
       
   416             break;
       
   417             }            
       
   418 
       
   419         case EMusuiCmdViewZoom:
       
   420             {
       
   421             ZoomL();
       
   422             break;
       
   423             }
       
   424             
       
   425         case EMusuiCmdViewZoomIn:
       
   426             {
       
   427             iLiveObserver.SetZoomVisible( MUS_NO_TOOLBAR ? iZoomSelected : iToolbarZoomSelected ); 
       
   428             iSession->ZoomInL();
       
   429             iLiveObserver.SetZoomL( iSession->CurrentZoomL() );
       
   430             break;
       
   431             }
       
   432         case EMusuiCmdViewZoomOut:
       
   433             {
       
   434             iLiveObserver.SetZoomVisible( MUS_NO_TOOLBAR ? iZoomSelected : iToolbarZoomSelected ); 
       
   435             iSession->ZoomOutL();
       
   436             iLiveObserver.SetZoomL( iSession->CurrentZoomL() );
       
   437             break;
       
   438             }
       
   439 
       
   440         case EMusuiCmdToolbarBrightness:
       
   441             {
       
   442             iToolbarZoomSelected = EFalse;
       
   443             iToolbarBrightnessSelected = ETrue;
       
   444             iLiveObserver.SetBrightnessValues( iSession->MinBrightnessL(),
       
   445                                                iSession->MaxBrightnessL() );
       
   446             iLiveObserver.SetBrightnessL( iSession->CurrentBrightnessL() );
       
   447             
       
   448             iLiveObserver.SetBrightnessVisible( iToolbarBrightnessSelected );
       
   449             break;
       
   450             }
       
   451         case EMusuiCmdViewBrightness:
       
   452             {
       
   453             BrightnessL();
       
   454             break;
       
   455             }            
       
   456             
       
   457         case EMusuiCmdViewIncreaseBrightness:
       
   458             {
       
   459 			iLiveObserver.SetBrightnessVisible( MUS_NO_TOOLBAR ? iBrightnessSelected : iToolbarBrightnessSelected ); 
       
   460             iSession->IncreaseBrightnessL();
       
   461             iLiveObserver.SetBrightnessL( iSession->CurrentBrightnessL() );
       
   462             break;
       
   463             }
       
   464         case EMusuiCmdViewDecreaseBrightness:
       
   465             {
       
   466 			iLiveObserver.SetBrightnessVisible( MUS_NO_TOOLBAR ? iBrightnessSelected : iToolbarBrightnessSelected ); 
       
   467             iSession->DecreaseBrightnessL();
       
   468             iLiveObserver.SetBrightnessL( iSession->CurrentBrightnessL() );
       
   469             break;
       
   470             }            
       
   471 
       
   472         case EMusuiCmdRecord:
       
   473             {
       
   474             // Show toolbar hidden while showing options menu
       
   475             iEventObserver.SetToolbarVisibility( ETrue );
       
   476             
       
   477             if ( iDiskFull )
       
   478             	{
       
   479             	DiskFull();
       
   480             	}
       
   481             else
       
   482             	{
       
   483 	            iSession->RecordL( ETrue );
       
   484 	            iEventObserver.ShowNaviPaneIconL( EMusUiNaviIconRecord );
       
   485             	}
       
   486             break;
       
   487             }
       
   488         case EMusuiCmdStopRecording:
       
   489             {
       
   490             // Show toolbar hidden while showing options menu
       
   491             iEventObserver.SetToolbarVisibility( ETrue );
       
   492             
       
   493             iSession->RecordL( EFalse );
       
   494             iEventObserver.ShowNaviPaneIconL( EMusUiNaviIconRecordNot );
       
   495             break;
       
   496             }
       
   497             
       
   498         default:
       
   499             {
       
   500             // Try more general handling
       
   501             CMusUiEventController::HandleCommandL( aCommand );
       
   502             break;
       
   503             }
       
   504         }
       
   505     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::HandleCommandL" );
       
   506     }
       
   507     
       
   508 
       
   509 // -----------------------------------------------------------------------------
       
   510 //
       
   511 // -----------------------------------------------------------------------------
       
   512 //
       
   513 void CMusUiLiveSharingController::LevelIndicatorDismissed()
       
   514     {
       
   515     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::LevelIndicatorDismissed" );
       
   516     if ( MUS_NO_TOOLBAR )
       
   517         {
       
   518         iZoomSelected = EFalse;
       
   519         iBrightnessSelected = EFalse;
       
   520         TRAP_IGNORE( iSharingObserver.EnableMiddleSoftkeyL( IsLoudSpeakerEnabled() ?
       
   521                                                 R_MUSUI_VIEW_OPS_MSK_IHF_OFF :
       
   522                                                 R_MUSUI_VIEW_OPS_MSK_IHF_ON ) );
       
   523         }
       
   524     else
       
   525         {
       
   526         if ( iToolbarZoomSelected )
       
   527             {
       
   528             iToolbarZoomSelected = EFalse;
       
   529             if ( !AknLayoutUtils::PenEnabled() )
       
   530                 {
       
   531                 TRAP_IGNORE( iSharingObserver.HighlightSelectedToolbarItem(EMusuiCmdToolbarZoom) );
       
   532                 }
       
   533             }
       
   534         else if( iToolbarBrightnessSelected )
       
   535             {
       
   536             iToolbarBrightnessSelected = EFalse;            
       
   537             if ( !AknLayoutUtils::PenEnabled() )
       
   538                 {
       
   539                 TRAP_IGNORE( iSharingObserver.HighlightSelectedToolbarItem(EMusuiCmdToolbarBrightness) );
       
   540                 }
       
   541             }
       
   542             
       
   543         }
       
   544     
       
   545     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::LevelIndicatorDismissed" );
       
   546     }
       
   547 
       
   548 
       
   549 
       
   550 // -----------------------------------------------------------------------------
       
   551 //
       
   552 // -----------------------------------------------------------------------------
       
   553 //
       
   554 TMusUiNaviMediaDecorator CMusUiLiveSharingController::RecordIcon()
       
   555     {
       
   556     MUS_LOG( "mus: [MUSUI ]     CMusUiLiveSharingController::RecordIcon" );
       
   557         
       
   558     return (iSession->IsRecording() == EFalse) ?
       
   559                             EMusUiNaviIconRecordNot :
       
   560                             EMusUiNaviIconRecord;
       
   561     }
       
   562 
       
   563 
       
   564 // -----------------------------------------------------------------------------
       
   565 //
       
   566 // -----------------------------------------------------------------------------
       
   567 //
       
   568 TBool CMusUiLiveSharingController::IsBrightnessSupported()
       
   569     {
       
   570     if ( !iSession )
       
   571         {
       
   572         return EFalse;
       
   573         }
       
   574     TRAPD( error, iSession->SetBrightnessL( iSession->CurrentBrightnessL() ) )
       
   575     return ( error == KErrNotSupported ) ? EFalse : ETrue;
       
   576     }
       
   577 
       
   578     
       
   579 // -----------------------------------------------------------------------------
       
   580 //
       
   581 // -----------------------------------------------------------------------------
       
   582 //
       
   583 TBool CMusUiLiveSharingController::IsDiskFull()
       
   584     {
       
   585     return iDiskFull;	
       
   586     }
       
   587     
       
   588     
       
   589 // -----------------------------------------------------------------------------
       
   590 //
       
   591 // -----------------------------------------------------------------------------
       
   592 //
       
   593 TBool CMusUiLiveSharingController::ToolbarZoomSelected()
       
   594     {
       
   595     return iToolbarZoomSelected;
       
   596     }
       
   597 
       
   598 
       
   599 // -----------------------------------------------------------------------------
       
   600 //
       
   601 // -----------------------------------------------------------------------------
       
   602 //
       
   603 TBool CMusUiLiveSharingController::ToolbarBrightnessSelected()
       
   604     {
       
   605     return iToolbarBrightnessSelected;
       
   606     }
       
   607 
       
   608 // -----------------------------------------------------------------------------
       
   609 //
       
   610 // -----------------------------------------------------------------------------
       
   611 //
       
   612 TBool CMusUiLiveSharingController::ZoomSelected()
       
   613     {
       
   614     return iZoomSelected;
       
   615     }
       
   616 
       
   617 
       
   618 // -----------------------------------------------------------------------------
       
   619 //
       
   620 // -----------------------------------------------------------------------------
       
   621 //
       
   622 TBool CMusUiLiveSharingController::BrightnessSelected()
       
   623     {
       
   624     return iBrightnessSelected;
       
   625     }
       
   626 
       
   627 
       
   628 // -----------------------------------------------------------------------------
       
   629 //
       
   630 // -----------------------------------------------------------------------------
       
   631 //
       
   632 void CMusUiLiveSharingController::ZoomL()
       
   633     {
       
   634     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::ZoomL" );
       
   635     iZoomSelected = ETrue;
       
   636     iLiveObserver.SetZoomValues( iSession->MinZoomL(), iSession->MaxZoomL() );
       
   637     iLiveObserver.SetZoomL( iSession->CurrentZoomL() );
       
   638     iLiveObserver.SetZoomVisible( ETrue );
       
   639     
       
   640     if ( MUS_NO_TOOLBAR )
       
   641         {
       
   642         iSharingObserver.EnableMiddleSoftkeyL( R_MUSUI_VIEW_MSK_OK );
       
   643         }
       
   644     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::ZoomL" );
       
   645     }
       
   646 
       
   647 
       
   648 // -----------------------------------------------------------------------------
       
   649 //
       
   650 // -----------------------------------------------------------------------------
       
   651 //
       
   652 void CMusUiLiveSharingController::BrightnessL()
       
   653     {
       
   654     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::BrightnessL" );
       
   655     iBrightnessSelected = ETrue;
       
   656     iLiveObserver.SetBrightnessValues( iSession->MinBrightnessL(), 
       
   657             iSession->MaxBrightnessL() );
       
   658     iLiveObserver.SetBrightnessL( iSession->CurrentBrightnessL() );
       
   659     iLiveObserver.SetBrightnessVisible( ETrue );
       
   660 
       
   661     if ( MUS_NO_TOOLBAR )
       
   662         {
       
   663         iSharingObserver.EnableMiddleSoftkeyL( R_MUSUI_VIEW_MSK_OK );
       
   664         }
       
   665     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::BrightnessL" );
       
   666     }
       
   667 
       
   668 
       
   669 // -----------------------------------------------------------------------------
       
   670 //
       
   671 // -----------------------------------------------------------------------------
       
   672 //
       
   673 void CMusUiLiveSharingController::HandleMiddleSoftkeyOkL()
       
   674     {
       
   675     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::HandleMiddleSoftkeyOkL" );
       
   676 
       
   677     if ( iZoomSelected )
       
   678         {
       
   679         iZoomSelected = EFalse;
       
   680         iLiveObserver.SetZoomVisible( EFalse );
       
   681         }
       
   682     else if ( iBrightnessSelected )
       
   683         {
       
   684         iZoomSelected = EFalse;
       
   685         iLiveObserver.SetBrightnessVisible( EFalse );
       
   686         }
       
   687     
       
   688     iSharingObserver.EnableMiddleSoftkeyL( IsLoudSpeakerEnabled() ?
       
   689                                                 R_MUSUI_VIEW_OPS_MSK_IHF_OFF :
       
   690                                                 R_MUSUI_VIEW_OPS_MSK_IHF_ON );
       
   691     
       
   692     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::HandleMiddleSoftkeyOkL" );
       
   693     }
       
   694 
       
   695 // -----------------------------------------------------------------------------
       
   696 //
       
   697 // -----------------------------------------------------------------------------
       
   698 //
       
   699 void CMusUiLiveSharingController::ZoomInL()
       
   700     {
       
   701     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::ZoomInL" );
       
   702     iSession->ZoomInL();
       
   703     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::ZoomInL" );
       
   704     }
       
   705 
       
   706 
       
   707 // -----------------------------------------------------------------------------
       
   708 //
       
   709 // -----------------------------------------------------------------------------
       
   710 //
       
   711 void CMusUiLiveSharingController::ZoomOutL()
       
   712     {
       
   713     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::ZoomOutL" );
       
   714     iSession->ZoomOutL();
       
   715     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::ZoomOutL" );
       
   716     }
       
   717 
       
   718 
       
   719 // -----------------------------------------------------------------------------
       
   720 //
       
   721 // -----------------------------------------------------------------------------
       
   722 //
       
   723 void CMusUiLiveSharingController::IncreaseBrightnessL()
       
   724     {
       
   725     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::IncreaseBrightnessL" );
       
   726     iSession->IncreaseBrightnessL();
       
   727     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::IncreaseBrightnessL" );
       
   728     }
       
   729 
       
   730 
       
   731 // -----------------------------------------------------------------------------
       
   732 //
       
   733 // -----------------------------------------------------------------------------
       
   734 //
       
   735 void CMusUiLiveSharingController::DecreaseBrightnessL()
       
   736     {
       
   737     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::DecreaseBrightnessL" );
       
   738     iSession->DecreaseBrightnessL();
       
   739     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::DecreaseBrightnessL" );
       
   740     }
       
   741 
       
   742 
       
   743 // -----------------------------------------------------------------------------
       
   744 //
       
   745 // -----------------------------------------------------------------------------
       
   746 //
       
   747 void CMusUiLiveSharingController::DiskFull()
       
   748     {
       
   749     // Update the icon:
       
   750     TRAP_IGNORE( iEventObserver.ShowNaviPaneIconL( EMusUiNaviIconRecordNot );
       
   751     DismissWaitDialog();
       
   752     // Saving ends when disk is full but streaming continues (user is notified)
       
   753     TRAP_IGNORE( MusUiDialogUtil::ShowGlobalErrorDialogL( R_MUS_VIEW_NOTE_MEMORY_LOW ) ) );
       
   754     iDiskFull = ETrue;
       
   755     }
       
   756 
       
   757 // -----------------------------------------------------------------------------
       
   758 //
       
   759 // -----------------------------------------------------------------------------
       
   760 //
       
   761 void CMusUiLiveSharingController::OrientationRefreshEnded()  
       
   762     {
       
   763     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::OrientationRefreshEnded" );
       
   764     iLiveObserver.DoRefreshView();
       
   765     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::OrientationRefreshEnded" );
       
   766     }
       
   767     
       
   768 // -----------------------------------------------------------------------------
       
   769 //
       
   770 // -----------------------------------------------------------------------------
       
   771 //
       
   772 void CMusUiLiveSharingController::SessionEstablished()
       
   773     {
       
   774     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::SessionEstablished" );
       
   775     
       
   776     iSessionEstablished = ETrue;
       
   777     
       
   778     TRAPD( error, iResourceHandler->RequestCameraL( ETrue ) );
       
   779     if ( error != KErrNone )
       
   780         {
       
   781         MUS_LOG1( "mus: [MUSUI ]     RequestCameraL leave code: %d", error )
       
   782         }
       
   783         
       
   784     CMusUiSendController::SessionEstablished(); // Base class handling
       
   785     
       
   786     iVideoToBeSaved = ETrue;
       
   787     
       
   788     MusSettingsKeys::TAutoRecord autoRecordValue = EAutoRecordOff; 
       
   789         TRAPD ( errAutoRecord, autoRecordValue = 
       
   790                     MultimediaSharingSettings::AutoRecordSettingL() );
       
   791     if ( errAutoRecord != KErrNone )
       
   792         {
       
   793         MUS_LOG1( "mus: [MUSUI ]     AutoRecordSettingL leave code: %d", errAutoRecord )
       
   794         HandleError( errAutoRecord );
       
   795         }
       
   796     
       
   797     if ( autoRecordValue != EAutoRecordOff )
       
   798         {
       
   799         TRAPD ( errRecordL, iSession->RecordL( ETrue ) );
       
   800         if ( errRecordL != KErrNone )
       
   801             {
       
   802             MUS_LOG1( "mus: [MUSUI ]     RecordL leave code: %d", errRecordL )
       
   803             HandleError( errRecordL );
       
   804             }
       
   805         }
       
   806 
       
   807     TRAP_IGNORE( iEventObserver.ShowNaviPaneIconL( RecordIcon() ) )
       
   808     
       
   809     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::SessionEstablished" );
       
   810     }
       
   811 
       
   812 
       
   813 // -----------------------------------------------------------------------------
       
   814 //
       
   815 // -----------------------------------------------------------------------------
       
   816 //
       
   817 void CMusUiLiveSharingController::SessionTerminated()
       
   818     {
       
   819     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::SessionTerminated" );    
       
   820     iSessionEstablished = EFalse;
       
   821     if ( !ExitOccured() )
       
   822         {
       
   823         DismissWaitDialog();
       
   824         
       
   825         TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) );
       
   826         }
       
   827     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::SessionTerminated" );
       
   828     }
       
   829 
       
   830 
       
   831 // -----------------------------------------------------------------------------
       
   832 //
       
   833 // -----------------------------------------------------------------------------
       
   834 //
       
   835 void CMusUiLiveSharingController::SessionConnectionLost()
       
   836     {
       
   837     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::SessionConnectionLost" );
       
   838     iSessionEstablished = EFalse;
       
   839     DismissWaitDialog();
       
   840     if ( !ExitOccured() )
       
   841         {
       
   842         TRAP_IGNORE( MusUiDialogUtil::ShowGlobalErrorDialogL( 
       
   843                             R_MUS_LIVE_SHARING_VIEW_NOTE_CONNECTION_LOST ) );
       
   844         }
       
   845     
       
   846     TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) );
       
   847         
       
   848     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::SessionConnectionLost" );
       
   849     }
       
   850 
       
   851 
       
   852 // -----------------------------------------------------------------------------
       
   853 //
       
   854 // -----------------------------------------------------------------------------
       
   855 //
       
   856 void CMusUiLiveSharingController::SessionFailed()
       
   857     {
       
   858     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::SessionFailed" );
       
   859     iSessionEstablished = EFalse;
       
   860     if ( !ExitOccured() )
       
   861         {
       
   862         DismissWaitDialog();
       
   863        
       
   864         TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) );
       
   865         }
       
   866 
       
   867     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::SessionFailed" );
       
   868     }
       
   869 
       
   870 
       
   871 // -----------------------------------------------------------------------------
       
   872 //
       
   873 // -----------------------------------------------------------------------------
       
   874 //
       
   875 void CMusUiLiveSharingController::StreamIdle()
       
   876     {
       
   877     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::StreamIdle" );
       
   878     DismissWaitDialog();
       
   879     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::StreamIdle" );
       
   880     }
       
   881 
       
   882 
       
   883 // -----------------------------------------------------------------------------
       
   884 //
       
   885 // -----------------------------------------------------------------------------
       
   886 //
       
   887 void CMusUiLiveSharingController::StreamStreaming()
       
   888     {
       
   889     MUS_LOG( "mus: [MUSUI ]  -> CMusUiLiveSharingController::StreamStreaming" );
       
   890     //DismissWaitDialog();
       
   891     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::StreamStreaming" );
       
   892     }
       
   893 
       
   894 
       
   895 // -----------------------------------------------------------------------------
       
   896 //
       
   897 // -----------------------------------------------------------------------------
       
   898 //
       
   899 void CMusUiLiveSharingController::SessionTimeChanged(
       
   900                         const TTimeIntervalSeconds& aSeconds )
       
   901     {
       
   902     if ( aSeconds.Int() > -1 )
       
   903         {
       
   904         iSharingObserver.UpdateSessionTime( SessionTimeFormatted( aSeconds ) );
       
   905         }
       
   906     }
       
   907 
       
   908 
       
   909 // -----------------------------------------------------------------------------
       
   910 //
       
   911 // -----------------------------------------------------------------------------
       
   912 //
       
   913 void CMusUiLiveSharingController::InactivityTimeout()
       
   914     {
       
   915     MUS_LOG( "mus: [MUSUI ] -> CMusUiLiveSharingController::InactivityTimeout" );
       
   916     DismissWaitDialog();
       
   917     if ( !ExitOccured() )
       
   918         {
       
   919         TRAP_IGNORE( MusUiDialogUtil::ShowGlobalErrorDialogL( 
       
   920                             R_MUS_LIVE_SHARING_VIEW_NOTE_SERVICE_N_A ) );
       
   921         }
       
   922     
       
   923     TRAP_IGNORE( iCallbackService->AsyncEventL( EMusUiAsyncHandleExit ) );
       
   924         
       
   925     MUS_LOG( "mus: [MUSUI ] <- CMusUiLiveSharingController::InactivityTimeout" );
       
   926     }
       
   927 
       
   928 // -----------------------------------------------------------------------------
       
   929 // Determines whether Session established or not
       
   930 // -----------------------------------------------------------------------------
       
   931 //
       
   932 TBool CMusUiLiveSharingController::IsSessionEstablished()
       
   933 	{
       
   934 	return iSessionEstablished;
       
   935 	}
       
   936 
       
   937 // -----------------------------------------------------------------------------
       
   938 // 
       
   939 // -----------------------------------------------------------------------------
       
   940 //
       
   941 void CMusUiLiveSharingController::HandlePauseResumeInToolbar()
       
   942     {
       
   943     TBool isPlaying( EFalse );
       
   944     TRAP_IGNORE( isPlaying = IsPlayingL() )
       
   945     if ( isPlaying )
       
   946         {
       
   947         iSharingObserver.ReplaceToolbarCommand( EMusuiCmdToolbarUnPauseLive,
       
   948                                                 EMusuiCmdToolbarPauseLive,
       
   949                                                 ETrue );
       
   950         }
       
   951     else
       
   952         {
       
   953         iSharingObserver.ReplaceToolbarCommand( EMusuiCmdToolbarPauseLive,
       
   954                                                 EMusuiCmdToolbarUnPauseLive,
       
   955                                                 ETrue );
       
   956         }
       
   957     }
       
   958 
       
   959 // -----------------------------------------------------------------------------
       
   960 // Workaround for problem at lower level (encoder side) which causes crash
       
   961 // if several sequential pause/resumes are done too rapidly. Discard state change
       
   962 // attempt if it occurs too quickly after previous state change.
       
   963 // -----------------------------------------------------------------------------
       
   964 //
       
   965 void CMusUiLiveSharingController::UserInitiatedCameraStateChangeL( TBool aEnable )
       
   966     {
       
   967     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiLiveSharingController::UserInitiatedCameraStateChangeL, enable:", 
       
   968               aEnable );
       
   969     
       
   970     if ( iPauseResumeGuardTimer->IsActive() ){
       
   971         MUS_LOG( "mus: [MUSUI ]  <- State change ignored as guard timer is running!" );
       
   972         return;
       
   973     }
       
   974     
       
   975     if ( aEnable )
       
   976         {
       
   977         PlayL();
       
   978         }
       
   979     else
       
   980         {
       
   981         PauseL();
       
   982         }
       
   983     
       
   984     iPauseResumeGuardTimer->After( KMusUiPauseResumeGuardPeriod );
       
   985     
       
   986     MUS_LOG( "mus: [MUSUI ]  <- CMusUiLiveSharingController::UserInitiatedCameraStateChangeL" );
       
   987     }
       
   988 
       
   989 
       
   990 // End of file
       
   991