videoplayback/videohelix/src/mpxvideoplaybackstate.cpp
changeset 37 4eb2df7f7cbe
parent 36 8aed59de29f9
child 38 ff53afa8ad05
equal deleted inserted replaced
36:8aed59de29f9 37:4eb2df7f7cbe
    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: 39 %
    19 // Version : %version: 41 %
    20 
    20 
    21 
    21 
    22 //
    22 //
    23 //  INCLUDE FILES
    23 //  INCLUDE FILES
    24 //
    24 //
    25 #include <mpxcommandgeneraldefs.h>
    25 #include <mpxcommandgeneraldefs.h>
    26 #include <mpxmessagegeneraldefs.h>
    26 #include <mpxmessagegeneraldefs.h>
       
    27 #include <mpxmediageneralextdefs.h>
    27 
    28 
    28 #include "mpxvideoplaybackcontroller.h"
    29 #include "mpxvideoplaybackcontroller.h"
    29 #include "mpxvideoplaybackstate.h"
    30 #include "mpxvideoplaybackstate.h"
    30 #include <mpxvideoplaybackdefs.h>
    31 #include <mpxvideoplaybackdefs.h>
    31 #include <mpxplaybackpluginobserver.h>
    32 #include <mpxplaybackpluginobserver.h>
    52 void CMPXVideoPlaybackState::ConstructL( CMPXVideoPlaybackController* aVideoPlaybackCtlr )
    53 void CMPXVideoPlaybackState::ConstructL( CMPXVideoPlaybackController* aVideoPlaybackCtlr )
    53 {
    54 {
    54     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackState::ConstructL()"));
    55     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackState::ConstructL()"));
    55 
    56 
    56     iVideoPlaybackCtlr = aVideoPlaybackCtlr;
    57     iVideoPlaybackCtlr = aVideoPlaybackCtlr;
    57     iVideoPlaybackCtlr->iPBPluginError = KErrNone;
       
    58 
    58 
    59     User::LeaveIfError( iFs.Connect() );
    59     User::LeaveIfError( iFs.Connect() );
    60     iFs.ShareProtected();
    60     iFs.ShareProtected();
    61 }
    61 }
    62 
    62 
   294     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackState::RetrieveFileDetailsL()"));
   294     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackState::RetrieveFileDetailsL()"));
   295 
   295 
   296     TUint attrG(0);  //  General attributes
   296     TUint attrG(0);  //  General attributes
   297     TUint attrV(0);  //  Video attributes
   297     TUint attrV(0);  //  Video attributes
   298 
   298 
   299     if (iVideoPlaybackCtlr->iPBPluginError != KErrNone)
   299     if ( iVideoPlaybackCtlr->iPBPluginError != KErrNone )
   300     {
   300     {
       
   301         if ( iVideoPlaybackCtlr->iClipName )
       
   302         {
       
   303             aMedia->SetTextValueL(
       
   304                 TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralUri ),
       
   305                 *( iVideoPlaybackCtlr->iClipName ) );
       
   306         }
       
   307 
   301         aMedia->SetTObjectValueL<TInt>(
   308         aMedia->SetTObjectValueL<TInt>(
   302             TMPXAttribute( KMPXMediaVideoError ), iVideoPlaybackCtlr->iPBPluginError );
   309             TMPXAttribute( KMPXMediaVideoError ), iVideoPlaybackCtlr->iPBPluginError );
   303 
   310 
   304         iVideoPlaybackCtlr->iPBPluginError = KErrNone;
   311         iVideoPlaybackCtlr->iPBPluginError = KErrNone;
   305     }
   312     }
   483             TMPXAttribute( KMPXMediaVideoTvOutConnected ),
   490             TMPXAttribute( KMPXMediaVideoTvOutConnected ),
   484             iVideoPlaybackCtlr->iAccessoryMonitor->IsTvOutConnected() );
   491             iVideoPlaybackCtlr->iAccessoryMonitor->IsTvOutConnected() );
   485     }
   492     }
   486 
   493 
   487     //
   494     //
   488     //  TV-Out Playback Allowed
       
   489     //
       
   490     if ( attrV & KMPXMediaVideoTvOutPlayAllowed.iAttributeId )
       
   491     {
       
   492         aMedia->SetTObjectValueL<TInt>(
       
   493             TMPXAttribute( KMPXMediaVideoTvOutPlayAllowed ),
       
   494             iVideoPlaybackCtlr->iAccessoryMonitor->IsTvOutPlaybackAllowed() );
       
   495     }
       
   496 
       
   497     //
       
   498     //  BitRate
   495     //  BitRate
   499     //
   496     //
   500     if ( attrV & KMPXMediaVideoBitRate.iAttributeId )
   497     if ( attrV & KMPXMediaVideoBitRate.iAttributeId )
   501     {
   498     {
   502         aMedia->SetTObjectValueL<TInt>(
   499         aMedia->SetTObjectValueL<TInt>(
   576     {
   573     {
   577         aMedia->SetTextValueL(
   574         aMedia->SetTextValueL(
   578             TMPXAttribute( KMPXMediaVideoKeywords ),
   575             TMPXAttribute( KMPXMediaVideoKeywords ),
   579             *( iVideoPlaybackCtlr->iFileDetails->iKeywords ) );
   576             *( iVideoPlaybackCtlr->iFileDetails->iKeywords ) );
   580     }
   577     }
   581     
   578 
   582     //
   579     //
   583     //  Creation date/time 
   580     //  Creation date/time
   584     //
   581     //
   585     if ( attrV & KMPXMediaVideoCreated.iAttributeId )
   582     if ( attrV & KMPXMediaVideoCreated.iAttributeId )
   586     {
   583     {
   587         aMedia->SetTObjectValueL<TInt>(
   584         aMedia->SetTObjectValueL<TInt>(
   588             TMPXAttribute( KMPXMediaVideoCreated ),
   585             TMPXAttribute( KMPXMediaVideoCreated ),
   589             iVideoPlaybackCtlr->iFileDetails->iCreationTime );
   586             iVideoPlaybackCtlr->iFileDetails->iCreationTime );
   590     }
   587     }
   591 
   588 
   592     //
   589     //
   593     //  Last Modified date/time 
   590     //  Last Modified date/time
   594     //
   591     //
   595     if ( attrV & KMPXMediaVideoLastModified.iAttributeId )
   592     if ( attrV & KMPXMediaVideoLastModified.iAttributeId )
   596     {
   593     {
   597         aMedia->SetTObjectValueL<TInt>(
   594         aMedia->SetTObjectValueL<TInt>(
   598             TMPXAttribute( KMPXMediaVideoLastModified ),
   595             TMPXAttribute( KMPXMediaVideoLastModified ),
   750 //  ------------------------------------------------------------------------------------------------
   747 //  ------------------------------------------------------------------------------------------------
   751 void CMPXVideoPlaybackState::IssuePlayCommand( TMPXVideoPlaybackState aState,
   748 void CMPXVideoPlaybackState::IssuePlayCommand( TMPXVideoPlaybackState aState,
   752                                                MMPXPlaybackPluginObserver::TEvent aEvent,
   749                                                MMPXPlaybackPluginObserver::TEvent aEvent,
   753                                                TBool aSendEvent )
   750                                                TBool aSendEvent )
   754 {
   751 {
   755     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackState::CMPXVideoPlaybackState::IssuePlayCommand()"),
   752     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackState::IssuePlayCommand()"),
   756                    _L("aState = %d, aEvent  = %d, aSendEvent = %d"), aState, aEvent, aSendEvent );
   753                    _L("aState = %d, aEvent  = %d, aSendEvent = %d"), aState, aEvent, aSendEvent );
   757 
   754 
   758     MPX_TRAPD( err, iVideoPlaybackCtlr->iPlayer->PlayL() );
   755     MPX_TRAPD( err, iVideoPlaybackCtlr->iPlayer->PlayL() );
   759 
   756 
   760     if ( err == KErrNone )
   757     if ( err == KErrNone )
   767         }
   764         }
   768     }
   765     }
   769     else
   766     else
   770     {
   767     {
   771         TRAP_IGNORE( SendErrorToViewL( err ) );
   768         TRAP_IGNORE( SendErrorToViewL( err ) );
       
   769     }
       
   770 }
       
   771 
       
   772 //  ------------------------------------------------------------------------------------------------
       
   773 //    CMPXVideoPlaybackState::UpdateSeekableL()
       
   774 //  ------------------------------------------------------------------------------------------------
       
   775 void CMPXVideoPlaybackState::UpdateSeekableL( CMPXCommand& aCmd )
       
   776 {
       
   777     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackState::UpdateSeekableL()"));
       
   778 
       
   779     iVideoPlaybackCtlr->iSeekable = aCmd.ValueTObjectL<TBool>(KMPXMediaGeneralExtVideoSeekable);
       
   780 
       
   781     if ( iVideoPlaybackCtlr->iFileDetails )
       
   782     {
       
   783         iVideoPlaybackCtlr->iFileDetails->iSeekable &= iVideoPlaybackCtlr->iSeekable;
   772     }
   784     }
   773 }
   785 }
   774 
   786 
   775 // *************************************************************************************************
   787 // *************************************************************************************************
   776 //
   788 //
   827 
   839 
   828     TInt error = KErrNone;
   840     TInt error = KErrNone;
   829 
   841 
   830     if ( iVideoPlaybackCtlr->iPBPluginError != KErrNone )
   842     if ( iVideoPlaybackCtlr->iPBPluginError != KErrNone )
   831     {
   843     {
       
   844         if ( iVideoPlaybackCtlr->iClipName )
       
   845         {
       
   846             //
       
   847             //  Send the clip name and error code for further processing
       
   848             //
       
   849             aMedia->SetTextValueL(
       
   850                 TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralUri ),
       
   851                 *( iVideoPlaybackCtlr->iClipName ) );
       
   852         }
       
   853 
   832         aMedia->SetTObjectValueL<TInt>(
   854         aMedia->SetTObjectValueL<TInt>(
   833             TMPXAttribute( KMPXMediaVideoError ), iVideoPlaybackCtlr->iPBPluginError );
   855             TMPXAttribute( KMPXMediaVideoError ), iVideoPlaybackCtlr->iPBPluginError );
   834 
   856 
   835         iVideoPlaybackCtlr->iPBPluginError = KErrNone;
   857         iVideoPlaybackCtlr->iPBPluginError = KErrNone;
   836     }
   858     }
   898 void CMPXNotInitialisedState::HandlePlay()
   920 void CMPXNotInitialisedState::HandlePlay()
   899 {
   921 {
   900     MPX_DEBUG(_L("CMPXNotInitialisedState::HandlePlay() Plugin error"));
   922     MPX_DEBUG(_L("CMPXNotInitialisedState::HandlePlay() Plugin error"));
   901 
   923 
   902      MPX_TRAPD( err, SendErrorToViewL( iVideoPlaybackCtlr->iPBPluginError ) );
   924      MPX_TRAPD( err, SendErrorToViewL( iVideoPlaybackCtlr->iPBPluginError ) );
       
   925 }
       
   926 
       
   927 //  ------------------------------------------------------------------------------------------------
       
   928 //    CMPXNotInitialisedState::UpdateSeekableL()
       
   929 //  ------------------------------------------------------------------------------------------------
       
   930 void CMPXNotInitialisedState::UpdateSeekableL( CMPXCommand& /*aCmd*/ )
       
   931 {
       
   932     MPX_DEBUG(_L("CMPXNotInitialisedState::UpdateSeekableL()"));
       
   933 
       
   934     //
       
   935     //  Do not update the seekable state since the plugin is in the not initialized state
       
   936     //  An error probably occurred, plugin went to not initialized.  If update was applied,
       
   937     //  it would not be cleared for the next clip since we are already in not initialized
       
   938     //  state.
       
   939     //
   903 }
   940 }
   904 
   941 
   905 // *************************************************************************************************
   942 // *************************************************************************************************
   906 //
   943 //
   907 //                       CMPXInitialisingState
   944 //                       CMPXInitialisingState
  1022 
  1059 
  1023         iVideoPlaybackCtlr->iPlayer->Prepare();
  1060         iVideoPlaybackCtlr->iPlayer->Prepare();
  1024     }
  1061     }
  1025     else
  1062     else
  1026     {
  1063     {
  1027         //
  1064         iVideoPlaybackCtlr->HandleError( aError );
  1028         // Transistion back to EMPXVideoNotInitialized, for pre loaded plugin
       
  1029         // this state will alert the view that pre loading failed
       
  1030         //
       
  1031         iVideoPlaybackCtlr->ChangeState( EMPXVideoNotInitialized );
       
  1032 
       
  1033         // Store the error, in case of pre loaded pluging this can
       
  1034         // later be sent to the view
       
  1035         iVideoPlaybackCtlr->iPBPluginError = aError;
       
  1036 
       
  1037         //
       
  1038         //  move the FW state to Initialized irrespective of the playback state
       
  1039         //  This enables the FW to send initailized event to view, which in turn
       
  1040         //  queries for the error
       
  1041         //
       
  1042         iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent(
       
  1043             MMPXPlaybackPluginObserver::EPInitialised,
       
  1044             0,
       
  1045             KErrNone );
       
  1046     }
  1065     }
  1047 }
  1066 }
  1048 
  1067 
  1049 //  ------------------------------------------------------------------------------------------------
  1068 //  ------------------------------------------------------------------------------------------------
  1050 //    CMPXInitialisingState::HandlePrepareComplete
  1069 //    CMPXInitialisingState::HandlePrepareComplete
  1088         iVideoPlaybackCtlr->iMPXPluginObs->
  1107         iVideoPlaybackCtlr->iMPXPluginObs->
  1089             HandlePluginEvent( MMPXPlaybackPluginObserver::EPInitialised, duration, KErrNone );
  1108             HandlePluginEvent( MMPXPlaybackPluginObserver::EPInitialised, duration, KErrNone );
  1090     }
  1109     }
  1091     else
  1110     else
  1092     {
  1111     {
  1093         //
  1112         iVideoPlaybackCtlr->HandleError( aError );
  1094         // Transistion back to EMPXVideoNotInitialized, for pre loaded plugin
       
  1095         // this state will alert the view that pre loading failed
       
  1096         //
       
  1097         iVideoPlaybackCtlr->ChangeState( EMPXVideoNotInitialized );
       
  1098 
       
  1099         // Store the error, in case of pre loaded pluging this can
       
  1100         // later be sent to the view
       
  1101         iVideoPlaybackCtlr->iPBPluginError = aError;
       
  1102 
       
  1103         //
       
  1104         //  move the FW state to Initialized irrespective of the playback state
       
  1105         //  This enables the FW to send initailized event to view, which in turn
       
  1106         //  queries for the error
       
  1107         //
       
  1108         iVideoPlaybackCtlr->iMPXPluginObs->
       
  1109             HandlePluginEvent( MMPXPlaybackPluginObserver::EPInitialised, 0, KErrNone );
       
  1110     }
  1113     }
  1111 }
  1114 }
  1112 
  1115 
  1113 //  ------------------------------------------------------------------------------------------------
  1116 //  ------------------------------------------------------------------------------------------------
  1114 //  CMPXInitialisingState::HandleVolumeChange
  1117 //  CMPXInitialisingState::HandleVolumeChange
  1743 void CMPXBufferingState::HandleLoadingStarted()
  1746 void CMPXBufferingState::HandleLoadingStarted()
  1744 {
  1747 {
  1745     MPX_DEBUG(_L("CMPXBufferingState::HandleLoadingStarted()"));
  1748     MPX_DEBUG(_L("CMPXBufferingState::HandleLoadingStarted()"));
  1746 
  1749 
  1747     TInt loadingPercentage = RetrieveBufferingPercentage();
  1750     TInt loadingPercentage = RetrieveBufferingPercentage();
  1748     
  1751 
  1749     if ( loadingPercentage < 100 )
  1752     if ( loadingPercentage < 100 )
  1750     {
  1753     {
  1751         MPX_TRAPD( err,
  1754         MPX_TRAPD( err,
  1752         {
  1755         {
  1753             CMPXMessage* message = CMPXMessage::NewL();
  1756             CMPXMessage* message = CMPXMessage::NewL();
  1754             CleanupStack::PushL( message );
  1757             CleanupStack::PushL( message );
  1755     
  1758 
  1756             message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, 
  1759             message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId,
  1757                                                       KMPXMediaIdVideoPlayback );
  1760                                                       KMPXMediaIdVideoPlayback );
  1758             
  1761 
  1759             message->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand, 
  1762             message->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand,
  1760                                                                  EPbCmdLoadingStarted );
  1763                                                                  EPbCmdLoadingStarted );
  1761     
  1764 
  1762             iVideoPlaybackCtlr->iMPXPluginObs->HandlePlaybackMessage( message, KErrNone );
  1765             iVideoPlaybackCtlr->iMPXPluginObs->HandlePlaybackMessage( message, KErrNone );
  1763     
  1766 
  1764             CleanupStack::PopAndDestroy( message );
  1767             CleanupStack::PopAndDestroy( message );
  1765         } );
  1768         } );
  1766     }
  1769     }
  1767 }
  1770 }
  1768 
  1771