videoplayback/videohelix/src/mpxvideoplayerutility.cpp
branchRCL_3
changeset 23 8f0df5c82986
parent 16 7f2b2a65da29
child 54 315810614048
--- a/videoplayback/videohelix/src/mpxvideoplayerutility.cpp	Tue May 11 16:15:40 2010 +0300
+++ b/videoplayback/videohelix/src/mpxvideoplayerutility.cpp	Tue May 25 12:44:54 2010 +0300
@@ -16,13 +16,14 @@
 */
 
 
-// Version : %version: 20 %
+// Version : %version: 22 %
 
 
 #include <AudioPreference.h>
 #include <mmf/server/mmffile.h>
 #include <caf/caftypes.h>
 #include <mpxmessagegeneraldefs.h>
+#include <fbs.h>
 
 #include "mpxvideoplayerutility.h"
 #include "mpxvideoplaybackcontroller.h"
@@ -45,7 +46,8 @@
 }
 
 CMpxVideoPlayerUtility::CMpxVideoPlayerUtility( CMPXVideoPlaybackController* aVideoPlaybackCtrl )
-    : iVideoPlaybackController( aVideoPlaybackCtrl )
+    : CActive( EPriorityStandard )
+    , iVideoPlaybackController( aVideoPlaybackCtrl )
     , iVideoControllerCustomCommands( iController )
     , iVideoPlayControllerCustomCommands( iController )
     , iAudioPlayDeviceCustomCommands( iController )
@@ -60,6 +62,8 @@
 void CMpxVideoPlayerUtility::ConstructL()
 {
     OpenControllerL();
+        
+    CActiveScheduler::Add( this );
 }
 
 CMpxVideoPlayerUtility::~CMpxVideoPlayerUtility()
@@ -84,6 +88,17 @@
 
     iController.Close();
     iDirectScreenAccessAbort = EFalse;
+    
+    if ( IsActive() )
+    {
+        Cancel();
+        
+        if ( iPosterFrameBitmap )
+        {
+            delete iPosterFrameBitmap;
+            iPosterFrameBitmap = NULL;         
+        }
+    }    
 }
 
 void CMpxVideoPlayerUtility::Reset()
@@ -308,6 +323,55 @@
     MPX_DEBUG(_L("CMpxVideoPlayerUtility::GetVideoLoadingProgressL(%d)"), aPercentageProgress );
 }
 
+void CMpxVideoPlayerUtility::GetFrameL()
+{    
+    MPX_DEBUG(_L("CMpxVideoPlayerUtility::GetFrameL"));
+       
+    // dont get another frame if a request is already pending
+    //
+    if ( ! IsActive() )
+    {
+        iPosterFrameBitmap = new (ELeave) CFbsBitmap;
+        User::LeaveIfError(iPosterFrameBitmap->Create(TSize(0,0), EColor16MU));  
+                
+        iVideoPlayControllerCustomCommands.GetFrame( *iPosterFrameBitmap, iStatus );   
+        SetActive();    
+    }
+
+}
+
+void CMpxVideoPlayerUtility::RunL()
+{
+    MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::RunL()"));
+    
+    if ( iStatus.Int() == KErrNone )
+    {   
+        iVideoPlaybackController->HandleFrameReady( iStatus.Int() );        
+    }   
+    else
+    {
+        // Bitmap ownership will NOT be transferred to thumbnail manager so delete it    
+        delete iPosterFrameBitmap;
+        iPosterFrameBitmap = NULL;        
+    }        
+}
+
+void CMpxVideoPlayerUtility::DoCancel()
+{
+    MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::DoCancel()"));
+    
+    // Bitmap ownership will NOT be transferred to thumbnail manager so delete it       
+    delete iPosterFrameBitmap;
+    iPosterFrameBitmap = NULL;         
+}
+
+CFbsBitmap& CMpxVideoPlayerUtility::GetBitmap()
+{
+    MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::GetBitmap()"));
+        
+    return *iPosterFrameBitmap;
+}
+
 void CMpxVideoPlayerUtility::PlayL()
 {
     MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::PlayL()"));
@@ -485,22 +549,23 @@
     if ( iSurfaceId.IsNull() )
     {
         TSurfaceId surfaceId;
-        TRect cropRect;
-        TVideoAspectRatio aspectRatio;
 
         error = iVideoPlaySurfaceSupportCustomCommands.GetSurfaceParameters( surfaceId,
-                                                                             cropRect,
-                                                                             aspectRatio );
+                                                                             iCropRect,
+                                                                             iAspectRatio );
 
         if ( error == KErrNone )
         {
-            //
-            //  Send data to the display handler to remove old surface and add new surface
-            //
-            MPX_TRAPD( err, SendSurfaceCommandL( EPbMsgVideoSurfaceCreated,
-                                                 surfaceId,
-                                                 cropRect,
-                                                 aspectRatio ) );
+            if ( iVideoPlaybackController->IsViewActivated() )
+            {
+                //
+                //  Send data to the display handler to remove old surface and add new surface
+                //
+                MPX_TRAPD( err, SendSurfaceCommandL( EPbMsgVideoSurfaceCreated,
+                                                     surfaceId,
+                                                     iCropRect,
+                                                     iAspectRatio ) );
+            }
 
             iSurfaceId = surfaceId;
         }
@@ -634,6 +699,23 @@
     }
 }
 
+// -------------------------------------------------------------------------------------------------
+//   CMpxVideoPlayerUtility::SendSurfaceCreatedCommand()
+// -------------------------------------------------------------------------------------------------
+//
+void CMpxVideoPlayerUtility::SendSurfaceCreatedCommand()
+{
+    MPX_ENTER_EXIT(_L("CMpxVideoPlayerUtility::SendSurfaceCreatedCommand()"));
+
+    if ( ! iSurfaceId.IsNull() )
+    {
+        MPX_TRAPD( err, SendSurfaceCommandL( EPbMsgVideoSurfaceCreated,
+                                             iSurfaceId,
+                                             iCropRect,
+                                             iAspectRatio ) );
+    }
+}
+
 #endif
 
 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API