diff mbox series

[v3,2/3] bap: For broadcast ep extract capabilities from BASE

Message ID 20230818133552.20673-3-silviu.barbulescu@nxp.com (mailing list archive)
State New, archived
Headers show
Series Configure broadcast endpoint with BASE | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Silviu Florian Barbulescu Aug. 18, 2023, 1:35 p.m. UTC
From: Claudia Draghicescu <claudia.rosu@nxp.com>

bap: For broadcast ep parse BASE to extract capabilities

---
 profiles/audio/bap.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 8cbb238ef..de19023a9 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -74,6 +74,7 @@  struct bap_ep {
 	struct bt_bap_qos qos;
 	unsigned int id;
 	DBusMessage *msg;
+	struct iovec *base;
 };
 
 struct bap_data {
@@ -272,7 +273,8 @@  static int parse_array(DBusMessageIter *iter, struct iovec **iov)
 }
 
 static int parse_properties(DBusMessageIter *props, struct iovec **caps,
-				struct iovec **metadata, struct bt_bap_qos *qos)
+				struct iovec **metadata, struct iovec **base,
+				struct bt_bap_qos *qos)
 {
 	const char *key;
 	struct bt_bap_io_qos io_qos;
@@ -438,9 +440,20 @@  static int parse_properties(DBusMessageIter *props, struct iovec **caps,
 	}
 
 	if (broadcast) {
+		uint32_t presDelay;
+		uint8_t numSubgroups, numBis;
+		struct bt_bap_codec codec;
+
 		memcpy(&qos->bcast.io_qos, &io_qos, sizeof(io_qos));
 		qos->bcast.framing = framing;
-
+		if (!base)
+			return 0;
+		if (!(*base))
+			*base = new0(struct iovec, 1);
+		util_iov_memcpy(*base, (*caps)->iov_base, (*caps)->iov_len);
+		bap_parse_base((*caps)->iov_base, (*caps)->iov_len, bap_debug,
+			&presDelay, &numSubgroups, &numBis, &codec,
+			caps, NULL);
 	} else {
 		memcpy(&qos->ucast.io_qos, &io_qos, sizeof(io_qos));
 		qos->ucast.framing = framing;
@@ -565,7 +578,8 @@  static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg,
 		ep->qos.ucast.cis_id = BT_ISO_QOS_CIS_UNSET;
 	}
 
-	if (parse_properties(&props, &ep->caps, &ep->metadata, &ep->qos) < 0) {
+	if (parse_properties(&props, &ep->caps, &ep->metadata,
+				&ep->base, &ep->qos) < 0) {
 		DBG("Unable to parse properties");
 		return btd_error_invalid_args(msg);
 	}
@@ -1244,10 +1258,10 @@  static void bap_connect_io_broadcast(struct bap_data *data, struct bap_ep *ep,
 		g_source_remove(ep->io_id);
 		ep->io_id = 0;
 	}
-	base.base_len = ep->caps->iov_len;
+	base.base_len = ep->base->iov_len;
 
 	memset(base.base, 0, 248);
-	memcpy(base.base, ep->caps->iov_base, base.base_len);
+	memcpy(base.base, ep->base->iov_base, ep->base->iov_len);
 	DBG("ep %p stream %p ", ep, stream);
 	ba2str(btd_adapter_get_address(adapter), addr);