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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #ifndef REMCONPLAYERINFORMATIONTARGETOBSERVER_H
23 #define REMCONPLAYERINFORMATIONTARGETOBSERVER_H
26 #include <remcon/avrcpspec.h>
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.
39 class MPlayerCapabilitiesObserver
43 Remove all notification events from the supported list
45 IMPORT_C void ClearEvents();
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
55 IMPORT_C TInt AddEvent(TRegisterNotificationEvent aEvent);
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.
65 IMPORT_C TInt RemoveEvent(TRegisterNotificationEvent aEvent);
67 const static TInt KMaxCompanyID = 0xFFFFFF;
68 const static TInt KMaxNrOfCompanyIDs = 255;
71 Remove all additional company IDs from the supported list
73 IMPORT_C void ClearCompanyIds();
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.
85 IMPORT_C TInt AddCompanyId(TInt aID);
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.
93 IMPORT_C TInt RemoveCompanyID(TInt aID);
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;
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.
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
115 class MPlayerApplicationSettingsObserver
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
135 IMPORT_C void DefineAttributeL(TUint aAttributeID,
136 TDesC8& aAttributeText,
137 RArray<TUint> &aValues,
138 RArray<TPtrC8> &aValueTexts,
139 TUint aInitialValue);
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
150 IMPORT_C void SetAttributeL(TUint aAttributeID, TUint aValue);
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;
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.
167 class PlayerApplicationSettingsResourceInit
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
176 IMPORT_C static void DefineAttributesL(MPlayerApplicationSettingsObserver& aSettings, CResourceFile &aResource);
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
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
189 class MPlayerEventsObserver
192 enum TTargetBatteryStatus
219 static const TUint64 KNoTrackSelected = KMaxTUint64;
221 static const TUint32 KPlaybackPositionUnknown = 0xFFFFFFFF;
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
230 IMPORT_C void PlaybackStatusChanged(TPlaybackStatus aStatus);
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.
240 IMPORT_C void TrackChanged(TUint64 aTrackId, TUint32 aLengthInMilliseconds);
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.
246 IMPORT_C void TrackReachedEnd();
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.
252 IMPORT_C void TrackReachedStart();
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
262 IMPORT_C void SetPlaybackPosition(TUint32 aMilliseconds);
265 Call this function to report the current battery status
266 @param aBatteryStatus The current battery status.
268 IMPORT_C void SetBatteryStatus(TTargetBatteryStatus aBatteryStatus);
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;
282 Clients must implement this interface if they require callbacks
283 when the controller has changed the settings via a SetPASValue message
285 class MPlayerApplicationSettingsNotify
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.
293 virtual void MpasnSetPlayerApplicationValueL(const RArray<TInt>& aAttributeID,
294 const RArray<TInt>& aAttributeValue)=0;
298 #endif // REMCONPLAYERINFORMATIONTARGETOBSERVER_H