diff mbox series

[2/3] src/profile: Export Remote Audio Volume Control SDP value for HSP HS role via first bit in features value

Message ID 20200413162513.2221-3-pali@kernel.org (mailing list archive)
State New, archived
Headers show
Series bluez: Export SDP "Remote audio volume control" item for HSP profile | expand

Commit Message

Pali Rohár April 13, 2020, 4:25 p.m. UTC
Remote Audio Volume Control property in SDP record for HSP HS role
indicates if device supports volume control.

It is required for DBus agents which implements audio part of HSP
profile to know if remote device supports volume control or not.

With this change bluez exports status of this SDP property via firt bit
in Features entry in NewConnection() DBus callback method, like for HFP
profile.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 src/profile.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/profile.c b/src/profile.c
index 884440408..3b7e08f26 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -923,10 +923,26 @@  static void append_prop(gpointer a, gpointer b)
 }
 
 static uint16_t get_supported_features(const sdp_record_t *rec,
-					bool *have_features)
+					const char *uuid, bool *have_features)
 {
 	sdp_data_t *data;
 
+	if (strcasecmp(uuid, HSP_AG_UUID) == 0) {
+		/* HSP AG role does not provide any features */
+		*have_features = false;
+		return 0;
+	} else if (strcasecmp(uuid, HSP_HS_UUID) == 0) {
+		/* HSP HS role provides Remote Audio Volume Control */
+		data = sdp_data_get(rec, SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL);
+		if (!data || data->dtd != SDP_BOOL) {
+			*have_features = false;
+			return 0;
+		} else {
+			*have_features = true;
+			return data->val.int8 ? 0x1 : 0x0;
+		}
+	}
+
 	data = sdp_data_get(rec, SDP_ATTR_SUPPORTED_FEATURES);
 	if (!data || data->dtd != SDP_UINT16) {
 		*have_features = false;
@@ -979,7 +995,7 @@  static bool send_new_connection(struct ext_profile *ext, struct ext_io *conn)
 		rec = btd_device_get_record(conn->device, remote_uuid);
 		if (rec) {
 			conn->features = get_supported_features(rec,
-							&conn->have_features);
+					remote_uuid, &conn->have_features);
 			conn->version = get_profile_version(rec);
 		}
 	}
@@ -1596,7 +1612,7 @@  static void record_cb(sdp_list_t *recs, int err, gpointer user_data)
 		if (conn->psm == 0 && sdp_get_proto_desc(protos, OBEX_UUID))
 			conn->psm = get_goep_l2cap_psm(rec);
 
-		conn->features = get_supported_features(rec,
+		conn->features = get_supported_features(rec, ext->remote_uuid,
 							&conn->have_features);
 		conn->version = get_profile_version(rec);