profiles: Add remote endpoint path to SelectProperties
authorFrédéric Danis <frederic.danis@collabora.com>
Tue, 30 Aug 2022 14:47:32 +0000 (16:47 +0200)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/audio/bap.c
profiles/audio/media.c
src/shared/bap.c
src/shared/bap.h

index d539ba8..b1e17f4 100644 (file)
@@ -557,6 +557,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);
index af013dc..b03439a 100644 (file)
@@ -1102,16 +1102,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;
 
@@ -1124,7 +1128,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;
 
@@ -1132,6 +1136,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);
index 8edc7b7..150b211 100644 (file)
@@ -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;
index ff4bac3..93b00d7 100644 (file)
@@ -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);