videoplayerapp/mpxvideoplayer/src/mpxvideoembeddedpdlhandler.cpp
changeset 0 96612d01cf9f
child 2 dec420019252
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Handles PDL commands passed in by other appilcations
       
    15  *
       
    16 */
       
    17 
       
    18 // Version : %version:  10 %
       
    19 
       
    20 
       
    21 #include <mpxcommand.h>
       
    22 #include <mpxcommandgeneraldefs.h>
       
    23 #include <mpxmessagegeneraldefs.h>
       
    24 #include <mpxplaybackmessage.h>
       
    25 #include <mpxplaybackutility.h>
       
    26 #include <mpxmediageneraldefs.h>
       
    27 
       
    28 #include <mpxviewutility.h>
       
    29 #include <mpxviewpluginmanager.h>
       
    30 #include <mpxviewplugin.h>
       
    31 
       
    32 #include "mpxvideoembeddedpdlhandler.h"
       
    33 #include "mpxvideoplayerappuiengine.h"
       
    34 #include "mpxvideoplayerconstants.h"
       
    35 #include <mpxvideoplaybackdefs.h>
       
    36 #include "mpxvideo_debug.h"
       
    37 
       
    38 CMpxVideoEmbeddedPdlHandler*
       
    39 CMpxVideoEmbeddedPdlHandler::NewL( CMpxVideoPlayerAppUiEngine* aAppUiEngine )
       
    40 {
       
    41     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::NewL()"));
       
    42 
       
    43     CMpxVideoEmbeddedPdlHandler* self = new ( ELeave ) CMpxVideoEmbeddedPdlHandler( aAppUiEngine );
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL();
       
    46     CleanupStack::Pop( self );
       
    47     return self;
       
    48 }
       
    49 
       
    50 // -------------------------------------------------------------------------------------------------
       
    51 //   C++ constructor can NOT contain any code that might leave.
       
    52 // -------------------------------------------------------------------------------------------------
       
    53 //
       
    54 CMpxVideoEmbeddedPdlHandler::CMpxVideoEmbeddedPdlHandler( CMpxVideoPlayerAppUiEngine* aAppUiEngine )
       
    55     : iAppUiEngine( aAppUiEngine )
       
    56 {
       
    57 }
       
    58 
       
    59 // -------------------------------------------------------------------------------------------------
       
    60 //   Destructor.
       
    61 // -------------------------------------------------------------------------------------------------
       
    62 //
       
    63 CMpxVideoEmbeddedPdlHandler::~CMpxVideoEmbeddedPdlHandler()
       
    64 {
       
    65     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::~CMpxVideoEmbeddedPdlHandler()"));
       
    66 
       
    67     if ( iDownloadFileName )
       
    68     {
       
    69         delete iDownloadFileName;
       
    70         iDownloadFileName = NULL;
       
    71     }
       
    72 }
       
    73 
       
    74 // -------------------------------------------------------------------------------------------------
       
    75 //   Symbian 2nd phase constructor can leave.
       
    76 // -------------------------------------------------------------------------------------------------
       
    77 //
       
    78 void CMpxVideoEmbeddedPdlHandler::ConstructL()
       
    79 {
       
    80 }
       
    81 
       
    82 // -------------------------------------------------------------------------------------------------
       
    83 //   CMpxVideoEmbeddedPdlHandler::ConnectToEmbeddedDownloadL()
       
    84 // -------------------------------------------------------------------------------------------------
       
    85 //
       
    86 void CMpxVideoEmbeddedPdlHandler::ConnectToEmbeddedDownloadL( TInt aDlId, TDesC& aFileName )
       
    87 {
       
    88     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::ConnectToEmbeddedDownloadL()"),
       
    89                    _L("aDlId = %d, aFileName = %S"), aDlId, &aFileName );
       
    90 
       
    91     iEmbeddedPdlCase = ETrue;
       
    92 
       
    93     if ( iDownloadFileName )
       
    94     {
       
    95         //
       
    96         //  Check if this is the same download that is loaded
       
    97         //  If it is, issue a play command to resume playback
       
    98 
       
    99         if ( ( aDlId == iDownloadId ) && ( ! aFileName.Compare( *iDownloadFileName ) ) )
       
   100         {
       
   101             iAppUiEngine->PlaybackUtility()->CommandL( EPbCmdPlay );
       
   102         }
       
   103         else
       
   104         {
       
   105             //
       
   106             //  New download received, close old playback plugin
       
   107             //
       
   108             iAppUiEngine->PlaybackUtility()->CommandL( EPbCmdClose );
       
   109 
       
   110             StartNewDownloadL( aDlId, aFileName );
       
   111         }
       
   112     }
       
   113     else
       
   114     {
       
   115         StartNewDownloadL( aDlId, aFileName );
       
   116     }
       
   117 }
       
   118 
       
   119 // -------------------------------------------------------------------------------------------------
       
   120 //   CMpxVideoEmbeddedPdlHandler::ConnectToCollectionDownloadL()
       
   121 // -------------------------------------------------------------------------------------------------
       
   122 //
       
   123 void CMpxVideoEmbeddedPdlHandler::ConnectToCollectionDownloadL( TInt aDlId, TDesC& aFileName )
       
   124 {
       
   125     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::ConnectToCollectionDownloadL()"),
       
   126                    _L("aDlId = %d, aFileName = %S"), aDlId, &aFileName );
       
   127 
       
   128     iEmbeddedPdlCase = EFalse;
       
   129 
       
   130     //
       
   131     //  The playback plugin will not be loaded for collection downloads
       
   132     //
       
   133     StartNewDownloadL( aDlId, aFileName );
       
   134 }
       
   135 
       
   136 // -------------------------------------------------------------------------------------------------
       
   137 //   CMpxVideoEmbeddedPdlHandler::StartNewDownloadL()
       
   138 // -------------------------------------------------------------------------------------------------
       
   139 //
       
   140 void CMpxVideoEmbeddedPdlHandler::StartNewDownloadL( TInt aDlId, TDesC& aFileName )
       
   141 {
       
   142     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::StartNewDownloadL()"),
       
   143                    _L("aDlId = %d, aFileName = %S"), aDlId, &aFileName );
       
   144 
       
   145     //
       
   146     //  Save the download parameters
       
   147     //
       
   148     iDownloadId = aDlId;
       
   149     delete iDownloadFileName;
       
   150     iDownloadFileName = NULL;
       
   151     iDownloadFileName = aFileName.AllocL();
       
   152 
       
   153     //
       
   154     //  Create the Playback Utility
       
   155     //
       
   156     iAppUiEngine->CreateEmbeddedPdlPlaybackUtilityMemberVariablesL();
       
   157 
       
   158     SendPdlCustomCommandL( EPbCmdStartPd, iDownloadId );
       
   159 
       
   160     iAppUiEngine->InitializeFileL( *iDownloadFileName );
       
   161 }
       
   162 
       
   163 // -------------------------------------------------------------------------------------------------
       
   164 //   CMpxVideoEmbeddedPdlHandler::SendPdlCustomCommandL()
       
   165 // -------------------------------------------------------------------------------------------------
       
   166 //
       
   167 void CMpxVideoEmbeddedPdlHandler::SendPdlCustomCommandL( TMPXPlaybackPdCommand aCustomCmd,
       
   168                                                          TInt aData )
       
   169 {
       
   170     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::SendPdlCustomCommandL"),
       
   171                    _L("aCustomCmd = %d, aData = %d"), aCustomCmd, aData );
       
   172 
       
   173     CMPXCommand* cmd = CMPXCommand::NewL();
       
   174     CleanupStack::PushL( cmd );
       
   175 
       
   176     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
   177     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackPD );
       
   178     cmd->SetTObjectValueL<TMPXPlaybackPdCommand>( KMPXCommandPlaybackGeneralType, aCustomCmd );
       
   179     cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackPDTransactionID, aData );
       
   180     cmd->SetTextValueL( KMPXMediaVideoPlaybackFileName, *iDownloadFileName );
       
   181     cmd->SetTObjectValueL<TInt>( KMPXMediaVideoMovePdlFile, iEmbeddedPdlCase );
       
   182 
       
   183     iAppUiEngine->PlaybackUtility()->CommandL( *cmd );
       
   184 
       
   185     CleanupStack::PopAndDestroy( cmd );
       
   186 }
       
   187 
       
   188 // -------------------------------------------------------------------------------------------------
       
   189 //   CMpxVideoEmbeddedPdlHandler::ClearPdlInformation()
       
   190 // -------------------------------------------------------------------------------------------------
       
   191 //
       
   192 void CMpxVideoEmbeddedPdlHandler::ClearPdlInformation()
       
   193 {
       
   194     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::ClearPdlInformation"));
       
   195 
       
   196     if ( iDownloadFileName )
       
   197     {
       
   198         delete iDownloadFileName;
       
   199         iDownloadFileName = NULL;
       
   200     }
       
   201 
       
   202     iDownloadId = KErrNotFound;
       
   203 }
       
   204 
       
   205 // EOF