bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpplayerinfomanager.cpp
changeset 1 6a1fe72036e3
parent 0 f63038272f30
child 49 9866e1d49556
equal deleted inserted replaced
0:f63038272f30 1:6a1fe72036e3
    44 
    44 
    45 static TBool PlayerCompare(const TRemConClientId* aId, const TAvrcpMediaPlayerItem& aItem)
    45 static TBool PlayerCompare(const TRemConClientId* aId, const TAvrcpMediaPlayerItem& aItem)
    46 	{
    46 	{
    47 	LOG_STATIC_FUNC
    47 	LOG_STATIC_FUNC
    48 	return (aId && *aId == aItem.iId);
    48 	return (aId && *aId == aItem.iId);
       
    49 	}
       
    50 
       
    51 enum TFirstAbsVolSupport { EFirstAbsVolSupport };
       
    52 static TBool FirstAbsVolSupport(const TFirstAbsVolSupport*, const TAvrcpMediaPlayerItem& aItem)
       
    53 	{
       
    54 	LOG_STATIC_FUNC
       
    55 	return aItem.iId != KNullClientId && aItem.iAbsoluteVolumeSupport;
       
    56 	}
       
    57 
       
    58 enum TFirstBrowsingSupport { EFirstBrowsingSupport };
       
    59 static TBool FirstBrowsingSupport(const TFirstBrowsingSupport*, const TAvrcpMediaPlayerItem& aItem)
       
    60 	{
       
    61 	LOG_STATIC_FUNC
       
    62 	return aItem.iId != KNullClientId && (aItem.iSdpFeatures & AvrcpSdp::EBrowsing);
    49 	}
    63 	}
    50 
    64 
    51 CAvrcpPlayerInfoManager* CAvrcpPlayerInfoManager::NewL(MRemConBearerObserver& aObserver, MRemConCommandInterface& aCommandInterface)
    65 CAvrcpPlayerInfoManager* CAvrcpPlayerInfoManager::NewL(MRemConBearerObserver& aObserver, MRemConCommandInterface& aCommandInterface)
    52 	{
    66 	{
    53 	LOG_STATIC_FUNC
    67 	LOG_STATIC_FUNC
   174 				TRAP_IGNORE(UpdateTgServiceRecordL());
   188 				TRAP_IGNORE(UpdateTgServiceRecordL());
   175 				}
   189 				}
   176 			}
   190 			}
   177 		}
   191 		}
   178 
   192 
   179 
       
   180 
       
   181 	if(!err)
   193 	if(!err)
   182 		{
   194 		{
   183 		for(TInt i = 0; i<iObservers.Count(); i++)
   195 		for(TInt i = 0; i<iObservers.Count(); i++)
   184 			{
   196 			{
   185 			iObservers[i]->MpcoAvailablePlayersChanged();
   197 			iObservers[i]->MpcoAvailablePlayersChanged();
   730 				}
   742 				}
   731 			}
   743 			}
   732 		}
   744 		}
   733 	}
   745 	}
   734 
   746 
       
   747 /**
       
   748 If the client ID is set to a valid ID then we shall return the support
       
   749 status for the specific player referenced by the ID.
       
   750 Otherwise we shall return generic support which will indicate support across
       
   751 the device.
       
   752 @return whether absolute volume control is supported either by the specific player
       
   753 associated with a client ID, or generally by the device if an invalid client ID is
       
   754 provided.
       
   755  */
   735 TBool CAvrcpPlayerInfoManager::AbsoluteVolumeSupportedL(const TRemConClientId& aClientId) const
   756 TBool CAvrcpPlayerInfoManager::AbsoluteVolumeSupportedL(const TRemConClientId& aClientId) const
   736 	{
   757 	{
   737 	LOG_FUNC
   758 	LOG_FUNC
   738 	ASSERT_CONTROL_THREAD
   759 	ASSERT_CONTROL_THREAD
   739 
   760 
   740 	iLock.Wait();
   761 	iLock.Wait();
   741 	CleanupSignalPushL(iLock);
   762 	CleanupSignalPushL(iLock);
   742 	
   763 	
   743 	TInt index = iPlayers.Find(aClientId, PlayerCompare);
   764 	TBool supported = EFalse;
   744 	if(index < 0)
   765 	// If we receive a "NULL" client ID then it means that we should 
   745 		{
   766 	// return whether abs vol is generically supported by the device.
   746 		LEAVEL(KErrNotFound);
   767 	if(aClientId == KNullClientId)
   747 		}
   768 		{
   748 	TBool supported = iPlayers[index].iAbsoluteVolumeSupport;
   769 		// Try to find the first player supporting abs vol, if there is one then it is supported 
       
   770 		TInt index = iPlayers.Find(EFirstAbsVolSupport, FirstAbsVolSupport);
       
   771 		supported = (index >= 0);
       
   772 		}
       
   773 	else
       
   774 		{
       
   775 		// The abs vol support for a specific player is required, so return that.
       
   776 		TInt index = iPlayers.Find(aClientId, PlayerCompare);
       
   777 		if(index < 0)
       
   778 			{
       
   779 			LEAVEL(KErrNotFound);
       
   780 			}
       
   781 		supported = iPlayers[index].iAbsoluteVolumeSupport;
       
   782 		}
   749 	
   783 	
   750 	CleanupStack::PopAndDestroy(&iLock);
   784 	CleanupStack::PopAndDestroy(&iLock);
   751 	
   785 	
   752 	return supported;
   786 	return supported;
   753 	}
   787 	}
   758 	ASSERT_CONTROL_THREAD
   792 	ASSERT_CONTROL_THREAD
   759 
   793 
   760 	iLock.Wait();
   794 	iLock.Wait();
   761 	CleanupSignalPushL(iLock);
   795 	CleanupSignalPushL(iLock);
   762 	
   796 	
   763 	TInt index = iPlayers.Find(aClientId, PlayerCompare);
   797 	TBool supported = EFalse;
   764 	if(index < 0)
   798 	// If we receive a "NULL" client ID then it means that we should 
   765 		{
   799 	// return whether browsing is generically supported by the device.
   766 		LEAVEL(KErrNotFound);
   800 	if(aClientId == KNullClientId)
   767 		}
   801 		{
   768 	TBool supported = iPlayers[index].iSdpFeatures & AvrcpSdp::EBrowsing;
   802 		// Try to find the first player supporting browsing, if there is one then it is supported 
       
   803 		TInt index = iPlayers.Find(EFirstBrowsingSupport, FirstBrowsingSupport);
       
   804 		supported = (index >= 0);
       
   805 		}
       
   806 	else
       
   807 		{
       
   808 		// The browsing support for a specific player is required, so return that.
       
   809 		TInt index = iPlayers.Find(aClientId, PlayerCompare);
       
   810 		if(index < 0)
       
   811 			{
       
   812 			LEAVEL(KErrNotFound);
       
   813 			}
       
   814 		supported = iPlayers[index].iSdpFeatures & AvrcpSdp::EBrowsing;
       
   815 		}
   769 	
   816 	
   770 	CleanupStack::PopAndDestroy(&iLock);
   817 	CleanupStack::PopAndDestroy(&iLock);
   771 	
   818 	
   772 	return supported;
   819 	return supported;
   773 	}
   820 	}