From: "Maheta, Abhay" <abhay.maheshbhai.maheta@xxxxxxxxx> This adds new API to set stream metadata. --- src/shared/bap.c | 20 ++++++++++++++++---- src/shared/bap.h | 2 ++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 0ae0eba33..cc89d65a3 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -2787,7 +2787,7 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type, struct bt_pac *p; struct bt_ltv *cc; struct bt_pac_metadata *meta; - struct iovec data, metadata; + struct iovec data, *metadata = NULL; p = iov_pull_mem(&iov, sizeof(*p)); if (!p) { @@ -2816,13 +2816,16 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type, data.iov_len = p->cc_len; data.iov_base = cc; - metadata.iov_len = meta->len; - metadata.iov_base = meta->data; + if (meta->len) { + metadata = new0(struct iovec, 1); + metadata->iov_len = meta->len; + metadata->iov_base = meta->data; + } iov_pull_mem(&iov, meta->len); pac = bap_pac_new(bap->rdb, NULL, type, &p->codec, NULL, &data, - &metadata); + metadata); if (!pac) continue; @@ -4567,6 +4570,15 @@ struct bt_bap_qos *bt_bap_stream_get_qos(struct bt_bap_stream *stream) return &stream->qos; } +void bt_bap_stream_set_metadata(struct bt_bap_stream *stream, + struct iovec *meta) +{ + if (!stream) + return; + + stream->meta = meta; +} + struct iovec *bt_bap_stream_get_metadata(struct bt_bap_stream *stream) { if (!stream) diff --git a/src/shared/bap.h b/src/shared/bap.h index 923669f32..0c83726da 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -249,6 +249,8 @@ uint8_t bt_bap_stream_get_dir(struct bt_bap_stream *stream); uint32_t bt_bap_stream_get_location(struct bt_bap_stream *stream); struct iovec *bt_bap_stream_get_config(struct bt_bap_stream *stream); struct bt_bap_qos *bt_bap_stream_get_qos(struct bt_bap_stream *stream); +void bt_bap_stream_set_metadata(struct bt_bap_stream *stream, + struct iovec *meta); struct iovec *bt_bap_stream_get_metadata(struct bt_bap_stream *stream); struct io *bt_bap_stream_get_io(struct bt_bap_stream *stream); -- 2.25.1