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 #include "stream_lc3.h"
18 
19 struct tx_stream {
20 	struct bt_bap_stream *bap_stream;
21 	uint16_t seq_num;
22 
23 #if defined(CONFIG_LIBLC3)
24 	struct stream_lc3_tx lc3_tx;
25 #endif /* CONFIG_LIBLC3 */
26 };
27 
28 /**
29  * @brief Initialize TX
30  *
31  * This will initialize TX if not already initialized. This creates and starts a thread that
32  * will attempt to send data on all streams registered with stream_tx_register().
33  */
34 void stream_tx_init(void);
35 
36 /**
37  * @brief Register a stream for TX
38  *
39  * This will add it to the list of streams the TX thread will attempt to send on.
40  *
41  * @retval 0 on success
42  * @retval -EINVAL if @p bap_stream is NULL
43  * @retval -EINVAL if @p bap_stream.codec_cfg contains invalid values
44  * @retval -ENOEXEC if the LC3 encoder failed to initialize
45  * @retval -ENOMEM if not more streams can be registered
46  */
47 int stream_tx_register(struct bt_bap_stream *bap_stream);
48 
49 /**
50  * @brief Unregister a stream for TX
51  *
52  * This will remove it to the list of streams the TX thread will attempt to send on.
53  *
54  * @retval 0 on success
55  * @retval -EINVAL if @p bap_stream is NULL
56  * @retval -EALREADY if the stream is currently not registered
57  */
58 int stream_tx_unregister(struct bt_bap_stream *bap_stream);
59 
60 #endif /* STREAM_TX_H */
61