Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: Audio: redone the base subgroup struct. #68676

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions include/zephyr/bluetooth/audio/bap.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
extern "C" {
#endif


#if defined(CONFIG_BT_BAP_SCAN_DELEGATOR)
#define BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN
#define BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS
#else
#define BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN 0
#define BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS 0
#endif

/** Periodic advertising state reported by the Scan Delegator */
enum bt_bap_pa_state {
/** The periodic advertising has not been synchronized */
Expand Down Expand Up @@ -255,15 +246,17 @@ struct bt_bap_unicast_group;
struct bt_bap_ep;

/** Struct to hold subgroup specific information for the receive state */
struct bt_bap_scan_delegator_subgroup {
struct bt_bap_bass_subgroup {
/** BIS synced bitfield */
uint32_t bis_sync;

/** Length of the metadata */
uint8_t metadata_len;

#if defined(CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE)
/** The metadata */
uint8_t metadata[BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN];
uint8_t metadata[CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE];
Thalley marked this conversation as resolved.
Show resolved Hide resolved
#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE */
};

/** Represents the Broadcast Audio Scan Service receive state */
Expand Down Expand Up @@ -296,7 +289,7 @@ struct bt_bap_scan_delegator_recv_state {
uint8_t num_subgroups;

/** Subgroup specific information */
struct bt_bap_scan_delegator_subgroup subgroups[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS];
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
Thalley marked this conversation as resolved.
Show resolved Hide resolved
};

struct bt_bap_scan_delegator_cb {
Expand Down Expand Up @@ -367,7 +360,6 @@ struct bt_bap_scan_delegator_cb {
void (*broadcast_code)(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE]);

/**
* @brief Broadcast Isochronous Stream synchronize request
*
Expand All @@ -391,7 +383,7 @@ struct bt_bap_scan_delegator_cb {
*/
int (*bis_sync_req)(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint32_t bis_sync_req[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS]);
const uint32_t bis_sync_req[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS]);
Thalley marked this conversation as resolved.
Show resolved Hide resolved
};

/** Structure holding information of audio stream endpoint */
Expand Down Expand Up @@ -1921,7 +1913,7 @@ int bt_bap_scan_delegator_set_pa_state(uint8_t src_id,
*/
int bt_bap_scan_delegator_set_bis_sync_state(
uint8_t src_id,
uint32_t bis_synced[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS]);
uint32_t bis_synced[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS]);

struct bt_bap_scan_delegator_add_src_param {
/** The periodic adverting sync */
Expand All @@ -1937,7 +1929,7 @@ struct bt_bap_scan_delegator_add_src_param {
uint8_t num_subgroups;

/** Subgroup specific information */
struct bt_bap_scan_delegator_subgroup subgroups[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS];
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
};

/**
Expand Down Expand Up @@ -1974,7 +1966,7 @@ struct bt_bap_scan_delegator_mod_src_param {
* If a subgroup's metadata_len is set to 0, the existing metadata
* for the subgroup will remain unchanged
*/
struct bt_bap_scan_delegator_subgroup subgroups[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS];
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
};

/**
Expand Down Expand Up @@ -2214,7 +2206,7 @@ struct bt_bap_broadcast_assistant_add_src_param {
uint8_t num_subgroups;

/** Pointer to array of subgroups */
struct bt_bap_scan_delegator_subgroup *subgroups;
struct bt_bap_bass_subgroup *subgroups;
};

/**
Expand Down Expand Up @@ -2247,7 +2239,7 @@ struct bt_bap_broadcast_assistant_mod_src_param {
uint8_t num_subgroups;

/** Pointer to array of subgroups */
struct bt_bap_scan_delegator_subgroup *subgroups;
struct bt_bap_bass_subgroup *subgroups;
};

/** @brief Modify a source on the server.
Expand Down
2 changes: 1 addition & 1 deletion include/zephyr/bluetooth/audio/cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ struct bt_cap_commander_broadcast_reception_start_member_param {
*
* At least one bit in one of the subgroups bis_sync parameters shall be set.
*/
struct bt_bap_scan_delegator_subgroup *subgroups;
struct bt_bap_bass_subgroup *subgroups;

/** Number of subgroups */
size_t num_subgroups;
Expand Down
4 changes: 0 additions & 4 deletions samples/bluetooth/broadcast_audio_assistant/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ CONFIG_BT_TINYCRYPT_ECC=y

CONFIG_BT_EXT_ADV=y
CONFIG_BT_BAP_BROADCAST_ASSISTANT=y

# CONFIG_BT_BAP_SCAN_DELEGATOR=y is required until the following
# bug is fixed: https://github.com/zephyrproject-rtos/zephyr/issues/68338
CONFIG_BT_BAP_SCAN_DELEGATOR=y
2 changes: 1 addition & 1 deletion samples/bluetooth/broadcast_audio_assistant/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
int main(void)
{
int err;
struct bt_bap_scan_delegator_subgroup subgroup = { 0 };
struct bt_bap_bass_subgroup subgroup = { 0 };
struct bt_bap_broadcast_assistant_add_src_param param = { 0 };

err = bt_enable(NULL);
Expand Down
2 changes: 1 addition & 1 deletion samples/bluetooth/broadcast_audio_sink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CONFIG_BT_BAP_SCAN_DELEGATOR=y
CONFIG_BT_ISO_MAX_CHAN=2
CONFIG_BT_BAP_BROADCAST_SNK_SUBGROUP_COUNT=2
CONFIG_BT_BAP_BROADCAST_SNK_STREAM_COUNT=2
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS=2
CONFIG_BT_BAP_BASS_MAX_SUBGROUPS=2
CONFIG_BT_BUF_ACL_RX_SIZE=255
CONFIG_BT_BUF_ACL_TX_SIZE=251

Expand Down
2 changes: 1 addition & 1 deletion samples/bluetooth/broadcast_audio_sink/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ static void broadcast_code_cb(struct bt_conn *conn,

static int bis_sync_req_cb(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint32_t bis_sync_req[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS])
const uint32_t bis_sync_req[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS])
{
const bool bis_synced = k_sem_count_get(&sem_bis_synced) > 0U;

Expand Down
24 changes: 10 additions & 14 deletions subsys/bluetooth/audio/Kconfig.bap
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ config BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE
help
Number of octets to support for Codec Specific Configuration metadata.

config BT_BAP_BASS_MAX_SUBGROUPS
int "Maximum number of subgroups supported for the BASS receive states"
default 1
range 1 24
help
This option sets the maximum number of subgroups supported.
Due to limitations in advertising data, the maximum size of all subgroups are 249.
The minimum size of a subgroup is 10 octets.
So effectively there can be a maximum of 24 subgroups in a BASE.

config BT_AUDIO_CODEC_CAP_MAX_DATA_SIZE
int "Codec Capabilities Data Size"
default 19
Expand Down Expand Up @@ -221,20 +231,6 @@ config BT_BAP_SCAN_DELEGATOR_RECV_STATE_COUNT
server. Each characteristic may hold information to sync to a
periodic advertise or a broadcast isochronous stream.

config BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN
int "Scan Delegator Maximum Metadata Length"
default 32
range 0 255
help
The maximum metadata length support by the BASS server.

config BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS
int "Scan Delegator Maximum Number of Subgroups support"
default 1
range 0 31
help
The maximum number of BIS subgroups supported.

config BT_BAP_SCAN_DELEGATOR_BUF_TIMEOUT
int "Milliseconds of timeout when handle concurrent access to the long read ASE buffer"
range 0 1000
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/audio/bap_broadcast_assistant.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static int parse_recv_state(const void *data, uint16_t length,

recv_state->num_subgroups = net_buf_simple_pull_u8(&buf);
for (int i = 0; i < recv_state->num_subgroups; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup = &recv_state->subgroups[i];
struct bt_bap_bass_subgroup *subgroup = &recv_state->subgroups[i];
uint8_t *metadata;

if (buf.len < sizeof(subgroup->bis_sync)) {
Expand Down
6 changes: 3 additions & 3 deletions subsys/bluetooth/audio/bap_broadcast_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static void update_recv_state_big_synced(const struct bt_bap_broadcast_sink *sin

mod_src_param.num_subgroups = sink->subgroup_count;
for (uint8_t i = 0U; i < sink->subgroup_count; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup_param = &mod_src_param.subgroups[i];
struct bt_bap_bass_subgroup *subgroup_param = &mod_src_param.subgroups[i];
const struct bt_bap_broadcast_sink_subgroup *sink_subgroup = &sink->subgroups[i];

/* Set the bis_sync value to the indexes available per subgroup */
Expand Down Expand Up @@ -440,7 +440,7 @@ static void broadcast_sink_add_src(struct bt_bap_broadcast_sink *sink)
static bool base_subgroup_meta_cb(const struct bt_bap_base_subgroup *subgroup, void *user_data)
{
struct bt_bap_scan_delegator_mod_src_param *mod_src_param = user_data;
struct bt_bap_scan_delegator_subgroup *subgroup_param;
struct bt_bap_bass_subgroup *subgroup_param;
uint8_t *meta;
int ret;

Expand Down Expand Up @@ -496,7 +496,7 @@ static void update_recv_state_base(const struct bt_bap_broadcast_sink *sink,
mod_src_param.broadcast_id = recv_state->broadcast_id;
mod_src_param.num_subgroups = sink->subgroup_count;
for (uint8_t i = 0U; i < sink->subgroup_count; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup_param = &mod_src_param.subgroups[i];
struct bt_bap_bass_subgroup *subgroup_param = &mod_src_param.subgroups[i];
const struct bt_bap_broadcast_sink_subgroup *sink_subgroup = &sink->subgroups[i];

/* Set the bis_sync value to the indexes available per subgroup */
Expand Down
Loading
Loading