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 MATTHIAS 24 * RINGWALD 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 * avdtp_sink.h 40 * 41 * Audio/Video Distribution Transport Protocol (AVDTP) Sink 42 * 43 * AVDTP Sink is a device that accepts streamed media data. 44 */ 45 46 #ifndef AVDTP_SINK_H 47 #define AVDTP_SINK_H 48 49 #include <stdint.h> 50 #include "hci.h" 51 #include "classic/avdtp.h" 52 53 #if defined __cplusplus 54 extern "C" { 55 #endif 56 57 /* API_START */ 58 59 /** 60 * @brief Set up AVDTP Sink device. 61 */ 62 void avdtp_sink_init(avdtp_context_t * avdtp_context); 63 64 // returns avdtp_stream_endpoint_t * 65 avdtp_stream_endpoint_t * avdtp_sink_create_stream_endpoint(avdtp_sep_type_t sep_type, avdtp_media_type_t media_type); 66 67 void avdtp_sink_register_media_transport_category(uint8_t seid); 68 void avdtp_sink_register_reporting_category(uint8_t seid); 69 void avdtp_sink_register_delay_reporting_category(uint8_t seid); 70 void avdtp_sink_register_recovery_category(uint8_t seid, uint8_t maximum_recovery_window_size, uint8_t maximum_number_media_packets); 71 void avdtp_sink_register_header_compression_category(uint8_t seid, uint8_t back_ch, uint8_t media, uint8_t recovery); 72 void avdtp_sink_register_multiplexing_category(uint8_t seid, uint8_t fragmentation); 73 74 void avdtp_sink_register_media_codec_category(uint8_t seid, avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type, uint8_t * media_codec_info, uint16_t media_codec_info_len); 75 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); 76 77 /** 78 * @brief Register callback for the AVDTP Sink client. 79 * @param callback 80 */ 81 void avdtp_sink_register_packet_handler(btstack_packet_handler_t callback); 82 83 /** 84 * @brief Connect to device with a bluetooth address. (and perform configuration?) 85 * @param bd_addr 86 * @param avdtp_cid Assigned avdtp cid 87 */ 88 uint8_t avdtp_sink_connect(bd_addr_t bd_addr, uint16_t * avdtp_cid); 89 90 void avdtp_sink_register_media_handler(void (*callback)(uint8_t local_seid, uint8_t *packet, uint16_t size)); 91 /** 92 * @brief Disconnect from device with connection handle. 93 * @param avdtp_cid 94 */ 95 uint8_t avdtp_sink_disconnect(uint16_t avdtp_cid); 96 97 /** 98 * @brief Discover stream endpoints 99 * @param avdtp_cid 100 */ 101 uint8_t avdtp_sink_discover_stream_endpoints(uint16_t avdtp_cid); 102 103 /** 104 * @brief Get capabilities 105 * @param avdtp_cid 106 */ 107 uint8_t avdtp_sink_get_capabilities(uint16_t avdtp_cid, uint8_t acp_seid); 108 109 /** 110 * @brief Get all capabilities 111 * @param avdtp_cid 112 */ 113 uint8_t avdtp_sink_get_all_capabilities(uint16_t avdtp_cid, uint8_t acp_seid); 114 115 /** 116 * @brief Set configuration 117 * @param avdtp_cid 118 */ 119 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); 120 121 /** 122 * @brief Reconfigure stream 123 * @param avdtp_cid 124 * @param seid 125 */ 126 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); 127 128 /** 129 * @brief Get configuration 130 * @param avdtp_cid 131 */ 132 uint8_t avdtp_sink_get_configuration(uint16_t avdtp_cid, uint8_t acp_seid); 133 134 135 /** 136 * @brief Open stream 137 * @param avdtp_cid 138 * @param seid 139 */ 140 uint8_t avdtp_sink_open_stream(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid); 141 142 143 /** 144 * @brief Start stream 145 * @param local_seid 146 */ 147 uint8_t avdtp_sink_start_stream(uint16_t avdtp_cid, uint8_t local_seid); 148 149 /** 150 * @brief Abort stream 151 * @param local_seid 152 */ 153 uint8_t avdtp_sink_abort_stream(uint16_t avdtp_cid, uint8_t local_seid); 154 155 /** 156 * @brief Start stream 157 * @param local_seid 158 */ 159 uint8_t avdtp_sink_stop_stream(uint16_t avdtp_cid, uint8_t local_seid); 160 161 /** 162 * @brief Suspend stream 163 * @param local_seid 164 */ 165 uint8_t avdtp_sink_suspend(uint16_t avdtp_cid, uint8_t local_seid); 166 167 /** 168 * @brief Report delay 169 * @param local_seid 170 * @param delay_100us 171 */ 172 uint8_t avdtp_sink_delay_report(uint16_t avdtp_cid, uint8_t local_seid, uint16_t delay_100us); 173 174 // AVDTP_SI_DELAYREPORT 175 176 /* API_END */ 177 178 179 #if defined __cplusplus 180 } 181 #endif 182 183 #endif // AVDTP_SINK_H 184