mpx/playbackframework/playbackserver/inc/mpxplaybackserversession.h
changeset 0 a2952bb97e68
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:  Playback server session
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMPXPLAYBACKSESSION_H
       
    20 #define CMPXPLAYBACKSESSION_H
       
    21 
       
    22 
       
    23 #include <e32cons.h>
       
    24 #include <f32file.h>
       
    25 #include <s32mem.h>
       
    26 #include <mpxplaybackengineobserver.h>
       
    27 #include "mpxplaybackserverdefs.h"
       
    28 
       
    29 class CMPXPlaybackEngine;
       
    30 class CMPXMessageQueue;
       
    31 
       
    32 /**
       
    33 * Music playback server session
       
    34 */
       
    35 class CMPXPlaybackSession : public CSession2,
       
    36                             public MMPXPlaybackEngineObserver
       
    37     {
       
    38 public:
       
    39 
       
    40     /**
       
    41     *  Two-phased constructor. Leaves on failure.
       
    42     *
       
    43     *  @return The constructed object
       
    44     */
       
    45     static CMPXPlaybackSession* NewL();
       
    46 
       
    47     /**
       
    48     *  C++ constructor
       
    49     *
       
    50     */
       
    51     CMPXPlaybackSession();
       
    52 
       
    53     /**
       
    54     *  Destructor
       
    55     */
       
    56     ~CMPXPlaybackSession();
       
    57     
       
    58 private:
       
    59 
       
    60     /**
       
    61     *  From CSession2
       
    62     *  Service request
       
    63     *  @param aMessage message object
       
    64     */
       
    65     void ServiceL(const RMessage2& aMessage);
       
    66 
       
    67     /**
       
    68     *  Dispatch message
       
    69     *
       
    70     *  @param aMessage message object
       
    71     *  @return message completion code
       
    72     */
       
    73     void DispatchMessageL( const RMessage2& aMessage, TInt& aMsgHandleResult );
       
    74     
       
    75     /**
       
    76     *  Set playback mode
       
    77     *
       
    78     *  @param aMessage message object
       
    79     */
       
    80     void SetModeL(const RMessage2& aMessage);
       
    81 
       
    82     /**
       
    83     *  Get client id from message
       
    84     *
       
    85     *  @param aMessage message object
       
    86     *  @reutrn client thread id
       
    87     */
       
    88     TThreadId ClientIdL(const RMessage2& aMessage);
       
    89 
       
    90     /**
       
    91     *  Init player from file 
       
    92     *
       
    93     *  @param aMessage message object
       
    94     */
       
    95     void InitFromFileL(const RMessage2& aMessage);
       
    96 
       
    97     /**
       
    98     *  Cancel outstanding requests
       
    99     */
       
   100     void CancelRequests();
       
   101 
       
   102     /**
       
   103     *  Set request as async
       
   104     *
       
   105     *  @param aMessage message object
       
   106     */
       
   107     void SetAsync(const RMessage2& aMessage);
       
   108     
       
   109     /**
       
   110     *  Complete async request
       
   111     *
       
   112     *  @param aErr error code
       
   113     *  @param aSlot1 message slot 1
       
   114     *  @param aVal1 value in the slot 1
       
   115     *  @param aSlot2 message slot 2
       
   116     *  @param aVal2 value in the slot 2
       
   117     */
       
   118     void CompleteAsync(TInt aErr,
       
   119                         TInt aSlot1 = 0, const TDesC8* aVal1 = NULL,
       
   120                         TInt aSlot2 = 0,const TDesC8* aVal2 = NULL);
       
   121                         
       
   122 
       
   123     /**
       
   124     *  Writes data from the specified source descriptor to the specified
       
   125     *  message slot
       
   126     *
       
   127     *  @param aErr error code
       
   128     *  @param aSlot1 message slot 1
       
   129     *  @param aVal1 value in the slot 1
       
   130     *  @param aSlot2 message slot 2
       
   131     *  @param aVal2 value in the slot 2
       
   132     *  @return KErrNone, if successful, otherwise system error code
       
   133     */
       
   134     TInt DoWriteData(TInt aSlot1 = 0, const TDesC8* aVal1 = NULL,
       
   135                      TInt aSlot2 = 0, const TDesC8* aVal2 = NULL);
       
   136 
       
   137     /**
       
   138     *  Get current selection
       
   139     *
       
   140     *  @param aMessage message object
       
   141     */
       
   142     void GetSelectionL(const RMessage2& aMessage);
       
   143     
       
   144     /**
       
   145     *  Helper methods for transferring variable sized arrays and objects
       
   146     */
       
   147     
       
   148     /**
       
   149     *  Create the buffer filled with player UIDs
       
   150     *
       
   151     *  @param aMessage message object
       
   152     *  @return the size of buffer
       
   153     */
       
   154     TInt CreatePlayerUidsBufferL(const RMessage2& aMessage);
       
   155 
       
   156     /**
       
   157     *  Check if player is valid
       
   158     */
       
   159     void CheckPlayerL();
       
   160     
       
   161 private:  
       
   162 
       
   163     /**
       
   164     *  From MMPXPlaybackEngineObserver
       
   165     *  Handle playback property
       
   166     *
       
   167     *  @param aProperty the property
       
   168     *  @param aValue the value of the property
       
   169     *  @param aError error code
       
   170     */
       
   171     void HandleProperty(TMPXPlaybackProperty aProperty,
       
   172                                TInt aValue, 
       
   173                                TInt aError);
       
   174 
       
   175     /**
       
   176     *  From MMPXPlaybackEngineObserver
       
   177     *  Method is called continously until aComplete=ETrue, signifying that 
       
   178     *  it is done and there will be no more callbacks
       
   179     *  Only new items are passed each time
       
   180     *
       
   181     *  @param aPlayer UID of the subplayer
       
   182     *  @param aSubPlayers a list of sub players
       
   183     *  @param aComplete ETrue no more sub players. EFalse more subplayer
       
   184     *                   expected
       
   185     *  @param aError error code
       
   186     */
       
   187     void HandleSubPlayerNames(TUid aPlayer,
       
   188                               const MDesCArray* aSubPlayers,
       
   189                               TBool aComplete,
       
   190                               TInt aError);
       
   191 
       
   192     /**
       
   193     *  From MMPXPlaybackEngineObserver
       
   194     *  Handle media properties
       
   195     *
       
   196     *  @param aMedia media object
       
   197     *  @param aError error code
       
   198     */
       
   199     void HandleMedia(CMPXMedia* aMedia, TInt aError); 
       
   200 
       
   201     /**
       
   202      *  From MMPXPlaybackEngineObserver
       
   203      *  Handle completion of a asynchronous command
       
   204      *
       
   205      *  @param aCommandResult result of the command, NULL if error
       
   206      *  @param aError error code    
       
   207      */
       
   208      void HandlePlaybackCommandComplete(CMPXCommand* aCommandResult, 
       
   209                                         TInt aError);
       
   210     
       
   211 private:
       
   212 
       
   213     /**
       
   214     *  2nd phase constructor
       
   215     */
       
   216     void ConstructL();
       
   217     
       
   218 private:
       
   219     CMPXPlaybackEngine* iPlayer;
       
   220     RMessage2 iMessage;    
       
   221     TBool iCompleteRequest;
       
   222     //
       
   223     // Data for client, for current request
       
   224     //
       
   225     CBufBase* iSyncBuffer;
       
   226     CBufBase* iAsyncBuffer;
       
   227     CMPXMedia* iMedia;
       
   228     CMPXMessageQueue* iMessageQueue; // Message queue
       
   229     };
       
   230         
       
   231 #endif // CMPXPLAYBACKSESSION_H
       
   232