1 /* 2 * Copyright (C) 2016 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 * 4. Any redistribution, use, or modification is done solely for 17 * personal benefit and not for any commercial purpose or for 18 * monetary gain. 19 * 20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24 * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Please inquire about commercial licensing options at 34 * [email protected] 35 * 36 */ 37 38 /** 39 * @title AVDTP Sink 40 * 41 * Audio/Video Distribution Transport Protocol (AVDTP) Sink is a device that accepts streamed media data. 42 * 43 */ 44 45 #ifndef AVDTP_SINK_H 46 #define AVDTP_SINK_H 47 48 #include <stdint.h> 49 #include "hci.h" 50 #include "classic/avdtp.h" 51 52 #if defined __cplusplus 53 extern "C" { 54 #endif 55 56 /* API_START */ 57 58 /** 59 * @brief Set up AVDTP Sink device. 60 */ 61 void avdtp_sink_init(void); 62 63 // returns avdtp_stream_endpoint_t * 64 avdtp_stream_endpoint_t * avdtp_sink_create_stream_endpoint(avdtp_sep_type_t sep_type, avdtp_media_type_t media_type); 65 66 /** 67 * @brief Unregister stream endpoint and free it's memory 68 * @param stream_endpoint created by avdtp_sink_create_stream_endpoint 69 */ 70 void avdtp_sink_finalize_stream_endpoint(avdtp_stream_endpoint_t * stream_endpoint); 71 72 void avdtp_sink_register_media_transport_category(uint8_t seid); 73 void avdtp_sink_register_reporting_category(uint8_t seid); 74 void avdtp_sink_register_delay_reporting_category(uint8_t seid); 75 void avdtp_sink_register_recovery_category(uint8_t seid, uint8_t maximum_recovery_window_size, uint8_t maximum_number_media_packets); 76 void avdtp_sink_register_header_compression_category(uint8_t seid, uint8_t back_ch, uint8_t media, uint8_t recovery); 77 void avdtp_sink_register_multiplexing_category(uint8_t seid, uint8_t fragmentation); 78 79 void avdtp_sink_register_media_codec_category(uint8_t seid, avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type, const uint8_t *media_codec_info, uint16_t media_codec_info_len); 80 void avdtp_sink_register_content_protection_category(uint8_t seid, uint16_t cp_type, const uint8_t * cp_type_value, uint8_t cp_type_value_len); 81 82 /** 83 * @brief Register callback for the AVDTP Sink client. 84 * @param callback 85 */ 86 void avdtp_sink_register_packet_handler(btstack_packet_handler_t callback); 87 88 /** 89 * @brief Connect to device with a bluetooth address. (and perform configuration?) 90 * @param bd_addr 91 * @param avdtp_cid Assigned avdtp cid 92 */ 93 uint8_t avdtp_sink_connect(bd_addr_t bd_addr, uint16_t * avdtp_cid); 94 95 void avdtp_sink_register_media_handler(void (*callback)(uint8_t local_seid, uint8_t *packet, uint16_t size)); 96 /** 97 * @brief Disconnect from device with connection handle. 98 * @param avdtp_cid 99 */ 100 uint8_t avdtp_sink_disconnect(uint16_t avdtp_cid); 101 102 /** 103 * @brief Discover stream endpoints 104 * @param avdtp_cid 105 */ 106 uint8_t avdtp_sink_discover_stream_endpoints(uint16_t avdtp_cid); 107 108 /** 109 * @brief Get capabilities 110 * @param avdtp_cid 111 */ 112 uint8_t avdtp_sink_get_capabilities(uint16_t avdtp_cid, uint8_t acp_seid); 113 114 /** 115 * @brief Get all capabilities 116 * @param avdtp_cid 117 */ 118 uint8_t avdtp_sink_get_all_capabilities(uint16_t avdtp_cid, uint8_t acp_seid); 119 120 /** 121 * @brief Set configuration 122 * @param avdtp_cid 123 */ 124 uint8_t avdtp_sink_set_configuration(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration); 125 126 /** 127 * @brief Reconfigure stream 128 * @param avdtp_cid 129 * @param seid 130 */ 131 uint8_t avdtp_sink_reconfigure(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration); 132 133 /** 134 * @brief Get configuration 135 * @param avdtp_cid 136 */ 137 uint8_t avdtp_sink_get_configuration(uint16_t avdtp_cid, uint8_t acp_seid); 138 139 140 /** 141 * @brief Open stream 142 * @param avdtp_cid 143 * @param seid 144 */ 145 uint8_t avdtp_sink_open_stream(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid); 146 147 148 /** 149 * @brief Start stream 150 * @param local_seid 151 */ 152 uint8_t avdtp_sink_start_stream(uint16_t avdtp_cid, uint8_t local_seid); 153 154 /** 155 * @brief Abort stream 156 * @param local_seid 157 */ 158 uint8_t avdtp_sink_abort_stream(uint16_t avdtp_cid, uint8_t local_seid); 159 160 /** 161 * @brief Start stream 162 * @param local_seid 163 */ 164 uint8_t avdtp_sink_stop_stream(uint16_t avdtp_cid, uint8_t local_seid); 165 166 /** 167 * @brief Suspend stream 168 * @param local_seid 169 */ 170 uint8_t avdtp_sink_suspend(uint16_t avdtp_cid, uint8_t local_seid); 171 172 /** 173 * @brief Report delay 174 * @param local_seid 175 * @param delay_100us 176 */ 177 uint8_t avdtp_sink_delay_report(uint16_t avdtp_cid, uint8_t local_seid, uint16_t delay_100us); 178 179 /** 180 * @brief Register media configuration validator. Can reject insuitable configuration or report stream endpoint as currently busy 181 * @note validator has to return AVDTP error codes like: AVDTP_ERROR_CODE_SEP_IN_USE or AVDTP_ERROR_CODE_UNSUPPORTED_CONFIGURATION 182 * the callback receives the media configuration in the same format as the existing AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION 183 * and similar 184 * @param callback 185 */ 186 void avdtp_sink_register_media_config_validator(uint8_t (*callback)(const avdtp_stream_endpoint_t * stream_endpoint, const uint8_t * event, uint16_t size)); 187 188 /** 189 * @brief De-Init AVDTP Sink. 190 */ 191 void avdtp_sink_deinit(void); 192 193 // AVDTP_SI_DELAYREPORT 194 195 /* API_END */ 196 197 198 #if defined __cplusplus 199 } 200 #endif 201 202 #endif // AVDTP_SINK_H 203