xref: /btstack/example/le_audio_demo_util_sink.h (revision 04405944daf596bbfd35041c36bcd39e66e48ea4)
124b69d49SMatthias Ringwald /*
224b69d49SMatthias Ringwald  * Copyright (C) 2023 BlueKitchen GmbH
324b69d49SMatthias Ringwald  *
424b69d49SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
524b69d49SMatthias Ringwald  * modification, are permitted provided that the following conditions
624b69d49SMatthias Ringwald  * are met:
724b69d49SMatthias Ringwald  *
824b69d49SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
924b69d49SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
1024b69d49SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
1124b69d49SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
1224b69d49SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
1324b69d49SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
1424b69d49SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
1524b69d49SMatthias Ringwald  *    from this software without specific prior written permission.
1624b69d49SMatthias Ringwald  *
1724b69d49SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
1824b69d49SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1924b69d49SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
2024b69d49SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
2124b69d49SMatthias Ringwald  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
2224b69d49SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
2324b69d49SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
2424b69d49SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2524b69d49SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2624b69d49SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
2724b69d49SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2824b69d49SMatthias Ringwald  * SUCH DAMAGE.
2924b69d49SMatthias Ringwald  *
3024b69d49SMatthias Ringwald  */
3124b69d49SMatthias Ringwald 
3224b69d49SMatthias Ringwald /**
3324b69d49SMatthias Ringwald  *  @brief Send/receive isochronous audio, used by le_audio_* demos
3424b69d49SMatthias Ringwald  */
3524b69d49SMatthias Ringwald 
3624b69d49SMatthias Ringwald #ifndef LE_AUDIO_DEMO_UTIL_SINK_H
3724b69d49SMatthias Ringwald #define LE_AUDIO_DEMO_UTIL_SINK_H
3824b69d49SMatthias Ringwald 
3924b69d49SMatthias Ringwald #include <stdint.h>
4024b69d49SMatthias Ringwald #include "bluetooth.h"
4124b69d49SMatthias Ringwald #include "btstack_bool.h"
4224b69d49SMatthias Ringwald #include "btstack_lc3.h"
4324b69d49SMatthias Ringwald 
4424b69d49SMatthias Ringwald #if defined __cplusplus
4524b69d49SMatthias Ringwald extern "C" {
4624b69d49SMatthias Ringwald #endif
4724b69d49SMatthias Ringwald 
48*04405944SMatthias Ringwald enum btstack_codec_ids_e {
49*04405944SMatthias Ringwald     BTSTACK_CODEC_ID_NONE = 0,
50*04405944SMatthias Ringwald     BTSTACK_CODEC_ID_COUNTER,
51*04405944SMatthias Ringwald     BTSTACK_CODEC_ID_LOOPBACK,
52*04405944SMatthias Ringwald };
53*04405944SMatthias Ringwald 
5424b69d49SMatthias Ringwald /**
5524b69d49SMatthias Ringwald  * @brief Init sink functionality
5624b69d49SMatthias Ringwald  * @param filename_wav
5724b69d49SMatthias Ringwald  */
5824b69d49SMatthias Ringwald void le_audio_demo_util_sink_init(const char * filename_wav);
5924b69d49SMatthias Ringwald 
6024b69d49SMatthias Ringwald /**
6124b69d49SMatthias Ringwald  * @brief Enable LC3plus if available for 10 ms frame duration
6224b69d49SMatthias Ringwald  * @param enable
6324b69d49SMatthias Ringwald  */
6424b69d49SMatthias Ringwald void le_audio_demo_util_sink_enable_lc3plus(bool enable);
6524b69d49SMatthias Ringwald 
6624b69d49SMatthias Ringwald /**
6724b69d49SMatthias Ringwald  * @brief Configure unicast sink
6824b69d49SMatthias Ringwald  *        Supported num_streams x num_channels_per_stream configurations: 1 x 1, 1 x 2, 2 x 1
6924b69d49SMatthias Ringwald  * @param num_streams
7024b69d49SMatthias Ringwald  * @param num_channels_per_stream
7124b69d49SMatthias Ringwald  * @param sampling_frequency_hz
7224b69d49SMatthias Ringwald  * @param frame_duration
7324b69d49SMatthias Ringwald  * @param octets_per_frame
7424b69d49SMatthias Ringwald  * @param iso_interval_1250us
7524b69d49SMatthias Ringwald  * @param flush_timeout
7624b69d49SMatthias Ringwald  */
7724b69d49SMatthias Ringwald void le_audio_demo_util_sink_configure_unicast(uint8_t num_streams, uint8_t num_channels_per_stream, uint32_t sampling_frequency_hz,
7824b69d49SMatthias Ringwald                                                btstack_lc3_frame_duration_t frame_duration, uint16_t octets_per_frame,
7924b69d49SMatthias Ringwald                                                uint32_t iso_interval_1250us, uint8_t flush_timeout);
8024b69d49SMatthias Ringwald 
8124b69d49SMatthias Ringwald /**
8224b69d49SMatthias Ringwald  * @brief Configure broadcast sink
8324b69d49SMatthias Ringwald  *        Supported num_streams x num_channels_per_stream configurations: 1 x 1, 1 x 2, 2 x 1
8424b69d49SMatthias Ringwald  * @param num_streams
8524b69d49SMatthias Ringwald  * @param num_channels_per_stream
8624b69d49SMatthias Ringwald  * @param sampling_frequency_hz
8724b69d49SMatthias Ringwald  * @param frame_duration
8824b69d49SMatthias Ringwald  * @param octets_per_frame
8924b69d49SMatthias Ringwald  * @param iso_interval_1250us
9024b69d49SMatthias Ringwald  * @param pre_transmission_offset
9124b69d49SMatthias Ringwald  */
9224b69d49SMatthias Ringwald void le_audio_demo_util_sink_configure_broadcast(uint8_t num_streams, uint8_t num_channels_per_stream, uint32_t sampling_frequency_hz,
9324b69d49SMatthias Ringwald                                                btstack_lc3_frame_duration_t frame_duration, uint16_t octets_per_frame,
9424b69d49SMatthias Ringwald                                                uint32_t iso_interval_1250us, uint8_t pre_transmission_offset);
9524b69d49SMatthias Ringwald 
9624b69d49SMatthias Ringwald /**
9724b69d49SMatthias Ringwald  * @brief Process ISO packet
9824b69d49SMatthias Ringwald  * @param stream_index
9924b69d49SMatthias Ringwald  * @param packet
10024b69d49SMatthias Ringwald  * @param size
10124b69d49SMatthias Ringwald  */
10224b69d49SMatthias Ringwald void le_audio_demo_util_sink_receive(uint8_t stream_index, uint8_t *packet, uint16_t size);
10324b69d49SMatthias Ringwald 
10424b69d49SMatthias Ringwald /**
105a18990d3SMatthias Ringwald  * @brief Analyze counting ISO packets
106a18990d3SMatthias Ringwald  * @param stream_index
107a18990d3SMatthias Ringwald  * @param packet
108a18990d3SMatthias Ringwald  * @param size
109a18990d3SMatthias Ringwald  */
110a18990d3SMatthias Ringwald void le_audio_demo_util_sink_count(uint8_t stream_index, uint8_t *packet, uint16_t size);
111a18990d3SMatthias Ringwald 
112a18990d3SMatthias Ringwald /**
11324b69d49SMatthias Ringwald  * @brief Close sink: close wav file, stop playbacl
11424b69d49SMatthias Ringwald  */
11524b69d49SMatthias Ringwald void le_audio_demo_util_sink_close(void);
11624b69d49SMatthias Ringwald 
11724b69d49SMatthias Ringwald #if defined __cplusplus
11824b69d49SMatthias Ringwald }
11924b69d49SMatthias Ringwald #endif
12024b69d49SMatthias Ringwald #endif // LE_AUDIO_DEMO_UTIL_SINK_H
121