videoplayback/videoplaybackviews/src/mpxvideoplaybackdisplayhandler.cpp
branchRCL_3
changeset 9 5294c000a26d
parent 8 ce5ada96ab30
child 10 112a725ff2c2
equal deleted inserted replaced
8:ce5ada96ab30 9:5294c000a26d
    13 *
    13 *
    14 * Description:   Implementation of video playback display handler
    14 * Description:   Implementation of video playback display handler
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 10 %
    18 
       
    19 // Version : %version: 11 %
       
    20 
    19 
    21 
    20 #include <sysutil.h>
    22 #include <sysutil.h>
    21 #include <s32file.h>
    23 #include <s32file.h>
    22 #include <mpxcommand.h>
    24 #include <mpxcommand.h>
    23 #include <mpxcommandgeneraldefs.h>
    25 #include <mpxcommandgeneraldefs.h>
    24 #include <mpxplaybackutility.h>
    26 #include <mpxplaybackutility.h>
    25 
    27 
    26 #include "mpxvideoplaybackdisplayhandler.h"
    28 #include "mpxvideoplaybackdisplayhandler.h"
    27 #include "mpxvideoregion.h"
    29 #include "mpxvideoregion.h"
    28 #include "mpxvideoplaybackviewfiledetails.h"
    30 #include "mpxvideoplaybackviewfiledetails.h"
       
    31 #include "mpxvideoplaybackcontainer.h"
       
    32 #include "mpxcommonvideoplaybackview.hrh"
    29 #include <mpxvideoplaybackdefs.h>
    33 #include <mpxvideoplaybackdefs.h>
    30 
    34 
    31 
    35 
    32 _LIT( KAspectRatioFile, "c:\\private\\200159b2\\mpxvideoplayer_aspect_ratio.dat" );
    36 _LIT( KAspectRatioFile, "c:\\private\\200159b2\\mpxvideoplayer_aspect_ratio.dat" );
    33 
    37 
    34 
    38 
    35 CMPXVideoPlaybackDisplayHandler::CMPXVideoPlaybackDisplayHandler( MMPXPlaybackUtility* aPlayUtil )
    39 CMPXVideoPlaybackDisplayHandler::CMPXVideoPlaybackDisplayHandler(
       
    40                                      MMPXPlaybackUtility* aPlayUtil,
       
    41                                      CMPXVideoPlaybackContainer* aContainer)
    36     : iPlaybackUtility( aPlayUtil )
    42     : iPlaybackUtility( aPlayUtil )
       
    43     , iContainer( aContainer )
    37 #ifdef SYMBIAN_BUILD_GCE
    44 #ifdef SYMBIAN_BUILD_GCE
    38     , iScaleWidth( 100.0f )
    45     , iScaleWidth( 100.0f )
    39     , iScaleHeight( 100.0f )
    46     , iScaleHeight( 100.0f )
    40     , iHorizontalPosition( EHorizontalAlignCenter )
    47     , iHorizontalPosition( EHorizontalAlignCenter )
    41     , iVerticalPosition( EVerticalAlignCenter )
    48     , iVerticalPosition( EVerticalAlignCenter )
    63 
    70 
    64     iSurfaceId = TSurfaceId::CreateNullId();
    71     iSurfaceId = TSurfaceId::CreateNullId();
    65 }
    72 }
    66 
    73 
    67 CMPXVideoPlaybackDisplayHandler*
    74 CMPXVideoPlaybackDisplayHandler*
    68 CMPXVideoPlaybackDisplayHandler::NewL( MMPXPlaybackUtility* aPlayUtil )
    75 CMPXVideoPlaybackDisplayHandler::NewL( MMPXPlaybackUtility* aPlayUtil,
       
    76                                        CMPXVideoPlaybackContainer* aContainer )
    69 {
    77 {
    70     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::NewL()"));
    78     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::NewL()"));
    71 
    79 
    72     CMPXVideoPlaybackDisplayHandler* self =
    80     CMPXVideoPlaybackDisplayHandler* self =
    73         new(ELeave) CMPXVideoPlaybackDisplayHandler( aPlayUtil );
    81         new(ELeave) CMPXVideoPlaybackDisplayHandler( aPlayUtil, aContainer );
    74 
    82 
    75     CleanupStack::PushL( self );
    83     CleanupStack::PushL( self );
    76     self->ConstructL();
    84     self->ConstructL();
    77     CleanupStack::Pop();
    85     CleanupStack::Pop();
    78     return self;
    86     return self;
    89 
    97 
    90 // -------------------------------------------------------------------------------------------------
    98 // -------------------------------------------------------------------------------------------------
    91 //   CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL()
    99 //   CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL()
    92 // -------------------------------------------------------------------------------------------------
   100 // -------------------------------------------------------------------------------------------------
    93 //
   101 //
    94 void CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL(
   102 void CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL( CWsScreenDevice& aScreenDevice,
    95                                           CWsScreenDevice& aScreenDevice,
   103                                                             RWindow& aWin )
    96                                           RWindow& aWin )
       
    97 {
   104 {
    98     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL()"));
   105     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL()"));
    99 
   106 
   100 #ifdef SYMBIAN_BUILD_GCE
   107 #ifdef SYMBIAN_BUILD_GCE
   101     AddDisplayWindowL( aScreenDevice, aWin, &aWin );
   108     AddDisplayWindowL( aScreenDevice, aWin, &aWin );
   112 
   119 
   113     CMPXCommand* cmd = CMPXCommand::NewL();
   120     CMPXCommand* cmd = CMPXCommand::NewL();
   114     CleanupStack::PushL( cmd );
   121     CleanupStack::PushL( cmd );
   115 
   122 
   116     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
   123     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
   124     cmd->SetTObjectValueL<TBool>( KMPXCommandPlaybackGeneralNoBuffer, ETrue );
   117     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
   125     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
   118     cmd->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand,
   126     cmd->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand,
   119                                                      EPbCmdSurfaceRemoved );
   127                                                      EPbCmdSurfaceRemoved );
   120 
   128 
   121     iPlaybackUtility->CommandL( *cmd );
   129     iPlaybackUtility->CommandL( *cmd );
   125 
   133 
   126 // -------------------------------------------------------------------------------------------------
   134 // -------------------------------------------------------------------------------------------------
   127 //   CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow()
   135 //   CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow()
   128 // -------------------------------------------------------------------------------------------------
   136 // -------------------------------------------------------------------------------------------------
   129 //
   137 //
   130 void CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow()
   138 void CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow( TBool aSignalPlaybackPlugin )
   131 {
   139 {
   132     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow()"));
   140     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow()"),
       
   141                    _L("aSignalPlaybackPlugin = %d"), aSignalPlaybackPlugin );
   133 
   142 
   134 #ifdef SYMBIAN_BUILD_GCE
   143 #ifdef SYMBIAN_BUILD_GCE
   135     if ( iVideoDisplay )
   144     if ( iVideoDisplay )
   136     {
   145     {
       
   146         //
       
   147         //  Surface is being removed, signal the container so it can reset the background
       
   148         //
       
   149         if ( iContainer )
       
   150         {
       
   151             iContainer->HandleCommandL( EMPXPbvSurfaceRemoved );
       
   152         }
       
   153 
   137         delete iVideoDisplay;
   154         delete iVideoDisplay;
   138         iVideoDisplay = NULL;
   155         iVideoDisplay = NULL;
   139     }
   156     }
   140 #endif
   157 #endif
   141 
   158 
   142     if ( ! iSurfaceId.IsNull() )
   159     if ( ! iSurfaceId.IsNull() )
   143     {
   160     {
   144         //
   161         if ( aSignalPlaybackPlugin )
   145         //  Signal to the Playback Plugin that the surface has been removed
   162         {
   146         //
   163             //
   147         TRAP_IGNORE( SignalSurfaceRemovedL() );
   164             //  Signal to the Playback Plugin that the surface has been removed
       
   165             //
       
   166             TRAP_IGNORE( SignalSurfaceRemovedL() );
       
   167         }
   148 
   168 
   149         iSurfaceId = TSurfaceId::CreateNullId();
   169         iSurfaceId = TSurfaceId::CreateNullId();
   150     }
   170     }
   151 }
   171 }
   152 
   172 
   153 // -------------------------------------------------------------------------------------------------
   173 // -------------------------------------------------------------------------------------------------
   154 //   CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessageL()
   174 //   CMPXVideoPlaybackDisplayHandler::HandleVideoDisplaySyncMessageL()
   155 // -------------------------------------------------------------------------------------------------
   175 // -------------------------------------------------------------------------------------------------
   156 //
   176 //
   157 TMPXVideoDisplayCommand
   177 void
   158 CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessageL( CMPXMessage* aMessage )
   178 CMPXVideoPlaybackDisplayHandler::HandleVideoDisplaySyncMessageL( CMPXMessage* aMessage )
   159 {
   179 {
   160     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessage()"));
   180     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::HandleVideoDisplaySyncMessageL()"));
   161 
   181 
   162     TMPXVideoDisplayCommand message =
   182     TMPXVideoDisplayCommand message =
   163         ( *(aMessage->Value<TMPXVideoDisplayCommand>(KMPXMediaVideoDisplayCommand)) );
   183         ( *(aMessage->Value<TMPXVideoDisplayCommand>(KMPXMediaVideoDisplayCommand)) );
   164 
   184 
   165     MPX_DEBUG(
   185     MPX_DEBUG(
   166       _L("CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessageL() message = %d"), message );
   186       _L("CMPXVideoPlaybackDisplayHandler::HandleVideoDisplaySyncMessageL() message = %d"), message );
   167 
   187 
   168     switch ( message )
   188     switch ( message )
   169     {
   189     {
   170 #ifdef SYMBIAN_BUILD_GCE
   190 #ifdef SYMBIAN_BUILD_GCE
   171         case EPbMsgVideoSurfaceCreated:
   191         case EPbMsgVideoSurfaceCreated:
   183             SurfaceRemoved();
   203             SurfaceRemoved();
   184             break;
   204             break;
   185         }
   205         }
   186         case EPbMsgVideoRemoveDisplayWindow:
   206         case EPbMsgVideoRemoveDisplayWindow:
   187         {
   207         {
   188             if ( iVideoDisplay )
   208             RemoveDisplayWindow( EFalse );
   189             {
       
   190                 delete iVideoDisplay;
       
   191                 iVideoDisplay = NULL;
       
   192             }
       
   193 
       
   194             iSurfaceId = TSurfaceId::CreateNullId();
       
   195 
       
   196             break;
   209             break;
   197         }
   210         }
   198 #endif
   211 #endif
   199     }
   212     }
   200 
   213 
   201     return message;
   214     //
   202 }
   215     //  Signal Sync Message handling is complete
   203 
   216     //
       
   217     iPlaybackUtility->CommandL( EPbCmdSyncMsgComplete );
       
   218 }
   204 
   219 
   205 // -------------------------------------------------------------------------------------------------
   220 // -------------------------------------------------------------------------------------------------
   206 //   CMPXVideoPlaybackDisplayHandler::SetAspectRatioL()
   221 //   CMPXVideoPlaybackDisplayHandler::SetAspectRatioL()
   207 // -------------------------------------------------------------------------------------------------
   222 // -------------------------------------------------------------------------------------------------
   208 //
   223 //
   226         iAspectRatioArray[iCurrentIndexForAspectRatio].scalingType = (TMMFScalingType)aspectRatio;
   241         iAspectRatioArray[iCurrentIndexForAspectRatio].scalingType = (TMMFScalingType)aspectRatio;
   227     }
   242     }
   228 
   243 
   229     return aspectRatio;
   244     return aspectRatio;
   230 }
   245 }
   231 
       
   232 
   246 
   233 // -------------------------------------------------------------------------------------------------
   247 // -------------------------------------------------------------------------------------------------
   234 //   CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL
   248 //   CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL
   235 // -------------------------------------------------------------------------------------------------
   249 // -------------------------------------------------------------------------------------------------
   236 //
   250 //
   361     }
   375     }
   362 
   376 
   363     CleanupStack::PopAndDestroy();
   377     CleanupStack::PopAndDestroy();
   364 }
   378 }
   365 
   379 
   366 
       
   367 // -------------------------------------------------------------------------------------------------
   380 // -------------------------------------------------------------------------------------------------
   368 //   CMPXVideoPlaybackDisplayHandler::LoadAspectRatioL
   381 //   CMPXVideoPlaybackDisplayHandler::LoadAspectRatioL
   369 // -------------------------------------------------------------------------------------------------
   382 // -------------------------------------------------------------------------------------------------
   370 //
   383 //
   371 void CMPXVideoPlaybackDisplayHandler::LoadAspectRatioL()
   384 void CMPXVideoPlaybackDisplayHandler::LoadAspectRatioL()
   425 
   438 
   426     delete tempDisplay;
   439     delete tempDisplay;
   427 
   440 
   428     TRect cropRect = TRect( aWin->Size() );
   441     TRect cropRect = TRect( aWin->Size() );
   429 
   442 
   430     MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL() cropRect (%d, %d), (%d, %d)"),
   443     MPX_DEBUG(
       
   444         _L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL() cropRect (%d, %d), (%d, %d)"),
   431         cropRect.iTl.iX, cropRect.iTl.iY, cropRect.iBr.iX, cropRect.iBr.iY);
   445         cropRect.iTl.iX, cropRect.iTl.iY, cropRect.iBr.iX, cropRect.iBr.iY);
   432 
   446 
   433     MPX_TRAPD( dispError,
   447     MPX_TRAPD( dispError,
   434         iVideoDisplay->AddDisplayWindowL( &aWindowBase,
   448         iVideoDisplay->AddDisplayWindowL( &aWindowBase,
   435                                           cropRect,
   449                                           cropRect,
   451     //
   465     //
   452     if ( iSurfaceCached )
   466     if ( iSurfaceCached )
   453     {
   467     {
   454         iVideoDisplay->SurfaceCreated( iSurfaceId, iCropRect, iAspectRatio, iCropRect );
   468         iVideoDisplay->SurfaceCreated( iSurfaceId, iCropRect, iAspectRatio, iCropRect );
   455 
   469 
       
   470         if ( iContainer )
       
   471         {
       
   472             iContainer->HandleCommandL( EMPXPbvSurfaceCreated );
       
   473         }
       
   474 
   456         iSurfaceCached = EFalse;
   475         iSurfaceCached = EFalse;
   457     }
   476     }
   458 }
   477 }
   459 
   478 
   460 // -------------------------------------------------------------------------------------------------
   479 // -------------------------------------------------------------------------------------------------
   486 
   505 
   487         //
   506         //
   488         //  Add new surface
   507         //  Add new surface
   489         //
   508         //
   490         iVideoDisplay->SurfaceCreated( iSurfaceId, iCropRect, iAspectRatio, iCropRect );
   509         iVideoDisplay->SurfaceCreated( iSurfaceId, iCropRect, iAspectRatio, iCropRect );
       
   510 
       
   511         if ( iContainer )
       
   512         {
       
   513             iContainer->HandleCommandL( EMPXPbvSurfaceCreated );
       
   514         }
   491     }
   515     }
   492     else
   516     else
   493     {
   517     {
   494         //
   518         //
   495         //  Video display has not been created yet, save surface information to create
   519         //  Video display has not been created yet, save surface information to create
   533 {
   557 {
   534     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SurfaceRemoved()"));
   558     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SurfaceRemoved()"));
   535 
   559 
   536     if ( iVideoDisplay )
   560     if ( iVideoDisplay )
   537     {
   561     {
       
   562         if ( iContainer )
       
   563         {
       
   564             iContainer->HandleCommandL( EMPXPbvSurfaceRemoved );
       
   565         }
       
   566 
   538         iVideoDisplay->RemoveSurface();
   567         iVideoDisplay->RemoveSurface();
   539     }
   568     }
   540 
   569 
   541     iSurfaceId = TSurfaceId::CreateNullId();
   570     iSurfaceId = TSurfaceId::CreateNullId();
   542 }
   571 }