1 /*
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef STREAM_TX_H
8 #define STREAM_TX_H
9 
10 #include <stdint.h>
11 
12 #include <zephyr/bluetooth/conn.h>
13 #include <zephyr/bluetooth/audio/bap.h>
14 #include <zephyr/bluetooth/audio/cap.h>
15 #include <zephyr/types.h>
16 
17 /**
18  * @brief Initialize TX
19  *
20  * This will initialize TX if not already initialized. This creates and starts a thread that
21  * will attempt to send data on all streams registered with bap_stream_tx_register().
22  */
23 void bap_stream_tx_init(void);
24 
25 /**
26  * @brief Register a stream for TX
27  *
28  * This will add it to the list of streams the TX thread will attempt to send on.
29  *
30  * @param bap_stream The stream to register
31  *
32  * @retval 0 on success
33  * @retval -EINVAL @p bap_stream is NULL
34  * @retval -EINVAL @p bap_stream is not configured for TX
35  * @retval -EINVAL @p bap_stream.codec_cfg contains invalid values
36  * @retval -ENOMEM if not more streams can be registered
37  */
38 int bap_stream_tx_register(struct bt_bap_stream *bap_stream);
39 
40 /**
41  * @brief Unregister a stream for TX
42  *
43  * This will remove it to the list of streams the TX thread will attempt to send on.
44  *
45  * @param bap_stream The stream to unregister
46  *
47  * @retval 0 on success
48  * @retval -EINVAL @p bap_stream is NULL
49  * @retval -EINVAL @p bap_stream is not configured for TX
50  * @retval -EALREADY @p bap_stream is currently not registered
51  */
52 int bap_stream_tx_unregister(struct bt_bap_stream *bap_stream);
53 
54 /**
55  * @brief Test if the provided stream has been configured for TX
56  *
57  * @param bap_stream The stream to test for TX support
58  *
59  * @retval true if it has been configured for TX, and false if not
60  */
61 bool bap_stream_tx_can_send(const struct bt_bap_stream *stream);
62 
63 /**
64  * @brief Callback to indicate a TX complete
65  *
66  * @param stream The stream that completed TX
67  */
68 void bap_stream_tx_sent_cb(struct bt_bap_stream *stream);
69 #endif /* STREAM_TX_H */
70