videoplayback/videohelix/src/mpxvideoplaybackmode.cpp
branchRCL_3
changeset 18 baf439b22ddd
parent 16 67eb01668b0e
child 21 315810614048
equal deleted inserted replaced
16:67eb01668b0e 18:baf439b22ddd
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  This class plays local video file
    14 * Description:  This class plays local video file
    15  *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // Version : %version: 32 %
    19 // Version : %version: 33 %
    20 
    20 
    21 
    21 
    22 //
    22 //
    23 //  INCLUDE FILES
    23 //  INCLUDE FILES
    24 //
    24 //
    25 #include <mmf/server/mmffile.h>
    25 #include <mmf/server/mmffile.h>
    26 #include <MMFROPCustomCommandConstants.h>
    26 #include <MMFROPCustomCommandConstants.h>
    27 #include <mpxplaybackpluginobserver.h>
    27 #include <mpxplaybackpluginobserver.h>
       
    28 #include <mpxmessagegeneraldefs.h>
       
    29 #include <mpxplaybackmessage.h>
    28 
    30 
    29 #include <etel.h>    // 3G
    31 #include <etel.h>    // 3G
    30 #include <etelmm.h>
    32 #include <etelmm.h>
    31 #include <mmtsy_names.h>
    33 #include <mmtsy_names.h>
    32 
    34 
   221         if ( iVideoPlaybackCtlr->IsVideoCall() )
   223         if ( iVideoPlaybackCtlr->IsVideoCall() )
   222         {
   224         {
   223             MPX_TRAPD( err,
   225             MPX_TRAPD( err,
   224                 iVideoPlaybackCtlr->iState->SendErrorToViewL( KMPXVideoCallOngoingError ) );
   226                 iVideoPlaybackCtlr->iState->SendErrorToViewL( KMPXVideoCallOngoingError ) );
   225         }
   227         }
   226         else if ( iVideoPlaybackCtlr->IsKeyLocked() && 
   228         else if ( iVideoPlaybackCtlr->IsKeyLocked() &&
   227                   iVideoPlaybackCtlr->iFileDetails->iVideoEnabled )
   229                   iVideoPlaybackCtlr->iFileDetails->iVideoEnabled )
   228         {
   230         {
   229             // playback not allowed for the clip having video if keylock is true
   231             // playback not allowed for the clip having video if keylock is true
   230             // Let playAllowed remain false
   232             // Let playAllowed remain false
   231         }
   233         }
   232         else
   234         else
   233         {
   235         {
   234             playAllowed = ETrue;
   236             playAllowed = ETrue;
   235         }
   237         }
   236     }
   238     }
       
   239 
   237     return playAllowed;
   240     return playAllowed;
   238 }
   241 }
   239 
   242 
   240 //  ------------------------------------------------------------------------------------------------
   243 //  ------------------------------------------------------------------------------------------------
   241 //  CMPXVideoPlaybackMode::IsNetworkMode2GL
   244 //  CMPXVideoPlaybackMode::IsNetworkMode2GL
   277     MPX_DEBUG(_L("CMPXVideoPlaybackMode::IsNetworkMode2GL(%d)"), networkMode2g);
   280     MPX_DEBUG(_L("CMPXVideoPlaybackMode::IsNetworkMode2GL(%d)"), networkMode2g);
   278 
   281 
   279     return networkMode2g;
   282     return networkMode2g;
   280 }
   283 }
   281 
   284 
   282 
       
   283 //  ------------------------------------------------------------------------------------------------
   285 //  ------------------------------------------------------------------------------------------------
   284 //    CMPXVideoPlaybackMode::HandleSetPosterFrame()
   286 //    CMPXVideoPlaybackMode::HandleSetPosterFrame()
   285 //  ------------------------------------------------------------------------------------------------
   287 //  ------------------------------------------------------------------------------------------------
   286 void CMPXVideoPlaybackMode::HandleSetPosterFrame()
   288 void CMPXVideoPlaybackMode::HandleSetPosterFrame()
   287 {
   289 {
   289 }
   291 }
   290 
   292 
   291 //  ------------------------------------------------------------------------------------------------
   293 //  ------------------------------------------------------------------------------------------------
   292 //    CMPXVideoPlaybackMode::HandleSetPosterFrame()
   294 //    CMPXVideoPlaybackMode::HandleSetPosterFrame()
   293 //  ------------------------------------------------------------------------------------------------
   295 //  ------------------------------------------------------------------------------------------------
   294 void CMPXVideoPlaybackMode::HandleFrameReady(TInt /*aError*/)
   296 void CMPXVideoPlaybackMode::HandleFrameReady( TInt /*aError*/ )
   295 {
   297 {
   296     MPX_DEBUG(_L("CMPXLocalPlaybackMode::HandleFrameReady()"));
   298     MPX_DEBUG(_L("CMPXVideoPlaybackMode::HandleFrameReady()"));
   297 }
   299 }
       
   300 
       
   301 //  ------------------------------------------------------------------------------------------------
       
   302 //    CMPXVideoPlaybackMode::SendErrorToView()
       
   303 //  ------------------------------------------------------------------------------------------------
       
   304 TBool CMPXVideoPlaybackMode::SendErrorToView( TInt aError )
       
   305 {
       
   306     MPX_DEBUG(_L("CMPXLocalPlaybackMode::SendErrorToView(%d)"), ETrue);
       
   307 
       
   308     return ETrue;
       
   309 }
       
   310 
       
   311 //  ------------------------------------------------------------------------------------------------
       
   312 //    CMPXVideoPlaybackMode::HandlePauseToPlayTransitionL()
       
   313 //  ------------------------------------------------------------------------------------------------
       
   314 void CMPXVideoPlaybackMode::HandlePauseToPlayTransitionL()
       
   315 {
       
   316     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackMode::HandlePauseToPlayTransitionL()"));
       
   317 
       
   318     iVideoPlaybackCtlr->iState->IssuePlayCommand( EMPXVideoPlaying,
       
   319                                                   MMPXPlaybackPluginObserver::EPPlaying );
       
   320 }
       
   321 
   298 //************************************************************************************************//
   322 //************************************************************************************************//
   299 //          CMPXLocalPlaybackMode
   323 //          CMPXLocalPlaybackMode
   300 //************************************************************************************************//
   324 //************************************************************************************************//
   301 CMPXVideoPlaybackMode*
   325 CMPXVideoPlaybackMode*
   302 CMPXLocalPlaybackMode::NewL( CMPXVideoPlaybackController* aVideoPlaybackCtlr )
   326 CMPXLocalPlaybackMode::NewL( CMPXVideoPlaybackController* aVideoPlaybackCtlr )
   427         if ( iVideoPlaybackCtlr->IsVideoCall() )
   451         if ( iVideoPlaybackCtlr->IsVideoCall() )
   428         {
   452         {
   429             MPX_TRAPD(err,
   453             MPX_TRAPD(err,
   430                       iVideoPlaybackCtlr->iState->SendErrorToViewL( KMPXVideoCallOngoingError ));
   454                       iVideoPlaybackCtlr->iState->SendErrorToViewL( KMPXVideoCallOngoingError ));
   431         }
   455         }
   432         else if ( iVideoPlaybackCtlr->IsKeyLocked() && 
   456         else if ( iVideoPlaybackCtlr->IsKeyLocked() &&
   433                   iVideoPlaybackCtlr->iFileDetails->iVideoEnabled )
   457                   iVideoPlaybackCtlr->iFileDetails->iVideoEnabled )
   434         {
   458         {
   435             // playback not allowed for the clip having video if keylock is true
   459             // playback not allowed for the clip having video if keylock is true
   436             // Let playAllowed remain false
   460             // Let playAllowed remain false
   437         }
   461         }
   488                                                               0,
   512                                                               0,
   489                                                               KErrNone );
   513                                                               KErrNone );
   490     }
   514     }
   491 }
   515 }
   492 
   516 
       
   517 
   493 //************************************************************************************************//
   518 //************************************************************************************************//
   494 //          CMPXLiveStreamingPlaybackMode
   519 //          CMPXLiveStreamingPlaybackMode
   495 //************************************************************************************************//
   520 //************************************************************************************************//
       
   521 
   496 CMPXVideoPlaybackMode*
   522 CMPXVideoPlaybackMode*
   497 CMPXLiveStreamingPlaybackMode::NewL( CMPXVideoPlaybackController* aVideoPlaybackCtlr )
   523 CMPXLiveStreamingPlaybackMode::NewL( CMPXVideoPlaybackController* aVideoPlaybackCtlr )
   498 {
   524 {
   499    MPX_ENTER_EXIT(_L("CMPXLiveStreamingPlaybackMode::NewL()"));
   525    MPX_ENTER_EXIT(_L("CMPXLiveStreamingPlaybackMode::NewL()"));
   500 
   526 
   516 //  ------------------------------------------------------------------------------------------------
   542 //  ------------------------------------------------------------------------------------------------
   517 void CMPXLiveStreamingPlaybackMode::HandlePause()
   543 void CMPXLiveStreamingPlaybackMode::HandlePause()
   518 {
   544 {
   519     MPX_ENTER_EXIT(_L("CMPXLiveStreamingPlaybackMode::HandlePause()"));
   545     MPX_ENTER_EXIT(_L("CMPXLiveStreamingPlaybackMode::HandlePause()"));
   520 
   546 
       
   547     //
       
   548     //  Send a stop command to the player, but change state to pause
       
   549     //  The view will not close and the play button will be the only active button
       
   550     //
   521     iVideoPlaybackCtlr->iPlayer->Stop();
   551     iVideoPlaybackCtlr->iPlayer->Stop();
   522 
   552 
   523     iVideoPlaybackCtlr->ChangeState( EMPXVideoStopped );
   553     iVideoPlaybackCtlr->ChangeState( EMPXVideoPaused );
   524 
   554 
   525     iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPStopped,
   555     iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPPaused,
   526                                                           0,
   556                                                           0,
   527                                                           KErrNone );
   557                                                           KErrNone );
   528 }
   558 }
   529 
   559 
   530 //  ------------------------------------------------------------------------------------------------
   560 //  ------------------------------------------------------------------------------------------------
   531 //    CMPXLiveStreamingPlaybackMode::HandleBackground()
   561 //    CMPXLiveStreamingPlaybackMode::SendErrorToView()
   532 //  ------------------------------------------------------------------------------------------------
   562 //  ------------------------------------------------------------------------------------------------
   533 void CMPXLiveStreamingPlaybackMode::HandleBackground()
   563 TBool CMPXLiveStreamingPlaybackMode::SendErrorToView( TInt aError )
   534 {
   564 {
   535     MPX_DEBUG(_L("CMPXLiveStreamingPlaybackMode::HandleBackground()"));
   565     TBool retval = ETrue;
   536 
   566 
   537     if ( iVideoPlaybackCtlr->iAppInForeground )
   567     if ( aError == KErrSessionClosed )
   538     {
   568     {
   539         if ( iVideoPlaybackCtlr->IsPhoneCall() ||
   569         retval = EFalse;
   540              iVideoPlaybackCtlr->IsVideoCall() ||
   570     }
   541              ( iVideoPlaybackCtlr->IsKeyLocked() &&
   571 
   542                iVideoPlaybackCtlr->iFileDetails->iVideoEnabled ) )
   572     MPX_DEBUG(_L("CMPXLiveStreamingPlaybackMode::SendErrorToView(%d)"), retval);
   543         {
   573 
   544             iVideoPlaybackCtlr->iState->HandlePause();
   574     return retval;
   545         }
   575 }
   546     }
   576 
       
   577 //  ------------------------------------------------------------------------------------------------
       
   578 //    CMPXLiveStreamingPlaybackMode::HandlePauseToPlayTransitionL()
       
   579 //  ------------------------------------------------------------------------------------------------
       
   580 void CMPXLiveStreamingPlaybackMode::HandlePauseToPlayTransitionL()
       
   581 {
       
   582     MPX_ENTER_EXIT(_L("CMPXLiveStreamingPlaybackMode::HandlePauseToPlayTransitionL()"));
       
   583 
       
   584     //
       
   585     //  For live streaming, the controller must be reinitialized
       
   586     //  Send a state change to Initializing to the view
       
   587     //
       
   588     CMPXMessage* msg = CMPXMessage::NewL();
       
   589     CleanupStack::PushL( msg );
       
   590 
       
   591     msg->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageGeneral );
       
   592     msg->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXPlaybackMessage::EStateChanged );
       
   593     msg->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EPbStateInitialising );
       
   594     msg->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0 );
       
   595 
       
   596     iVideoPlaybackCtlr->iMPXPluginObs->HandlePlaybackMessage( msg, KErrNone );
       
   597 
       
   598     CleanupStack::PopAndDestroy( msg );
       
   599 
       
   600     iVideoPlaybackCtlr->ChangeState( EMPXVideoInitializing );
       
   601 
       
   602     iVideoPlaybackCtlr->iPlayer->Reset();
       
   603 
       
   604     //
       
   605     //  Reinitialize the player with the file handle or url
       
   606     //
       
   607     if ( iVideoPlaybackCtlr->iFileHandle.SubSessionHandle() )
       
   608     {
       
   609         iVideoPlaybackCtlr->iPlayer->OpenFileL( iVideoPlaybackCtlr->iFileHandle );
       
   610     }
       
   611 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   612     else if ( iVideoPlaybackCtlr->iFileHandle64.SubSessionHandle() )
       
   613     {
       
   614         iVideoPlaybackCtlr->iPlayer->OpenFile64L( iVideoPlaybackCtlr->iFileHandle64 );
       
   615     }
       
   616 #endif
   547     else
   617     else
   548     {
   618     {
   549         iVideoPlaybackCtlr->iState->HandlePause();
   619         iVideoPlaybackCtlr->iPlayer->OpenUrlL( iVideoPlaybackCtlr->iClipName->Des(),
   550     }
   620                                                iVideoPlaybackCtlr->iAccessPointId );
   551 }
   621     }
       
   622 }
       
   623 
   552 
   624 
   553 //************************************************************************************************//
   625 //************************************************************************************************//
   554 //          CMPXProgressiveDLPlaybackMode
   626 //          CMPXProgressiveDLPlaybackMode
   555 //************************************************************************************************//
   627 //************************************************************************************************//
   556 CMPXVideoPlaybackMode*
   628 CMPXVideoPlaybackMode*
   567 
   639 
   568 void CMPXProgressiveDLPlaybackMode::ConstructL( CMPXVideoPlaybackController* aVideoPlaybackCtlr )
   640 void CMPXProgressiveDLPlaybackMode::ConstructL( CMPXVideoPlaybackController* aVideoPlaybackCtlr )
   569 {
   641 {
   570     iVideoPlaybackCtlr = aVideoPlaybackCtlr;
   642     iVideoPlaybackCtlr = aVideoPlaybackCtlr;
   571 
   643 
   572 #ifdef USE_S60_DOWNLOAD_MANAGER 
   644 #ifdef USE_S60_DOWNLOAD_MANAGER
   573     //
   645     //
   574     //  Create the Download Mgr Interface
   646     //  Create the Download Mgr Interface
   575     //
   647     //
   576     iDlMgrIf = CMPXVideoDlMgrIf::NewL( iVideoPlaybackCtlr );
   648     iDlMgrIf = CMPXVideoDlMgrIf::NewL( iVideoPlaybackCtlr );
   577 #endif // USE_S60_DOWNLOAD_MANAGER 
   649 #endif // USE_S60_DOWNLOAD_MANAGER
   578 
   650 
   579 }
   651 }
   580 
   652 
   581 CMPXProgressiveDLPlaybackMode::~CMPXProgressiveDLPlaybackMode()
   653 CMPXProgressiveDLPlaybackMode::~CMPXProgressiveDLPlaybackMode()
   582 {
   654 {
   583     MPX_DEBUG(_L("CMPXProgressiveDLPlaybackMode::~CMPXProgressiveDLPlaybackMode()"));
   655     MPX_DEBUG(_L("CMPXProgressiveDLPlaybackMode::~CMPXProgressiveDLPlaybackMode()"));
   584 
   656 
   585 #ifdef USE_S60_DOWNLOAD_MANAGER 
   657 #ifdef USE_S60_DOWNLOAD_MANAGER
   586     if ( iDlMgrIf )
   658     if ( iDlMgrIf )
   587     {
   659     {
   588         delete iDlMgrIf;
   660         delete iDlMgrIf;
   589         iDlMgrIf = NULL;
   661         iDlMgrIf = NULL;
   590     }
   662     }
   591 #endif // USE_S60_DOWNLOAD_MANAGER 
   663 #endif // USE_S60_DOWNLOAD_MANAGER
   592 
   664 
   593 }
   665 }
   594 
   666 
   595 #ifdef USE_S60_DOWNLOAD_MANAGER 
   667 #ifdef USE_S60_DOWNLOAD_MANAGER
   596 
   668 
   597 //  ------------------------------------------------------------------------------------------------
   669 //  ------------------------------------------------------------------------------------------------
   598 //    CMPXProgressiveDLPlaybackMode::ConnectToDownloadL()
   670 //    CMPXProgressiveDLPlaybackMode::ConnectToDownloadL()
   599 //  ------------------------------------------------------------------------------------------------
   671 //  ------------------------------------------------------------------------------------------------
   600 //
   672 //