1 /* @file 2 * @brief Internal APIs for BAP ISO handling 3 * 4 * Copyright (c) 2022 Codecoup 5 * Copyright (c) 2023 Nordic Semiconductor ASA 6 * 7 * SPDX-License-Identifier: Apache-2.0 8 */ 9 10 #include <zephyr/bluetooth/iso.h> 11 #include <zephyr/bluetooth/audio/audio.h> 12 #include <zephyr/bluetooth/audio/bap.h> 13 14 struct bt_bap_iso_dir { 15 struct bt_bap_stream *stream; 16 struct bt_bap_ep *ep; 17 struct bt_iso_chan_path path; 18 struct bt_iso_chan_io_qos qos; 19 uint8_t cc[CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE]; 20 }; 21 22 struct bt_bap_iso { 23 struct bt_iso_chan chan; 24 struct bt_iso_chan_qos qos; 25 26 struct bt_bap_iso_dir rx; 27 struct bt_bap_iso_dir tx; 28 29 /* Must be at the end so that everything else in the structure can be 30 * memset to zero without affecting the ref. 31 */ 32 atomic_t ref; 33 }; 34 35 typedef bool (*bt_bap_iso_func_t)(struct bt_bap_iso *iso, void *user_data); 36 37 struct bt_bap_iso *bt_bap_iso_new(void); 38 struct bt_bap_iso *bt_bap_iso_ref(struct bt_bap_iso *iso); 39 void bt_bap_iso_unref(struct bt_bap_iso *iso); 40 void bt_bap_iso_foreach(bt_bap_iso_func_t func, void *user_data); 41 struct bt_bap_iso *bt_bap_iso_find(bt_bap_iso_func_t func, void *user_data); 42 void bt_bap_iso_init(struct bt_bap_iso *iso, struct bt_iso_chan_ops *ops); 43 void bt_bap_iso_bind_ep(struct bt_bap_iso *iso, struct bt_bap_ep *ep); 44 void bt_bap_iso_unbind_ep(struct bt_bap_iso *iso, struct bt_bap_ep *ep); 45 struct bt_bap_ep *bt_bap_iso_get_ep(bool unicast_client, struct bt_bap_iso *iso, 46 enum bt_audio_dir dir); 47 48 struct bt_bap_ep *bt_bap_iso_get_paired_ep(const struct bt_bap_ep *ep); 49 /* Unicast client-only functions*/ 50 void bt_bap_iso_bind_stream(struct bt_bap_iso *bap_iso, struct bt_bap_stream *stream, 51 enum bt_audio_dir dir); 52 void bt_bap_iso_unbind_stream(struct bt_bap_iso *bap_iso, struct bt_bap_stream *stream, 53 enum bt_audio_dir dir); 54 struct bt_bap_stream *bt_bap_iso_get_stream(struct bt_bap_iso *iso, enum bt_audio_dir dir); 55