diff mbox series

[BlueZ,2/5] shared/bap: Get broadcast channel location from stream capabilities

Message ID 20240419180752.96699-3-andrei.istodorescu@nxp.com
State New
Headers show
Series Create transports for matching BISes | expand

Commit Message

Andrei Istodorescu April 19, 2024, 6:07 p.m. UTC
Get the channel location from the stream's configured capabilities,
rather than from the local PACS database capabilities.
---
 src/shared/bap.c | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 6328ff35f3c3..36f0b0a3b50a 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -5628,9 +5628,24 @@  uint8_t bt_bap_stream_get_dir(struct bt_bap_stream *stream)
 		return BT_BAP_BCAST_SINK;
 }
 
+static void bap_sink_get_allocation(size_t i, uint8_t l, uint8_t t,
+		uint8_t *v, void *user_data)
+{
+	uint32_t location32;
+
+	if (!v)
+		return;
+
+	memcpy(&location32, v, l);
+	*((uint32_t *)user_data) = le32_to_cpu(location32);
+}
+
 uint32_t bt_bap_stream_get_location(struct bt_bap_stream *stream)
 {
 	struct bt_pacs *pacs;
+	uint8_t type = BAP_CHANNEL_ALLOCATION_LTV_TYPE;
+	uint32_t allocation = 0;
+	struct iovec *caps;
 
 	if (!stream)
 		return 0x00000000;
@@ -5644,10 +5659,13 @@  uint32_t bt_bap_stream_get_location(struct bt_bap_stream *stream)
 			return pacs->sink_loc_value;
 	}
 
-	/* TO DO get the location values from metadata
-	 * for brodcast source and sink
-	 */
-	return stream->bap->ldb->pacs->source_loc_value;
+	caps = bt_bap_stream_get_config(stream);
+
+	/* Get stream allocation from capabilities */
+	util_ltv_foreach(caps->iov_base, caps->iov_len, &type,
+			bap_sink_get_allocation, &allocation);
+
+	return allocation;
 }
 
 struct iovec *bt_bap_stream_get_config(struct bt_bap_stream *stream)
@@ -6322,18 +6340,6 @@  struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream)
 	return base_iov;
 }
 
-static void bap_sink_get_allocation(size_t i, uint8_t l, uint8_t t,
-		uint8_t *v, void *user_data)
-{
-	uint32_t location32;
-
-	if (!v)
-		return;
-
-	memcpy(&location32, v, l);
-	*((uint32_t *)user_data) = le32_to_cpu(location32);
-}
-
 /*
  * This function compares PAC Codec Specific Capabilities, with the Codec
  * Specific Configuration LTVs received in the BASE of the BAP Source. The