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_audio_codec_qos 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_AUDIO_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_audio_codec_qos 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 /* Only for BTP BAP commands */ 49 struct bt_bap_broadcast_source *bap_broadcast; 50 /* Only for BTP CAP commands */ 51 struct bt_cap_broadcast_source *cap_broadcast; 52 }; 53 54 int btp_bap_broadcast_init(void); 55 struct btp_bap_broadcast_local_source *btp_bap_broadcast_local_source_get(uint8_t source_id); 56 struct btp_bap_broadcast_stream *btp_bap_broadcast_stream_alloc( 57 struct btp_bap_broadcast_local_source *source); 58 59 uint8_t btp_bap_broadcast_source_setup(const void *cmd, uint16_t cmd_len, 60 void *rsp, uint16_t *rsp_len); 61 uint8_t btp_bap_broadcast_source_release(const void *cmd, uint16_t cmd_len, 62 void *rsp, uint16_t *rsp_len); 63 uint8_t btp_bap_broadcast_adv_start(const void *cmd, uint16_t cmd_len, 64 void *rsp, uint16_t *rsp_len); 65 uint8_t btp_bap_broadcast_adv_stop(const void *cmd, uint16_t cmd_len, 66 void *rsp, uint16_t *rsp_len); 67 uint8_t btp_bap_broadcast_source_start(const void *cmd, uint16_t cmd_len, 68 void *rsp, uint16_t *rsp_len); 69 uint8_t btp_bap_broadcast_source_stop(const void *cmd, uint16_t cmd_len, 70 void *rsp, uint16_t *rsp_len); 71 uint8_t btp_bap_broadcast_sink_setup(const void *cmd, uint16_t cmd_len, 72 void *rsp, uint16_t *rsp_len); 73 uint8_t btp_bap_broadcast_sink_release(const void *cmd, uint16_t cmd_len, 74 void *rsp, uint16_t *rsp_len); 75 uint8_t btp_bap_broadcast_scan_start(const void *cmd, uint16_t cmd_len, 76 void *rsp, uint16_t *rsp_len); 77 uint8_t btp_bap_broadcast_scan_stop(const void *cmd, uint16_t cmd_len, 78 void *rsp, uint16_t *rsp_len); 79 uint8_t btp_bap_broadcast_sink_sync(const void *cmd, uint16_t cmd_len, 80 void *rsp, uint16_t *rsp_len); 81 uint8_t btp_bap_broadcast_sink_stop(const void *cmd, uint16_t cmd_len, 82 void *rsp, uint16_t *rsp_len); 83 uint8_t btp_bap_broadcast_sink_bis_sync(const void *cmd, uint16_t cmd_len, 84 void *rsp, uint16_t *rsp_len); 85 uint8_t btp_bap_broadcast_discover_scan_delegators(const void *cmd, uint16_t cmd_len, 86 void *rsp, uint16_t *rsp_len); 87 uint8_t btp_bap_broadcast_assistant_scan_start(const void *cmd, uint16_t cmd_len, 88 void *rsp, uint16_t *rsp_len); 89 uint8_t btp_bap_broadcast_assistant_scan_stop(const void *cmd, uint16_t cmd_len, 90 void *rsp, uint16_t *rsp_len); 91 uint8_t btp_bap_broadcast_assistant_add_src(const void *cmd, uint16_t cmd_len, 92 void *rsp, uint16_t *rsp_len); 93 uint8_t btp_bap_broadcast_assistant_remove_src(const void *cmd, uint16_t cmd_len, 94 void *rsp, uint16_t *rsp_len); 95 uint8_t btp_bap_broadcast_assistant_modify_src(const void *cmd, uint16_t cmd_len, 96 void *rsp, uint16_t *rsp_len); 97 uint8_t btp_bap_broadcast_assistant_set_broadcast_code(const void *cmd, uint16_t cmd_len, 98 void *rsp, uint16_t *rsp_len); 99 uint8_t btp_bap_broadcast_assistant_send_past(const void *cmd, uint16_t cmd_len, 100 void *rsp, uint16_t *rsp_len); 101