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