public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 0/3] profiles: Add remote endpoint path to SelectProperties
@ 2022-08-30 14:47 Frédéric Danis
  2022-08-30 14:47 ` [PATCH BlueZ v2 1/3] " Frédéric Danis
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Frédéric Danis @ 2022-08-30 14:47 UTC (permalink / raw)
  To: linux-bluetooth

The SelectProperties method is only called on the central (initiator)
device. But there's no information related to the remote device for which
is call is done.
These commits allow the audio server to link this call method to the
appropriate remote endpoint.

Changes in V2:
- Set endpoint part of the dictionary properties
- Pass rpac to select function instead of DBus specific path
- Add a new commit to keep consistency after fixing previous
  patch for a checkpatch warning

Frédéric Danis (3):
  profiles: Add remote endpoint path to SelectProperties
  doc: Add remote endpoint path to SelectProperties
  profiles: Fix function definition style

 doc/media-api.txt      |  6 ++++--
 profiles/audio/bap.c   |  2 ++
 profiles/audio/media.c | 15 ++++++++++++---
 src/shared/bap.c       | 12 +++++++++++-
 src/shared/bap.h       | 11 +++++++----
 5 files changed, 36 insertions(+), 10 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH BlueZ v3 1/3] profiles: Add remote endpoint path to SelectProperties
@ 2022-08-30 20:54 Frédéric Danis
  2022-08-30 22:03 ` bluez.test.bot
  0 siblings, 1 reply; 8+ messages in thread
From: Frédéric Danis @ 2022-08-30 20:54 UTC (permalink / raw)
  To: linux-bluetooth

This adds the remote endpoint path to the dictionary sent in
SelectProperties.
It allows audio application to know for which remote endpoint the call is
done and so for which it should act as an initiator.
---
 profiles/audio/bap.c   |  2 ++
 profiles/audio/media.c | 15 ++++++++++++---
 src/shared/bap.c       | 12 +++++++++++-
 src/shared/bap.h       |  7 +++++--
 4 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index d388afe56..67aba3bd7 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -555,6 +555,8 @@ static struct bap_ep *ep_register(struct btd_service *service,
 		return NULL;
 	}
 
+	bt_bap_pac_set_user_data(rpac, ep->path);
+
 	DBG("ep %p lpac %p rpac %p path %s", ep, ep->lpac, ep->rpac, ep->path);
 
 	queue_push_tail(queue, ep);
diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index ff3fa197b..85278a6d9 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -889,16 +889,20 @@ done:
 	data->cb(data->pac, err, caps, metadata, &qos, data->user_data);
 }
 
-static int pac_select(struct bt_bap_pac *pac, struct bt_bap_pac_qos *qos,
-			struct iovec *caps, struct iovec *metadata,
+static int pac_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
+			struct bt_bap_pac_qos *qos,
 			bt_bap_pac_select_t cb, void *cb_data, void *user_data)
 {
 	struct media_endpoint *endpoint = user_data;
+	struct iovec *caps;
+	struct iovec *metadata;
+	const char *endpoint_path;
 	struct pac_select_data *data;
 	DBusMessage *msg;
 	DBusMessageIter iter, dict;
 	const char *key = "Capabilities";
 
+	bt_bap_pac_get_codec(rpac, NULL, &caps, &metadata);
 	if (!caps)
 		return -EINVAL;
 
@@ -911,7 +915,7 @@ static int pac_select(struct bt_bap_pac *pac, struct bt_bap_pac_qos *qos,
 	}
 
 	data = new0(struct pac_select_data, 1);
-	data->pac = pac;
+	data->pac = lpac;
 	data->cb = cb;
 	data->user_data = cb_data;
 
@@ -919,6 +923,11 @@ static int pac_select(struct bt_bap_pac *pac, struct bt_bap_pac_qos *qos,
 
 	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict);
 
+	endpoint_path = bt_bap_pac_get_user_data(rpac);
+	if (endpoint_path)
+		g_dbus_dict_append_entry(&dict, "Endpoint",
+					DBUS_TYPE_OBJECT_PATH, &endpoint_path);
+
 	g_dbus_dict_append_basic_array(&dict, DBUS_TYPE_STRING, &key,
 					DBUS_TYPE_BYTE, &caps->iov_base,
 					caps->iov_len);
diff --git a/src/shared/bap.c b/src/shared/bap.c
index 8edc7b72e..150b2116e 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -3934,6 +3934,16 @@ int bt_bap_pac_get_codec(struct bt_bap_pac *pac, uint8_t *id,
 	return bt_bap_pac_get_vendor_codec(pac, id, NULL, NULL, data, metadata);
 }
 
+void bt_bap_pac_set_user_data(struct bt_bap_pac *pac, void *user_data)
+{
+	pac->user_data = user_data;
+}
+
+void *bt_bap_pac_get_user_data(struct bt_bap_pac *pac)
+{
+	return pac->user_data;
+}
+
 static bool find_ep_unused(const void *data, const void *user_data)
 {
 	const struct bt_bap_endpoint *ep = data;
@@ -4066,7 +4076,7 @@ int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
 	if (!lpac->ops || !lpac->ops->select)
 		return -EOPNOTSUPP;
 
-	lpac->ops->select(lpac, &rpac->qos, rpac->data, rpac->metadata,
+	lpac->ops->select(lpac, rpac, &rpac->qos,
 					func, user_data, lpac->user_data);
 
 	return 0;
diff --git a/src/shared/bap.h b/src/shared/bap.h
index ff4bac330..93b00d771 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -120,8 +120,8 @@ struct bt_bap_pac *bt_bap_add_pac(struct gatt_db *db, const char *name,
 					struct iovec *metadata);
 
 struct bt_bap_pac_ops {
-	int (*select) (struct bt_bap_pac *pac, struct bt_bap_pac_qos *qos,
-			struct iovec *caps, struct iovec *metadata,
+	int (*select)(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
+			struct bt_bap_pac_qos *qos,
 			bt_bap_pac_select_t cb, void *cb_data, void *user_data);
 	int (*config) (struct bt_bap_stream *stream, struct iovec *cfg,
 			struct bt_bap_qos *qos, bt_bap_pac_config_t cb,
@@ -186,6 +186,9 @@ int bt_bap_pac_get_vendor_codec(struct bt_bap_pac *pac, uint8_t *id,
 int bt_bap_pac_get_codec(struct bt_bap_pac *pac, uint8_t *id,
 				struct iovec **data, struct iovec **metadata);
 
+void bt_bap_pac_set_user_data(struct bt_bap_pac *pac, void *user_data);
+void *bt_bap_pac_get_user_data(struct bt_bap_pac *pac);
+
 /* Stream related functions */
 int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
 			bt_bap_pac_select_t func, void *user_data);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH BlueZ 1/2] profiles: Add remote endpoint path to SelectProperties
@ 2022-08-29 20:31 Frédéric Danis
  2022-08-29 21:29 ` bluez.test.bot
  0 siblings, 1 reply; 8+ messages in thread
From: Frédéric Danis @ 2022-08-29 20:31 UTC (permalink / raw)
  To: linux-bluetooth

---
 profiles/audio/bap.c   | 2 +-
 profiles/audio/media.c | 3 +++
 src/shared/bap.c       | 2 ++
 src/shared/bap.h       | 2 ++
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index d388afe56..cf27ec0ae 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -613,7 +613,7 @@ static bool pac_found(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
 
 	/* TODO: Cache LRU? */
 	if (btd_service_is_initiator(service))
-		bt_bap_select(lpac, rpac, select_cb, ep);
+		bt_bap_select(lpac, rpac, ep->path, select_cb, ep);
 
 	return true;
 }
diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index ff3fa197b..8d777eedd 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -891,6 +891,7 @@ done:
 
 static int pac_select(struct bt_bap_pac *pac, struct bt_bap_pac_qos *qos,
 			struct iovec *caps, struct iovec *metadata,
+			const char *remote_ep_path,
 			bt_bap_pac_select_t cb, void *cb_data, void *user_data)
 {
 	struct media_endpoint *endpoint = user_data;
@@ -917,6 +918,8 @@ static int pac_select(struct bt_bap_pac *pac, struct bt_bap_pac_qos *qos,
 
 	dbus_message_iter_init_append(msg, &iter);
 
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &remote_ep_path);
+
 	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict);
 
 	g_dbus_dict_append_basic_array(&dict, DBUS_TYPE_STRING, &key,
diff --git a/src/shared/bap.c b/src/shared/bap.c
index 8edc7b72e..691fec2fa 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -4058,6 +4058,7 @@ static bool match_pac(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
 }
 
 int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
+			const char *remote_ep_path,
 			bt_bap_pac_select_t func, void *user_data)
 {
 	if (!lpac || !rpac || !func)
@@ -4067,6 +4068,7 @@ int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
 		return -EOPNOTSUPP;
 
 	lpac->ops->select(lpac, &rpac->qos, rpac->data, rpac->metadata,
+					remote_ep_path,
 					func, user_data, lpac->user_data);
 
 	return 0;
diff --git a/src/shared/bap.h b/src/shared/bap.h
index ff4bac330..da5fe1431 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -122,6 +122,7 @@ struct bt_bap_pac *bt_bap_add_pac(struct gatt_db *db, const char *name,
 struct bt_bap_pac_ops {
 	int (*select) (struct bt_bap_pac *pac, struct bt_bap_pac_qos *qos,
 			struct iovec *caps, struct iovec *metadata,
+			const char *remote_ep_path,
 			bt_bap_pac_select_t cb, void *cb_data, void *user_data);
 	int (*config) (struct bt_bap_stream *stream, struct iovec *cfg,
 			struct bt_bap_qos *qos, bt_bap_pac_config_t cb,
@@ -188,6 +189,7 @@ int bt_bap_pac_get_codec(struct bt_bap_pac *pac, uint8_t *id,
 
 /* Stream related functions */
 int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
+			const char *remote_ep_path,
 			bt_bap_pac_select_t func, void *user_data);
 
 struct bt_bap_stream *bt_bap_config(struct bt_bap *bap,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-08-30 22:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-30 14:47 [PATCH BlueZ v2 0/3] profiles: Add remote endpoint path to SelectProperties Frédéric Danis
2022-08-30 14:47 ` [PATCH BlueZ v2 1/3] " Frédéric Danis
2022-08-30 16:07   ` bluez.test.bot
2022-08-30 14:47 ` [PATCH BlueZ v2 2/3] doc: " Frédéric Danis
2022-08-30 14:47 ` [PATCH BlueZ v2 3/3] profiles: Fix function definition style Frédéric Danis
2022-08-30 21:30 ` [PATCH BlueZ v2 0/3] profiles: Add remote endpoint path to SelectProperties patchwork-bot+bluetooth
  -- strict thread matches above, loose matches on Subject: below --
2022-08-30 20:54 [PATCH BlueZ v3 1/3] " Frédéric Danis
2022-08-30 22:03 ` bluez.test.bot
2022-08-29 20:31 [PATCH BlueZ 1/2] " Frédéric Danis
2022-08-29 21:29 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox