videoplayback/videohelix/src/mpxvideoplayerutility.cpp
changeset 24 7d93ee07fb27
parent 17 69946d1824c4
child 52 e3cecb93e76a
equal deleted inserted replaced
20:b9e04db066d4 24:7d93ee07fb27
    14 * Description:  This class is the interface between the playback plugin and RMMFController
    14 * Description:  This class is the interface between the playback plugin and RMMFController
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // Version : %version: 20 %
    19 // Version : %version: 22 %
    20 
    20 
    21 
    21 
    22 #include <AudioPreference.h>
    22 #include <AudioPreference.h>
    23 #include <mmf/server/mmffile.h>
    23 #include <mmf/server/mmffile.h>
    24 #include <caf/caftypes.h>
    24 #include <caf/caftypes.h>
    25 #include <mpxmessagegeneraldefs.h>
    25 #include <mpxmessagegeneraldefs.h>
       
    26 #include <fbs.h>
    26 
    27 
    27 #include "mpxvideoplayerutility.h"
    28 #include "mpxvideoplayerutility.h"
    28 #include "mpxvideoplaybackcontroller.h"
    29 #include "mpxvideoplaybackcontroller.h"
    29 #include <mpxvideoplaybackdefs.h>
    30 #include <mpxvideoplaybackdefs.h>
    30 #include "mpxvideo_debug.h"
    31 #include "mpxvideo_debug.h"
    43     CleanupStack::Pop();
    44     CleanupStack::Pop();
    44     return self;
    45     return self;
    45 }
    46 }
    46 
    47 
    47 CMpxVideoPlayerUtility::CMpxVideoPlayerUtility( CMPXVideoPlaybackController* aVideoPlaybackCtrl )
    48 CMpxVideoPlayerUtility::CMpxVideoPlayerUtility( CMPXVideoPlaybackController* aVideoPlaybackCtrl )
    48     : iVideoPlaybackController( aVideoPlaybackCtrl )
    49     : CActive( EPriorityStandard )
       
    50     , iVideoPlaybackController( aVideoPlaybackCtrl )
    49     , iVideoControllerCustomCommands( iController )
    51     , iVideoControllerCustomCommands( iController )
    50     , iVideoPlayControllerCustomCommands( iController )
    52     , iVideoPlayControllerCustomCommands( iController )
    51     , iAudioPlayDeviceCustomCommands( iController )
    53     , iAudioPlayDeviceCustomCommands( iController )
    52     , iDrmCustomCommands( iController )
    54     , iDrmCustomCommands( iController )
    53     , iVideoPlayControllerExtCustomCommands( iController )
    55     , iVideoPlayControllerExtCustomCommands( iController )
    58 }
    60 }
    59 
    61 
    60 void CMpxVideoPlayerUtility::ConstructL()
    62 void CMpxVideoPlayerUtility::ConstructL()
    61 {
    63 {
    62     OpenControllerL();
    64     OpenControllerL();
       
    65         
       
    66     CActiveScheduler::Add( this );
    63 }
    67 }
    64 
    68 
    65 CMpxVideoPlayerUtility::~CMpxVideoPlayerUtility()
    69 CMpxVideoPlayerUtility::~CMpxVideoPlayerUtility()
    66 {
    70 {
    67     MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::~CMpxVideoPlayerUtility()"));
    71     MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::~CMpxVideoPlayerUtility()"));
    82 
    86 
    83     iSurfaceId = TSurfaceId::CreateNullId();
    87     iSurfaceId = TSurfaceId::CreateNullId();
    84 
    88 
    85     iController.Close();
    89     iController.Close();
    86     iDirectScreenAccessAbort = EFalse;
    90     iDirectScreenAccessAbort = EFalse;
       
    91     
       
    92     if ( IsActive() )
       
    93     {
       
    94         Cancel();
       
    95         
       
    96         if ( iPosterFrameBitmap )
       
    97         {
       
    98             delete iPosterFrameBitmap;
       
    99             iPosterFrameBitmap = NULL;         
       
   100         }
       
   101     }    
    87 }
   102 }
    88 
   103 
    89 void CMpxVideoPlayerUtility::Reset()
   104 void CMpxVideoPlayerUtility::Reset()
    90 {
   105 {
    91     MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::Reset()"));
   106     MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::Reset()"));
   306         iVideoPlayControllerCustomCommands.GetLoadingProgress( aPercentageProgress ) );
   321         iVideoPlayControllerCustomCommands.GetLoadingProgress( aPercentageProgress ) );
   307 
   322 
   308     MPX_DEBUG(_L("CMpxVideoPlayerUtility::GetVideoLoadingProgressL(%d)"), aPercentageProgress );
   323     MPX_DEBUG(_L("CMpxVideoPlayerUtility::GetVideoLoadingProgressL(%d)"), aPercentageProgress );
   309 }
   324 }
   310 
   325 
       
   326 void CMpxVideoPlayerUtility::GetFrameL()
       
   327 {    
       
   328     MPX_DEBUG(_L("CMpxVideoPlayerUtility::GetFrameL"));
       
   329        
       
   330     // dont get another frame if a request is already pending
       
   331     //
       
   332     if ( ! IsActive() )
       
   333     {
       
   334         iPosterFrameBitmap = new (ELeave) CFbsBitmap;
       
   335         User::LeaveIfError(iPosterFrameBitmap->Create(TSize(0,0), EColor16MU));  
       
   336                 
       
   337         iVideoPlayControllerCustomCommands.GetFrame( *iPosterFrameBitmap, iStatus );   
       
   338         SetActive();    
       
   339     }
       
   340 
       
   341 }
       
   342 
       
   343 void CMpxVideoPlayerUtility::RunL()
       
   344 {
       
   345     MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::RunL()"));
       
   346     
       
   347     if ( iStatus.Int() == KErrNone )
       
   348     {   
       
   349         iVideoPlaybackController->HandleFrameReady( iStatus.Int() );        
       
   350     }   
       
   351     else
       
   352     {
       
   353         // Bitmap ownership will NOT be transferred to thumbnail manager so delete it    
       
   354         delete iPosterFrameBitmap;
       
   355         iPosterFrameBitmap = NULL;        
       
   356     }        
       
   357 }
       
   358 
       
   359 void CMpxVideoPlayerUtility::DoCancel()
       
   360 {
       
   361     MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::DoCancel()"));
       
   362     
       
   363     // Bitmap ownership will NOT be transferred to thumbnail manager so delete it       
       
   364     delete iPosterFrameBitmap;
       
   365     iPosterFrameBitmap = NULL;         
       
   366 }
       
   367 
       
   368 CFbsBitmap& CMpxVideoPlayerUtility::GetBitmap()
       
   369 {
       
   370     MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::GetBitmap()"));
       
   371         
       
   372     return *iPosterFrameBitmap;
       
   373 }
       
   374 
   311 void CMpxVideoPlayerUtility::PlayL()
   375 void CMpxVideoPlayerUtility::PlayL()
   312 {
   376 {
   313     MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::PlayL()"));
   377     MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::PlayL()"));
   314 
   378 
   315     User::LeaveIfError( iController.Play() );
   379     User::LeaveIfError( iController.Play() );
   483     TInt error = KErrNone;
   547     TInt error = KErrNone;
   484 
   548 
   485     if ( iSurfaceId.IsNull() )
   549     if ( iSurfaceId.IsNull() )
   486     {
   550     {
   487         TSurfaceId surfaceId;
   551         TSurfaceId surfaceId;
   488         TRect cropRect;
       
   489         TVideoAspectRatio aspectRatio;
       
   490 
   552 
   491         error = iVideoPlaySurfaceSupportCustomCommands.GetSurfaceParameters( surfaceId,
   553         error = iVideoPlaySurfaceSupportCustomCommands.GetSurfaceParameters( surfaceId,
   492                                                                              cropRect,
   554                                                                              iCropRect,
   493                                                                              aspectRatio );
   555                                                                              iAspectRatio );
   494 
   556 
   495         if ( error == KErrNone )
   557         if ( error == KErrNone )
   496         {
   558         {
   497             //
   559             if ( iVideoPlaybackController->IsViewActivated() )
   498             //  Send data to the display handler to remove old surface and add new surface
   560             {
   499             //
   561                 //
   500             MPX_TRAPD( err, SendSurfaceCommandL( EPbMsgVideoSurfaceCreated,
   562                 //  Send data to the display handler to remove old surface and add new surface
   501                                                  surfaceId,
   563                 //
   502                                                  cropRect,
   564                 MPX_TRAPD( err, SendSurfaceCommandL( EPbMsgVideoSurfaceCreated,
   503                                                  aspectRatio ) );
   565                                                      surfaceId,
       
   566                                                      iCropRect,
       
   567                                                      iAspectRatio ) );
       
   568             }
   504 
   569 
   505             iSurfaceId = surfaceId;
   570             iSurfaceId = surfaceId;
   506         }
   571         }
   507     }
   572     }
   508     else
   573     else
   632 
   697 
   633         CleanupStack::PopAndDestroy( msg );
   698         CleanupStack::PopAndDestroy( msg );
   634     }
   699     }
   635 }
   700 }
   636 
   701 
       
   702 // -------------------------------------------------------------------------------------------------
       
   703 //   CMpxVideoPlayerUtility::SendSurfaceCreatedCommand()
       
   704 // -------------------------------------------------------------------------------------------------
       
   705 //
       
   706 void CMpxVideoPlayerUtility::SendSurfaceCreatedCommand()
       
   707 {
       
   708     MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::SendSurfaceCreatedCommand()"));
       
   709 
       
   710     if ( ! iSurfaceId.IsNull() )
       
   711     {
       
   712         MPX_TRAPD( err, SendSurfaceCommandL( EPbMsgVideoSurfaceCreated,
       
   713                                              iSurfaceId,
       
   714                                              iCropRect,
       
   715                                              iAspectRatio ) );
       
   716     }
       
   717 }
       
   718 
   637 #endif
   719 #endif
   638 
   720 
   639 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   721 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   640 
   722 
   641 void CMpxVideoPlayerUtility::OpenFile64L( const RFile64& aFile )
   723 void CMpxVideoPlayerUtility::OpenFile64L( const RFile64& aFile )