mbox series

[BlueZ,v4,0/6] Add support for BAP broadcast sink

Message ID 20230802132355.4953-1-claudia.rosu@nxp.com
Headers show
Series Add support for BAP broadcast sink | expand

Message

Claudia Draghicescu Aug. 2, 2023, 1:23 p.m. UTC
This series of patches adds support for BAP broadcast sink.
It consists in registering a broadcastsink endpoint using the
Basic Audio Announcement Service UUID,
discovering of broadcast advertisers that announce the
Broadcast Audio Announcement Service, synchronizes to the Periodic
advertisements of the source and synchronizes to the BIG advertised
in the PA train.
To retrieve the BASE info advertised in the PA train, the patch
Bluetooth: ISO: Add support for periodic adv reports processing
was used.

This feature was tested using bluetoothctl with the following commands:

[bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06
[bluetooth]# scan on
[NEW] Endpoint /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0
[bluetooth]# endpoint.config
/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0
/local/endpoint/ep0 16_2_1

Claudia Draghicescu (6):
  client/player: Add broadcast sink endpoint registration
  btio: Add support for getsockopt(BT_ISO_BASE)
  adapter: Broadcast source discovery
  bap: Create synchronization with source and create BAP broadcast sink
    stream
  media: Add broadcast sink media endpoint
  transport: Update transport properties for a broadcast stream

 btio/btio.c                |  13 +-
 client/player.c            |  61 +++++++-
 profiles/audio/bap.c       | 300 +++++++++++++++++++++++++++++++++----
 profiles/audio/media.c     |  81 ++++++++--
 profiles/audio/media.h     |   3 +-
 profiles/audio/transport.c | 245 +++++++++++++++++++++++++++++-
 src/adapter.c              |  48 ++++++
 src/adapter.h              |   2 +
 src/shared/bap.c           | 153 ++++++++++++++++---
 src/shared/bap.h           |  11 +-
 10 files changed, 835 insertions(+), 82 deletions(-)


base-commit: 8eb1dee87e019f29b6c8233dfe0f9aef8ee44461

Comments

Luiz Augusto von Dentz Aug. 2, 2023, 5:38 p.m. UTC | #1
Hi Claudia,

On Wed, Aug 2, 2023 at 6:49 AM Claudia Draghicescu <claudia.rosu@nxp.com> wrote:
>
> This adds a new method in the adapter driver, device_resolved() called
> when a broadcast source that advertises the BCAA_UUID is discovered.
>
> ---
>  src/adapter.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  src/adapter.h |  2 ++
>  2 files changed, 50 insertions(+)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 491bd7031..29c6a576a 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -7029,6 +7029,45 @@ static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data,
>         return got_match;
>  }
>
> +static int find_baas(gconstpointer a, gconstpointer b)
> +{
> +       const struct eir_sd *sd = a;
> +       const char *baas_uuid = b;
> +
> +       return strcmp(sd->uuid, baas_uuid);
> +}
> +
> +static bool accept_bcast_adv(struct btd_adapter *adapter)
> +{
> +       if ((btd_adapter_has_settings(adapter, MGMT_SETTING_ISO_SYNC_RECEIVER)))
> +               return true;
> +
> +       return false;
> +}
> +
> +static bool is_bcast_source(struct eir_data *eir_data)
> +{
> +       if (!(eir_data->flags & (EIR_LIM_DISC | EIR_GEN_DISC))
> +               && (g_slist_find_custom(eir_data->sd_list,
> +                               BCAA_SERVICE_UUID, find_baas))) {
> +               return true;
> +       }
> +
> +       return false;
> +}
> +static void bcast_new_source(struct btd_adapter *adapter,
> +                                struct btd_device *device)
> +{
> +       GSList *l;
> +
> +       for (l = adapter->drivers; l; l = g_slist_next(l)) {
> +               struct btd_adapter_driver *driver = l->data;
> +
> +               if (!strcmp(driver->name, "bcast"))
> +                       driver->device_discovered(adapter, device);
> +       }
> +}

This code probably doesn't belong here, profile specific code like the
above shall be left to the plugin to handle.

>  static void filter_duplicate_data(void *data, void *user_data)
>  {
>         struct discovery_client *client = data;
> @@ -7152,12 +7191,21 @@ void btd_adapter_device_found(struct btd_adapter *adapter,
>                         return;
>                 }
>
> +               if (accept_bcast_adv(adapter) && is_bcast_source(&eir_data))
> +                       monitoring = true;
> +
>                 if (!discoverable && !monitoring && !eir_data.rsi) {
>                         eir_data_free(&eir_data);
>                         return;
>                 }
>
>                 dev = adapter_create_device(adapter, bdaddr, bdaddr_type);
> +
> +               if (dev && is_bcast_source(&eir_data)) {
> +                       bcast_new_source(adapter, dev);
> +                       btd_device_set_temporary(dev, false);
> +               }
> +
>         }
>
>         if (!dev) {
> diff --git a/src/adapter.h b/src/adapter.h
> index ca96c1f65..ee32f7110 100644
> --- a/src/adapter.h
> +++ b/src/adapter.h
> @@ -125,6 +125,8 @@ struct btd_adapter_driver {
>                                                 struct btd_device *device);
>         void (*device_resolved)(struct btd_adapter *adapter,
>                                                 struct btd_device *device);
> +       void (*device_discovered)(struct btd_adapter *adapter,
> +                                               struct btd_device *device);

Let me figure out the driver interface since I think it is better to
use the btd_device_driver and then have a generic match by UUID.

>         /* Indicates the driver is experimental and shall only be registered
>          * when experimental has been enabled (see: main.conf:Experimental).
> --
> 2.34.1
>