videoplayerapp/videoplayerengine/src/mpxvideoembeddedpdlhandler.cpp
changeset 15 cf5481c2bc0b
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
       
     1 /*
       
     2 * Copyright (c) 2009 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:  2 %
       
    19 
       
    20 
       
    21 
       
    22 #include <mpxcommand.h>
       
    23 #include <mpxcommandgeneraldefs.h>
       
    24 #include <mpxmessagegeneraldefs.h>
       
    25 #include <mpxplaybackmessage.h>
       
    26 #include <mpxplaybackutility.h>
       
    27 #include <mpxmediageneraldefs.h>
       
    28 
       
    29 #include <mpxviewutility.h>
       
    30 #include <mpxviewpluginmanager.h>
       
    31 #include <mpxviewplugin.h>
       
    32 #include <mpxvideoplaybackdefs.h>
       
    33 
       
    34 #include "mpxvideoembeddedpdlhandler.h"
       
    35 #include "mpxvideoplayerappuiengine.h"
       
    36 #include "mpxvideoplayerconstants.h"
       
    37 #include "mpxvideo_debug.h"
       
    38 
       
    39 CMpxVideoEmbeddedPdlHandler*
       
    40 CMpxVideoEmbeddedPdlHandler::NewL( CMpxVideoPlayerAppUiEngine* aAppUiEngine )
       
    41 {
       
    42     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::NewL()"));
       
    43 
       
    44     CMpxVideoEmbeddedPdlHandler* self = new ( ELeave ) CMpxVideoEmbeddedPdlHandler( aAppUiEngine );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     CleanupStack::Pop( self );
       
    48     return self;
       
    49 }
       
    50 
       
    51 // -------------------------------------------------------------------------------------------------
       
    52 //   C++ constructor can NOT contain any code that might leave.
       
    53 // -------------------------------------------------------------------------------------------------
       
    54 //
       
    55 CMpxVideoEmbeddedPdlHandler::CMpxVideoEmbeddedPdlHandler( CMpxVideoPlayerAppUiEngine* aAppUiEngine )
       
    56     : iAppUiEngine( aAppUiEngine )
       
    57 {
       
    58 }
       
    59 
       
    60 // -------------------------------------------------------------------------------------------------
       
    61 //   Destructor.
       
    62 // -------------------------------------------------------------------------------------------------
       
    63 //
       
    64 CMpxVideoEmbeddedPdlHandler::~CMpxVideoEmbeddedPdlHandler()
       
    65 {
       
    66     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::~CMpxVideoEmbeddedPdlHandler()"));
       
    67 
       
    68     if ( iDownloadFileName )
       
    69     {
       
    70         delete iDownloadFileName;
       
    71         iDownloadFileName = NULL;
       
    72     }
       
    73 }
       
    74 
       
    75 // -------------------------------------------------------------------------------------------------
       
    76 //   Symbian 2nd phase constructor can leave.
       
    77 // -------------------------------------------------------------------------------------------------
       
    78 //
       
    79 void CMpxVideoEmbeddedPdlHandler::ConstructL()
       
    80 {
       
    81 }
       
    82 
       
    83 // -------------------------------------------------------------------------------------------------
       
    84 //   CMpxVideoEmbeddedPdlHandler::ConnectToEmbeddedDownloadL()
       
    85 // -------------------------------------------------------------------------------------------------
       
    86 //
       
    87 void CMpxVideoEmbeddedPdlHandler::ConnectToEmbeddedDownloadL( TInt aDlId, TDesC& aFileName )
       
    88 {
       
    89     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::ConnectToEmbeddedDownloadL()"),
       
    90                    _L("aDlId = %d, aFileName = %S"), aDlId, &aFileName );
       
    91 
       
    92     if ( iDownloadFileName )
       
    93     {
       
    94         //
       
    95         //  Check if this is the same download that is loaded
       
    96         //  If it is, issue a play command to resume playback
       
    97 
       
    98         if ( ( aDlId == iDownloadId ) && ( ! aFileName.Compare( *iDownloadFileName ) ) )
       
    99         {
       
   100             iAppUiEngine->PlaybackUtility()->CommandL( EPbCmdPlay );
       
   101         }
       
   102         else
       
   103         {
       
   104             //
       
   105             //  New download received, close old playback plugin
       
   106             //
       
   107             iAppUiEngine->PlaybackUtility()->CommandL( EPbCmdClose );
       
   108 
       
   109             StartNewDownloadL( aDlId, aFileName );
       
   110         }
       
   111     }
       
   112     else
       
   113     {
       
   114         StartNewDownloadL( aDlId, aFileName );
       
   115     }
       
   116 }
       
   117 
       
   118 // -------------------------------------------------------------------------------------------------
       
   119 //   CMpxVideoEmbeddedPdlHandler::ConnectToCollectionDownloadL()
       
   120 // -------------------------------------------------------------------------------------------------
       
   121 //
       
   122 void CMpxVideoEmbeddedPdlHandler::ConnectToCollectionDownloadL( TInt aDlId, TDesC& aFileName )
       
   123 {
       
   124     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::ConnectToCollectionDownloadL()"),
       
   125                    _L("aDlId = %d, aFileName = %S"), aDlId, &aFileName );
       
   126 
       
   127     //
       
   128     //  The playback plugin will not be loaded for collection downloads
       
   129     //
       
   130     StartNewDownloadL( aDlId, aFileName );
       
   131 }
       
   132 
       
   133 // -------------------------------------------------------------------------------------------------
       
   134 //   CMpxVideoEmbeddedPdlHandler::StartNewDownloadL()
       
   135 // -------------------------------------------------------------------------------------------------
       
   136 //
       
   137 void CMpxVideoEmbeddedPdlHandler::StartNewDownloadL( TInt aDlId, TDesC& aFileName )
       
   138 {
       
   139     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::StartNewDownloadL()"),
       
   140                    _L("aDlId = %d, aFileName = %S"), aDlId, &aFileName );
       
   141 
       
   142     //
       
   143     //  Save the download parameters
       
   144     //
       
   145     iDownloadId = aDlId;
       
   146     delete iDownloadFileName;
       
   147     iDownloadFileName = NULL;
       
   148     iDownloadFileName = aFileName.AllocL();
       
   149 
       
   150     //
       
   151     //  Create the Playback Utility
       
   152     //
       
   153     iAppUiEngine->CreateEmbeddedPdlPlaybackUtilityMemberVariablesL();
       
   154 
       
   155     SendPdlCustomCommandL( EPbCmdStartPd, iDownloadId );
       
   156 
       
   157     iAppUiEngine->PlaybackUtility()->InitL( *iDownloadFileName );
       
   158 }
       
   159 
       
   160 // -------------------------------------------------------------------------------------------------
       
   161 //   CMpxVideoEmbeddedPdlHandler::SendPdlCustomCommandL()
       
   162 // -------------------------------------------------------------------------------------------------
       
   163 //
       
   164 void CMpxVideoEmbeddedPdlHandler::SendPdlCustomCommandL( TMPXPlaybackPdCommand aCustomCmd,
       
   165                                                          TInt aData )
       
   166 {
       
   167     MPX_ENTER_EXIT(_L("CMpxVideoEmbeddedPdlHandler::SendPdlCustomCommandL"),
       
   168                    _L("aCustomCmd = %d, aData = %d"), aCustomCmd, aData );
       
   169 
       
   170     CMPXCommand* cmd = CMPXCommand::NewL();
       
   171     CleanupStack::PushL( cmd );
       
   172 
       
   173     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
   174     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackPD );
       
   175     cmd->SetTObjectValueL<TMPXPlaybackPdCommand>( KMPXCommandPlaybackGeneralType, aCustomCmd );
       
   176     cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackPDTransactionID, aData );
       
   177     cmd->SetTextValueL( KMPXMediaVideoPlaybackFileName, *iDownloadFileName );
       
   178     cmd->SetTObjectValueL<TInt>( KMPXMediaVideoMovePdlFile, ETrue );
       
   179 
       
   180     iAppUiEngine->PlaybackUtility()->CommandL( *cmd );
       
   181 
       
   182     CleanupStack::PopAndDestroy( cmd );
       
   183 }
       
   184 
       
   185 // EOF