mtpdataproviders/mtpplaybackcontroldp/mtpplaybackmpximplementation/inc/cmtpplaybackcontrolimpl.h
branchRCL_3
changeset 20 4a793f564d72
parent 19 0aa8cc770c8a
child 21 74aa6861c87d
equal deleted inserted replaced
19:0aa8cc770c8a 20:4a793f564d72
     1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #ifndef CMTPPLAYBACKCONTROLIMPL_H
       
    22 #define CMTPPLAYBACKCONTROLIMPL_H
       
    23 
       
    24 #include <mpxplaybackobserver.h>
       
    25 
       
    26 #include "mmtpplaybackinterface.h"
       
    27 #include "mtpplaybackcontrolconst.h"
       
    28 #include "mtpdebug.h"
       
    29 
       
    30 class MMPXPlaybackUtility;
       
    31 class CMPXCollectionPath;
       
    32 class CMPXCollectionPlaylist;
       
    33 
       
    34 class CMTPPlaybackCommandChecker;
       
    35 class CMTPPlaybackPlaylistHelper;
       
    36 class CMTPPlaybackResumeHelper;
       
    37 class CMTPPlaybackCommand;
       
    38 class CMTPPbCmdParam;
       
    39 
       
    40 
       
    41 NONSHARABLE_CLASS( CMTPPlaybackControlImpl ) : public CActive,
       
    42                                                public MMPXPlaybackObserver,
       
    43                                                public MMPXPlaybackCallback,
       
    44                                                public MMTPPlaybackControl
       
    45     {
       
    46 private:
       
    47 
       
    48     friend class CMTPPlaybackCommandChecker;
       
    49     friend class CMTPPlaybackPlaylistHelper;
       
    50     friend class CMTPPlaybackResumeHelper;
       
    51     
       
    52 public: // Constructors and destructor
       
    53 
       
    54     /**
       
    55      * Two-phased constructor.
       
    56      */
       
    57     static CMTPPlaybackControlImpl* NewL( MMTPPlaybackObserver& aObserver );
       
    58     /**
       
    59     *  Frees resource, and destroy the object itself.
       
    60     */
       
    61     void Close();
       
    62     /**
       
    63      * Destructor.
       
    64      */
       
    65     virtual ~CMTPPlaybackControlImpl();
       
    66     
       
    67 public:    
       
    68     /**
       
    69      * From MMTPPlaybackControl
       
    70      * @param aCmd, refer to CMTPPlaybackCommand
       
    71      * @param aCallback, refer to MMTPPlaybackCallback
       
    72      */
       
    73     void CommandL( CMTPPlaybackCommand& aCmd, 
       
    74             MMTPPlaybackCallback* aCallback = NULL);
       
    75     
       
    76 private:
       
    77 	
       
    78     /**
       
    79      * From MMPXPlaybackObserver
       
    80      * See mpxplaybackobserver.h for detailed description.
       
    81      */
       
    82     void HandlePlaybackMessage( CMPXMessage* aMessage, TInt aError );
       
    83     
       
    84     /**
       
    85      * From MMPXPlaybackCallback
       
    86      * See mpxplaybackobserver.h for detailed description.
       
    87      */
       
    88     void HandlePropertyL( TMPXPlaybackProperty aProperty, TInt aValue, TInt aError );
       
    89     
       
    90     /**
       
    91      * From MMPXPlaybackCallback
       
    92      * See mpxplaybackobserver.h for detailed description.
       
    93      */
       
    94     void HandleSubPlayerNamesL( TUid aPlayer, const MDesCArray* aSubPlayers, TBool aComplete, TInt aError );
       
    95     
       
    96     /**
       
    97      * From MMPXPlaybackCallback
       
    98      * See mpxplaybackobserver.h for detailed description.
       
    99      */
       
   100     void HandleMediaL( const CMPXMedia& aMedia, TInt aError );
       
   101     
       
   102 private:// From CActive
       
   103     
       
   104     /**
       
   105      * DoCancel.
       
   106      */
       
   107     void DoCancel();
       
   108     
       
   109     /**
       
   110      * RunL.
       
   111      */
       
   112     void RunL();
       
   113     
       
   114 private:
       
   115     
       
   116     /**
       
   117      * C++ default constructor.
       
   118      */
       
   119     CMTPPlaybackControlImpl( MMTPPlaybackObserver& aObserver );
       
   120     
       
   121     /**
       
   122      * By default Symbian 2nd phase constructor is private.
       
   123      */
       
   124     void ConstructL();
       
   125     
       
   126 private:
       
   127     
       
   128     /**
       
   129      * Get Playlist from collection complete..
       
   130      */
       
   131     void GetPlaylistFromCollectionCompleteL( const CMPXCollectionPlaylist& aPlaylist );
       
   132     
       
   133     /**
       
   134      * Deactive other player so that we can play
       
   135      */
       
   136     void DeActiveOtherPlayerL();
       
   137     
       
   138     /**
       
   139      * Check playback command and cache
       
   140      */
       
   141     void CheckPlaybackCmdAndCacheL( CMTPPlaybackCommand& aCmd );
       
   142     
       
   143     /**
       
   144      * UpdateCommandArrary
       
   145      */
       
   146     void UpdateCommandArray();
       
   147     
       
   148     /**
       
   149      * Require current media
       
   150      */
       
   151     void RequestMediaL();
       
   152     
       
   153     /**
       
   154      * Handle commandL
       
   155      */
       
   156     void DoCommandL();
       
   157     
       
   158     /**
       
   159      *  Handle playback message
       
   160      *
       
   161      *  @param aMessage playback message
       
   162      */
       
   163     void DoHandlePlaybackMessageL( const CMPXMessage& aMessage );
       
   164     
       
   165     /**
       
   166      *  Handle playback property
       
   167      *
       
   168      *  @param aProperty the property
       
   169      *  @param aValue the value of the property
       
   170      */
       
   171     void DoHandlePropertyL( TInt aProperty, TInt aValue );
       
   172 
       
   173     /**
       
   174      *  Handle playback state changed.
       
   175      *
       
   176      *  @param aState New Playback state
       
   177      */
       
   178     void DoHandleStateChangedL( TMPXPlaybackState aState );
       
   179     
       
   180     /**
       
   181      *  Handle request media.
       
   182      */
       
   183     void DoHandleMediaL( const CMPXMedia& aMedia );
       
   184     
       
   185     /**
       
   186      *  Handle Media changed.
       
   187      *
       
   188      */
       
   189     void DoHandleMediaChangedL();
       
   190     
       
   191     /**
       
   192      *  Handle Initialize Complete.
       
   193      *
       
   194      */
       
   195     void DoHandleInitializeCompleteL();
       
   196     
       
   197     /**
       
   198      *  Handle error.
       
   199      *
       
   200      */
       
   201     void DoHandleError( TInt aErr );
       
   202     
       
   203     /**
       
   204      * Compare two path
       
   205      * @param aPathBase the base path
       
   206      * @param aPathNew the new path
       
   207      * @param aLevel compare level
       
   208      */
       
   209     TBool IfEqual( const CMPXCollectionPath& aPathBase, const CMPXCollectionPath& aPathNew, TUint aLevel );
       
   210     
       
   211     /**
       
   212     *  Map states from TMPXPlaybackState to TMPlayerState
       
   213     *
       
   214     *  @param aState State in TMPXPlaybackState format
       
   215     *  @return State in TMPlayerState format
       
   216     */
       
   217     TMTPPlaybackState MapState( TMPXPlaybackState aState );
       
   218     
       
   219     /**
       
   220     *  Map error from TInt to the error defined in interface
       
   221     */
       
   222     TInt MapError( TInt error );
       
   223     
       
   224     /**
       
   225      *Complete a sync request
       
   226     */
       
   227     void CompleteSelf( TInt aCompletionCode );
       
   228     
       
   229     /*
       
   230      * Initiate MPX Playback Command
       
   231      */
       
   232     void InitiateMPXPlaybackCommandL( TMPXPlaybackCommand aCommand, TBool aIsMTPPlaybackUtility );
       
   233     
       
   234     /*
       
   235      * SendMPXPlaybackCommandL
       
   236      */
       
   237     void SendMPXPlaybackCommandL( TMPXPlaybackCommand aCommand, TBool aIsMTPPlaybackUtility );
       
   238     
       
   239     
       
   240     /*
       
   241      * SendPlaybackCommandCompleteL
       
   242      */
       
   243     void SendPlaybackCommandCompleteL();
       
   244     
       
   245     /*
       
   246      * SendPlaybackEventL
       
   247      */
       
   248     void SendPlaybackEventL( TMTPPlaybackEvent aEvt );
       
   249     
       
   250     /**
       
   251      * Reset playback command
       
   252      */
       
   253     void ResetPlaybackCommand();
       
   254     
       
   255 private:
       
   256     
       
   257     /**
       
   258      * return current state.
       
   259      */
       
   260     TMPXPlaybackState CurrentState() const;
       
   261     
       
   262     /**
       
   263      * return previous state.
       
   264      */
       
   265     TMPXPlaybackState PreviousState() const;
       
   266     
       
   267     /**
       
   268      * return song count.
       
   269      */
       
   270     TInt32 SongCount() const;
       
   271     
       
   272     /**
       
   273      * return song index.
       
   274      */
       
   275     TInt32 SongIndex() const;
       
   276     
       
   277     /**
       
   278      * Cache mtp playback command.
       
   279      */
       
   280     void SetMTPPBCmd( TMTPPlaybackCommand aMTPPBCmd );
       
   281     
       
   282     /**
       
   283      * return mtp playback command.
       
   284      */
       
   285     TMTPPlaybackCommand MTPPBCmdHandling() const;
       
   286     
       
   287 private:
       
   288     
       
   289     MMTPPlaybackObserver*        iObserver;// Not owned
       
   290     MMTPPlaybackCallback*        iCallback;// Not owned
       
   291     
       
   292     MMPXPlaybackUtility*         iPlaybackUtility;// Owned
       
   293     MMPXPlaybackUtility*         iNowActivePlaybackUtility;// Owned
       
   294     
       
   295     CMTPPlaybackCommandChecker*  iPlaybackCommandChecker;//Owned
       
   296     CMTPPlaybackPlaylistHelper*  iPlaybackPlaylistHelper;//Owned
       
   297     CMTPPlaybackResumeHelper*    iPlaybackResumeHelper;
       
   298     
       
   299     CMPXCollectionPlaylist*      iPlayList;   //Owned
       
   300     RResumeCmdArray              iPrepareCmdArray;//Owned
       
   301     RResumeCmdArray              iResumeCmdArray;//Owned
       
   302     CMTPPbCmdParam*              iCmdParam;
       
   303     
       
   304     TMTPPlaybackCommand          iMTPPBCmd;
       
   305     TMPXPlaybackState            iPreState;
       
   306     TMPXPlaybackState            iState;
       
   307     
       
   308     /**
       
   309     FLOGGER debug trace member variable.
       
   310      */
       
   311     __FLOG_DECLARATION_MEMBER;
       
   312     };
       
   313 
       
   314 #endif // CMTPPLAYBACKCONTROLIMPL_H
       
   315 // End of File