epoc32/include/mw/playerinformationtargetobserver.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
equal deleted inserted replaced
2:2fe1408b6811 3:e1b950c65cb4
       
     1 // Copyright (c) 2007-2009 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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @publishedAll
       
    21  @released
       
    22 */
       
    23 
       
    24 #ifndef REMCONPLAYERINFORMATIONTARGETOBSERVER_H
       
    25 #define REMCONPLAYERINFORMATIONTARGETOBSERVER_H
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <remcon/avrcpspec.h>
       
    29 #include <barsc2.h>
       
    30 
       
    31 
       
    32 /**
       
    33 This class is used to define the capabilities of the current application,
       
    34 and the implementation will generate AVRCP responses to the controller.
       
    35 For the event part of the API, it is recommended to add all events which make
       
    36 sense for the media player. In general, this will be everything except
       
    37 ESystemStatusChanged. The company ID part of the API is only needed if
       
    38 the media player needs to support vendor extensions other than bluetooth SIG.
       
    39 The bluetooth SIG company ID is always included in responses to a COMPANY_ID request.
       
    40 */
       
    41 class MPlayerCapabilitiesObserver 
       
    42 	{
       
    43 	public:
       
    44 		/**
       
    45 		Remove all notification events from the supported list
       
    46 		*/
       
    47 		IMPORT_C void ClearEvents();
       
    48 		/**
       
    49 		Add a notification event to the supported list of events
       
    50 		The AVRCP 1.3 specification mandates that PlaybackStatusChanged
       
    51 		and TrackChanged events must be supported; KErrAlreadyExists will
       
    52 		be returned if AddEvent() is called with either of these events.
       
    53 		@param aEvent the event to add
       
    54 		@return KErrAlreadyExists if the event is already present.
       
    55 		KErrNotSupported if the event isn't supported by the implementation, e.g.. ESystemStatusChanged
       
    56 		*/
       
    57 		IMPORT_C TInt AddEvent(TRegisterNotificationEvent aEvent);
       
    58 		/**
       
    59 		Remove a notification event from the supported list of events
       
    60 		The AVRCP 1.3 specification mandates that PlaybackStatusChanged
       
    61 		and TrackChanged events must be supported; KErrNotSupported will
       
    62 		be returned if RemoveEvent() is called with either of these events.
       
    63 		@param aEvent the event to remove
       
    64 		@return KErrNone if this completes successfully, KErrNotFound if aID
       
    65 		was not in the list, or any other system wide error code.
       
    66 		*/
       
    67 		IMPORT_C TInt RemoveEvent(TRegisterNotificationEvent aEvent);
       
    68 
       
    69 		const static TInt KMaxCompanyID = 0xFFFFFF;
       
    70 		const static TInt KMaxNrOfCompanyIDs = 255;
       
    71 		
       
    72 		/**
       
    73 		Remove all additional company IDs from the supported list
       
    74 		*/
       
    75 		IMPORT_C void ClearCompanyIds();
       
    76 		/**
       
    77 		Add a company id to the supported list of company ids.
       
    78 		The AVRCP 1.3 specification mandates that the Bluetooth SIG vendor id 
       
    79 		must be supported; KErrAlreadyExists will be returned if AddCompanyId()
       
    80 		is called with this company id.
       
    81 		@param aID the id to add
       
    82 		@return KErrNone if this completes successfully,
       
    83 		KErrAlreadyExists if aID is already present,
       
    84 		KErrOverflow if the maximum number of company ids are already listed,
       
    85 		or any other system wide error code.
       
    86 		*/
       
    87 		IMPORT_C TInt AddCompanyId(TInt aID);
       
    88 		/**
       
    89 		Remove a company id from the list of supported vendor extensions.
       
    90 		The Bluetooth SIG id can't be removed, as this must always be supported
       
    91 		@param aID the id to remove
       
    92 		@return KErrNone if this completes successfully, KErrNotFound if aID
       
    93 		was not in the list, or any other system wide error code.
       
    94 		*/
       
    95 		IMPORT_C TInt RemoveCompanyID(TInt aID);
       
    96 		
       
    97 	private:
       
    98 		virtual void DoClearEvents() = 0;
       
    99 		virtual TInt DoAddEvent(TRegisterNotificationEvent aEvent) = 0;
       
   100 		virtual TInt DoRemoveEvent(TRegisterNotificationEvent aEvent) = 0;
       
   101 		virtual void DoClearCompanyIds() = 0;
       
   102 		virtual TInt DoAddCompanyId(TInt aID) = 0;
       
   103 		virtual TInt DoRemoveCompanyID(TInt aID) = 0;
       
   104 	};
       
   105 
       
   106 /**
       
   107 This class is for supporting the player application settings PDUs in AVRCP1.3
       
   108 specification section 5.2. The RegisterNotification PDU for
       
   109 EVENT_PLAYER_APPLICATION_SETTING_CHANGED is also supported through this API.
       
   110 
       
   111 The media player should first define all the attributes it supports, using
       
   112 DefineAttributeL. When an attribute's value is changed by the media player,
       
   113 it should call SetAttributeL to inform the controller. When the controller
       
   114 changes a setting, the media player application receives a callback via the
       
   115 MPlayerApplicationSettingsNotify interface
       
   116 */
       
   117 class MPlayerApplicationSettingsObserver 
       
   118 	{
       
   119 	public:
       
   120 		/**
       
   121 		Define an attribute supported by this player.
       
   122 		It will be included in future responses to the following PDUs:
       
   123 			ListPlayerApplicationSettingAttributes,
       
   124 			ListPlayerApplicationSettingValues,
       
   125 			GetCurrentPlayerApplicationSettingValue,
       
   126 			GetPlayerApplicationSettingAttributeText,
       
   127 			GetPlayerApplicationSettingValueText,
       
   128 		@param aAttributeID The specification or player defined attribute
       
   129 		@param aAttributeText The UTF8 text name of the attribute(allowed text length is 1-255) - the API will take a copy
       
   130 		@param aValues The list of defined values
       
   131 		@param aValueTexts The UTF8 text for each defined value(allowed text length is 1-255) - The API will make copies.
       
   132 		@param aInitialValue The initial value for this attribute
       
   133 		@leave KErrNoMemory if memory could not be allocated to store the copies of aAttributeID and relative settings
       
   134 		@leave KErrNotSupported if attribute or value is out of specification defined range,
       
   135 			or aValueTexts is not equal length to aValues
       
   136 		*/
       
   137 		IMPORT_C void DefineAttributeL(TUint aAttributeID,
       
   138 										TDesC8& aAttributeText,
       
   139 										RArray<TUint> &aValues,
       
   140 										RArray<TPtrC8> &aValueTexts,
       
   141 										TUint aInitialValue);
       
   142 
       
   143 		/**
       
   144 		Set the current value of a previously defined attribute
       
   145 		This updates the cache and will cause completion of a 
       
   146 		pending EVENT_PLAYER_APPLICATION_SETTING_CHANGED notification PDU
       
   147 		@param aAttributeID The specification or player defined attribute
       
   148 		@param aValue The current value
       
   149 		@leave KErrNotFound if the attribute is not defined,
       
   150 			KErrArgument if the value is not valid according to the definition
       
   151 		*/
       
   152 		IMPORT_C void SetAttributeL(TUint aAttributeID, TUint aValue);
       
   153 
       
   154 	private:
       
   155 		virtual void DoDefineAttributeL(TUint aAttributeID,
       
   156 										TDesC8& aAttributeText,
       
   157 										RArray<TUint> &aValues,
       
   158 										RArray<TPtrC8> &aValueTexts,
       
   159 										TUint aInitialValue) = 0;
       
   160 		virtual void DoSetAttributeL(TUint aAttributeID, TUint aValue) = 0;
       
   161 	
       
   162 	};
       
   163 
       
   164 /**
       
   165 This is a helper API allowing CPlayerApplicationSettings to be initialised
       
   166 via a resource file. Using a resource file may help to provide localised text
       
   167 for the attributes and values, according to current language setting of the phone.
       
   168 */
       
   169 class PlayerApplicationSettingsResourceInit
       
   170 	{
       
   171 	public:
       
   172 	/**
       
   173 	Defines multiple attributes supported by this player, which are listed in a resource file.
       
   174 	@param aSettings The CPlayerApplicationSettings object on which the attributes should be defined
       
   175 	@param aResource A fully constructed CResourceFile
       
   176 	@leave KErrNoMemory, or leave from CResourceFile functions
       
   177 	*/
       
   178 	IMPORT_C static void DefineAttributesL(MPlayerApplicationSettingsObserver& aSettings, CResourceFile &aResource);
       
   179 	};
       
   180 
       
   181 /**
       
   182 This class supports the notification PDUs in AVRCP1.3 specification section 5.4,
       
   183 with the following exceptions:
       
   184    EVENT_SYSTEM_STATUS_CHANGED is not supported, it is only for adaptors that plug into a media player
       
   185    EVENT_PLAYER_APPLICATION_SETTING_CHANGED is supported through the CPlayerApplicationSettings API
       
   186 
       
   187 Events are pushed by the media player calling functions in this API, where they are
       
   188 cached until the controller pulls them via a GetPlayStatus or RegisterNotification PDU
       
   189 @see CPlayerApplicationSettings
       
   190 */
       
   191 class MPlayerEventsObserver 
       
   192 	{
       
   193 	public:
       
   194 		enum TTargetBatteryStatus
       
   195 			{
       
   196 			ENormal     = 0,
       
   197 			EWarning    = 1,
       
   198 			ECritical   = 2,
       
   199 			EExternal   = 3,
       
   200 			EFullCharge = 4,
       
   201 			EUnknown	= 5
       
   202 			};	
       
   203 			
       
   204 		enum TPlaybackStatus
       
   205 			{
       
   206 			EStopped = 0,
       
   207 			EPlaying = 1,
       
   208 			EPaused = 2,
       
   209 			EFwdSeek = 3,
       
   210 			ERevSeek = 4,
       
   211 			EError = 0xFF
       
   212 			};
       
   213 
       
   214 		enum TPlayPosition
       
   215 			{
       
   216 			EStart = 0,
       
   217 			EMiddle = 1,
       
   218 			EEnd= 2,
       
   219 			};
       
   220 
       
   221 		static const TUint64 KNoTrackSelected = KMaxTUint64;
       
   222 
       
   223 		static const TUint32 KPlaybackPositionUnknown = 0xFFFFFFFF;
       
   224 		
       
   225 		/**
       
   226 		Call this function whenever the playback status changes.
       
   227 		It will be used to complete pending EVENT_PLAYBACK_STATUS_CHANGED
       
   228 		and EVENT_PLAYBACK_POS_CHANGED notifications.
       
   229 		The value is used to generate the response to a GetPlayStatus PDU.
       
   230 		@param aStatus The specification defined playback status
       
   231 		*/
       
   232 		IMPORT_C void PlaybackStatusChanged(TPlaybackStatus aStatus);
       
   233 		/**
       
   234 		Call this function whenever the current media track is changed.
       
   235 		use KNoTrackSelected to indicate that there is no media selected. 
       
   236 		This is the default value on construction. It will be used to
       
   237 		complete pending EVENT_TRACK_CHANGED and EVENT_PLAYBACK_POS_CHANGED notifications.
       
   238 		The values are used to generate the response to a GetPlayStatus PDU.
       
   239 		@param aTrackId A handle to the current track.
       
   240 		@param aLengthInMilliseconds The length of the current track.
       
   241 		*/
       
   242 		IMPORT_C void TrackChanged(TUint64 aTrackId, TUint32 aLengthInMilliseconds);
       
   243 		/**
       
   244 		Call this function whenever the current track reaches the end position,
       
   245 		e.g. due to playback or forward seek. It will be used to complete
       
   246 		pending EVENT_TRACK_REACHED_END and EVENT_PLAYBACK_POS_CHANGED notifications.
       
   247 		*/
       
   248 		IMPORT_C void TrackReachedEnd();
       
   249 		/**
       
   250 		Call this function whenever the current track reaches the start position,
       
   251 		e.g. due to reverse seek (rewind). It will be used to complete pending
       
   252 		EVENT_TRACK_REACHED_START and EVENT_PLAYBACK_POS_CHANGED notifications.
       
   253 		*/
       
   254 		IMPORT_C void TrackReachedStart();
       
   255 		/**
       
   256 		Call this function during playback or seek operations, to indicate the
       
   257 		current position within the track. It will be used to complete a pending
       
   258 		EVENT_PLAYBACK_POS_CHANGED notification. The value is used to generate the
       
   259 		response to a GetPlayStatus PDU.
       
   260 		@param aMilliseconds The current playback position. It is recommended to call
       
   261 		with a resolution <=1000ms to satisfy the 1s resolution of the notification
       
   262 		playback interval.
       
   263 		*/
       
   264 		IMPORT_C void SetPlaybackPosition(TUint32 aMilliseconds);
       
   265 
       
   266 		/**
       
   267 		Call this function to report the current battery status
       
   268 		@param aBatteryStatus The current battery status.
       
   269 		*/
       
   270 		IMPORT_C void SetBatteryStatus(TTargetBatteryStatus aBatteryStatus);
       
   271 		
       
   272 	private:
       
   273 		virtual void DoPlaybackStatusChanged(TPlaybackStatus aStatus) = 0;
       
   274 		virtual void DoTrackChanged(TUint64 aTrackId, TUint32 aLengthInMilliseconds) = 0;
       
   275 		virtual void DoTrackReachedEnd() = 0;
       
   276 		virtual void DoTrackReachedStart() = 0;
       
   277 		virtual void DoSetPlaybackPosition(TUint32 aMilliseconds) = 0;
       
   278 		virtual void DoSetBatteryStatus(TTargetBatteryStatus aBatteryStatus) = 0;
       
   279 	
       
   280 		
       
   281 	};
       
   282 
       
   283 /**
       
   284 Clients must implement this interface if they require callbacks 
       
   285 when the controller has changed the settings via a SetPASValue message
       
   286 */
       
   287 class MPlayerApplicationSettingsNotify  
       
   288 	{
       
   289 	public:
       
   290 		/**
       
   291 		This is called when the controller has changed a setting
       
   292 		@param aAttributeID A list of attribute IDs whose value has changed.
       
   293 		@param aAttributeValue A list of new values for the attributes listed in aAttributeID.
       
   294 		*/
       
   295 		virtual void MpasnSetPlayerApplicationValueL(const RArray<TInt>& aAttributeID,
       
   296 													const RArray<TInt>& aAttributeValue)=0;
       
   297 	};
       
   298 	
       
   299 
       
   300 #endif // REMCONPLAYERINFORMATIONTARGETOBSERVER_H