mpx/playbackframework/playbackserver/inc/mpxplaybackserver.h
changeset 0 a2952bb97e68
child 15 d240f0a77280
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Playback server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMPXPLAYBACKSERVER_H
       
    20 #define CMPXPLAYBACKSERVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "mpxclientlistobserver.h"
       
    24 #include "mpxplaybackserverdefs.h"
       
    25 #include "mpxplaybackactiveengineobserver.h"
       
    26 
       
    27 class CMPXPlaybackEngine;
       
    28 class CMPXMessageQueue;
       
    29 class CTspClientMapper;
       
    30 class CMPXPluginMonitor;
       
    31 
       
    32 /**
       
    33 * Music playback server
       
    34 */
       
    35 NONSHARABLE_CLASS(CMPXPlaybackServer) : public CPolicyServer,
       
    36                                         public MMPXPlaybackActiveEngineObserver,
       
    37                                         public MMPXClientlistObserver
       
    38     {
       
    39 public:
       
    40 
       
    41     /**
       
    42     *  Two-phased constructor. Leaves on failure.
       
    43     *
       
    44     *  @return The constructed object
       
    45     */
       
    46     static CMPXPlaybackServer* NewL();
       
    47 
       
    48     /**
       
    49     *  Destructor
       
    50     */
       
    51     ~CMPXPlaybackServer();
       
    52 
       
    53     /**
       
    54     *  Create a player for a specific client, or returns an existing player
       
    55     *  depending on the mode and whether it already exists.
       
    56     *
       
    57     *  @param aModeId playback mode id
       
    58     *  @param aClientId thread id of the client
       
    59     *  @aMsgQueue message queue for the client
       
    60     *  @leave The function leaves with one of the system wide error codes,
       
    61     *         if the operation fails.
       
    62     */
       
    63     CMPXPlaybackEngine* CreatePlayerL(const TUid& aModeId,
       
    64                                       const TInt aCategory, 
       
    65                                       TThreadId aClientId,
       
    66                                       CMPXMessageQueue* aMsgQueue);
       
    67 
       
    68     /**
       
    69     * Increments number of sessions this server holds
       
    70     */
       
    71     void AddClient();
       
    72 
       
    73     /**
       
    74     *  Decrements number of sessions this server holds, and if now zero, shuts
       
    75     *  down server. ALSO removes client from player, and if the player has no
       
    76     *  more clients, it gets deleted.
       
    77     *
       
    78     *  @param aMsgQueue message queue for the client
       
    79     */
       
    80     void RemoveClient(const CMPXMessageQueue& aMsgQueue);
       
    81 
       
    82     /**
       
    83      *  Retursn last active process id
       
    84      *
       
    85      *  @return process id of last active process
       
    86      */
       
    87     TProcessId LastActiveProcessId();
       
    88 
       
    89 private:
       
    90 
       
    91     /**
       
    92     *  Add a new player
       
    93     *
       
    94     *  @param aClientId thread id of the client
       
    95     *  @param aModeId playback mode id
       
    96     *  @aMsgQueue message queue for the client
       
    97 	*  @param aCategory category of engine
       
    98     *  @leave The function leaves with one of the system wide error codes,
       
    99     *         if the operation fails.
       
   100     *  @return pointer to engine
       
   101     */
       
   102     CMPXPlaybackEngine* AddNewPlayerL(TThreadId aClientId,
       
   103                                       const TUid& aModeId,
       
   104                                       CMPXMessageQueue* aMsgQueue,
       
   105                                       const TInt aCategory); 
       
   106 
       
   107     /**
       
   108     *  Attach to a default player within the same thread
       
   109     *
       
   110     *  @param aClientId thread id of the client which attachs to existing player
       
   111     *  @aMsgQueue message queue for the client
       
   112 	*  @param aCategory category of engine
       
   113     *  @leave The function leaves with one of the system wide error codes,
       
   114     *         if the operation fails.
       
   115     *  @return pointer to engine or NULL if not found
       
   116     */
       
   117     CMPXPlaybackEngine* AddToDefaultPlayerL(TThreadId aClientId,
       
   118                                             CMPXMessageQueue* aMsgQueue,
       
   119                                             const TInt aCategory); 
       
   120 
       
   121     /**
       
   122      *  Returns index of recent active player
       
   123      *
       
   124      *  @leave The function leaves with one of the system wide error codes,
       
   125      *         if the operation fails.
       
   126      *  @return index to recent active player, KErrNotFound if not found
       
   127      */
       
   128      TInt IndexOfRecentActivePlayer();
       
   129 
       
   130 	 /**
       
   131      *  Returns index of recent active player
       
   132      *	@param aCategory category of engine
       
   133      *  @leave The function leaves with one of the system wide error codes,
       
   134      *         if the operation fails.
       
   135      *  @return index to recent active player, KErrNotFound if not found
       
   136      */
       
   137      TInt IndexOfRecentActivePlayer(TInt aCategory);
       
   138 
       
   139 private:
       
   140 
       
   141     /**
       
   142     *  C++ constructor
       
   143     *
       
   144     *  @param aPriority  priority of server
       
   145     *  @param aPolicy security policy
       
   146     */
       
   147     CMPXPlaybackServer(TInt aPriority, const TPolicy &aPolicy);
       
   148 
       
   149     /**
       
   150     *  2nd phase constructor
       
   151     */
       
   152     void ConstructL();
       
   153 
       
   154 private: // from base class
       
   155     /**
       
   156     *   From MMPXPlaybackActiveEngineObserver
       
   157     *   Handle active engine
       
   158     *
       
   159     *   @param aEngine pointer to active engine
       
   160     *   @param aActive ETrue activated, EFalse deactivated
       
   161     */
       
   162     void HandleActiveEngineL(const CMPXPlaybackEngine* aEngine, TBool aActive);
       
   163 
       
   164     /**
       
   165     *  From CPolicyServer/CServer2
       
   166     *  Create a new session
       
   167     *
       
   168     *  @param aVersion version of the server
       
   169     *  @param aMessage message object
       
   170     */
       
   171     CSession2* NewSessionL(const TVersion& aVersion,
       
   172                            const RMessage2& aMessage) const;
       
   173 
       
   174     /**
       
   175      *  From MMPXClientlistObserver
       
   176      *  Observer client change
       
   177      */
       
   178     void HandleClientChange(const TProcessId& aPid,
       
   179                             MMPXClientlistObserver::TChangeType aChangeType);
       
   180 
       
   181 private:
       
   182     // The players are sorted by the time activated. In other word, the last
       
   183     // active player is always the first item.
       
   184     RPointerArray<CMPXPlaybackEngine> iPlayers;
       
   185     TInt iClients;
       
   186     CMPXPluginMonitor* iPluginMonitor;
       
   187 #ifdef RD_TSP_CLIENT_MAPPER
       
   188     CTspClientMapper* iClientMapper;
       
   189 #endif
       
   190     };
       
   191 
       
   192 #endif // CMPXPLAYBACKSERVER_H
       
   193