mmappfw_plat/mpx_playback_utility_api/tsrc/testvideoplaybackplugin/src/testvideoplaybackplugin.cpp
branchRCL_3
changeset 67 16db3449d7ba
parent 63 91d5ad76f5c6
child 69 71775bb0f6c0
equal deleted inserted replaced
63:91d5ad76f5c6 67:16db3449d7ba
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:  CTestVideoPlaybackPlugin implementation
       
    15 *
       
    16 */
       
    17 
       
    18 //
       
    19 //  INCLUDE FILES
       
    20 //
       
    21 #include <apgcli.h>
       
    22 #include <e32cmn.h>
       
    23 #include <mpxmediageneraldefs.h>
       
    24 #include <mpxcommandgeneraldefs.h>
       
    25 #include <mpxmessagegeneraldefs.h>
       
    26 #include <mpxplaybackcommanddefs.h>
       
    27 #include <mpxvideoplaybackdefs.h>
       
    28 #include <mpxplaybackpluginobserver.h>
       
    29 #include <mpxplaybackplugin.h>
       
    30 #include <mpxlog.h>
       
    31 #include <mpxmedia.h>
       
    32 
       
    33 #include "testvideoplaybackplugin.h"
       
    34 #include "mpxplaybackutilitytestdefs.h"
       
    35 #include "mpxplaybackutilitytest.h"
       
    36 
       
    37 
       
    38 //
       
    39 //  CONSTANTS
       
    40 //
       
    41 const TUid KLocalPlaybackUid = { 0x10282556 };
       
    42 
       
    43 
       
    44 // ============================ MEMBER FUNCTIONS ===============================
       
    45 
       
    46 //  ----------------------------------------------------------------------------
       
    47 //    Two-phased constructor.
       
    48 //  ----------------------------------------------------------------------------
       
    49 //
       
    50 CTestVideoPlaybackPlugin* CTestVideoPlaybackPlugin::NewL( TAny* /*aInitParams*/ )
       
    51 {
       
    52     
       
    53     CTestVideoPlaybackPlugin* p = new (ELeave) CTestVideoPlaybackPlugin();
       
    54     CleanupStack::PushL(p);
       
    55     p->ConstructL();
       
    56     CleanupStack::Pop(p);
       
    57     return p;
       
    58 }
       
    59 
       
    60 //  ----------------------------------------------------------------------------
       
    61 //    Symbian 2nd phase constructor can leave.
       
    62 //  ----------------------------------------------------------------------------
       
    63 //
       
    64 void CTestVideoPlaybackPlugin::ConstructL()
       
    65 {
       
    66     MPX_FUNC_EX("CTestVideoPlaybackPlugin::ConstructL()");
       
    67     User::LeaveIfError( iFs.Connect() );
       
    68     iFs.ShareProtected();
       
    69     
       
    70     iEventArray = new (ELeave) CArrayPtrFlat<TTestVideoPlaybackCallbackEvent>( 1 );
       
    71     iCallback   = CIdle::NewL( CActive::EPriorityLow );
       
    72 }
       
    73 
       
    74 //  ----------------------------------------------------------------------------
       
    75 //    C++ constructor
       
    76 //  ----------------------------------------------------------------------------
       
    77 //
       
    78 CTestVideoPlaybackPlugin::CTestVideoPlaybackPlugin() 
       
    79 
       
    80 {
       
    81     MPX_FUNC_EX("CTestVideoPlaybackPlugin::CTestVideoPlaybackPlugin()");
       
    82 }
       
    83 
       
    84 //  ----------------------------------------------------------------------------
       
    85 //    Destructor
       
    86 //  ----------------------------------------------------------------------------
       
    87 //
       
    88 CTestVideoPlaybackPlugin::~CTestVideoPlaybackPlugin()
       
    89 {
       
    90     MPX_FUNC_EX("CTestVideoPlaybackPlugin::~CTestVideoPlaybackPlugin()");
       
    91     iFile.Close();
       
    92     iFs.Close();
       
    93     
       
    94     if ( iCallback->IsActive() )
       
    95     {
       
    96         iCallback->Cancel();
       
    97     }
       
    98 
       
    99     delete iCallback;
       
   100 
       
   101     iEventArray->ResetAndDestroy();
       
   102 }
       
   103 
       
   104 //  ----------------------------------------------------------------------------
       
   105 //    Set observer
       
   106 //  ----------------------------------------------------------------------------
       
   107 //
       
   108 void CTestVideoPlaybackPlugin::SetObserver( MMPXPlaybackPluginObserver& aObs )
       
   109 {
       
   110     MPX_FUNC_EX("CTestVideoPlaybackPlugin::SetObserver( MMPXPlaybackPluginObserver& aObs )");
       
   111     iObs = &aObs;
       
   112 }
       
   113 
       
   114 //  ----------------------------------------------------------------------------
       
   115 //    Initializes a clip for playback from a file name
       
   116 //  ----------------------------------------------------------------------------
       
   117 //
       
   118 void CTestVideoPlaybackPlugin::InitialiseL( const TDesC& aSong )
       
   119 {
       
   120     
       
   121     MPX_FUNC_EX("CTestVideoPlaybackPlugin::InitialiseL( const TDesc& aSong)");
       
   122     
       
   123 	delete iClipName;
       
   124     iClipName = NULL;
       
   125     iClipName = aSong.AllocL();
       
   126 
       
   127     iFile.Close();
       
   128 
       
   129     TInt err = iFile.Open( iFs, aSong, EFileRead | EFileShareReadersOrWriters );
       
   130 
       
   131     //
       
   132     //  Remap KErrNotReady to KErrNotFound, because it is referencing a drive
       
   133     //  that is not existent
       
   134     //
       
   135     if ( KErrNotReady == err )
       
   136     {
       
   137         err = KErrNotFound;
       
   138     }
       
   139 
       
   140     // if aSong is an streaming link and contains one of the streaming schemas
       
   141     // eg. rtsp:// , http:// etc. then a file handle can not be opened
       
   142     // ignore KErrBadName
       
   143     if (err != KErrBadName)
       
   144     {
       
   145         User::LeaveIfError( err );    
       
   146     }    
       
   147 
       
   148     
       
   149     TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   150     
       
   151     event->iEvent = MMPXPlaybackPluginObserver::EPInitialised;
       
   152     event->iData = 0;
       
   153     event->iError = KErrNone;
       
   154     
       
   155     AddCallbackEvent( event );
       
   156     
       
   157     event = new TTestVideoPlaybackCallbackEvent;
       
   158     event->iEvent = MMPXPlaybackPluginObserver::EPBufferingStarted;
       
   159     event->iData = 0;
       
   160     event->iError = KErrNone;
       
   161         
       
   162     AddCallbackEvent( event );    
       
   163 }
       
   164 
       
   165 //  ----------------------------------------------------------------------------
       
   166 //    Initializes a clip for playback from a file handle
       
   167 //  ----------------------------------------------------------------------------
       
   168 //
       
   169 void CTestVideoPlaybackPlugin::InitialiseL( RFile& aSong )
       
   170 {
       
   171     MPX_FUNC_EX("CTestVideoPlaybackPlugin::InitialiseL( RFile& aSong )");
       
   172     
       
   173     delete iClipName;
       
   174     iClipName = NULL;
       
   175     iClipName = HBufC::NewL( KMaxFileName );
       
   176     TPtr ptr = iClipName->Des();
       
   177     aSong.FullName( ptr );
       
   178 
       
   179     iFile.Close();
       
   180     User::LeaveIfError( iFile.Duplicate( aSong ));
       
   181     
       
   182     TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   183     
       
   184     event->iEvent = MMPXPlaybackPluginObserver::EPInitialised;
       
   185     event->iData = 0;
       
   186     event->iError = KErrNone;
       
   187     
       
   188     AddCallbackEvent( event );
       
   189 
       
   190     event = new TTestVideoPlaybackCallbackEvent;
       
   191     event->iEvent = MMPXPlaybackPluginObserver::EPBufferingStarted;
       
   192     event->iData = 0;
       
   193     event->iError = KErrNone;
       
   194         
       
   195     AddCallbackEvent( event );        
       
   196 }
       
   197 
       
   198 /**
       
   199 * Initializes a file for playback.
       
   200 *
       
   201 * @since S60 9.2
       
   202 * @param aUri URI of the item
       
   203 * @param aType the mime type of the item
       
   204 * @param aAccessPoint the access point
       
   205 */
       
   206 void CTestVideoPlaybackPlugin::InitStreamingL(const TDesC& /*aUri*/, 
       
   207         const TDesC8& /*aType*/, TInt /*aAccessPoint*/, TInt /*aPosition*/)
       
   208 {
       
   209     MPX_FUNC_EX("CTestVideoPlaybackPlugin::InitStreamingL(const TDesC& /*aUri*/, const TDesC8& /*aType*/, TInt /*aAccessPoint*/, TInt /*aPosition*/)");
       
   210     
       
   211     TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   212     
       
   213     event->iEvent = MMPXPlaybackPluginObserver::EPInitialised;
       
   214     event->iData = 0;
       
   215     event->iError = KErrNone;
       
   216     
       
   217     AddCallbackEvent( event );
       
   218 
       
   219     event = new TTestVideoPlaybackCallbackEvent;
       
   220     event->iEvent = MMPXPlaybackPluginObserver::EPBufferingStarted;
       
   221     event->iData = 0;
       
   222     event->iError = KErrNone;
       
   223         
       
   224     AddCallbackEvent( event );    
       
   225 }
       
   226 
       
   227 /**
       
   228 * Initializes a file handle for playback.
       
   229 *
       
   230 * @since S60 9.2
       
   231 * @param aFile file handle of a file
       
   232 * @param aAccessPoint the access point
       
   233 */
       
   234 void CTestVideoPlaybackPlugin::InitStreamingL(RFile& /*aFile*/, TInt /*aAccessPoint*/, TInt /*aPosition*/)
       
   235 {
       
   236     MPX_FUNC_EX("CTestVideoPlaybackPlugin::InitStreamingL(RFile& /*aFile*/, TInt /*aAccessPoint*/, TInt /*aPosition*/)");
       
   237         
       
   238     TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   239     
       
   240     event->iEvent = MMPXPlaybackPluginObserver::EPInitialised;
       
   241     event->iData = 0;
       
   242     event->iError = KErrNone;
       
   243     
       
   244     AddCallbackEvent( event );    
       
   245     
       
   246     event = new TTestVideoPlaybackCallbackEvent;
       
   247     event->iEvent = MMPXPlaybackPluginObserver::EPBufferingStarted;
       
   248     event->iData = 0;
       
   249     event->iError = KErrNone;
       
   250         
       
   251     AddCallbackEvent( event );    
       
   252 }
       
   253 
       
   254 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   255 /**
       
   256 * Initializes a file handle for playback.
       
   257 *
       
   258 * @since S60 9.2
       
   259 * @param aFile 64 bit file handle of a file
       
   260 * @param aAccessPoint the access point
       
   261 */
       
   262 void CTestVideoPlaybackPlugin::InitStreaming64L(RFile64& /*aFile*/, TInt /*aAccessPoint*/, TInt /*aPosition*/)
       
   263 {
       
   264     MPX_FUNC_EX("CTestVideoPlaybackPlugin::InitStreaming64L(RFile64& /*aFile*/, TInt /*aAccessPoint*/, TInt /*aPosition*/)");
       
   265     
       
   266     TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   267     
       
   268     event->iEvent = MMPXPlaybackPluginObserver::EPInitialised;
       
   269     event->iData = 0;
       
   270     event->iError = KErrNone;
       
   271     
       
   272     AddCallbackEvent( event );
       
   273 
       
   274     event = new TTestVideoPlaybackCallbackEvent;
       
   275     event->iEvent = MMPXPlaybackPluginObserver::EPBufferingStarted;
       
   276     event->iData = 0;
       
   277     event->iError = KErrNone;
       
   278         
       
   279     AddCallbackEvent( event );    
       
   280 }
       
   281 
       
   282 /**
       
   283 * Initializes a song for playback.
       
   284 *
       
   285 * @since S60 9.2
       
   286 * @param aFile 64 bit file handle of a song
       
   287 */
       
   288 void CTestVideoPlaybackPlugin::Initialise64L(RFile64& /*aSong*/, TInt /*aPosition*/)
       
   289 {
       
   290     MPX_FUNC_EX("CTestVideoPlaybackPlugin::Initialise64L(RFile64& /*aSong*/, TInt /*aPosition*/)");
       
   291     
       
   292     TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   293     
       
   294     event->iEvent = MMPXPlaybackPluginObserver::EPInitialised;
       
   295     event->iData = 0;
       
   296     event->iError = KErrNone;
       
   297     
       
   298     AddCallbackEvent( event );
       
   299 
       
   300     event = new TTestVideoPlaybackCallbackEvent;
       
   301     event->iEvent = MMPXPlaybackPluginObserver::EPBufferingStarted;
       
   302     event->iData = 0;
       
   303     event->iError = KErrNone;
       
   304         
       
   305     AddCallbackEvent( event );    
       
   306 }
       
   307 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   308 
       
   309 //  ----------------------------------------------------------------------------
       
   310 //    Executes a command on the selected song
       
   311 //  ----------------------------------------------------------------------------
       
   312 //
       
   313 void CTestVideoPlaybackPlugin::CommandL( CMPXCommand& aCmd )
       
   314 {
       
   315     MPX_FUNC_EX("CTestVideoPlaybackPlugin::CommandL( CMPXCommand& aCmd )");
       
   316     
       
   317     if ( aCmd.IsSupported( KMPXStifPlaybackCommand ) )
       
   318     {
       
   319        TMPXStifCommand cmd = static_cast<TMPXStifCommand>(aCmd.ValueTObjectL<TInt>(KMPXStifPlaybackCommand));
       
   320        TMPXPlaybackState state = static_cast<TMPXPlaybackState>(aCmd.ValueTObjectL<TInt>(KMPXCommandPlaybackGeneralData));
       
   321        
       
   322        MPX_DEBUG3("CTestVideoPlaybackPlugin::CommandL cmd = %d, state = %d ", cmd, state);
       
   323        
       
   324        switch ( cmd )
       
   325        {
       
   326            case EPbStifPlayComplete:
       
   327            {
       
   328                MPX_DEBUG1("CTestVideoPlaybackPlugin::CommandL aCmd is EPbStifPlaybackComplete");
       
   329 
       
   330                TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   331 
       
   332                event->iEvent = MMPXPlaybackPluginObserver::EPPlayComplete;
       
   333                event->iData = 0;
       
   334                event->iError = KErrNone;
       
   335                    
       
   336                AddCallbackEvent( event );
       
   337 
       
   338                break;
       
   339            }
       
   340            case EPbStifSeekForward:
       
   341            {
       
   342                MPX_DEBUG1("CTestVideoPlaybackPlugin::CommandL aCmd is EPbStifSeekForward");
       
   343  
       
   344                TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   345 
       
   346                event->iEvent = MMPXPlaybackPluginObserver::EPPluginSeeking;
       
   347                event->iData = 0;
       
   348                event->iError = KErrNone;
       
   349                    
       
   350                AddCallbackEvent( event );
       
   351                
       
   352                event = new TTestVideoPlaybackCallbackEvent;
       
   353                event->iEvent = MMPXPlaybackPluginObserver::EPPositionChanged;
       
   354                event->iData = 0;
       
   355                event->iError = KErrNone;
       
   356                   
       
   357                AddCallbackEvent( event );
       
   358                
       
   359                if ( state == EPbStatePlaying )
       
   360                {
       
   361 
       
   362                    event = new TTestVideoPlaybackCallbackEvent;
       
   363                    event->iEvent = MMPXPlaybackPluginObserver::EPPlaying;
       
   364                    event->iData = 0;
       
   365                    event->iError = KErrNone;
       
   366                       
       
   367                    AddCallbackEvent( event );               
       
   368                }
       
   369                else if ( state == EPbStatePaused )
       
   370                {
       
   371 
       
   372                    event = new TTestVideoPlaybackCallbackEvent;
       
   373                    event->iEvent = MMPXPlaybackPluginObserver::EPPaused;
       
   374                    event->iData = 0;
       
   375                    event->iError = KErrNone;
       
   376                       
       
   377                    AddCallbackEvent( event );
       
   378                                           
       
   379                }
       
   380                break;
       
   381            }
       
   382                    
       
   383            case EPbStifSeekBackward:
       
   384            {
       
   385               MPX_DEBUG1("CTestVideoPlaybackPlugin::CommandL aCmd is EPbStifSeekBackward");
       
   386 
       
   387               TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   388               
       
   389               event->iEvent = MMPXPlaybackPluginObserver::EPPluginSeeking;
       
   390               event->iData = 0;
       
   391               event->iError = KErrNone;
       
   392                   
       
   393               AddCallbackEvent( event );
       
   394               
       
   395               event = new TTestVideoPlaybackCallbackEvent;
       
   396               event->iEvent = MMPXPlaybackPluginObserver::EPPositionChanged;
       
   397               event->iData = 0;
       
   398               event->iError = KErrNone;
       
   399                  
       
   400               AddCallbackEvent( event );
       
   401               
       
   402               if ( state == EPbStatePlaying )
       
   403               {
       
   404 
       
   405                   event = new TTestVideoPlaybackCallbackEvent;
       
   406                   event->iEvent = MMPXPlaybackPluginObserver::EPPlaying;
       
   407                   event->iData = 0;
       
   408                   event->iError = KErrNone;
       
   409                      
       
   410                   AddCallbackEvent( event );            
       
   411               }
       
   412               else if ( state == EPbStatePaused )
       
   413               {
       
   414 
       
   415                   event = new TTestVideoPlaybackCallbackEvent;
       
   416                   event->iEvent = MMPXPlaybackPluginObserver::EPPaused;
       
   417                   event->iData = 0;
       
   418                   event->iError = KErrNone;
       
   419                      
       
   420                   AddCallbackEvent( event );
       
   421               }
       
   422               break;
       
   423            }
       
   424            
       
   425            default:
       
   426            {
       
   427                MPX_DEBUG1("CTestVideoPlaybackPlugin::CommandL aCmd default");
       
   428                break;
       
   429            }
       
   430        }
       
   431    }       
       
   432 }
       
   433 
       
   434 
       
   435 //  ----------------------------------------------------------------------------
       
   436 //    Executes a command on the selected song
       
   437 //  ----------------------------------------------------------------------------
       
   438 //
       
   439 void CTestVideoPlaybackPlugin::CommandL(TMPXPlaybackCommand aCmd, TInt /*aData*/)
       
   440 {
       
   441     MPX_FUNC_EX("CTestVideoPlaybackPlugin::CommandL(TMPXPlaybackCommand aCmd, TInt /*aData*/)");
       
   442     
       
   443     MPX_DEBUG2("CTestVideoPlaybackPlugin::CommandL aCmd = %d", aCmd);
       
   444 
       
   445     switch (aCmd)
       
   446     {            
       
   447         case EPbCmdPlay:
       
   448         {
       
   449             MPX_DEBUG1("CTestVideoPlaybackPlugin::CommandL aCmd is EPbCmdPlay");
       
   450 
       
   451             TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   452 
       
   453             event->iEvent = MMPXPlaybackPluginObserver::EPPlaying;
       
   454             event->iData = 0;
       
   455             event->iError = KErrNone;
       
   456                 
       
   457             AddCallbackEvent( event );
       
   458             
       
   459             break;
       
   460         }
       
   461             
       
   462         case EPbCmdClose:
       
   463         {
       
   464             MPX_DEBUG1("CTestVideoPlaybackPlugin::CommandL aCmd is EPbCmdClose");
       
   465 
       
   466             TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   467             
       
   468             event->iEvent = MMPXPlaybackPluginObserver::EPClosed;
       
   469             event->iData = 0;
       
   470             event->iError = KErrNone;
       
   471                 
       
   472             AddCallbackEvent( event );
       
   473 
       
   474             break;
       
   475         }
       
   476            
       
   477         case EPbCmdStop:
       
   478         {
       
   479             MPX_DEBUG1("CTestVideoPlaybackPlugin::CommandL aCmd is EPbCmdStop");
       
   480 
       
   481             TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   482 
       
   483             event->iEvent = MMPXPlaybackPluginObserver::EPStopped;
       
   484             event->iData = 0;
       
   485             event->iError = KErrNone;
       
   486                 
       
   487             AddCallbackEvent( event );
       
   488 
       
   489             break;
       
   490         }
       
   491             
       
   492         case EPbCmdPause:
       
   493         {
       
   494             MPX_DEBUG1("CTestVideoPlaybackPlugin::CommandL aCmd is EPbCmdPause");
       
   495 
       
   496             TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   497 
       
   498             event->iEvent = MMPXPlaybackPluginObserver::EPPaused;
       
   499             event->iData = 0;
       
   500             event->iError = KErrNone;
       
   501                 
       
   502             AddCallbackEvent( event );
       
   503             
       
   504             break;
       
   505         }
       
   506             
       
   507         case EPbCmdStartSeekForward:
       
   508         {
       
   509             MPX_DEBUG1("CTestVideoPlaybackPlugin::CommandL aCmd is EPbCmdStartSeekForward");
       
   510 
       
   511             TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   512             
       
   513             event->iEvent = MMPXPlaybackPluginObserver::EPPluginSeeking;
       
   514             event->iData = 0;
       
   515             event->iError = KErrNone;
       
   516                 
       
   517             AddCallbackEvent( event );
       
   518 
       
   519             event = new TTestVideoPlaybackCallbackEvent;
       
   520             event->iEvent = MMPXPlaybackPluginObserver::EPPositionChanged;
       
   521             event->iData = 0;
       
   522             event->iError = KErrNone;
       
   523 
       
   524             AddCallbackEvent( event );
       
   525             
       
   526             event = new TTestVideoPlaybackCallbackEvent;
       
   527             event->iEvent = MMPXPlaybackPluginObserver::EPPlaying;
       
   528             event->iData = 0;
       
   529             event->iError = KErrNone;
       
   530 
       
   531             AddCallbackEvent( event );
       
   532             
       
   533             break;
       
   534         }
       
   535                 
       
   536         default:
       
   537         {
       
   538             MPX_DEBUG1("CTestVideoPlaybackPlugin::CommandL aCmd default");
       
   539             break;
       
   540         }
       
   541     }
       
   542 }
       
   543 
       
   544 
       
   545 //  ----------------------------------------------------------------------------
       
   546 //    Sets a property of the plugin
       
   547 //  ----------------------------------------------------------------------------
       
   548 //
       
   549 void CTestVideoPlaybackPlugin::SetL( TMPXPlaybackProperty aProperty, TInt aValue )
       
   550 {
       
   551     MPX_FUNC_EX("CTestVideoPlaybackPlugin::SetL( TMPXPlaybackProperty /*aProperty*/, TInt /*aValue*/ )");
       
   552     MPX_DEBUG3("CTestVideoPlaybackPlugin::SetL aProperty = %d, aValue = %d", aProperty, aValue);
       
   553     
       
   554     TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   555 
       
   556     event->iEvent = MMPXPlaybackPluginObserver::EPSetComplete;
       
   557     event->iData = aProperty;
       
   558     event->iError = KErrNone;
       
   559         
       
   560     AddCallbackEvent( event );    
       
   561 }
       
   562 
       
   563 //  ----------------------------------------------------------------------------
       
   564 //    Gets a property of the plugin (async)
       
   565 //  ----------------------------------------------------------------------------
       
   566 //
       
   567 void CTestVideoPlaybackPlugin::PropertyL( TMPXPlaybackProperty /*aProperty*/ ) const
       
   568 {
       
   569 
       
   570 }
       
   571 
       
   572 //  ----------------------------------------------------------------------------
       
   573 //    Gets a list of sub players, UPnP only
       
   574 //  ----------------------------------------------------------------------------
       
   575 //
       
   576 void CTestVideoPlaybackPlugin::SubPlayerNamesL()
       
   577 {
       
   578     MPX_FUNC_EX("CTestVideoPlaybackPlugin::SubPlayerNamesL()");
       
   579     
       
   580     iObs->HandleSubPlayerNames( KLocalPlaybackUid, NULL, ETrue, KErrNone );
       
   581 }
       
   582 
       
   583 //  ----------------------------------------------------------------------------
       
   584 //    Select a sub player
       
   585 //  ----------------------------------------------------------------------------
       
   586 //
       
   587 void CTestVideoPlaybackPlugin::SelectSubPlayerL( TInt /*aIndex*/ )
       
   588 {
       
   589     MPX_FUNC_EX("CTestVideoPlaybackPlugin::SelectSubPlayerL( TInt aIndex )");
       
   590     
       
   591     User::Leave( KErrNotSupported );
       
   592 }
       
   593 
       
   594 //  ----------------------------------------------------------------------------
       
   595 //    Returns current sub player name
       
   596 //  ----------------------------------------------------------------------------
       
   597 //
       
   598 const TDesC& CTestVideoPlaybackPlugin::SubPlayerName()
       
   599 {
       
   600     MPX_FUNC_EX("CTestVideoPlaybackPlugin::SubPlayerName()");
       
   601     
       
   602     return KNullDesC;
       
   603 }
       
   604 
       
   605 //  ----------------------------------------------------------------------------
       
   606 //    Current sub player index
       
   607 //  ----------------------------------------------------------------------------
       
   608 //
       
   609 TInt CTestVideoPlaybackPlugin::SubPlayerIndex() const
       
   610 {
       
   611      
       
   612     return KErrNotFound;
       
   613 }
       
   614 
       
   615 //  ----------------------------------------------------------------------------
       
   616 //    Gets media properties
       
   617 //  ----------------------------------------------------------------------------
       
   618 //
       
   619 void CTestVideoPlaybackPlugin::MediaL( const TArray<TMPXAttribute>& /*aAttrs*/ )
       
   620 {
       
   621     MPX_FUNC_EX("CTestVideoPlaybackPlugin::MediaL( const TArray TMPXAttribute )");
       
   622 }
       
   623 
       
   624 //  ----------------------------------------------------------------------------
       
   625 //    Cancel request
       
   626 //  ----------------------------------------------------------------------------
       
   627 //
       
   628 void CTestVideoPlaybackPlugin::CancelRequest()
       
   629 {
       
   630     MPX_FUNC_EX("CTestVideoPlaybackPlugin::CancelRequest()");
       
   631 }
       
   632 
       
   633 //  ----------------------------------------------------------------------------
       
   634 //  CTestVideoPlaybackPlugin::GetFileHandle()
       
   635 //  ----------------------------------------------------------------------------
       
   636 //
       
   637 RFile CTestVideoPlaybackPlugin::GetFileHandle()
       
   638 {
       
   639     MPX_FUNC_EX("CTestVideoPlaybackPlugin::GetFileHandle()");
       
   640     
       
   641     return iFile;
       
   642 }
       
   643 
       
   644 /**
       
   645 * Initializes a song for playback.
       
   646 *
       
   647 * @since S60 9.2
       
   648 * @param aSong the song path
       
   649 * @param aPosition the starting position
       
   650 */
       
   651 void CTestVideoPlaybackPlugin::InitialiseWithPositionL(const TDesC& aSong, TInt aPosition)
       
   652 {
       
   653     MPX_FUNC_EX("CTestVideoPlaybackPlugin::InitialiseWithPositionL(const TDesC& /*aSong*/, TInt /*aPosition*/)");
       
   654     
       
   655     delete iClipName;
       
   656     iClipName = NULL;
       
   657     iClipName = aSong.AllocL();
       
   658 
       
   659     iFile.Close();
       
   660 
       
   661     TInt err = iFile.Open( iFs, aSong, EFileRead | EFileShareReadersOrWriters );
       
   662 
       
   663     //
       
   664     //  Remap KErrNotReady to KErrNotFound, because it is referencing a drive
       
   665     //  that is not existent
       
   666     //
       
   667     if ( KErrNotReady == err )
       
   668     {
       
   669         err = KErrNotFound;
       
   670     }
       
   671 
       
   672     // if aSong is an streaming link and contains one of the streaming schemas
       
   673     // eg. rtsp:// , http:// etc. then a file handle can not be opened
       
   674     // ignore KErrBadName
       
   675     if (err != KErrBadName)
       
   676     {
       
   677         User::LeaveIfError( err );    
       
   678     }            
       
   679     
       
   680     TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   681     
       
   682     event->iEvent = MMPXPlaybackPluginObserver::EPInitialised;
       
   683     event->iData = 0;
       
   684     event->iError = KErrNone;
       
   685     
       
   686     AddCallbackEvent( event );    
       
   687     
       
   688     event = new TTestVideoPlaybackCallbackEvent;
       
   689     event->iEvent = MMPXPlaybackPluginObserver::EPBufferingStarted;
       
   690     event->iData = 0;
       
   691     event->iError = KErrNone;
       
   692         
       
   693     AddCallbackEvent( event );
       
   694 }
       
   695 
       
   696 /**
       
   697 * Initializes a song for playback.
       
   698 *
       
   699 * @since S60 9.2
       
   700 * @param aFile file handle of a song
       
   701 * @param aPosition the starting position
       
   702 */
       
   703 void CTestVideoPlaybackPlugin::InitialiseWithPositionL(RFile& aSong, TInt aPosition)
       
   704 {
       
   705     MPX_FUNC_EX("CTestVideoPlaybackPlugin::InitialiseWithPositionL(RFile& aSong, TInt aPosition)");
       
   706 
       
   707     delete iClipName;
       
   708     iClipName = NULL;
       
   709     iClipName = HBufC::NewL( KMaxFileName );
       
   710     TPtr ptr = iClipName->Des();
       
   711     aSong.FullName( ptr );
       
   712 
       
   713     iFile.Close();
       
   714     User::LeaveIfError( iFile.Duplicate( aSong ));
       
   715     
       
   716     
       
   717     TTestVideoPlaybackCallbackEvent* event = new (ELeave) TTestVideoPlaybackCallbackEvent;
       
   718     
       
   719     event->iEvent = MMPXPlaybackPluginObserver::EPInitialised;
       
   720     event->iData = 0;
       
   721     event->iError = KErrNone;
       
   722     
       
   723     AddCallbackEvent( event );
       
   724 
       
   725     event = new TTestVideoPlaybackCallbackEvent;
       
   726     event->iEvent = MMPXPlaybackPluginObserver::EPBufferingStarted;
       
   727     event->iData = 0;
       
   728     event->iError = KErrNone;
       
   729             
       
   730     AddCallbackEvent( event );
       
   731 }
       
   732 
       
   733 
       
   734 void CTestVideoPlaybackPlugin::RunL()
       
   735 {
       
   736     MPX_FUNC_EX("CTestVideoPaybackPlugin::RunL");   
       
   737 }
       
   738 
       
   739 void CTestVideoPlaybackPlugin::DoCancel()
       
   740 {
       
   741     MPX_FUNC_EX("CTestVideoPaybackPlugin::DoCancel");
       
   742 }
       
   743 
       
   744 void CTestVideoPlaybackPlugin::AddCallbackEvent( TTestVideoPlaybackCallbackEvent* event )
       
   745 {      
       
   746     MPX_DEBUG1("CTestVideoPlaybackPlugin::AddCallbackEvent");
       
   747     
       
   748     iEventArray->AppendL( event );
       
   749 
       
   750     if ( ! iCallback->IsActive() )
       
   751     {
       
   752         iCallback->Start( TCallBack( CTestVideoPlaybackPlugin::SendEvent, this ) );
       
   753     }
       
   754 }
       
   755 
       
   756 TInt CTestVideoPlaybackPlugin::SendEvent (TAny* aPtr )
       
   757 {
       
   758     MPX_DEBUG1("CTestVideoPlaybackPlugin::SendEvent");
       
   759     
       
   760     static_cast<CTestVideoPlaybackPlugin*>(aPtr)->DoSendEvent();
       
   761 
       
   762     return KErrNone;
       
   763 }
       
   764 
       
   765 void CTestVideoPlaybackPlugin::DoSendEvent()
       
   766 {
       
   767     MPX_DEBUG1("-->CTestVideoPlaybackPlugin::DoSendEvent");
       
   768 
       
   769     TInt count = iEventArray->Count();
       
   770 
       
   771     if ( count > 0 )
       
   772     {
       
   773     TTestVideoPlaybackCallbackEvent* event = (*iEventArray)[0];
       
   774         
       
   775     MMPXPlaybackPluginObserver::TEvent myevent = static_cast<MMPXPlaybackPluginObserver::TEvent>(event->iEvent);
       
   776     
       
   777         iObs->HandlePluginEvent( myevent, event->iData, event->iError);
       
   778 
       
   779         if ( count > 1 )
       
   780         {
       
   781             //
       
   782             //  More events exist, start another callback
       
   783             //
       
   784             MPX_DEBUG1("CTestVideoPlaybackPlugin::DoSendEvent - there are more events, start another callback");
       
   785             iCallback->Start( TCallBack( CTestVideoPlaybackPlugin::SendEvent, this ) );
       
   786         }
       
   787 
       
   788         iEventArray->Delete( 0 );
       
   789     }
       
   790     MPX_DEBUG1("<--CTestVideoPlaybackPlugin::DoSendEvent");
       
   791 }
       
   792 
       
   793 // End of file