mpxmusicplayer/metadatahandler/inc/mpxmetadatahandlerimp.h
changeset 0 ff3acec5bc43
child 23 455f89b7fcc5
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Implementation of metadata handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_CMPXMETADATAHANDLERIMP_H
       
    21 #define C_CMPXMETADATAHANDLERIMP_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <mpxplaybackobserver.h>
       
    25 #include <mpxplaybackframeworkdefs.h>
       
    26 #include <mpxcollectionplaylistobserver.h>
       
    27 
       
    28 #include <remconmediainformationtarget.h>
       
    29 #include <playerinformationtargetobserver.h>
       
    30 #include <remcongroupnavigationtargetobserver.h>
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CRemConInterfaceSelector;
       
    34 class CRepository;
       
    35 class MMPXPlaybackUtility;
       
    36 class MPlayerCapabilitiesObserver;
       
    37 class MPlayerApplicationSettingsObserver;
       
    38 class MPlayerEventsObserver;
       
    39 class CRemConGroupNavigationApiTarget;
       
    40 class CPlayerInfoTarget;
       
    41 class CEqualizerPresetChangeListener;
       
    42 
       
    43 
       
    44 /**
       
    45  *  Observer class for equalizer preset changes.
       
    46  *
       
    47  *  @lib mpxmetadatahandler.lib
       
    48  *  @since S60 v5.1
       
    49  */
       
    50 class MEqualizerPresetChangeListenerObserver
       
    51     {
       
    52 public:
       
    53 
       
    54     /**
       
    55      * Callback for receiving changes in the equalizer preset settings.
       
    56      *
       
    57      * @since S60 v5.1
       
    58      * @param aNewPreset The ID of the new equalizer preset
       
    59      */
       
    60     virtual void EqualizerPresetChangedL(TInt aNewPreset) = 0;
       
    61 
       
    62     };
       
    63 
       
    64 
       
    65 /**
       
    66  *  AVRCP 1.3 metadata handler implementation class
       
    67  *
       
    68  *  @lib mpxmetadatahandler.lib
       
    69  *  @since S60 v5.1
       
    70  */
       
    71 NONSHARABLE_CLASS( CMPXMetaDataHandlerImp ): public CBase,
       
    72 											 public MMPXMetaDataHandler,
       
    73 											 public MMPXPlaybackObserver,
       
    74 											 public MMPXPlaybackCallback,
       
    75 											 public MPlayerApplicationSettingsNotify,
       
    76 											 public MRemConMediaInformationTargetObserver,
       
    77 											 public MRemConGroupNavigationTargetObserver,
       
    78 											 public MMPXCollectionPlaylistObserver,
       
    79 											 public MEqualizerPresetChangeListenerObserver
       
    80 	{
       
    81 public:
       
    82 
       
    83 	/**
       
    84 	 * Two-phased constructor.
       
    85 	 *
       
    86 	 * @since v5.1
       
    87 	 * @param aInterfaceSelector RemCon interface selector.
       
    88 	 * @return Pointer to newly created object.
       
    89 	 */
       
    90 	static MMPXMetaDataHandler* NewL(CRemConInterfaceSelector &aInterfaceSelector);
       
    91 
       
    92 	/**
       
    93 	 * Destructor.
       
    94 	 */
       
    95 	virtual ~CMPXMetaDataHandlerImp();
       
    96 
       
    97 private:
       
    98 
       
    99 	/**
       
   100 	 * C++ default constructor.
       
   101 	 *
       
   102      * @since S60 v5.1
       
   103 	 */
       
   104 	CMPXMetaDataHandlerImp();
       
   105 
       
   106 	/**
       
   107 	 * By default Symbian 2nd phase constructor is private.
       
   108 	 * 
       
   109      * @since S60 v5.1
       
   110      * @param aInterfaceSelector RemCon interface selector.
       
   111 	 */
       
   112 	void ConstructL(CRemConInterfaceSelector &aInterfaceSelector);
       
   113 
       
   114 	/**
       
   115 	 * Handle playback message
       
   116 	 *
       
   117      * @since S60 v5.1
       
   118 	 * @param aMessage playback message
       
   119 	 */
       
   120 	void DoHandlePlaybackMessageL( const CMPXMessage& aMessage );
       
   121 
       
   122 	/**
       
   123 	 * Handle playback property
       
   124 	 *
       
   125      * @since S60 v5.1
       
   126 	 * @param aProperty the property
       
   127 	 * @param aValue the value of the property
       
   128 	 * @param aError error code
       
   129 	 */
       
   130 	void DoHandlePropertyL( TMPXPlaybackProperty aProperty, TInt aValue, TInt aError );
       
   131 
       
   132 	/**
       
   133 	 * Handle media properties.
       
   134 	 *
       
   135      * @since S60 v5.1
       
   136 	 * @param aMedia media properties
       
   137 	 * @param aError error code
       
   138 	 */
       
   139 	void DoHandleMediaL( const CMPXMedia& aMedia, TInt aError );
       
   140 
       
   141 	/**
       
   142 	 * Handle playback state changed.
       
   143 	 *
       
   144      * @since S60 v5.1
       
   145 	 * @param aState New Playback state
       
   146 	 */
       
   147 	void DoHandleStateChangedL( TMPXPlaybackState aState );
       
   148 
       
   149 // from base class MMPXPlaybackObserver
       
   150 
       
   151 	/**
       
   152 	 * From MMPXPlaybackObserver
       
   153 	 * Handle playback message
       
   154 	 *
       
   155      * @since S60 v5.1
       
   156 	 * @param aMessage playback message
       
   157 	 * @param aErr system error code.
       
   158 	 */
       
   159 	void HandlePlaybackMessage( CMPXMessage* aMessage, TInt aError );
       
   160 
       
   161 // from base class MMPXPlaybackCallback
       
   162 
       
   163 	/**
       
   164 	 * From MMPXPlaybackCallback
       
   165 	 * Handle playback property
       
   166 	 *
       
   167      * @since S60 v5.1
       
   168 	 * @param aProperty the property
       
   169 	 * @param aValue the value of the property
       
   170 	 * @param aError error code
       
   171 	 */
       
   172 	void HandlePropertyL( TMPXPlaybackProperty aProperty, TInt aValue, TInt aError );
       
   173 
       
   174 	/**
       
   175 	 * From MMPXPlaybackCallback
       
   176 	 * Method is called continously until aComplete=ETrue, signifying that
       
   177 	 * it is done and there will be no more callbacks
       
   178 	 * Only new items are passed each time
       
   179 	 *
       
   180      * @since S60 v5.1
       
   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 expected
       
   184 	 * @param aError error code
       
   185 	 */
       
   186 	void HandleSubPlayerNamesL( TUid aPlayer, const MDesCArray* aSubPlayers, 
       
   187 	                            TBool aComplete, TInt aError );
       
   188 
       
   189 	/**
       
   190 	 * From MMPXPlaybackCallback
       
   191 	 * Handle media properties
       
   192 	 *
       
   193      * @since S60 v5.1
       
   194 	 * @param aMedia media
       
   195 	 * @param aError error code
       
   196 	 */
       
   197 	void HandleMediaL( const CMPXMedia& aMedia, TInt aError );
       
   198 
       
   199 // From base class MMPXCollectionPlaylistObserver
       
   200 
       
   201     /**
       
   202      * From MMPXCollectionPlaylistObserver
       
   203      * Handle collection playlist change.
       
   204      *
       
   205      * @since S60 v5.1
       
   206      * @param aError KErrNotFound - Playlist is updated, current item removed
       
   207      *               KErrNone - Playlist is updated, current item is valid
       
   208      *               KErrEof - Playlist is updated, current item removed and
       
   209      *                          reached to the end of playlist
       
   210      */
       
   211 	void HandleCollectionPlaylistChange(TInt aError);
       
   212 
       
   213 // From base class MPlayerApplicationSettingsNotify
       
   214 
       
   215 	/**
       
   216 	 * From MPlayerApplicationSettingsNotify
       
   217 	 * This is called when the controller has changed a setting
       
   218 	 *
       
   219      * @since S60 v5.1
       
   220 	 * @param aAttributeID A list of attribute IDs whose value has changed.
       
   221 	 * @param aAttributeValue A list of new values for the attributes listed in aAttributeID.
       
   222 	 */
       
   223 	virtual void MpasnSetPlayerApplicationValueL(const RArray<TInt>& aAttributeID, const RArray<TInt>& aAttributeValue);
       
   224 
       
   225 // From base class MRemConMediaInformationTargetObserver
       
   226 
       
   227 	/**
       
   228 	 * From MRemConMediaInformationTargetObserver
       
   229 	 * For each element in aAttributeList the client should respond by calling
       
   230 	 * CRemConMediaInformationTarget::AttributeValue(). After all attributes have
       
   231 	 * been supplied the client should call CRemConMediaInformationTarget::Completed().
       
   232 	 *
       
   233      * @since S60 v5.1
       
   234 	 * @param aAttributeList A list of TAttributeID requested by the controller
       
   235 	 */
       
   236 	virtual void MrcmitoGetCurrentlyPlayingMetadata( TMediaAttributeIter& aAttributeIter );
       
   237 
       
   238 	/**
       
   239 	 * From MRemConGroupNavigationTargetObserver
       
   240 	 * Clients must implement this interface in order to instantiate objects of type
       
   241 	 * CRemConGroupNavigation. This interface passes incoming commands from RemCon to
       
   242 	 * the client.
       
   243 	 * A 'Next Group' has been received.
       
   244 	 * 
       
   245      * @since S60 v5.1
       
   246 	 * @param aButtonAct The button action associated with the command.
       
   247 	 */
       
   248 	virtual void MrcgntoNextGroup(TRemConCoreApiButtonAction aButtonAct);
       
   249 
       
   250 	/**
       
   251 	 * From MRemConGroupNavigationTargetObserver
       
   252 	 * For each element in aAttributeList the client should respond by calling
       
   253 	 * CRemConMediaInformationTarget::AttributeValue(). After all attributes have
       
   254 	 * been supplied the client should call CRemConMediaInformationTarget::Completed().
       
   255 	 * A 'Previous Group' has been received.
       
   256 	 * 
       
   257      * @since S60 v5.1
       
   258 	 * @param aButtonAct The button action associated with the command.
       
   259 	 */
       
   260 	virtual void MrcgntoPreviousGroup(TRemConCoreApiButtonAction aButtonAct);
       
   261 
       
   262 // From base class MEqualizerPresetChangeListenerObserver
       
   263 
       
   264     /**
       
   265      * From MEqualizerPresetChangeListenerObserver
       
   266      * Callback for receiving changes in the equalizer preset settings.
       
   267      *
       
   268      * @since S60 v5.1
       
   269      * @param aNewPreset The ID of the new equalizer preset
       
   270      */
       
   271 	virtual void EqualizerPresetChangedL(TInt aNewPreset);
       
   272 
       
   273 private:    // Data
       
   274 
       
   275     /**
       
   276      * The current player state (playing, paused, stopped).
       
   277      */
       
   278     TMPXPlaybackState iPlayerState;
       
   279 
       
   280     /**
       
   281      * Current track's position info (in seconds)
       
   282      */
       
   283     TInt iPlaybackPosition;
       
   284 
       
   285     /**
       
   286      * Current track's playing time info (in milliseconds)
       
   287      */
       
   288     TInt iPlayingTime;
       
   289 
       
   290     /**
       
   291      * Current track number
       
   292      */
       
   293     TInt iTrackNumber;
       
   294 
       
   295     /**
       
   296      * Last selected equalizer preset settings
       
   297      */
       
   298     TInt iLastEqPresetId;
       
   299 
       
   300 	/**
       
   301 	 * Current track's title info
       
   302      * Own.
       
   303 	 */
       
   304 	HBufC* iTrackTitle;
       
   305 
       
   306     /**
       
   307      * Current track's artist info
       
   308      * Own.
       
   309      */
       
   310 	HBufC* iArtist;
       
   311 
       
   312 	/**
       
   313      * Current track's album info
       
   314      * Own.
       
   315      */
       
   316 	HBufC* iAlbum;
       
   317 
       
   318 	/**
       
   319      * Current track's genre info
       
   320      * Own.
       
   321      */
       
   322 	HBufC* iGenre;
       
   323 	
       
   324 	/**
       
   325      * Current track's unique id info
       
   326      * Own.
       
   327      */
       
   328 	
       
   329 	TUid iColId;
       
   330 
       
   331     /**
       
   332      * Observer for equalizer preset changes
       
   333      * Own.
       
   334      */
       
   335     CEqualizerPresetChangeListener* iEqPresetListener;
       
   336 
       
   337     /**
       
   338      * Main interface to the player.
       
   339      * Not own.
       
   340      */
       
   341     MMPXPlaybackUtility* iPlaybackUtility;
       
   342 
       
   343     /**
       
   344      * Container for player information responses
       
   345      * Not own.
       
   346      */
       
   347     CPlayerInfoTarget* iPlayerInformationTarget;
       
   348 
       
   349     /**
       
   350      * Observer of this player's capabilities.
       
   351      * Not own.
       
   352      */
       
   353 	MPlayerCapabilitiesObserver* iPlayerCapabilitiesObserver;
       
   354 
       
   355     /**
       
   356      * Observer of this player's settings.
       
   357      * Not own.
       
   358      */
       
   359 	MPlayerApplicationSettingsObserver* iPlayerApplicationSettingsObserver;
       
   360 
       
   361 	/**
       
   362      * Observer of player events.
       
   363      * Not own.
       
   364      */
       
   365 	MPlayerEventsObserver* iPlayerEventsObserver;
       
   366 
       
   367 	/**
       
   368      * Interface for sending media information
       
   369      * Not own.
       
   370      */
       
   371 	CRemConMediaInformationTarget* iMediaInfoTarget;
       
   372 
       
   373 	/**
       
   374      * Interface for group navigation responses
       
   375      * Not own.
       
   376      */
       
   377 	CRemConGroupNavigationApiTarget* iGroupNavigationTarget;
       
   378 
       
   379 	};
       
   380 
       
   381 
       
   382 /**
       
   383  *  Helper class for receiving equalizer preset changed events.
       
   384  *
       
   385  *  @lib mpxmetadatahandler.lib
       
   386  *  @since S60 v5.1
       
   387  */
       
   388 NONSHARABLE_CLASS(CEqualizerPresetChangeListener): public CActive
       
   389 	{
       
   390 public:
       
   391 
       
   392 	/**
       
   393 	 * Two-phased constructor.
       
   394 	 *
       
   395 	 * @since v5.1
       
   396 	 * @param aFlags Flags for creating popups.
       
   397 	 * @param aObserver Custom command observer for media key handling.
       
   398 	 * @return Pointer to newly created object.
       
   399 	 */
       
   400 	static CEqualizerPresetChangeListener* NewL(MEqualizerPresetChangeListenerObserver& aObserver);
       
   401 
       
   402 	/**
       
   403 	 * Destructor.
       
   404 	 */
       
   405 	virtual ~CEqualizerPresetChangeListener();
       
   406 
       
   407     /**
       
   408      * Get the current equalizer preset ID
       
   409      *
       
   410      * @since S60 v5.1
       
   411      * @return The current preset ID
       
   412      */
       
   413 	TInt GetCurrentPresetL();
       
   414 
       
   415     /**
       
   416      * Set the equalizer preset
       
   417      *
       
   418      * @since S60 v5.1
       
   419      * @param aNewPreset The ID of the preset to be activated
       
   420      */
       
   421 	void ChangePresetL(TInt aNewPreset);
       
   422 
       
   423     /**
       
   424      * Start listening to equalizer preset changes
       
   425      *
       
   426      * @since S60 v5.1
       
   427      */
       
   428 	void StartL();
       
   429 
       
   430 	/**
       
   431      * Stop listening to equalizer preset changes
       
   432      *
       
   433      * @since S60 v5.1
       
   434      * @return The current preset ID
       
   435      */
       
   436 	void Stop();
       
   437 
       
   438 private:
       
   439 
       
   440 	/**
       
   441 	 * C++ default constructor.
       
   442 	 *
       
   443      * @since S60 v5.1
       
   444 	 * @param aObserver Client for receiving equalizer preset changed events
       
   445 	 */
       
   446 	CEqualizerPresetChangeListener(MEqualizerPresetChangeListenerObserver& aObserver);
       
   447 
       
   448 	/**
       
   449      * Symbian 2nd-phase constructor
       
   450      *
       
   451      * @since S60 v5.1
       
   452 	 */
       
   453 	void ConstructL();
       
   454 
       
   455 // from base class CActive
       
   456 
       
   457     /**
       
   458      * From CActive.
       
   459      * Called by the active scheduler when the request has been cancelled.
       
   460      *
       
   461      * @since S60 v5.1
       
   462      */
       
   463     virtual void DoCancel();
       
   464     
       
   465     /**
       
   466      * From CActive.
       
   467      * Called by the active scheduler when the request has been completed.
       
   468      *
       
   469      * @since S60 v5.1
       
   470      */
       
   471     virtual void RunL();
       
   472 
       
   473     /**
       
   474      * From CActive.
       
   475      * Called by the active scheduler when an error in RunL has occurred.
       
   476      *
       
   477      * @since S60 v5.1
       
   478      */
       
   479     TInt RunError( TInt aError );
       
   480 
       
   481 private:    // Data
       
   482 
       
   483     /**
       
   484      * Handle to Central Repository
       
   485      * Own.
       
   486      */
       
   487     CRepository* iRepository;
       
   488 
       
   489     /**
       
   490      * Client for receiving equalizer preset changed events
       
   491      * Not own.
       
   492      */
       
   493     MEqualizerPresetChangeListenerObserver& iObserver;
       
   494 
       
   495 	};
       
   496 
       
   497 #endif  // C_CMPXMETADATAHANDLERIMP_H
       
   498 
       
   499 // End of File