1 /* btp_bap_unicast.h - Bluetooth BAP Tester */ 2 3 /* 4 * Copyright (c) 2023 Codecoup 5 * Copyright (c) 2024 Nordic Semiconductor ASA 6 * 7 * SPDX-License-Identifier: Apache-2.0 8 */ 9 10 #include <stdint.h> 11 12 #include <zephyr/bluetooth/audio/cap.h> 13 14 #define BTP_BAP_UNICAST_MAX_SNK_STREAMS_COUNT MIN(CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT, \ 15 CONFIG_BT_ASCS_MAX_ASE_SNK_COUNT) 16 #define BTP_BAP_UNICAST_MAX_SRC_STREAMS_COUNT MIN(CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT, \ 17 CONFIG_BT_ASCS_MAX_ASE_SRC_COUNT) 18 #define BTP_BAP_UNICAST_MAX_STREAMS_COUNT BTP_BAP_UNICAST_MAX_SNK_STREAMS_COUNT + \ 19 BTP_BAP_UNICAST_MAX_SRC_STREAMS_COUNT 20 #define BTP_BAP_UNICAST_MAX_END_POINTS_COUNT CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT + \ 21 CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT 22 23 struct btp_bap_unicast_group { 24 struct bt_bap_qos_cfg qos[CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT]; 25 struct bt_bap_unicast_group *cig; 26 uint8_t cig_id; 27 bool in_use; 28 }; 29 30 struct btp_bap_unicast_stream { 31 struct btp_bap_audio_stream audio_stream; 32 uint8_t ase_id; 33 uint8_t conn_id; 34 uint8_t cig_id; 35 uint8_t cis_id; 36 struct bt_audio_codec_cfg codec_cfg; 37 bool already_sent; 38 bool in_use; 39 }; 40 41 struct btp_bap_unicast_connection { 42 bt_addr_le_t address; 43 struct btp_bap_unicast_stream streams[BTP_BAP_UNICAST_MAX_STREAMS_COUNT]; 44 size_t configured_sink_stream_count; 45 size_t configured_source_stream_count; 46 struct bt_bap_ep *end_points[BTP_BAP_UNICAST_MAX_END_POINTS_COUNT]; 47 size_t end_points_count; 48 }; 49 50 int btp_bap_unicast_init(void); 51 struct btp_bap_unicast_connection *btp_bap_unicast_conn_get(size_t conn_index); 52 int btp_bap_unicast_group_create(uint8_t cig_id, struct btp_bap_unicast_group **out_unicast_group); 53 struct btp_bap_unicast_group *btp_bap_unicast_group_find(uint8_t cig_id); 54 struct bt_bap_ep *btp_bap_unicast_end_point_find(struct btp_bap_unicast_connection *conn, 55 uint8_t ase_id); 56 struct btp_bap_unicast_stream *btp_bap_unicast_stream_find(struct btp_bap_unicast_connection *conn, 57 uint8_t ase_id); 58 struct btp_bap_unicast_stream *btp_bap_unicast_stream_alloc( 59 struct btp_bap_unicast_connection *conn); 60 void btp_bap_unicast_stream_free(struct btp_bap_unicast_stream *stream); 61 62 uint8_t btp_bap_discover(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len); 63 64 uint8_t btp_ascs_configure_codec(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len); 65 uint8_t btp_ascs_configure_qos(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len); 66 uint8_t btp_ascs_enable(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len); 67 uint8_t btp_ascs_receiver_start_ready(const void *cmd, uint16_t cmd_len, 68 void *rsp, uint16_t *rsp_len); 69 uint8_t btp_ascs_receiver_stop_ready(const void *cmd, uint16_t cmd_len, 70 void *rsp, uint16_t *rsp_len); 71 uint8_t btp_ascs_disable(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len); 72 uint8_t btp_ascs_release(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len); 73 uint8_t btp_ascs_update_metadata(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len); 74 uint8_t btp_ascs_add_ase_to_cis(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len); 75 uint8_t btp_ascs_preconfigure_qos(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len); 76