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