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 function for ClientAvailable and TargetFeaturesUpdated |
|
111 TInt SetItemDetails(TAvrcpMediaPlayerItem& aItem, TPlayerType aPlayerType, TPlayerSubType aPlayerSubType, const TDesC8& aName); |
|
112 void UpdateSdpRecord(const TAvrcpMediaPlayerItem& aItem); |
|
113 |
|
114 //--------------------------------------------------------- |
|
115 // Bulk thread only functions |
|
116 //--------------------------------------------------------- |
|
117 public: |
|
118 // Interface to bearer/remcon |
|
119 void BulkClientAvailable(const TRemConClientId& aId); |
|
120 void BulkClientNotAvailable(const TRemConClientId& aId); |
|
121 MIncomingCommandHandler* BulkStartedL(MRemConCommandInterface& aCommandInterface); |
|
122 void BulkStopped(); |
|
123 |
|
124 // Interface to command handler |
|
125 void MediaPlayerItemL(const TUint16& aAvrcpPlayerId, RMediaPlayerItem& aItem); |
|
126 |
|
127 |
|
128 private: // from MUidObserver |
|
129 void MuoUidChanged(TRemConClientId aId, TUint16 aUidCounter); |
|
130 void MuoError(TRemConClientId aId); |
|
131 |
|
132 |
|
133 |
|
134 //--------------------------------------------------------- |
|
135 // Common functions |
|
136 //--------------------------------------------------------- |
|
137 public: |
|
138 // Used to map between AVRCP player ids and RemCon client ids |
|
139 TRemConClientId ClientL(TUint16 aAvrcpPlayerId) const; |
|
140 TRemConClientId Client(TUint16 aAvrcpPlayerId) const; |
|
141 TUint16 PlayerL(const TRemConClientId& aClientId) const; |
|
142 |
|
143 // Used to retrieve list of current players |
|
144 TInt PlayerListing(TUint aStartItem, TUint aEndItem, RArray<TUint>& aPlayers); |
|
145 TInt PlayerListing(RArray<TUint>& aPlayers); |
|
146 |
|
147 private: |
|
148 CAvrcpPlayerInfoManager(MRemConBearerObserver& aObserver); |
|
149 void ConstructL(MRemConCommandInterface& aCommandInterface); |
|
150 |
|
151 TBool ValidPlayer(const TUint16& aAvrcpPlayerId) const; |
|
152 TInt NextPlayerIndex(); |
|
153 TInt SetPlayerFeatures(const TRemConClientId& aId, TPlayerFeatureBitmask& aBitmask, TUint8& aSdpFeatures, TBool& aAbsoluteVolumeSupported); |
|
154 void UpdateTgServiceRecordL(); |
|
155 |
|
156 private: |
|
157 RPointerArray<MPlayerChangeObserver> iObservers; |
|
158 RArray<TAvrcpMediaPlayerItem> iPlayers; |
|
159 CUidWatcher* iUidWatcher; |
|
160 CPlayStatusWatcher* iPlayStatusWatcher; |
|
161 MRemConBearerObserver& iControlBearerObserver; // unowned - used to determine features of players |
|
162 RSpecificThreadCallBack iControlThreadCallBack; |
|
163 |
|
164 RSdp iSdp; |
|
165 RSdpDatabase iSdpDatabase; |
|
166 TSdpServRecordHandle iControllerRecord; |
|
167 TSdpServRecordHandle iTargetRecord; |
|
168 |
|
169 mutable RFastLock iLock; // for use in const functions |
|
170 }; |
|
171 |
|
172 // The lock is only used for the following members.... |
|
173 // |
|
174 |
|
175 #endif //AVRCPPLAYERINFOMANAGER_H |
|