[PATCH BlueZ 01/10] shared/bap: Add separate API to merge caps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This moves the logic to merge L2 and L3 capabilities discovered
inside a BASE structure in a public API.
---
 src/shared/bap.c | 40 ++++++++++++++++++++++++----------------
 src/shared/bap.h |  2 ++
 2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index d59eac8cc..1259ee3c9 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -6607,29 +6607,21 @@ static struct bt_ltv_match bap_check_bis(struct bt_bap_db *ldb,
 	return compare_data;
 }
 
-void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index,
-		struct bt_bap_codec *codec,
-		struct iovec *l2_caps,
-		struct iovec *l3_caps,
-		struct bt_bap_pac **lpac,
-		struct iovec **caps)
+struct iovec *bt_bap_merge_caps(struct iovec *l2_caps, struct iovec *l3_caps)
 {
 	struct bt_ltv_extract merge_data = {0};
-	struct bt_ltv_match match_data;
 
 	if (!l2_caps)
 		/* Codec_Specific_Configuration parameters shall
 		 * be present at Level 2.
 		 */
-		return;
+		return NULL;
 
-	if (!l3_caps) {
+	if (!l3_caps)
 		/* Codec_Specific_Configuration parameters may
 		 * be present at Level 3.
 		 */
-		merge_data.result = util_iov_dup(l2_caps, 1);
-		goto done;
-	}
+		return util_iov_dup(l2_caps, 1);
 
 	merge_data.src = l3_caps;
 	merge_data.result = new0(struct iovec, 1);
@@ -6642,17 +6634,33 @@ void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index,
 			NULL,
 			bap_sink_check_level2_ltv, &merge_data);
 
-done:
+	return merge_data.result;
+}
+
+void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index,
+		struct bt_bap_codec *codec,
+		struct iovec *l2_caps,
+		struct iovec *l3_caps,
+		struct bt_bap_pac **lpac,
+		struct iovec **caps)
+{
+	struct iovec *merged_caps;
+	struct bt_ltv_match match_data;
+
+	merged_caps = bt_bap_merge_caps(l2_caps, l3_caps);
+	if (!merged_caps)
+		return;
+
 	/* Check each BIS Codec Specific Configuration LTVs against our Codec
 	 * Specific Capabilities and if the BIS matches create a PAC with it
 	 */
-	match_data = bap_check_bis(bap->ldb, merge_data.result);
+	match_data = bap_check_bis(bap->ldb, merged_caps);
 	if (match_data.found == true) {
-		*caps = merge_data.result;
+		*caps = merged_caps;
 		*lpac = match_data.data;
 		DBG(bap, "Matching BIS %i", bis_index);
 	} else {
-		util_iov_free(merge_data.result, 1);
+		util_iov_free(merged_caps, 1);
 		*caps = NULL;
 		*lpac = NULL;
 	}
diff --git a/src/shared/bap.h b/src/shared/bap.h
index b35b2711e..e63161dca 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -251,6 +251,8 @@ bool bt_bap_pac_bcast_is_local(struct bt_bap *bap, struct bt_bap_pac *pac);
 
 struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream);
 
+struct iovec *bt_bap_merge_caps(struct iovec *l2_caps, struct iovec *l3_caps);
+
 void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index,
 		struct bt_bap_codec *codec,
 		struct iovec *l2_caps,
-- 
2.39.2





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux