xref: /btstack/example/le_audio_demo_util_sink.h (revision d13e5cf6603f8d92493ebd8a19ad22c4dfb7a126)
1 /*
2  * Copyright (C) 2023 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
21  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  */
31 
32 /**
33  *  @brief Send/receive isochronous audio, used by le_audio_* demos
34  */
35 
36 #ifndef LE_AUDIO_DEMO_UTIL_SINK_H
37 #define LE_AUDIO_DEMO_UTIL_SINK_H
38 
39 #include <stdint.h>
40 #include "bluetooth.h"
41 #include "btstack_bool.h"
42 #include "btstack_lc3.h"
43 
44 #if defined __cplusplus
45 extern "C" {
46 #endif
47 
48 /**
49  * @brief Init sink functionality
50  * @param filename_wav
51  */
52 void le_audio_demo_util_sink_init(const char * filename_wav);
53 
54 /**
55  * @brief Enable LC3plus if available for 10 ms frame duration
56  * @param enable
57  */
58 void le_audio_demo_util_sink_enable_lc3plus(bool enable);
59 
60 /**
61  * @brief Configure unicast sink
62  *        Supported num_streams x num_channels_per_stream configurations: 1 x 1, 1 x 2, 2 x 1
63  * @param num_streams
64  * @param num_channels_per_stream
65  * @param sampling_frequency_hz
66  * @param frame_duration
67  * @param octets_per_frame
68  * @param iso_interval_1250us
69  * @param flush_timeout
70  */
71 void le_audio_demo_util_sink_configure_unicast(uint8_t num_streams, uint8_t num_channels_per_stream, uint32_t sampling_frequency_hz,
72                                                btstack_lc3_frame_duration_t frame_duration, uint16_t octets_per_frame,
73                                                uint32_t iso_interval_1250us, uint8_t flush_timeout);
74 
75 /**
76  * @brief Configure broadcast sink
77  *        Supported num_streams x num_channels_per_stream configurations: 1 x 1, 1 x 2, 2 x 1
78  * @param num_streams
79  * @param num_channels_per_stream
80  * @param sampling_frequency_hz
81  * @param frame_duration
82  * @param octets_per_frame
83  * @param iso_interval_1250us
84  * @param pre_transmission_offset
85  */
86 void le_audio_demo_util_sink_configure_broadcast(uint8_t num_streams, uint8_t num_channels_per_stream, uint32_t sampling_frequency_hz,
87                                                btstack_lc3_frame_duration_t frame_duration, uint16_t octets_per_frame,
88                                                uint32_t iso_interval_1250us, uint8_t pre_transmission_offset);
89 
90 /**
91  * @brief Process ISO packet
92  * @param stream_index
93  * @param packet
94  * @param size
95  */
96 void le_audio_demo_util_sink_receive(uint8_t stream_index, uint8_t *packet, uint16_t size);
97 
98 /**
99  * @brief Analyze counting ISO packets
100  * @param stream_index
101  * @param packet
102  * @param size
103  */
104 void le_audio_demo_util_sink_count(uint8_t stream_index, uint8_t *packet, uint16_t size);
105 
106 /**
107  * @brief Close sink: close wav file, stop playbacl
108  */
109 void le_audio_demo_util_sink_close(void);
110 
111 #if defined __cplusplus
112 }
113 #endif
114 #endif // LE_AUDIO_DEMO_UTIL_SINK_H
115