diff mbox series

[BlueZ,3/7] bass: Store Broadcast ID inside assistant struct

Message ID 20240805120429.67606-4-iulia.tanasescu@nxp.com (mailing list archive)
State Accepted
Commit a426c36171091b75c49226b4bb4a2563606e19f5
Headers show
Series Implement the MediaAssistant "Push" command | 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

Iulia Tanasescu Aug. 5, 2024, 12:04 p.m. UTC
A Broadcast Source is uniquely identified by its Broadcast ID, which
is being advertised in the Extended Advertising Data.

After discovering a Broadcast Source, a BAP Broadcast Assistant needs
to internally store the Broadcast ID, which will be transmitted to the
peer Scan Delegator via the BASS "Add Source" operation.
---
 profiles/audio/bass.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c
index 083988358..795b4b80a 100644
--- a/profiles/audio/bass.c
+++ b/profiles/audio/bass.c
@@ -3,7 +3,7 @@ 
  *
  *  BlueZ - Bluetooth protocol stack for Linux
  *
- *  Copyright 2023 NXP
+ *  Copyright 2023-2024 NXP
  *
  */
 
@@ -40,6 +40,7 @@ 
 #include "src/adapter.h"
 #include "src/shared/bass.h"
 #include "src/shared/bap.h"
+#include "src/shared/ad.h"
 
 #include "src/plugin.h"
 #include "src/gatt-database.h"
@@ -80,6 +81,7 @@  struct bass_assistant {
 	struct bass_data *data;		/* BASS session with peer device */
 	uint8_t sgrp;
 	uint8_t bis;
+	uint32_t bid;
 	struct bt_iso_qos qos;
 	struct iovec *meta;
 	struct iovec *caps;
@@ -198,6 +200,21 @@  static void assistant_free(void *data)
 	free(assistant);
 }
 
+static void src_ad_search_bid(void *data, void *user_data)
+{
+	struct bt_ad_service_data *sd = data;
+	struct bass_assistant *assistant = user_data;
+	struct iovec iov;
+
+	if (sd->uuid.type != BT_UUID16 || sd->uuid.value.u16 != BCAA_SERVICE)
+		return;
+
+	iov.iov_base = sd->data;
+	iov.iov_len = sd->len;
+
+	util_iov_pull_le24(&iov, &assistant->bid);
+}
+
 static struct bass_assistant *assistant_new(struct btd_adapter *adapter,
 		struct btd_device *device, struct bass_data *data,
 		uint8_t sgrp, uint8_t bis, struct bt_iso_qos *qos,
@@ -221,6 +238,9 @@  static struct bass_assistant *assistant_new(struct btd_adapter *adapter,
 	assistant->meta = util_iov_dup(meta, 1);
 	assistant->caps = util_iov_dup(caps, 1);
 
+	btd_device_foreach_service_data(assistant->device, src_ad_search_bid,
+							assistant);
+
 	ba2str(device_get_address(device), src_addr);
 	ba2str(device_get_address(data->device), dev_addr);