1 /* btp_bap_broadcast.h - Bluetooth BAP Tester */ 2 3 /* 4 * Copyright (c) 2023 Codecoup 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 9 #include <zephyr/bluetooth/audio/cap.h> 10 11 struct btp_bap_broadcast_stream { 12 struct btp_bap_audio_stream audio_stream; 13 struct bt_audio_codec_cfg codec_cfg; 14 uint8_t bis_id; 15 uint8_t subgroup_id; 16 bool bis_synced; 17 uint8_t source_id; 18 bool in_use; 19 bool already_sent; 20 }; 21 22 /* According to BT spec, a Broadcast Source can configure and establish one or more BIGs, 23 * each containing one or more BISes that are used to transport broadcast Audio Streams. 24 * For each BIG, the Broadcast Source shall generate a Broadcast_ID. 25 * For the time being, let's treat broadcast source as one BIG. 26 */ 27 struct btp_bap_broadcast_remote_source { 28 bt_addr_le_t address; 29 uint32_t broadcast_id; 30 struct btp_bap_broadcast_stream streams[CONFIG_BT_BAP_BROADCAST_SNK_STREAM_COUNT]; 31 struct bt_bap_stream *sink_streams[CONFIG_BT_BAP_BROADCAST_SNK_STREAM_COUNT]; 32 struct bt_bap_broadcast_sink *sink; 33 struct bt_bap_qos_cfg qos; 34 /* BIS Index bitfield read from Base */ 35 uint32_t bis_index_bitfield; 36 /* BIS Index bitfield read from sync request */ 37 uint32_t requested_bis_sync; 38 bool assistant_request; 39 uint8_t sink_broadcast_code[BT_ISO_BROADCAST_CODE_SIZE]; 40 const struct bt_bap_scan_delegator_recv_state *sink_recv_state; 41 }; 42 43 struct btp_bap_broadcast_local_source { 44 uint32_t broadcast_id; 45 struct bt_bap_qos_cfg qos; 46 struct btp_bap_broadcast_stream streams[CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT]; 47 struct bt_audio_codec_cfg subgroup_codec_cfg[CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT]; 48 uint8_t stream_count; 49 /* Only for BTP BAP commands */ 50 struct bt_bap_broadcast_source *bap_broadcast; 51 /* Only for BTP CAP commands */ 52 struct bt_cap_broadcast_source *cap_broadcast; 53 }; 54 55 int btp_bap_broadcast_init(void); 56 struct btp_bap_broadcast_local_source *btp_bap_broadcast_local_source_get(uint8_t source_id); 57 struct btp_bap_broadcast_stream *btp_bap_broadcast_stream_alloc( 58 struct btp_bap_broadcast_local_source *source); 59 60 uint8_t btp_bap_broadcast_source_setup(const void *cmd, uint16_t cmd_len, 61 void *rsp, uint16_t *rsp_len); 62 uint8_t btp_bap_broadcast_source_release(const void *cmd, uint16_t cmd_len, 63 void *rsp, uint16_t *rsp_len); 64 uint8_t btp_bap_broadcast_adv_start(const void *cmd, uint16_t cmd_len, 65 void *rsp, uint16_t *rsp_len); 66 uint8_t btp_bap_broadcast_adv_stop(const void *cmd, uint16_t cmd_len, 67 void *rsp, uint16_t *rsp_len); 68 uint8_t btp_bap_broadcast_source_start(const void *cmd, uint16_t cmd_len, 69 void *rsp, uint16_t *rsp_len); 70 uint8_t btp_bap_broadcast_source_stop(const void *cmd, uint16_t cmd_len, 71 void *rsp, uint16_t *rsp_len); 72 uint8_t btp_bap_broadcast_sink_setup(const void *cmd, uint16_t cmd_len, 73 void *rsp, uint16_t *rsp_len); 74 uint8_t btp_bap_broadcast_sink_release(const void *cmd, uint16_t cmd_len, 75 void *rsp, uint16_t *rsp_len); 76 uint8_t btp_bap_broadcast_scan_start(const void *cmd, uint16_t cmd_len, 77 void *rsp, uint16_t *rsp_len); 78 uint8_t btp_bap_broadcast_scan_stop(const void *cmd, uint16_t cmd_len, 79 void *rsp, uint16_t *rsp_len); 80 uint8_t btp_bap_broadcast_sink_sync(const void *cmd, uint16_t cmd_len, 81 void *rsp, uint16_t *rsp_len); 82 uint8_t btp_bap_broadcast_sink_stop(const void *cmd, uint16_t cmd_len, 83 void *rsp, uint16_t *rsp_len); 84 uint8_t btp_bap_broadcast_sink_bis_sync(const void *cmd, uint16_t cmd_len, 85 void *rsp, uint16_t *rsp_len); 86 uint8_t btp_bap_broadcast_discover_scan_delegators(const void *cmd, uint16_t cmd_len, 87 void *rsp, uint16_t *rsp_len); 88 uint8_t btp_bap_broadcast_assistant_scan_start(const void *cmd, uint16_t cmd_len, 89 void *rsp, uint16_t *rsp_len); 90 uint8_t btp_bap_broadcast_assistant_scan_stop(const void *cmd, uint16_t cmd_len, 91 void *rsp, uint16_t *rsp_len); 92 uint8_t btp_bap_broadcast_assistant_add_src(const void *cmd, uint16_t cmd_len, 93 void *rsp, uint16_t *rsp_len); 94 uint8_t btp_bap_broadcast_assistant_remove_src(const void *cmd, uint16_t cmd_len, 95 void *rsp, uint16_t *rsp_len); 96 uint8_t btp_bap_broadcast_assistant_modify_src(const void *cmd, uint16_t cmd_len, 97 void *rsp, uint16_t *rsp_len); 98 uint8_t btp_bap_broadcast_assistant_set_broadcast_code(const void *cmd, uint16_t cmd_len, 99 void *rsp, uint16_t *rsp_len); 100 uint8_t btp_bap_broadcast_assistant_send_past(const void *cmd, uint16_t cmd_len, 101 void *rsp, uint16_t *rsp_len); 102