2024-04-19 18:10:29

by Andrei Istodorescu

[permalink] [raw]
Subject: [PATCH BlueZ 0/5] Create transports for matching BISes

This patch refactors the flow for the BAP Broadcast Sink.
After observing the BASE information, streams and transports will be
generated for each BIS that matches local PAC capabilities.
Because endpoints are not available any more, local PAC (which contain
local registered capabilities) has a new list of setups. Each setup is
generated based on the matching BIS observed.
Then, the setup is used to configure a stream which then generates a
MediaTransport.
The transport is in the TRANSPORT_STATE_IDLE state until someone
acquires it. The "Acquire" procedure results in creating the IO using
BIG Create Sync. The successful reply of it causes the transport to be
advanced in TRANSPORT_STATE_ACTIVE state.

bluetoothctl log with two transports being created and acquired:
endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): a
[/local/endpoint/ep0] Locations: 3
[/local/endpoint/ep0] Supported Context (value): 3
Capabilities:
03 01 ff 00 02 02 03 02 03 03 05 04 1a 00 f0 00 ................
Metadata:
[bluetooth]# Endpoint /local/endpoint/ep0 registered

scan le

[bluetooth]# SetDiscoveryFilter success
[bluetooth]# hci7 type 6 discovering on
[bluetooth]# Discovery started
[bluetooth]# [CHG] Controller 00:60:37:A6:AE:22 Discovering: yes
[bluetooth]# [NEW] Device 07:34:BB:4B:6F:C3 07-34-BB-4B-6F-C3
[bluetooth]# hci7 07:34:BB:4B:6F:C3 type LE Random connected eir_len 0
[bluetooth]# [NEW] Transport /org/bluez/hci7/dev_07_34_BB_4B_6F_C3/bis1/
fd0
[bluetooth]# Endpoint: SetConfiguration
[bluetooth]# Transport /org/bluez/hci7/dev_07_34_BB_4B_6F_C3/bis1/fd0
[bluetooth]# Properties.Device: /org/bluez/hci7/dev_07_34_BB_4B_6F_C3
[bluetooth]# Auto Accepting...
[bluetooth]# [NEW] Transport /org/bluez/hci7/dev_07_34_BB_4B_6F_C3/bis2/
fd1
[bluetooth]# Endpoint: SetConfiguration
[bluetooth]# Transport /org/bluez/hci7/dev_07_34_BB_4B_6F_C3/bis2/fd1
[bluetooth]# Properties.Device: /org/bluez/hci7/dev_07_34_BB_4B_6F_C3
[bluetooth]# Auto Accepting...
[CHG] Device 07:34:BB:4B:6F:C3 Connected: yes

[07-34-BB-4B-6F-C3]# transport.acquire /org/bluez/hci7/
dev_07_34_BB_4B_6F_C3/bis1/fd0
auto acquiring...
Transport /org/bluez/hci7/dev_07_34_BB_4B_6F_C3/bis1/fd0 acquiring
[07-34-BB-4B-6F-C3]# hci7 07:34:BB:4B:6F:C3 type LE Random connected
eir_len 0
[07-34-BB-4B-6F-C3]# hci7 07:34:BB:4B:6F:C3 type LE Random connected
eir_len 0
[07-34-BB-4B-6F-C3]# Transport /org/bluez/hci7/dev_07_34_BB_4B_6F_C3/
bis1/fd0 acquiring complete
[07-34-BB-4B-6F-C3]# Acquire successful: fd 8 MTU 40:0
[07-34-BB-4B-6F-C3]# [CHG] Transport /org/bluez/hci7/
dev_07_34_BB_4B_6F_C3/bis1/fd0 State: active
hci7 type 6 discovering offm[seq 0] recv: 0 bytes # 1
hci7 type 6 discovering on9m[seq 146] recv: 0 bytes # 7
hci7 type 6 discovering offm[seq 149] recv: 0 bytes # 50
hci7 type 6 discovering on
[seq 2446] recv: 0 bytes #transport.release /org/bluez/hci7/
dev_07_34_BB_4B_6F_C3/bis1/fd0
[07-34-BB-4B-6F-C3]# [CHG] Transport /org/bluez/hci7/dev_07_34_BB_4B_6F_C3
/bis1/fd0 State: idle
[07-34-BB-4B-6F-C3]# Release successful

[07-34-BB-4B-6F-C3]# transport.acquire /org/bluez/hci7/
dev_07_34_BB_4B_6F_C3/bis2/fd1
auto acquiring...
Transport /org/bluez/hci7/dev_07_34_BB_4B_6F_C3/bis2/fd1 acquiring
[07-34-BB-4B-6F-C3]# hci7 07:34:BB:4B:6F:C3 type LE Random connected
eir_len 0
[07-34-BB-4B-6F-C3]# hci7 07:34:BB:4B:6F:C3 type LE Random connected
eir_len 0
[07-34-BB-4B-6F-C3]# Transport /org/bluez/hci7/dev_07_34_BB_4B_6F_C3/bis2
/fd1 acquiring complete
[07-34-BB-4B-6F-C3]# Acquire successful: fd 9 MTU 40:0
[07-34-BB-4B-6F-C3]# [CHG] Transport /org/bluez/hci7/dev_07_34_BB_4B_6F_C3
/bis2/fd1 State: active
hci7 type 6 discovering off
hci7 type 6 discovering on
[seq 1330] recv: 0 bytes #transport.release /org/bluez/hci7/
dev_07_34_BB_4B_6F_C3/bis2/fd1
[07-34-BB-4B-6F-C3]# 1;39m[seq 1331] recv: 0 bytes #Transport fd
disconnected
[07-34-BB-4B-6F-C3]# [CHG] Transport /org/bluez/hci7/dev_07_34_BB_4B_6F_C3
/bis2/fd1 State: idle
[07-34-BB-4B-6F-C3]# Release successful

Andrei Istodorescu (5):
shared/bap: Allow NULL bap endpoint in streams
shared/bap: Get broadcast channel location from stream capabilities
shared/bap: Update stream management to avoid PACs
shared/bap: In case of a BIS-PAC match return also the local pac
bap: Create streams and transports for each matching BIS

profiles/audio/bap.c | 184 ++++++++++++++++++++--------
src/shared/bap.c | 280 +++++++++++++++++++++----------------------
src/shared/bap.h | 6 +-
3 files changed, 279 insertions(+), 191 deletions(-)

--
2.40.1



2024-04-19 18:10:44

by Andrei Istodorescu

[permalink] [raw]
Subject: [PATCH BlueZ 3/5] shared/bap: Update stream management to avoid PACs

Set the stream to enabling for BAP Broadcast Sink, when the transport is
acquired.
Remove PAC logic for BAP Broadcast Sink stream creation.
---
src/shared/bap.c | 60 +++++-------------------------------------------
1 file changed, 6 insertions(+), 54 deletions(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 36f0b0a3b50a..d7a2f9381c53 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -2006,7 +2006,7 @@ static unsigned int bap_bcast_enable(struct bt_bap_stream *stream,
void *user_data)
{
if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE)
- stream_set_state(stream, BT_BAP_STREAM_STATE_STREAMING);
+ stream_set_state(stream, BT_BAP_STREAM_STATE_ENABLING);
else
stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG);

@@ -5287,7 +5287,6 @@ void bt_bap_cancel_select(struct bt_bap_pac *lpac, bt_bap_pac_select_t func,

static struct bt_bap_stream *bap_bcast_stream_new(struct bt_bap *bap,
struct bt_bap_pac *lpac,
- struct bt_bap_pac *rpac,
struct bt_bap_qos *pqos,
struct iovec *data)
{
@@ -5298,71 +5297,24 @@ static struct bt_bap_stream *bap_bcast_stream_new(struct bt_bap *bap,
if (!bap)
return NULL;

- if (!rpac && (lpac->type != BT_BAP_BCAST_SOURCE)
- && queue_isempty(bap->remote_eps))
- return NULL;
-
- if (lpac && rpac) {
- if ((rpac->type != BT_BAP_BCAST_SOURCE)
- && (!bap_codec_equal(&lpac->codec, &rpac->codec)))
- return NULL;
- } else {
- uint8_t type;
-
+ if (lpac->type == BT_BAP_BCAST_SOURCE) {
match.lpac = lpac;
- match.rpac = rpac;
+ match.rpac = NULL;
memset(&match.codec, 0, sizeof(match.codec));

- if (rpac)
- type = rpac->type;
- else if (lpac) {
- switch (lpac->type) {
- case BT_BAP_BCAST_SOURCE:
- type = BT_BAP_BCAST_SINK;
- break;
- case BT_BAP_BCAST_SINK:
- type = BT_BAP_BCAST_SOURCE;
- break;
- default:
- return NULL;
- }
- } else
- return NULL;
-
- bt_bap_foreach_pac(bap, type, match_pac, &match);
+ bt_bap_foreach_pac(bap, BT_BAP_BCAST_SINK, match_pac, &match);
if ((!match.lpac) || (!lpac))
return NULL;
- if (!match.rpac && (lpac->type != BT_BAP_BCAST_SOURCE))
- return NULL;

lpac = match.lpac;
- rpac = match.rpac;
- }
-
- match.lpac = lpac;
- match.rpac = rpac;

- if (lpac->type != BT_BAP_BCAST_SOURCE) {
- /* Check for existing stream */
- ep = queue_find(bap->remote_eps, find_ep_pacs, &match);
- if (!ep) {
- /* Check for unused ASE */
- ep = queue_find(bap->remote_eps, find_ep_unused,
- &match);
- if (!ep) {
- DBG(bap, "Unable to find unused ASE");
- return NULL;
- }
- }
- stream = ep->stream;
- } else {
ep = queue_find(bap->remote_eps, find_ep_source, NULL);
if (!ep)
return NULL;
}

if (!stream)
- stream = bap_stream_new(bap, ep, lpac, rpac, data, true);
+ stream = bap_stream_new(bap, ep, lpac, NULL, data, true);

return stream;
}
@@ -5415,7 +5367,7 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap,
if (bt_bap_get_att(bap))
return bap_ucast_stream_new(bap, lpac, rpac, pqos, data);

- return bap_bcast_stream_new(bap, lpac, rpac, pqos, data);
+ return bap_bcast_stream_new(bap, lpac, pqos, data);
}

struct bt_bap *bt_bap_stream_get_session(struct bt_bap_stream *stream)
--
2.40.1


2024-04-19 19:33:43

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH BlueZ 3/5] shared/bap: Update stream management to avoid PACs

Hi Andrei,

On Fri, Apr 19, 2024 at 2:08 PM Andrei Istodorescu
<[email protected]> wrote:
>
> Set the stream to enabling for BAP Broadcast Sink, when the transport is
> acquired.
> Remove PAC logic for BAP Broadcast Sink stream creation.
> ---
> src/shared/bap.c | 60 +++++-------------------------------------------
> 1 file changed, 6 insertions(+), 54 deletions(-)
>
> diff --git a/src/shared/bap.c b/src/shared/bap.c
> index 36f0b0a3b50a..d7a2f9381c53 100644
> --- a/src/shared/bap.c
> +++ b/src/shared/bap.c
> @@ -2006,7 +2006,7 @@ static unsigned int bap_bcast_enable(struct bt_bap_stream *stream,
> void *user_data)
> {
> if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE)
> - stream_set_state(stream, BT_BAP_STREAM_STATE_STREAMING);
> + stream_set_state(stream, BT_BAP_STREAM_STATE_ENABLING);

There is no Enabling state for Broadcast Stream in BAP:

https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/16212-BAP-html5/out/en/index-en.html#UUID-4a295bf2-6e50-be11-e827-c23e63569087_figure-idm4631863059107233170457600297

> else
> stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG);
>
> @@ -5287,7 +5287,6 @@ void bt_bap_cancel_select(struct bt_bap_pac *lpac, bt_bap_pac_select_t func,
>
> static struct bt_bap_stream *bap_bcast_stream_new(struct bt_bap *bap,
> struct bt_bap_pac *lpac,
> - struct bt_bap_pac *rpac,
> struct bt_bap_qos *pqos,
> struct iovec *data)
> {
> @@ -5298,71 +5297,24 @@ static struct bt_bap_stream *bap_bcast_stream_new(struct bt_bap *bap,
> if (!bap)
> return NULL;
>
> - if (!rpac && (lpac->type != BT_BAP_BCAST_SOURCE)
> - && queue_isempty(bap->remote_eps))
> - return NULL;
> -
> - if (lpac && rpac) {
> - if ((rpac->type != BT_BAP_BCAST_SOURCE)
> - && (!bap_codec_equal(&lpac->codec, &rpac->codec)))
> - return NULL;
> - } else {
> - uint8_t type;
> -
> + if (lpac->type == BT_BAP_BCAST_SOURCE) {
> match.lpac = lpac;
> - match.rpac = rpac;
> + match.rpac = NULL;
> memset(&match.codec, 0, sizeof(match.codec));
>
> - if (rpac)
> - type = rpac->type;
> - else if (lpac) {
> - switch (lpac->type) {
> - case BT_BAP_BCAST_SOURCE:
> - type = BT_BAP_BCAST_SINK;
> - break;
> - case BT_BAP_BCAST_SINK:
> - type = BT_BAP_BCAST_SOURCE;
> - break;
> - default:
> - return NULL;
> - }
> - } else
> - return NULL;
> -
> - bt_bap_foreach_pac(bap, type, match_pac, &match);
> + bt_bap_foreach_pac(bap, BT_BAP_BCAST_SINK, match_pac, &match);
> if ((!match.lpac) || (!lpac))
> return NULL;
> - if (!match.rpac && (lpac->type != BT_BAP_BCAST_SOURCE))
> - return NULL;
>
> lpac = match.lpac;
> - rpac = match.rpac;
> - }
> -
> - match.lpac = lpac;
> - match.rpac = rpac;
>
> - if (lpac->type != BT_BAP_BCAST_SOURCE) {
> - /* Check for existing stream */
> - ep = queue_find(bap->remote_eps, find_ep_pacs, &match);
> - if (!ep) {
> - /* Check for unused ASE */
> - ep = queue_find(bap->remote_eps, find_ep_unused,
> - &match);
> - if (!ep) {
> - DBG(bap, "Unable to find unused ASE");
> - return NULL;
> - }
> - }
> - stream = ep->stream;
> - } else {
> ep = queue_find(bap->remote_eps, find_ep_source, NULL);
> if (!ep)
> return NULL;
> }
>
> if (!stream)
> - stream = bap_stream_new(bap, ep, lpac, rpac, data, true);
> + stream = bap_stream_new(bap, ep, lpac, NULL, data, true);
>
> return stream;
> }
> @@ -5415,7 +5367,7 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap,
> if (bt_bap_get_att(bap))
> return bap_ucast_stream_new(bap, lpac, rpac, pqos, data);
>
> - return bap_bcast_stream_new(bap, lpac, rpac, pqos, data);
> + return bap_bcast_stream_new(bap, lpac, pqos, data);
> }
>
> struct bt_bap *bt_bap_stream_get_session(struct bt_bap_stream *stream)
> --
> 2.40.1
>


--
Luiz Augusto von Dentz

2024-04-23 17:40:52

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ 0/5] Create transports for matching BISes

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Fri, 19 Apr 2024 21:07:47 +0300 you wrote:
> This patch refactors the flow for the BAP Broadcast Sink.
> After observing the BASE information, streams and transports will be
> generated for each BIS that matches local PAC capabilities.
> Because endpoints are not available any more, local PAC (which contain
> local registered capabilities) has a new list of setups. Each setup is
> generated based on the matching BIS observed.
> Then, the setup is used to configure a stream which then generates a
> MediaTransport.
> The transport is in the TRANSPORT_STATE_IDLE state until someone
> acquires it. The "Acquire" procedure results in creating the IO using
> BIG Create Sync. The successful reply of it causes the transport to be
> advanced in TRANSPORT_STATE_ACTIVE state.
>
> [...]

Here is the summary with links:
- [BlueZ,1/5] shared/bap: Allow NULL bap endpoint in streams
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5b4d9abfdeee
- [BlueZ,2/5] shared/bap: Get broadcast channel location from stream capabilities
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=30b741baa569
- [BlueZ,3/5] shared/bap: Update stream management to avoid PACs
(no matching commit)
- [BlueZ,4/5] shared/bap: In case of a BIS-PAC match return also the local pac
(no matching commit)
- [BlueZ,5/5] bap: Create streams and transports for each matching BIS
(no matching commit)

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html