|
1 // Copyright (c) 2008-2010 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 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 @released |
|
22 */ |
|
23 |
|
24 #ifndef AVRCPPLAYERINFOMANAGER_H |
|
25 #define AVRCPPLAYERINFOMANAGER_H |
|
26 |
|
27 #include <btsdp.h> |
|
28 #include <e32base.h> |
|
29 #include <playerinformationtargetobserver.h> |
|
30 #include <remconcoreapi.h> |
|
31 #include <remcon/clientid.h> |
|
32 #include <remcon/playertype.h> |
|
33 #include <remcon/remconbearerobserver.h> |
|
34 #include "avrcpinternalinterface.h" |
|
35 #include "avrcputils.h" |
|
36 #include "playerbitmasks.h" |
|
37 #include "playerstatewatcher.h" |
|
38 |
|
39 const TInt KAvrcpMediaPlayerItemBaseSize = 28; |
|
40 |
|
41 NONSHARABLE_CLASS(MPlayerChangeObserver) |
|
42 { |
|
43 public: |
|
44 virtual void MpcoAvailablePlayersChanged() = 0; |
|
45 virtual void MpcoAddressedPlayerChangedLocally(TRemConClientId aClientId) = 0; |
|
46 virtual void MpcoUidCounterChanged(TRemConClientId aClientId) = 0; |
|
47 }; |
|
48 |
|
49 NONSHARABLE_STRUCT(TAvrcpMediaPlayerItem) |
|
50 { |
|
51 public: |
|
52 TRemConClientId iId; |
|
53 TUint8 iPlayerType; |
|
54 TUint32 iPlayerSubType; |
|
55 TPlayerFeatureBitmask iFeatureBitmask; |
|
56 TPtrC8 iName; |
|
57 // iUidCounter is set from the bulk thread and read from the control thread |
|
58 TUint16 iUidCounter; |
|
59 // iLastUpdatedUidCounter is only accessed from the control thread to see if an update |
|
60 // is needed |
|
61 TUint16 iLastUpdatedUidCounter; |
|
62 MPlayerEventsObserver::TPlaybackStatus iPlaybackStatus; |
|
63 TUint8 iSdpFeatures; |
|
64 TBool iBulkClientAvailable; |
|
65 // We store absolute volume support because it's returned as part of |
|
66 // a GetCapabilities(EventIds) response. Some implementations poll |
|
67 // for changes to this value so it's probably worthwhile avoiding |
|
68 // having to ask RemCon for it repeatedly. |
|
69 TBool iAbsoluteVolumeSupport; |
|
70 }; |
|
71 |
|
72 class MIncomingCommandHandler; |
|
73 class MRemConCommandInterface; |
|
74 class CUidWatcher; |
|
75 NONSHARABLE_CLASS(CAvrcpPlayerInfoManager) |
|
76 : public CBase, public MUidObserver, public MPlayStatusObserver |
|
77 { |
|
78 //--------------------------------------------------------- |
|
79 // Control thread only functions |
|
80 //--------------------------------------------------------- |
|
81 public: |
|
82 static CAvrcpPlayerInfoManager* NewL(MRemConBearerObserver& aObserver, MRemConCommandInterface& aCommandInterface); |
|
83 ~CAvrcpPlayerInfoManager(); |
|
84 |
|
85 // Interface to bearer/remcon |
|
86 void ClientAvailable(const TRemConClientId& aId, TPlayerType aClientType, TPlayerSubType aClientSubType, const TDesC8& aName); |
|
87 void ClientNotAvailable(const TRemConClientId& aId); |
|
88 void ClientStatus(TBool aControllerPresent, TBool aTargetPresent); |
|
89 TInt SetLocalAddressedClient(const TRemConClientId& aId); |
|
90 void ControllerFeaturesUpdatedL(RArray<TUid>& aSupportedInterfaces); |
|
91 void TargetFeaturesUpdated(const TRemConClientId& aId, TPlayerType aPlayerType, TPlayerSubType aPlayerSubType, const TDesC8& aName); |
|
92 MIncomingCommandHandler& InternalCommandHandler(); |
|
93 |
|
94 // Interface to command handler |
|
95 void AddObserverL(MPlayerChangeObserver& aObserver); |
|
96 void RemoveObserver(MPlayerChangeObserver& aObserver); |
|
97 TUint16 UidCounterL(const TRemConClientId& aClientId) const; |
|
98 TBool AbsoluteVolumeSupportedL(const TRemConClientId& aClientId) const; |
|
99 TBool BrowsingSupportedL(const TRemConClientId& aClientId) const; |
|
100 |
|
101 private: |
|
102 // Interface to uid counter updates |
|
103 static TInt PlayerUpdateCallBack(TAny* aPlayerInfoMgr); |
|
104 void UidCounterUpdate(); |
|
105 |
|
106 // from MPlayStatusObserver |
|
107 void MpsoPlayStatusChanged(TRemConClientId aId, MPlayerEventsObserver::TPlaybackStatus aPlaybackStatus); |
|
108 void MpsoError(TRemConClientId aId); |
|
109 |
|
110 // Helper functions for ClientAvailable and TargetFeaturesUpdated |
|
111 TInt SetItemDetails(TAvrcpMediaPlayerItem& aItem, TPlayerType aPlayerType, TPlayerSubType aPlayerSubType, const TDesC8& aName); |
|
112 void UpdateTargetSdpRecord(); |
|
113 |
|
114 // Helper function for SDP record publishing |
|
115 void CurrentTargetVersionAndFeatures(TUint16& aAvrcpVersion, TUint16& aAvctpVersion, TUint16& aSdpFeatures); |
|
116 |
|
117 //--------------------------------------------------------- |
|
118 // Bulk thread only functions |
|
119 //--------------------------------------------------------- |
|
120 public: |
|
121 // Interface to bearer/remcon |
|
122 void BulkClientAvailable(const TRemConClientId& aId); |
|
123 void BulkClientNotAvailable(const TRemConClientId& aId); |
|
124 MIncomingCommandHandler* BulkStartedL(MRemConCommandInterface& aCommandInterface); |
|
125 void BulkStopped(); |
|
126 |
|
127 // Interface to command handler |
|
128 void MediaPlayerItemL(const TUint16& aAvrcpPlayerId, RMediaPlayerItem& aItem); |
|
129 |
|
130 |
|
131 private: // from MUidObserver |
|
132 void MuoUidChanged(TRemConClientId aId, TUint16 aUidCounter); |
|
133 void MuoError(TRemConClientId aId); |
|
134 |
|
135 |
|
136 |
|
137 //--------------------------------------------------------- |
|
138 // Common functions |
|
139 //--------------------------------------------------------- |
|
140 public: |
|
141 // Used to map between AVRCP player ids and RemCon client ids |
|
142 TRemConClientId ClientL(TUint16 aAvrcpPlayerId) const; |
|
143 TRemConClientId Client(TUint16 aAvrcpPlayerId) const; |
|
144 TUint16 PlayerL(const TRemConClientId& aClientId) const; |
|
145 |
|
146 // Used to retrieve list of current players |
|
147 TInt PlayerListing(TUint aStartItem, TUint aEndItem, RArray<TUint>& aPlayers); |
|
148 TInt PlayerListing(RArray<TUint>& aPlayers); |
|
149 |
|
150 private: |
|
151 CAvrcpPlayerInfoManager(MRemConBearerObserver& aObserver); |
|
152 void ConstructL(MRemConCommandInterface& aCommandInterface); |
|
153 |
|
154 TBool ValidPlayer(const TUint16& aAvrcpPlayerId) const; |
|
155 TInt NextPlayerIndex(); |
|
156 TInt SetPlayerFeatures(const TRemConClientId& aId, TPlayerFeatureBitmask& aBitmask, TUint8& aSdpFeatures, TBool& aAbsoluteVolumeSupported); |
|
157 void UpdateTgServiceRecordL(); |
|
158 |
|
159 private: |
|
160 RPointerArray<MPlayerChangeObserver> iObservers; |
|
161 RArray<TAvrcpMediaPlayerItem> iPlayers; |
|
162 CUidWatcher* iUidWatcher; |
|
163 CPlayStatusWatcher* iPlayStatusWatcher; |
|
164 MRemConBearerObserver& iControlBearerObserver; // unowned - used to determine features of players |
|
165 RSpecificThreadCallBack iControlThreadCallBack; |
|
166 |
|
167 RSdp iSdp; |
|
168 RSdpDatabase iSdpDatabase; |
|
169 TSdpServRecordHandle iControllerRecord; |
|
170 TSdpServRecordHandle iTargetRecord; |
|
171 |
|
172 mutable RFastLock iLock; // for use in const functions |
|
173 }; |
|
174 |
|
175 // The lock is only used for the following members.... |
|
176 // |
|
177 |
|
178 #endif //AVRCPPLAYERINFOMANAGER_H |