videoplayback/hbvideoplaybackview/viewsrc/mpxvideoplaybackdisplayhandler.cpp
changeset 42 17f382c040b1
parent 41 229f037ce963
equal deleted inserted replaced
41:229f037ce963 42:17f382c040b1
    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:  22 %
    18 // Version : %version:  ou1cpsw#26 %
    19 
    19 
    20 #include <sysutil.h>
    20 #include <sysutil.h>
    21 #include <s32file.h>
    21 #include <s32file.h>
    22 #include <mpxcommand.h>
    22 #include <mpxcommand.h>
    23 #include <mpxcommandgeneraldefs.h>
    23 #include <mpxcommandgeneraldefs.h>
    24 #include <mpxplaybackutility.h>
    24 #include <mpxplaybackutility.h>
    25 #include <mpxvideoplaybackdefs.h>
    25 #include <mpxvideoplaybackdefs.h>
    26 #include <alfcompositionutility.h>
       
    27 
    26 
    28 #include "mpxvideocontainer.h"
    27 #include "mpxvideocontainer.h"
    29 #include "mpxvideoviewwrapper.h"
    28 #include "mpxvideoviewwrapper.h"
    30 #include "mpxvideoplaybackdisplayhandler.h"
    29 #include "mpxvideoplaybackdisplayhandler.h"
    31 #include "mpxvideoregion.h"
    30 #include "mpxvideoregion.h"
    67     iAspectRatioArray.Close();
    66     iAspectRatioArray.Close();
    68 
    67 
    69     if ( iVideoDisplay )
    68     if ( iVideoDisplay )
    70     {
    69     {
    71         SurfaceRemoved();
    70         SurfaceRemoved();
    72     	
    71 
    73         delete iVideoDisplay;
    72         delete iVideoDisplay;
    74         iVideoDisplay = NULL;
    73         iVideoDisplay = NULL;
    75     }
    74     }
    76 
    75 
    77 	if ( iVideoContainer )
    76 	if ( iVideoContainer )
   100 //  CMPXVideoPlaybackDisplayHandler::ConstructL()
    99 //  CMPXVideoPlaybackDisplayHandler::ConstructL()
   101 // -------------------------------------------------------------------------------------------------
   100 // -------------------------------------------------------------------------------------------------
   102 //
   101 //
   103 void CMPXVideoPlaybackDisplayHandler::ConstructL()
   102 void CMPXVideoPlaybackDisplayHandler::ConstructL()
   104 {
   103 {
   105     iResizingTimer = CPeriodic::NewL( CActive::EPriorityStandard );    
   104     iResizingTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   106     LoadAspectRatioL();
   105     LoadAspectRatioL();
   107 }
   106 }
   108 
   107 
   109 // -------------------------------------------------------------------------------------------------
   108 // -------------------------------------------------------------------------------------------------
   110 //   CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL()
   109 //   CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL()
   116                                           RWindow& aWin,
   115                                           RWindow& aWin,
   117                                           TRect aDisplayRect )
   116                                           TRect aDisplayRect )
   118 {
   117 {
   119     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL()"));
   118     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL()"));
   120 
   119 
   121     //
   120     if ( ! iVideoContainer )
   122     // Workaround start for PREQ-2669
   121     {
   123     //
   122         iVideoContainer = new ( ELeave ) CMPXVideoContainer();
   124     iVideoContainer = new ( ELeave ) CMPXVideoContainer();
   123         iVideoContainer->ConstructL();
   125     iVideoContainer->ConstructL();
   124         iVideoContainer->SetRect( aDisplayRect );
   126     iVideoContainer->SetRect( aDisplayRect );
   125     }
       
   126 
       
   127     aWin.SetSurfaceTransparency( ETrue );
   127 
   128 
   128     RWindowBase *videoWindow = iVideoContainer->DrawableWindow();
   129     RWindowBase *videoWindow = iVideoContainer->DrawableWindow();
   129     videoWindow->SetOrdinalPosition( -1 );
   130     videoWindow->SetOrdinalPosition( -1 );
   130     (&aWin)->SetOrdinalPosition( 0 );
   131     (&aWin)->SetOrdinalPosition( 0 );
   131 
   132 
   132     MPX_DEBUG(_L("VideoWindow ordinal position is: %d"), videoWindow->OrdinalPosition());
   133     MPX_DEBUG(_L("VideoWindow ordinal position is: %d"), videoWindow->OrdinalPosition());
   133     MPX_DEBUG(_L("UiWindow ordinal position is: %d"), (&aWin)->OrdinalPosition());
   134     MPX_DEBUG(_L("UiWindow ordinal position is: %d"), (&aWin)->OrdinalPosition());
   134 
   135 
   135     int status = KErrNone;
       
   136 
       
   137     TRAP
       
   138     ( status,
       
   139         {
       
   140             CAlfCompositionSource* me = CAlfCompositionSource::NewL( aWin );
       
   141             me->EnableAlpha();
       
   142             delete me;
       
   143             me = NULL;
       
   144         }
       
   145     );
       
   146 
       
   147     MPX_DEBUG(
       
   148         _L("CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL() status : %d"), status);
       
   149 
       
   150     //
       
   151     // Workaround end
       
   152     //
       
   153 
       
   154     AddDisplayWindowL( aScreenDevice, *videoWindow, (RWindow*)videoWindow );
   136     AddDisplayWindowL( aScreenDevice, *videoWindow, (RWindow*)videoWindow );
   155 }
   137 }
   156 
   138 
   157 // -------------------------------------------------------------------------------------------------
   139 // -------------------------------------------------------------------------------------------------
   158 //   CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow()
   140 //   CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow()
   166     {
   148     {
   167         SurfaceRemoved();
   149         SurfaceRemoved();
   168         delete iVideoDisplay;
   150         delete iVideoDisplay;
   169         iVideoDisplay = NULL;
   151         iVideoDisplay = NULL;
   170     }
   152     }
   171 	
   153 
   172     if ( iVideoContainer )
   154     if ( iVideoContainer )
   173     {
   155     {
   174         delete iVideoContainer;
   156         delete iVideoContainer;
   175         iVideoContainer = NULL;
   157         iVideoContainer = NULL;
   176     }
   158     }
   241 // -------------------------------------------------------------------------------------------------
   223 // -------------------------------------------------------------------------------------------------
   242 //   CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL
   224 //   CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL
   243 // -------------------------------------------------------------------------------------------------
   225 // -------------------------------------------------------------------------------------------------
   244 //
   226 //
   245 TInt CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL(
   227 TInt CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL(
   246                                           QMPXVideoPlaybackViewFileDetails* aFileDetails,
   228         QMPXVideoPlaybackViewFileDetails* aFileDetails, TReal32 aDisplayAspectRatio )
   247                                           TReal32 aDisplayAspectRatio )
       
   248 {
   229 {
   249     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL()"));
   230     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL()"));
   250 
   231 
   251     TInt newAspectRatio = EMMFNatural;
   232     TInt newAspectRatio = EMMFNatural;
   252 
   233 
   273             }
   254             }
   274         }
   255         }
   275 
   256 
   276         //
   257         //
   277         //  if can't find out match aspect ratio in dat file,
   258         //  if can't find out match aspect ratio in dat file,
   278         //  choose the scaling type through the rule        
   259         //  choose the scaling type through the rule
   279         //      aspectRatioDiff =  videoAspectRatio - aDisplayAspectRatio
   260         //      aspectRatioDiff =  videoAspectRatio - aDisplayAspectRatio
   280         //      aspectRatioDiff ==  0        ==> natural
   261         //      aspectRatioDiff ==  0        ==> natural
   281         //      aspectRatioDiff > 0.1        ==> zoom
   262         //      aspectRatioDiff > 0.1        ==> zoom
   282         //      aspectRatioDiff < - 0.3      ==> natural
   263         //      aspectRatioDiff < - 0.3      ==> natural
   283         //      aspectRatioDiff >= - 0.3 and <= 0.1   ==> stretch
   264         //      aspectRatioDiff >= - 0.3 and <= 0.1   ==> stretch
   284         //
   265         //
   285         
   266 
   286         if ( i == cnt )
   267         if ( i == cnt )
   287         {
   268         {
   288             if ( videoAspectRatio - aDisplayAspectRatio > 0.1 )
   269             if ( videoAspectRatio - aDisplayAspectRatio > 0.1 )
   289             {
   270             {
   290                 scalingType = EMMFZoom;
   271                 scalingType = EMMFZoom;
   432         if ( iResizingTimer->IsActive() )
   413         if ( iResizingTimer->IsActive() )
   433         {
   414         {
   434             iResizingTimer->Cancel();
   415             iResizingTimer->Cancel();
   435         }
   416         }
   436 
   417 
   437         iResizingTimer->Start( 
   418         iResizingTimer->Start(
   438                 0,
   419                 0,
   439                 KVIDEORESIZINGREPEATRATE,
   420                 KVIDEORESIZINGREPEATRATE,
   440                 TCallBack( CMPXVideoPlaybackDisplayHandler::UpdateVideoRectTimeOutL, this ) );                
   421                 TCallBack( CMPXVideoPlaybackDisplayHandler::UpdateVideoRectTimeOutL, this ) );
   441     }
   422     }
   442     else
   423     else
   443     {
   424     {
   444         SetVideoRectL( aClipRect );
   425         SetVideoRectL( aClipRect );
   445 
   426 
   468 //
   449 //
   469 void CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL()
   450 void CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL()
   470 {
   451 {
   471     iTransitionEffectCnt++;
   452     iTransitionEffectCnt++;
   472 
   453 
   473     TRect windowRect( (TInt)( (TReal32)iWindowRect.iTl.iX - iTlXDiff * (TReal32)iTransitionEffectCnt ), 
   454     TRect windowRect( (TInt)( (TReal32)iWindowRect.iTl.iX - iTlXDiff * (TReal32)iTransitionEffectCnt ),
   474                       (TInt)( (TReal32)iWindowRect.iTl.iY - iTlYDiff * (TReal32)iTransitionEffectCnt ), 
   455                       (TInt)( (TReal32)iWindowRect.iTl.iY - iTlYDiff * (TReal32)iTransitionEffectCnt ),
   475                       (TInt)( (TReal32)iWindowRect.iBr.iX - iBrXDiff * (TReal32)iTransitionEffectCnt ),
   456                       (TInt)( (TReal32)iWindowRect.iBr.iX - iBrXDiff * (TReal32)iTransitionEffectCnt ),
   476                       (TInt)( (TReal32)iWindowRect.iBr.iY - iBrYDiff * (TReal32)iTransitionEffectCnt ) );
   457                       (TInt)( (TReal32)iWindowRect.iBr.iY - iBrYDiff * (TReal32)iTransitionEffectCnt ) );
   477 
   458 
   478     MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL() %d %d %d %d"),
   459     MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL() %d %d %d %d"),
   479             windowRect.iTl.iX, windowRect.iTl.iY, windowRect.iBr.iX, windowRect.iBr.iY );
   460             windowRect.iTl.iX, windowRect.iTl.iY, windowRect.iBr.iX, windowRect.iBr.iY );
   504 {
   485 {
   505     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SetVideoRectL()"));
   486     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SetVideoRectL()"));
   506 
   487 
   507     if ( iVideoDisplay )
   488     if ( iVideoDisplay )
   508     {
   489     {
   509         iVideoDisplay->SetVideoExtentL( *iWindowBase, aRect, TRect( iWindowBase->Size() ) );        
   490         iVideoDisplay->SetVideoExtentL( *iWindowBase, aRect, TRect( iWindowBase->Size() ) );
   510     }
   491     }
   511 }
   492 }
   512 
   493 
   513 // -------------------------------------------------------------------------------------------------
   494 // -------------------------------------------------------------------------------------------------
   514 //   CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL()
   495 //   CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL()
   539     //
   520     //
   540     if ( cropRect.Width() < cropRect.Height() )
   521     if ( cropRect.Width() < cropRect.Height() )
   541     {
   522     {
   542         iRotation = EVideoRotationClockwise90;
   523         iRotation = EVideoRotationClockwise90;
   543     }
   524     }
   544     
   525 
   545     iWindowRect = cropRect;
   526     iWindowRect = cropRect;
   546     
   527 
   547     MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL() cropRect (%d, %d), (%d, %d)"),
   528     MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL() cropRect (%d, %d), (%d, %d)"),
   548         cropRect.iTl.iX, cropRect.iTl.iY, cropRect.iBr.iX, cropRect.iBr.iY);
   529         cropRect.iTl.iX, cropRect.iTl.iY, cropRect.iBr.iX, cropRect.iBr.iY);
   549 
   530 
   550     MPX_TRAPD( dispError,
   531     MPX_TRAPD( dispError,
   551     iVideoDisplay->AddDisplayWindowL( iWindowBase,
   532     iVideoDisplay->AddDisplayWindowL( iWindowBase,
   580 void CMPXVideoPlaybackDisplayHandler::SurfaceCreatedL( CMPXMessage* aMessage )
   561 void CMPXVideoPlaybackDisplayHandler::SurfaceCreatedL( CMPXMessage* aMessage )
   581 {
   562 {
   582     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SurfaceCreatedL()"));
   563     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SurfaceCreatedL()"));
   583 
   564 
   584     TSurfaceId oldSurfaceId = iSurfaceId;
   565     TSurfaceId oldSurfaceId = iSurfaceId;
   585     
   566 
   586     //
   567     //
   587     //  Extract the surface parameters from the message
   568     //  Extract the surface parameters from the message
   588     //
   569     //
   589     iSurfaceId = aMessage->ValueTObjectL<TSurfaceId>( KMPXMediaVideoDisplayTSurfaceId );
   570     iSurfaceId = aMessage->ValueTObjectL<TSurfaceId>( KMPXMediaVideoDisplayTSurfaceId );
   590     iCropRect = aMessage->ValueTObjectL<TRect>( KMPXMediaVideoDisplayCropRect );
   571     iCropRect = aMessage->ValueTObjectL<TRect>( KMPXMediaVideoDisplayCropRect );