mpx/playbackframework/playbackengine/inc/mpxplaybackengine.h
changeset 0 a2952bb97e68
child 9 bee149131e4b
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Controls playback via plug-ins
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CMPXPLAYBACKENGINE_H
       
    21 #define CMPXPLAYBACKENGINE_H
       
    22 
       
    23 
       
    24 #include <bamdesca.h>
       
    25 #include <badesca.h>
       
    26 //
       
    27 #include <mpxcenrepobserver.h>
       
    28 #include <mpxplaybackframeworkdefs.h>
       
    29 #include <mpxplaybackmessage.h>
       
    30 #include <mpxplaybackplugin.h>
       
    31 #include <mpxplaybackpluginobserver.h>
       
    32 #include <mpxpluginhandlerobserver.h>
       
    33 #include <mpxclientlist.h>
       
    34 #include <mpxtaskqueue.h>
       
    35 #include <mpxtaskqueueobserver.h>
       
    36 #include <mpxcollectionobserver.h>
       
    37 #include <mpxcollectionplaylistobserver.h>
       
    38 #include <mpxcommand.h>
       
    39 #include <mpxcollectionplaylist.h>
       
    40 #include <mpxmessagequeue.h>
       
    41 #include <mpxsubscription.h>
       
    42 
       
    43 #include "mpxplaybackpluginhandler.h"
       
    44 #include "mpxplaybackcommandbufferobserver.h"
       
    45 #include "mpxaccessoryobserver.h"
       
    46 #include "mpxplaybacksettings.h"
       
    47 
       
    48 class CMPXPluginMonitor;
       
    49 class CMPXPlaybackPluginHandler;
       
    50 class CMPXAutoResumeHandler;
       
    51 class CMPXPlaybackCmdBuffer;
       
    52 class CMPXCollectionPlaylist;
       
    53 class MMPXPlaybackActiveEngineObserver;
       
    54 class CMPXActiveTaskQueue;
       
    55 class CMPXPlaybackInitializer;
       
    56 class CMPXPlaybackMediaHelper;
       
    57 class CMPXPlaybackDummyMediaObserver;
       
    58 
       
    59 // Constants
       
    60 _LIT(KMPXPlaybackPluginVersion2, "MPXPlaybackPluginVersion2");
       
    61 /**
       
    62 *  The playback 'engine' which delegates to plug-ins (or 'players'). Unless
       
    63 *  stated otherwise, methods apply to currently loaded plug-in (player) and
       
    64 *  currently initialised song.
       
    65 */
       
    66 class CMPXPlaybackEngine : public CBase,
       
    67                            public MMPXPlaybackPluginObserver,
       
    68                            public MMPXPlaybackCmdBufferObserver,
       
    69                            public MBeating,
       
    70                            public MMPXAccessoryEventObserver,
       
    71                            public MMPXTaskQueueObserver,
       
    72                            public MMPXCollectionMediaObserver,
       
    73                            public MMPXCollectionPlaylistObserver,
       
    74                            public MMPXPluginHandlerObserver
       
    75     {
       
    76 public:
       
    77 
       
    78     /**
       
    79     *  Two-phased constructor.
       
    80     *
       
    81     *  @param aPluginMonitor plugin monitor
       
    82     *  @param aObserver engine observer
       
    83     *  @param aClientListObserver client list observer
       
    84     *  @param aModeId denotes whether this player is designated for the
       
    85     *                        stand-alone application
       
    86     *  @return Constructed object
       
    87     */
       
    88     IMPORT_C static CMPXPlaybackEngine* NewL(
       
    89                            CMPXPluginMonitor& aPluginMonitor,
       
    90                            MMPXPlaybackActiveEngineObserver& aObserver,
       
    91                            MMPXClientlistObserver* aClientListObserver,
       
    92                            const TUid& aModeId);
       
    93 
       
    94 
       
    95    /**
       
    96     *  Two-phased constructor.
       
    97     *
       
    98     *  @param aPluginMonitor plugin monitor
       
    99     *  @param aObserver engine observer
       
   100     *  @param aClientListObserver client list observer
       
   101     *  @param aModeId denotes whether this player is designated for the
       
   102     *                        stand-alone application
       
   103 	*  @param aCategory category of engine (Music, Video)
       
   104     *  @return Constructed object
       
   105     */
       
   106     IMPORT_C static CMPXPlaybackEngine* NewL(
       
   107                            CMPXPluginMonitor& aPluginMonitor,
       
   108                            MMPXPlaybackActiveEngineObserver& aObserver,
       
   109                            MMPXClientlistObserver* aClientListObserver,
       
   110                            const TUid& aModeId,
       
   111                            const TInt aCategory);
       
   112 
       
   113 						   
       
   114     /**
       
   115     *  Destructor
       
   116     */
       
   117     IMPORT_C ~CMPXPlaybackEngine();
       
   118 
       
   119 public:
       
   120 
       
   121     /**
       
   122     *  Returns reference to client list
       
   123     *
       
   124     *  @return client list object
       
   125     */
       
   126     inline CMPXClientList* ClientList();
       
   127 
       
   128     /**
       
   129     *  Returns object encapsulating list of clients and its management
       
   130     *
       
   131     *  @return playback plugin handler
       
   132     */
       
   133     inline CMPXPlaybackPluginHandler* PluginHandler();
       
   134 
       
   135     /**
       
   136     *  Does this player (i.e. the currently loaded plug-in) have access to
       
   137     *  audio resources
       
   138     *
       
   139     *  @return ETrue audio resource is used by the player
       
   140     */
       
   141     inline TBool IsPlayerActive() const;
       
   142 
       
   143     /**
       
   144     *  Return mode id of this engine
       
   145     *
       
   146     *  @return mode id
       
   147     */
       
   148     inline const TUid& ModeId() const;
       
   149 	
       
   150 
       
   151     /**
       
   152     *  Return category of this engine
       
   153     *
       
   154     *  @return category
       
   155     */
       
   156 
       
   157     inline const TInt Category() const;
       
   158 
       
   159 
       
   160     /**
       
   161     *  Current state
       
   162     *
       
   163     *  @return playback state
       
   164     */
       
   165     inline TMPXPlaybackState State() const;
       
   166 
       
   167     /**
       
   168     *  Current collection path, or NULL if none (i.e. not from collection)
       
   169     */
       
   170     inline const CMPXCollectionPlaylist* Playlist() const;
       
   171 
       
   172     /**
       
   173     *  Current song index, or KErrNotFound if none (i.e. not from collection)
       
   174     */
       
   175     inline TInt SongIndex() const;
       
   176 
       
   177     /**
       
   178     *  Current uri, or KNullDesC if none (i.e. uri not supplied)
       
   179     */
       
   180     inline const TDesC& Uri() const;
       
   181 
       
   182     /**
       
   183     *  Current file handle
       
   184     */
       
   185     inline const RFile& File() const;
       
   186 
       
   187     /**
       
   188      *  Retursn last active process id
       
   189      *
       
   190      *  @return process id of last active process
       
   191      */
       
   192     inline TProcessId LastActiveProcessId() const;
       
   193 
       
   194     /**
       
   195      *  Retursn last inactive process id
       
   196      *
       
   197      *  @return process id of last inactive process
       
   198      */
       
   199     inline TProcessId LastInactiveProcessId() const;
       
   200 
       
   201     /**
       
   202     *  Initializes the player with a song in the collection
       
   203     *
       
   204     *  @param aCollectionPath collection path
       
   205     *  @param aPlay Whether to initialize for playback, or
       
   206     *               else just to setup the engine first
       
   207     */
       
   208     IMPORT_C void InitL( const CMPXCollectionPlaylist& aPlaylist,
       
   209                          TBool aPlay );
       
   210 
       
   211     /**
       
   212     *  Initializes the player with a uri - doesn't use collection
       
   213     *
       
   214     *  @param aUri URI of the song
       
   215     *  @param aType the type of song
       
   216     */
       
   217     IMPORT_C void InitL(const TDesC& aUri,const TDesC8& aType);
       
   218 
       
   219     /**
       
   220     *  Initializes the player with a file - doesn't use collection
       
   221     *
       
   222     *  @aFile file handle
       
   223     */
       
   224     IMPORT_C void InitL(const RFile& aFile);
       
   225     
       
   226     /**
       
   227     *  Initializes the player with a uri and Access Point
       
   228     *
       
   229     *  @since S60 9.2
       
   230     *  @param aUri URI of the item
       
   231     *  @param aType the mime type of the item
       
   232     *  @param aAccessPoint the access point of the item
       
   233     */
       
   234     IMPORT_C void InitStreamingL(const TDesC& aUri, const TDesC8& aType, const TInt aAccessPoint);
       
   235 
       
   236     /**
       
   237     *  Initializes the player with a file and access point
       
   238     *
       
   239     *  @since S60 9.2
       
   240     *  @param aFile file handle
       
   241     *  @param aAccessPoint the access point of the item
       
   242     */
       
   243     IMPORT_C void InitStreamingL(const RFile& aFile, const TInt aAccessPoint);
       
   244 
       
   245     /**
       
   246     *  Cancel all outstanding, asynchronous requests
       
   247     */
       
   248     IMPORT_C void CancelRequests();
       
   249 
       
   250     /**
       
   251     *  Issue a playback command
       
   252     *
       
   253     *  @param aCmd playback command
       
   254     *  @param aData optional data
       
   255     */
       
   256     IMPORT_C void CommandL(TMPXPlaybackCommand aCmd,TInt aData=0);
       
   257 
       
   258     /**
       
   259      *  Issue a playback command
       
   260      *
       
   261      *  @param aCmd playback command
       
   262      *  @param aMsgQueue Message Queue for the client
       
   263      */
       
   264     IMPORT_C void CommandL(CMPXCommand& aCmd, const CMPXMessageQueue& aMsgQueue);
       
   265 
       
   266     /**
       
   267     *  Sets the property value. Value not set until a property changed event is
       
   268     *  returned to the client
       
   269     */
       
   270     IMPORT_C void SetL(TMPXPlaybackProperty aProperty,TInt aValue);
       
   271 
       
   272     /**
       
   273     *  Asynchronously retrieves the value of a property. Result will be called
       
   274     *  back by using MMPXPlaybackEngineObserver
       
   275     */
       
   276     IMPORT_C void PropertyL(TMPXPlaybackProperty aProperty,
       
   277                             MMPXPlaybackEngineObserver& aCallback);
       
   278 
       
   279     /**
       
   280     *  DEPRECATED
       
   281     *
       
   282     *  Asynchronously return media properties
       
   283     *  using MMPXPlaybackEngineObserver
       
   284     *
       
   285     *  @param aCallback playback callback
       
   286     *  @param aBuf parameter buffer, take over the ownership
       
   287     */
       
   288     IMPORT_C void MediaL(MMPXPlaybackEngineObserver& aCallback, CBufBase* aBuf);
       
   289 
       
   290     /**
       
   291     *  Asynchronously return media properties
       
   292     *  using MMPXPlaybackEngineObserver
       
   293     *
       
   294     *  @param aCallback playback callback
       
   295     *  @param aCmd Command object containing attribute spec and attribute array
       
   296     */
       
   297     IMPORT_C void MediaL(MMPXPlaybackEngineObserver& aCallback, const CMPXCommand& aCmd);
       
   298 
       
   299     /**
       
   300     *  Asynchronously retrieves the sub player names. See MMPXPlayerManager
       
   301     *
       
   302     *  @param aCallback playback callback
       
   303     */
       
   304     IMPORT_C void SubPlayerNamesL(TUid aPlayerUid,
       
   305                                   MMPXPlaybackEngineObserver& aCallback);
       
   306 
       
   307     /**
       
   308     * Gets media from the plugin
       
   309     *
       
   310     * @param aCallback Callback method to call after retrieving media
       
   311     * @param aCmd Command containing the media attributes and attribute specs.
       
   312     *             Ownership transfered
       
   313     */
       
   314     void MediaFromPluginL( MMPXPlaybackEngineObserver* aCallback,
       
   315                            CMPXCommand* aCmd );
       
   316     
       
   317 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   318     /**
       
   319     *  Current file handle
       
   320     */
       
   321     inline const RFile64& File64() const;
       
   322 
       
   323     /**
       
   324     *  Initializes the player with a file - doesn't use collection
       
   325     *
       
   326     *  @aFile file handle
       
   327     */
       
   328     IMPORT_C void Init64L(const RFile64& aFile);
       
   329     
       
   330     /**
       
   331     *  Initializes the player with a file and access point
       
   332     *
       
   333     *  @since S60 9.2
       
   334     *  @param aFile file handle
       
   335     *  @param aAccessPoint the access point of the item
       
   336     */
       
   337     IMPORT_C void InitStreaming64L(const RFile64& aFile, const TInt aAccessPoint);
       
   338 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   339     
       
   340 public:
       
   341 
       
   342     /**
       
   343     *  Handle command
       
   344     *
       
   345     *  @param aCmd command
       
   346     */
       
   347     void HandleCommandL(TMPXPlaybackCommand aCmd, TInt aData=0);
       
   348 
       
   349 private:
       
   350     enum TPlaySource
       
   351         {
       
   352         EPlayNone,
       
   353         EPlayFromCollection,
       
   354         EPlayFromUri,
       
   355         EPlayFromFile,
       
   356         EPlayFromFile64
       
   357         };
       
   358 
       
   359     enum TAsyncRequest
       
   360         {
       
   361         EProperty,
       
   362         EMedia,
       
   363         ESubPlayerNames,
       
   364         EHandleNext
       
   365         };
       
   366 
       
   367     /**
       
   368     *  Helper class to reflect playback call back to engine itself.
       
   369     */
       
   370     class TCallbackReflector : public MMPXPlaybackEngineObserver
       
   371         {
       
   372         public:
       
   373 
       
   374             /**
       
   375             *  Contructor
       
   376             *
       
   377             *  @param aEngine playback engine
       
   378             */
       
   379             inline TCallbackReflector(CMPXPlaybackEngine& aEngine);
       
   380 
       
   381             /**
       
   382             *  From MMPXPlaybackEngineObserver
       
   383             *  Handle playback property
       
   384             *
       
   385             *  @param aProperty the property
       
   386             *  @param aValue the value of the property
       
   387             *  @param aError error code
       
   388             */
       
   389             inline void HandleProperty(TMPXPlaybackProperty aProperty,
       
   390                                        TInt aValue,
       
   391                                        TInt aError);
       
   392 
       
   393             /**
       
   394             *  From MMPXPlaybackEngineObserver
       
   395             *  Method is called continously until aComplete=ETrue, signifying that
       
   396             *  it is done and there will be no more callbacks
       
   397             *  Only new items are passed each time
       
   398             *
       
   399             *  @param aPlayer UID of the subplayer
       
   400             *  @param aSubPlayers a list of sub players
       
   401             *  @param aComplete ETrue no more sub players. EFalse more subplayer
       
   402             *                   expected
       
   403             *  @param aError error code
       
   404             */
       
   405             inline void HandleSubPlayerNames(TUid aPlayer,
       
   406                                              const MDesCArray* aSubPlayers,
       
   407                                              TBool aComplete,
       
   408                                              TInt aError);
       
   409 
       
   410             /**
       
   411             *  From MMPXPlaybackEngineObserver
       
   412             *  Handle media object
       
   413             *
       
   414             *  @param aMedia media object
       
   415             *  @param aError error code
       
   416             */
       
   417             inline void HandleMedia(CMPXMedia* aMedia, TInt aError);
       
   418 
       
   419         private:
       
   420             CMPXPlaybackEngine& iEngine;
       
   421         };
       
   422 
       
   423 private:
       
   424 
       
   425     /**
       
   426     *  C++ constructor
       
   427     *
       
   428     *  @param aPluginMonitor plugin monitor
       
   429     *  @param aObserver engine observer
       
   430     *  @param aModeId player engine mode
       
   431     */
       
   432     CMPXPlaybackEngine(CMPXPluginMonitor& aPluginMonitor,
       
   433                        MMPXPlaybackActiveEngineObserver& aObserver,
       
   434                        const TUid& aModeId);
       
   435 					   
       
   436 
       
   437     /**
       
   438     *  C++ constructor
       
   439     *
       
   440     *  @param aPluginMonitor plugin monitor
       
   441     *  @param aObserver engine observer
       
   442     *  @param aModeId player engine mode
       
   443     *  @param aCategory player engine category
       
   444     */
       
   445 
       
   446     CMPXPlaybackEngine(CMPXPluginMonitor& aPluginMonitor,
       
   447                        MMPXPlaybackActiveEngineObserver& aObserver,
       
   448                        const TUid& aModeId,
       
   449                        const TInt aCategory);
       
   450 
       
   451 
       
   452     /**
       
   453     *  2nd phase contructor
       
   454     *
       
   455     *  @param aClientListObserver client list observer
       
   456     */
       
   457     void ConstructL(MMPXClientlistObserver* aClientListObserver);
       
   458 
       
   459 
       
   460 private: // Functions from base class
       
   461 
       
   462     /**
       
   463     *   From MBeating
       
   464     *   Handles a regular heartbeat timer event
       
   465     */
       
   466     void Beat();
       
   467 
       
   468     /**
       
   469     *   From MBeating
       
   470     *   Synchronises the heartbeat timer with system clock
       
   471     */
       
   472     void Synchronize();
       
   473 
       
   474     /**
       
   475     *   From MMPXPlayerAccessoryEventObserver
       
   476     *   Handle accessory event
       
   477     *
       
   478     *   @param aMode playback accessory mode
       
   479     */
       
   480     void HandleAccesoryEventL(TMPXPlaybackAccessoryMode aMode);
       
   481 
       
   482     /**
       
   483     *  From MMPXPlaybackPluginObserver
       
   484     *  Handle plugin event
       
   485     *
       
   486     *  @param aEvent the event type
       
   487     *  @param aData optional data
       
   488     *  @param aError error code of the event
       
   489     */
       
   490     void HandlePluginEvent(TEvent aEvent,TInt aData,TInt aError);
       
   491 
       
   492     /**
       
   493      * From MMPXPlaybackPluginObserver
       
   494      * Handle message from plug-in
       
   495      *
       
   496      * @param aMsg, message from the plug-in. Ownership not transferred.
       
   497      * @param aErr system error code. if aErr is not KErrNone, aMsg will not be
       
   498      *        used/dereferenced at playback engine.
       
   499      */
       
   500     void HandlePlaybackMessage(CMPXMessage* aMsg, TInt aErr);
       
   501 
       
   502     /**
       
   503     *  From MMPXPlaybackPluginObserver
       
   504     *  Async response for Value request
       
   505     *
       
   506     *  @param aProperty property key
       
   507     *  @param aValue property value
       
   508     *  @param aError error code
       
   509     */
       
   510     void HandleProperty(TMPXPlaybackProperty aProperty,
       
   511                          TInt aValue, TInt aError);
       
   512 
       
   513     /**
       
   514     *  From MMPXPlaybackPluginObserver
       
   515     *  Async response for MediaL request
       
   516     *
       
   517     *  @param aMedia media object
       
   518     *  @param aError error code
       
   519     */
       
   520     void HandleMedia(CMPXMedia* aMedia, TInt aError);
       
   521 
       
   522     /**
       
   523     *  From MMPXPlaybackPluginObserver
       
   524     *  Async response for subplayer request
       
   525     *
       
   526     *  @param aPlayer UID of the subplayer
       
   527     *  @param aSubPlayers array of subplayers
       
   528     *  @param aComplete ETrue, completed, EFalse, not completed
       
   529     *  @param aError error code
       
   530     */
       
   531     void HandleSubPlayerNames(TUid aPlayer, const MDesCArray* aSubPlayers,
       
   532                               TBool aComplete, TInt aError);
       
   533 
       
   534     /**
       
   535     *  From MMPXPlaybackCmdBufferObserver
       
   536     *  Handle command from buffering
       
   537     *
       
   538     *  @param aEvent comand info
       
   539     */
       
   540     void HandleCmdBufferEventL(const TMPXPlaybackCmdInfo& aEvent);
       
   541 
       
   542     /**
       
   543     *  From MMPXPlaybackCmdBufferObserver
       
   544     *  Handle command skip event from key buffering
       
   545     *
       
   546     * @param aSkipEvent Skip event
       
   547     */
       
   548     void HandleCmdBufferSkipEventL(const TMPXPlaybackSkipEvent aSkipEvent);
       
   549 
       
   550     ///////////////////////////////////////////////////////////////////////////
       
   551     // From MMPXTaskQueueObserver
       
   552 
       
   553     /**
       
   554     * Execute a task
       
   555     * @param aTask task number
       
   556     * @param aParamData, parameter
       
   557     * @param aPtrData, any object
       
   558     * @param aBuf, buffer containing externalized parameters for the task.
       
   559     * @param aCallback call back function pointer
       
   560     * @param aCObject1 object 1 owned by task queue
       
   561     * @param aCObject2 object 2 owned by task queue
       
   562     */
       
   563     void ExecuteTask(TInt aTask,
       
   564                      TInt aParamData,
       
   565                      TAny* aPtrData,
       
   566                      const CBufBase& aBuf,
       
   567                      TAny* aCallback,
       
   568                      CBase* aCObject1,
       
   569                      CBase* aCObject2);
       
   570 
       
   571     /**
       
   572     *  From MMPXCollectionMediaObserver
       
   573     *  Handle media properties from collection
       
   574     *
       
   575     *  @param aMedia media
       
   576     *  @param aError error code
       
   577     */
       
   578     void HandleCollectionMediaL(const CMPXMedia& aProperties, TInt aError);
       
   579 
       
   580     /**
       
   581     *  From MMPXCollectionPlaylistObserver
       
   582     *  Handle collection playlist change
       
   583     *
       
   584     *  @param aError KErrNotFound - Playlist is updated, current item removed
       
   585     *                KErrNone - Playlist is updated, current item is valid
       
   586     *                KErrEof - Playlist is updated, current item removed and
       
   587     *                          reached to the end of playlist
       
   588     */
       
   589     void HandleCollectionPlaylistChange(TInt aError);
       
   590 
       
   591     ///////////////////////////////////////////////////////////////////////////
       
   592     // From MMPXPluginHandlerObserver
       
   593 
       
   594     /*
       
   595     * @see MMPXPluginHandlerObserver
       
   596     */
       
   597     void HandlePluginHandlerEvent(TPluginHandlerEvents aEvent, const TUid& aPluginUid,
       
   598         TBool aLoaded, TInt aData);
       
   599 
       
   600 private:  // New functions
       
   601 
       
   602 
       
   603     /**
       
   604     *  Return current plugin
       
   605     *
       
   606     *  @return plugin object
       
   607     */
       
   608     inline CMPXPlaybackPlugin* PluginL() const;
       
   609 
       
   610     /**
       
   611     *  Suspend playback
       
   612     */
       
   613     void Suspend();
       
   614 
       
   615     /**
       
   616     *  Seek timer tick
       
   617     */
       
   618     void SeekTimerTick();
       
   619 
       
   620     /**
       
   621     *  Seek timer callback
       
   622     *
       
   623     *  @param aPtr pointer the this
       
   624     */
       
   625     static TInt SeekTimerCallback(TAny* aPtr);
       
   626 
       
   627     /**
       
   628     *  Init plugin
       
   629     *
       
   630     *  @param aSong, song path
       
   631     *  @param aType, song type
       
   632     *  @param aFile, file handle
       
   633     *  @param aAccessPoint aAccessPoint
       
   634     */
       
   635     void InitL(const TDesC* aSong,const TDesC8* aType,RFile* aFile, 
       
   636             TInt aAccessPoint=0);
       
   637 
       
   638     /**
       
   639     *  Handle play command
       
   640     */
       
   641     void HandlePlayL();
       
   642 
       
   643     /**
       
   644     *  Handle play command with fade in
       
   645     */
       
   646     void HandlePlayWithFadeInL();
       
   647 
       
   648     /**
       
   649     *  Handle pause command
       
   650     */
       
   651     void HandlePauseL();
       
   652 
       
   653     /**
       
   654     *  Handle stop command
       
   655     */
       
   656     void HandleStopL();
       
   657 
       
   658     /**
       
   659     *  Stop play back
       
   660     *  @param aSavePlaybackInfo flag to determine if the PlaybackInfo should be saved
       
   661     */
       
   662     void DoStopL(TBool aSavePlaybackInfo = ETrue);
       
   663 
       
   664     /**
       
   665     *  Handle next command
       
   666     *  @param aOffset offset to current index
       
   667     *  @param aIgnoreRepeat ETrue to ignore repeat setting
       
   668     */
       
   669     void HandleNextL( TInt aOffset = 1, TBool aIgnoreRepeat=EFalse );
       
   670 
       
   671     /**
       
   672     *  Handle previous command
       
   673     *  @param aOffset offset to current index
       
   674     *  @param aIgnoreRepeat ETrue to ignore repeat setting
       
   675     */
       
   676     void HandlePreviousL(TInt aOffset = -1, TBool aIgnoreRepeat=EFalse );
       
   677 
       
   678     /**
       
   679     *  Handle replay command
       
   680     */
       
   681     void HandleReplayL();
       
   682 
       
   683     /**
       
   684     *  Handle sart seekingcommand
       
   685     */
       
   686     void HandleStartSeekL(TBool aForward);
       
   687 
       
   688     /**
       
   689     *  Handle stop seeking command
       
   690     */
       
   691     void HandleStopSeekingL();
       
   692 
       
   693     /**
       
   694     *  Handle increase volume command
       
   695     */
       
   696     void HandleIncreaseVolumeL();
       
   697 
       
   698     /**
       
   699     *  Handle decrease volume command
       
   700     */
       
   701     void HandleDecreaseVolumeL();
       
   702 
       
   703     /**
       
   704     *  Handle set volume command
       
   705     */
       
   706     void HandleSetVolumeL(TInt aVolume);
       
   707 
       
   708     /**
       
   709     *  Handle mute command
       
   710     */
       
   711     void HandleMuteL(TBool aMute);
       
   712 
       
   713     /**
       
   714     *  Handle close command
       
   715     *  @param aData data to be forwarded to the player
       
   716     */
       
   717     void HandleCloseL( TInt aData = KErrNone );
       
   718 
       
   719     /**
       
   720     * Handle a custom command
       
   721     */
       
   722     void HandleEffectL(TInt aData);
       
   723 
       
   724     /**
       
   725     * Handle a custom command
       
   726     */
       
   727     void HandleDisableEffectL();
       
   728 
       
   729     /**
       
   730     * Handle a request to close the file handle for an item
       
   731     * @param aItemId item that is requested to be freed
       
   732     */
       
   733     void HandleCloseItemL( TInt aItemId );
       
   734 
       
   735     /**
       
   736     *  Sets the current properties for the plug-in
       
   737     */
       
   738     void SetPropertiesL();
       
   739 
       
   740     /**
       
   741     *  Stop seeking timer
       
   742     */
       
   743     void EndSeek();
       
   744 
       
   745     /**
       
   746     * Set a playback state
       
   747     * @param aState new state
       
   748     */
       
   749     void SetStateL(TMPXPlaybackState aState);
       
   750 
       
   751     /**
       
   752     * Set a playback state, takes in a TMPXPlaybackMessage with the
       
   753     * state already set as the iType parameter.  This Allows caller to
       
   754     * set iData information as well.
       
   755     * @param aMessage Message containing state information
       
   756     */
       
   757     void SetStateL( TMPXPlaybackMessage& aMsg );
       
   758 
       
   759     /**
       
   760     * Set player activated
       
   761     * @param aActive ETrue actived, EFalse inactived.
       
   762     */
       
   763     void SetPlayerActivated(TBool aActive);
       
   764 
       
   765     /**
       
   766     * Execute a task
       
   767     * @param aTask task number
       
   768     * @param aParamData, parameter
       
   769     * @param aPtrData, any object
       
   770     * @param aCallback call back function pointer
       
   771     * @param aBuf buffer data
       
   772     * @param aCObject1 object 1 owned by task queue
       
   773     * @param aCObject2 object 2 owned by task queue
       
   774     */
       
   775     void ExecuteTaskL(TInt aTask,
       
   776                       TInt aParamData,
       
   777                       TAny* aPtrData,
       
   778                       TAny* aCallback,
       
   779                       const CBufBase& aBuf,
       
   780                       CBase* aCObject1,
       
   781                       CBase* aCObject2);
       
   782 
       
   783     /**
       
   784     * @see MMPXTaskQueueObserver
       
   785     */
       
   786     void HandleTaskError(TInt aTask,
       
   787                          TAny* aPtrData,
       
   788                          TAny* aCallback,
       
   789                          TInt aError);
       
   790 
       
   791     /**
       
   792     * Handle error of execution
       
   793     * @param aTask task number
       
   794     * @param aErr error number
       
   795     * @param aParamData parameter
       
   796     */
       
   797     void HandleError(TInt aTask, TInt aErr, TInt aParamData = 0);
       
   798 
       
   799     /**
       
   800     * Get command from state
       
   801     */
       
   802     TMPXPlaybackCommand CommandFromState( TMPXPlaybackState aState );
       
   803 
       
   804     /**
       
   805     * Cleanup when the engine closed
       
   806     */
       
   807     void DoClose();
       
   808 
       
   809     /**
       
   810     * Media request from collection
       
   811     */
       
   812     void MediaFromCollectionL();
       
   813 
       
   814     /**
       
   815     *  Handle plugin event
       
   816     *
       
   817     *  @param aEvent the event type
       
   818     *  @param aData optional data
       
   819     *  @param aError error code of the event
       
   820     */
       
   821     void DoHandlePluginEventL(TEvent aEvent,TInt aData,TInt aError);
       
   822 
       
   823     /**
       
   824     *  Update playbackengine state machine
       
   825 	*  Handles plugin events that could cause state change in playback-engine
       
   826     *
       
   827     *  @param aEvent the event type
       
   828     *  @param aData optional data
       
   829     *  @param aError error code of the event
       
   830     */
       
   831     void UpdateStateMachineL(TEvent aEvent,TInt aData,TInt aError);    
       
   832     
       
   833    /*
       
   834     * Handle plugin event error handling
       
   835     * This is internal function called from DoHandlePluginEvent()
       
   836     * @param aEvent the event type
       
   837     * @param aError error code of the event
       
   838     */    
       
   839     void HandlePluginEventErrorHandling(TEvent aEvent, TInt aError);
       
   840 
       
   841     /*
       
   842      * Handle Plugin Event: Initialised
       
   843      * Handles the event called Initialised
       
   844      * @param aState the mpx playbackstate
       
   845      * @param aData data passed from playback plugin in call to HandlePluginEvent
       
   846      */
       
   847     void HandlePluginEventInitialisedL(TMPXPlaybackState& aState, TInt aData);    
       
   848     
       
   849     /**
       
   850     * Save playback Information
       
   851     */
       
   852     void SavePlaybackInfoL();
       
   853 
       
   854     /**
       
   855     * Increments play count
       
   856     */
       
   857     void SavePlaybackCompleteInfoL();
       
   858 
       
   859     /**
       
   860     * Restore playback position and state if it was saved previously
       
   861     */
       
   862     void RestorePlaybackPositionAndStateL( const CMPXMedia& aMedia );
       
   863 
       
   864     /**
       
   865     * Sets the volume increment depending on accessory state
       
   866     */
       
   867     void SetVolumeIncrement( TMPXPlaybackAccessoryMode aMode );
       
   868 
       
   869     /**
       
   870     * Marks the current item as corrupted
       
   871     * @param aCorrupted Flag if corrupted or not
       
   872     */
       
   873     void MarkItemCorrupted( const TBool aCorrupted );
       
   874 
       
   875     /**
       
   876     * Marks the current item as invalid
       
   877     * @param aInvalid Flag if invalid or not
       
   878     */
       
   879     void MarkItemInvalid( const TBool aInvalid );
       
   880 
       
   881     /**
       
   882     * Marks the current item as DRM invalid (e.g. no rights)
       
   883     * @param aDrmInvalid Flag if invalid or not
       
   884     */
       
   885     void MarkItemDrmInvalid( const TBool aDrmInvalid );
       
   886 
       
   887     /**
       
   888     * Sets flag bits
       
   889     * @aSet ETrue to set, EFalse to unset
       
   890     * @aFlag Flag bits to set/unset
       
   891     */
       
   892     void SetFlagBitsL( const TBool aSet, const TUint aFlag );
       
   893 
       
   894     /**
       
   895     * Creates a CMPXMedia object to be used to Set attributes
       
   896     * @param aPath Collection Path
       
   897     * @return CMPXMedia object
       
   898     */
       
   899     CMPXMedia* CreateMediaToSetLC( const CMPXCollectionPath& aPath );
       
   900 
       
   901     /**
       
   902     * Sends a request to iMediaHelper to request media
       
   903     */
       
   904     void RequestMediaL();
       
   905 
       
   906     /**
       
   907     * Sends a plugin handler message to all clients.
       
   908     * @param aMessageId the value of the KMPXMessageGeneralId attribute
       
   909     * @param aPluginUid plugin UID this message is for
       
   910     * @param aLoaded ETrue if the plugin is loaded
       
   911     * @param aVersion plugin version
       
   912     */
       
   913     void SendPluginHandlerMessageL(TInt aMessageId, const TUid& aPluginUid,
       
   914         TBool aLoaded, TInt aVersion = 0);
       
   915     
       
   916 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   917     /**
       
   918     *  Init plugin
       
   919     *
       
   920     *  @param aSong, song path
       
   921     *  @param aType, song type
       
   922     *  @param aFile, file handle
       
   923     *  @param aAccessPoint aAccessPoint
       
   924     */
       
   925     void Init64L(RFile64* aFile, TInt aAccessPoint=0);
       
   926 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   927     
       
   928 private:
       
   929     friend class TCallbackReflector;
       
   930     friend class CMPXPlaybackInitializer;
       
   931 
       
   932     TCallbackReflector iReflector;
       
   933     CMPXPluginMonitor& iPluginMonitor;
       
   934     CMPXClientList* iClientList;
       
   935     CMPXPlaybackInitializer* iInitializer;
       
   936     CMPXPlaybackPluginHandler* iPluginHandler;
       
   937     TBool iInitNext;
       
   938     /**
       
   939     *   Utilities
       
   940     */
       
   941     CHeartbeat* iProgressTimer;
       
   942     CPeriodic* iSeekTimer;
       
   943     CMPXAccessoryObserver* iAccessoryObs;
       
   944     CMPXPlaybackCmdBuffer* iCmdBuffer;
       
   945     CMPXPlaybackSettings* iPlaybackSettings;
       
   946     CMPXAutoResumeHandler* iAutoResumeHandler;
       
   947 
       
   948     /**
       
   949     *   Playlist/song data
       
   950     */
       
   951     CMPXCollectionPlaylist* iPlaylist;
       
   952     HBufC* iUri;
       
   953     TMPXItemId iItemId;
       
   954     RFile iFile;
       
   955     TPlaySource iPlaySource;
       
   956     TUint iDbFlag;
       
   957     TInt iMediaDuration;    // Duration value inside CMPXMedia
       
   958     
       
   959     TInt iAccessPoint;
       
   960     TBool iAccessPointSet;  // Access Point is set
       
   961     
       
   962     /**
       
   963     *   This player data
       
   964     */
       
   965     TMPXPlaybackState iState; // current state
       
   966     TMPXPlaybackState iNextState; // next possible state when handling commands
       
   967     TMPXPlaybackState iPluginState; // plugin state
       
   968     TBool iEmbeddedMode;
       
   969     TUid iModeId;
       
   970     TInt iCategory;
       
   971     TBool iPlayerActive;
       
   972     //
       
   973     TFixedArray<TInt,EPbPropertyNum> iProperties;
       
   974     TInt iSeekStep; // millisecond
       
   975     TInt iMaxSeekStep; // millisecond
       
   976     MMPXPlaybackActiveEngineObserver& iObserver;
       
   977     CMPXActiveTaskQueue* iTaskQueue;
       
   978     MMPXPlaybackEngineObserver* iCallback; // Not owned.
       
   979 
       
   980     TMPXPlaybackState iPreservedState;
       
   981     TInt iPreservedPosition;
       
   982 
       
   983     TInt iVolumeIncrement;
       
   984     RArray<TMPXAttribute> iMediaAttrs;
       
   985     TBool iSkipping;
       
   986     CMPXPlaybackMediaHelper* iMediaHelper;
       
   987 
       
   988     CMPXPlaybackDummyMediaObserver* iDummyMediaObserver;
       
   989     TUid iPluginUid; // plugin uid for current item of current playlist
       
   990     TProcessId iLastActiveProcess; // Last active process for this engine
       
   991     TProcessId iLastInactiveProcess; // Last inactive process for this engine
       
   992     TBool iInitVolume;  // Initialize volume on first creation
       
   993     // the index which be firstly saved when request media
       
   994     TInt iFirstRequestMediaIndex; 
       
   995 #if defined(__HIGH_RESOLUTION_VOLUME)
       
   996     // flag to indicate whether the volume setting has been rounded up last
       
   997     // used to adjust volume up button setting 
       
   998     TBool iVolRoundedUp;
       
   999 #endif
       
  1000     
       
  1001 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  1002     RFile64 iFile64;
       
  1003 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  1004     };
       
  1005 
       
  1006 #include "mpxplaybackengine.inl"
       
  1007 
       
  1008 #endif // CMPXPLAYBACKENGINE_H
       
  1009