xref: /btstack/src/classic/avdtp_sink.h (revision cd5f23a3250874824c01a2b3326a9522fea3f99f)
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(void);
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 /**
68  *  @brief Unregister stream endpoint and free it's memory
69  *  @param stream_endpoint created by avdtp_sink_create_stream_endpoint
70  */
71 void avdtp_sink_finalize_stream_endpoint(avdtp_stream_endpoint_t * stream_endpoint);
72 
73 void avdtp_sink_register_media_transport_category(uint8_t seid);
74 void avdtp_sink_register_reporting_category(uint8_t seid);
75 void avdtp_sink_register_delay_reporting_category(uint8_t seid);
76 void avdtp_sink_register_recovery_category(uint8_t seid, uint8_t maximum_recovery_window_size, uint8_t maximum_number_media_packets);
77 void avdtp_sink_register_header_compression_category(uint8_t seid, uint8_t back_ch, uint8_t media, uint8_t recovery);
78 void avdtp_sink_register_multiplexing_category(uint8_t seid, uint8_t fragmentation);
79 
80 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);
81 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);
82 
83 /**
84  * @brief Register callback for the AVDTP Sink client.
85  * @param callback
86  */
87 void avdtp_sink_register_packet_handler(btstack_packet_handler_t callback);
88 
89 /**
90  * @brief Connect to device with a bluetooth address. (and perform configuration?)
91  * @param bd_addr
92  * @param avdtp_cid Assigned avdtp cid
93  */
94 uint8_t avdtp_sink_connect(bd_addr_t bd_addr, uint16_t * avdtp_cid);
95 
96 void avdtp_sink_register_media_handler(void (*callback)(uint8_t local_seid, uint8_t *packet, uint16_t size));
97 /**
98  * @brief Disconnect from device with connection handle.
99  * @param avdtp_cid
100  */
101 uint8_t avdtp_sink_disconnect(uint16_t avdtp_cid);
102 
103 /**
104  * @brief Discover stream endpoints
105  * @param avdtp_cid
106  */
107 uint8_t avdtp_sink_discover_stream_endpoints(uint16_t avdtp_cid);
108 
109 /**
110  * @brief Get capabilities
111  * @param avdtp_cid
112  */
113 uint8_t avdtp_sink_get_capabilities(uint16_t avdtp_cid, uint8_t acp_seid);
114 
115 /**
116  * @brief Get all capabilities
117  * @param avdtp_cid
118  */
119 uint8_t avdtp_sink_get_all_capabilities(uint16_t avdtp_cid, uint8_t acp_seid);
120 
121 /**
122  * @brief Set configuration
123  * @param avdtp_cid
124  */
125 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);
126 
127 /**
128  * @brief Reconfigure stream
129  * @param avdtp_cid
130  * @param seid
131  */
132 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);
133 
134 /**
135  * @brief Get configuration
136  * @param avdtp_cid
137  */
138 uint8_t avdtp_sink_get_configuration(uint16_t avdtp_cid, uint8_t acp_seid);
139 
140 
141 /**
142  * @brief Open stream
143  * @param avdtp_cid
144  * @param seid
145  */
146 uint8_t avdtp_sink_open_stream(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid);
147 
148 
149 /**
150  * @brief Start stream
151  * @param local_seid
152  */
153 uint8_t avdtp_sink_start_stream(uint16_t avdtp_cid, uint8_t local_seid);
154 
155 /**
156  * @brief Abort stream
157  * @param local_seid
158  */
159 uint8_t avdtp_sink_abort_stream(uint16_t avdtp_cid, uint8_t local_seid);
160 
161 /**
162  * @brief Start stream
163  * @param local_seid
164  */
165 uint8_t avdtp_sink_stop_stream(uint16_t avdtp_cid, uint8_t local_seid);
166 
167 /**
168  * @brief Suspend stream
169  * @param local_seid
170  */
171 uint8_t avdtp_sink_suspend(uint16_t avdtp_cid, uint8_t local_seid);
172 
173 /**
174  * @brief Report delay
175  * @param local_seid
176  * @param delay_100us
177  */
178 uint8_t avdtp_sink_delay_report(uint16_t avdtp_cid, uint8_t local_seid, uint16_t delay_100us);
179 
180 /**
181  * @brief De-Init AVDTP Sink.
182  */
183 void avdtp_sink_deinit(void);
184 
185 // AVDTP_SI_DELAYREPORT
186 
187 /* API_END */
188 
189 
190 #if defined __cplusplus
191 }
192 #endif
193 
194 #endif // AVDTP_SINK_H
195