1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
131 ASSERT_BULK_THREAD; |
131 ASSERT_BULK_THREAD; |
132 delete iUidWatcher; |
132 delete iUidWatcher; |
133 iUidWatcher = NULL; |
133 iUidWatcher = NULL; |
134 } |
134 } |
135 |
135 |
136 void CAvrcpPlayerInfoManager::ClientAvailable(const TRemConClientId& aId, TPlayerType aClientType, TPlayerSubType aClientSubType, const TDesC8& aName) |
136 // Helper function for ClientAvailable and TargetFeaturesUpdated |
|
137 TInt CAvrcpPlayerInfoManager::SetItemDetails(TAvrcpMediaPlayerItem& aItem, TPlayerType aPlayerType, TPlayerSubType aPlayerSubType, const TDesC8& aName) |
|
138 { |
|
139 aItem.iPlayerType = aPlayerType; |
|
140 aItem.iPlayerSubType = aPlayerSubType; |
|
141 aItem.iName.Set(aName); |
|
142 aItem.iFeatureBitmask = TPlayerFeatureBitmask(); |
|
143 return SetPlayerFeatures(aItem.iId, aItem.iFeatureBitmask, aItem.iSdpFeatures, aItem.iAbsoluteVolumeSupport); |
|
144 } |
|
145 |
|
146 // Helper function for ClientAvailable and TargetFeaturesUpdated |
|
147 void CAvrcpPlayerInfoManager::UpdateSdpRecord(const TAvrcpMediaPlayerItem& aItem) |
|
148 { |
|
149 // Update SDP record, if this fails we carry on, it's non-fatal |
|
150 TInt sdpErr = KErrNone; |
|
151 if(!iTargetRecord) |
|
152 { |
|
153 TRAP(sdpErr, AvrcpSdpUtils::CreateServiceRecordL(iSdpDatabase, iTargetRecord, ETrue, |
|
154 (aItem.iSdpFeatures & AvrcpSdp::EBrowsing) ? AvrcpSdp::KAvrcpProfileVersion14 : AvrcpSdp::KAvrcpProfileVersion13)); |
|
155 } |
|
156 if(sdpErr == KErrNone) |
|
157 { |
|
158 TRAP_IGNORE(UpdateTgServiceRecordL()); |
|
159 } |
|
160 } |
|
161 |
|
162 void CAvrcpPlayerInfoManager::ClientAvailable(const TRemConClientId& aId, TPlayerType aPlayerType, TPlayerSubType aPlayerSubType, const TDesC8& aName) |
137 { |
163 { |
138 LOG_FUNC; |
164 LOG_FUNC; |
139 ASSERT_CONTROL_THREAD; |
165 ASSERT_CONTROL_THREAD; |
140 iLock.Wait(); |
166 iLock.Wait(); |
141 // Add this to our client list, using any holes in the client id array |
167 // Add this to our client list, using any holes in the client id array |
148 return; |
174 return; |
149 } |
175 } |
150 |
176 |
151 TAvrcpMediaPlayerItem& item = iPlayers[index]; |
177 TAvrcpMediaPlayerItem& item = iPlayers[index]; |
152 item.iId = aId; |
178 item.iId = aId; |
153 item.iPlayerType = aClientType; |
|
154 item.iPlayerSubType = aClientSubType; |
|
155 item.iName.Set(aName); |
|
156 item.iBulkClientAvailable = EFalse; |
179 item.iBulkClientAvailable = EFalse; |
157 item.iUidCounter = 0; |
180 item.iUidCounter = 0; |
158 item.iLastUpdatedUidCounter = 0; |
181 item.iLastUpdatedUidCounter = 0; |
159 item.iPlaybackStatus = MPlayerEventsObserver::EStopped; |
182 item.iPlaybackStatus = MPlayerEventsObserver::EStopped; |
160 item.iFeatureBitmask = TPlayerFeatureBitmask(); |
183 TInt err = SetItemDetails(item, aPlayerType, aPlayerSubType, aName); |
161 TInt err = SetPlayerFeatures(aId, item.iFeatureBitmask, item.iSdpFeatures, item.iAbsoluteVolumeSupport); |
|
162 |
184 |
163 // Release lock before calling out of player info manager in case |
185 // Release lock before calling out of player info manager in case |
164 // anyone needs to call back in - we're finished updating the |
186 // anyone needs to call back in - we're finished updating the |
165 // info now. |
187 // info now. |
166 iLock.Signal(); |
188 iLock.Signal(); |
167 |
189 |
168 if(!err) |
190 if(!err) |
169 { |
191 { |
170 TRAP(err, iPlayStatusWatcher->StartWatchingPlayerL(aId)); |
192 TRAP(err, iPlayStatusWatcher->StartWatchingPlayerL(aId)); |
171 |
|
172 if(!err) |
193 if(!err) |
173 { |
194 { |
174 // Update SDP record, if this fails we carry on, it's non-fatal |
195 UpdateSdpRecord(item); |
175 TInt sdpErr = KErrNone; |
196 for(TInt i = 0; i<iObservers.Count(); i++) |
176 if(!iTargetRecord) |
|
177 { |
197 { |
178 TRAP(sdpErr, AvrcpSdpUtils::CreateServiceRecordL(iSdpDatabase, |
198 iObservers[i]->MpcoAvailablePlayersChanged(); |
179 iTargetRecord, |
|
180 ETrue, |
|
181 (item.iSdpFeatures & AvrcpSdp::EBrowsing) ? |
|
182 AvrcpSdp::KAvrcpProfileVersion14 : |
|
183 AvrcpSdp::KAvrcpProfileVersion13)); |
|
184 } |
199 } |
185 |
200 } |
186 if(sdpErr == KErrNone) |
201 else |
187 { |
202 { |
188 TRAP_IGNORE(UpdateTgServiceRecordL()); |
203 iLock.Wait(); |
189 } |
204 iPlayers[index].iId = KNullClientId; |
190 } |
205 iLock.Signal(); |
191 } |
206 } |
192 |
|
193 if(!err) |
|
194 { |
|
195 for(TInt i = 0; i<iObservers.Count(); i++) |
|
196 { |
|
197 iObservers[i]->MpcoAvailablePlayersChanged(); |
|
198 } |
|
199 } |
|
200 else |
|
201 { |
|
202 iLock.Wait(); |
|
203 iPlayers[index].iId = KNullClientId; |
|
204 iLock.Signal(); |
|
205 } |
207 } |
206 } |
208 } |
207 |
209 |
208 void CAvrcpPlayerInfoManager::ClientNotAvailable(const TRemConClientId& aId) |
210 void CAvrcpPlayerInfoManager::ClientNotAvailable(const TRemConClientId& aId) |
209 { |
211 { |
299 } |
301 } |
300 |
302 |
301 AvrcpSdpUtils::UpdateProtocolDescriptorListL(iSdpDatabase, iControllerRecord, avctpVersion); |
303 AvrcpSdpUtils::UpdateProtocolDescriptorListL(iSdpDatabase, iControllerRecord, avctpVersion); |
302 AvrcpSdpUtils::UpdateProfileDescriptorListL(iSdpDatabase, iControllerRecord, avrcpVersion); |
304 AvrcpSdpUtils::UpdateProfileDescriptorListL(iSdpDatabase, iControllerRecord, avrcpVersion); |
303 AvrcpSdpUtils::UpdateSupportedFeaturesL(iSdpDatabase, iControllerRecord, AvrcpSdp::ERemoteControl, AvrcpSdp::KAvrcpBaseCtFeatures); |
305 AvrcpSdpUtils::UpdateSupportedFeaturesL(iSdpDatabase, iControllerRecord, AvrcpSdp::ERemoteControl, AvrcpSdp::KAvrcpBaseCtFeatures); |
|
306 } |
|
307 |
|
308 void CAvrcpPlayerInfoManager::TargetFeaturesUpdated(const TRemConClientId& aId, TPlayerType aPlayerType, TPlayerSubType aPlayerSubType, const TDesC8& aName) |
|
309 { |
|
310 LOG_FUNC; |
|
311 ASSERT_CONTROL_THREAD; |
|
312 iLock.Wait(); |
|
313 // Find this client in our client list |
|
314 TInt index = iPlayers.Find(aId, PlayerCompare); |
|
315 if(index < 0) |
|
316 { |
|
317 // Couldn't find client in client list, maybe we removed it after an earlier failure |
|
318 iLock.Signal(); |
|
319 return; |
|
320 } |
|
321 |
|
322 TAvrcpMediaPlayerItem& item = iPlayers[index]; |
|
323 TInt err = SetItemDetails(item, aPlayerType, aPlayerSubType, aName); |
|
324 |
|
325 // Release lock before calling out of player info manager in case |
|
326 // anyone needs to call back in - we're finished updating the |
|
327 // info now. |
|
328 iLock.Signal(); |
|
329 |
|
330 if(!err) |
|
331 { |
|
332 UpdateSdpRecord(item); |
|
333 } |
|
334 else |
|
335 { |
|
336 // There was an error updating the features so remove this client from the client list |
|
337 iLock.Wait(); |
|
338 iPlayers[index].iId = KNullClientId; |
|
339 iLock.Signal(); |
|
340 } |
|
341 |
|
342 for(TInt i = 0; i<iObservers.Count(); i++) |
|
343 { |
|
344 iObservers[i]->MpcoAvailablePlayersChanged(); |
|
345 } |
304 } |
346 } |
305 |
347 |
306 MIncomingCommandHandler& CAvrcpPlayerInfoManager::InternalCommandHandler() |
348 MIncomingCommandHandler& CAvrcpPlayerInfoManager::InternalCommandHandler() |
307 { |
349 { |
308 LOG_FUNC |
350 LOG_FUNC |