1 /* 2 * Copyright (C) {copyright_year} 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_SOURCE_H 37 #define LE_AUDIO_DEMO_UTIL_SOURCE_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 typedef enum { 49 AUDIO_SOURCE_COUNTER, 50 AUDIO_SOURCE_SINE, 51 AUDIO_SOURCE_MODPLAYER, 52 AUDIO_SOURCE_RECORDING, 53 AUDIO_SOURCE_LOOPBACK, 54 } le_audio_demo_source_generator; 55 56 /** 57 * @brief Init source functionality 58 */ 59 void le_audio_demo_util_source_init(void); 60 61 /** 62 * @brief Configure audio source 63 * Supported num_streams x num_channels_per_stream configurations: 1 x 1, 1 x 2, 2 x 1 64 * @param num_streams 65 * @param num_channels_per_stream 66 * @param sampling_frequency_hz 67 * @param frame_duration 68 * @param octets_per_frame 69 */ 70 void le_audio_demo_util_source_configure(uint8_t num_streams, uint8_t num_channels_per_stream, uint32_t sampling_frequency_hz, 71 btstack_lc3_frame_duration_t frame_duration, uint16_t octets_per_frame); 72 /** 73 * @brief Generate audio and encode as ISO frame 74 * @param channel 75 * @param generator 76 */ 77 78 void le_audio_demo_util_source_generate_iso_frame(le_audio_demo_source_generator generator); 79 80 /** 81 * @brief Send prepared ISO packet 82 * @param stream_index 83 * @param con_handle 84 */ 85 void le_audio_demo_util_source_send(uint8_t stream_index, hci_con_handle_t con_handle); 86 87 /** 88 * @brief Close source 89 */ 90 void le_audio_demo_util_source_close(void); 91 92 #if defined __cplusplus 93 } 94 #endif 95 #endif // LE_AUDIO_DEMO_UTIL_SOURCE_H 96