xref: /btstack/src/classic/avdtp_sink.h (revision f12924e0a61c0582b548a1e70cea1bd59ba21f1d)
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 "avdtp.h"
52 
53 #if defined __cplusplus
54 extern "C" {
55 #endif
56 
57 /* API_START */
58 /**
59  * @brief AVDTP Sink service record.
60  * @param service
61  * @param service_record_handle
62  * @param supported_features 16-bit bitmap, see AVDTP_SINK_SF_* values in avdtp.h
63  * @param service_name
64  * @param service_provider_name
65  */
66 void a2dp_sink_create_sdp_record(uint8_t * service,  uint32_t service_record_handle, uint16_t supported_features, const char * service_name, const char * service_provider_name);
67 
68 /**
69  * @brief Set up AVDTP Sink device.
70  */
71 void avdtp_sink_init(void);
72 
73 // returns avdtp_stream_endpoint_t *
74 avdtp_stream_endpoint_t * avdtp_sink_create_stream_endpoint(avdtp_sep_type_t sep_type, avdtp_media_type_t media_type);
75 
76 void avdtp_sink_register_media_transport_category(uint8_t seid);
77 void avdtp_sink_register_reporting_category(uint8_t seid);
78 void avdtp_sink_register_delay_reporting_category(uint8_t seid);
79 void avdtp_sink_register_recovery_category(uint8_t seid, uint8_t maximum_recovery_window_size, uint8_t maximum_number_media_packets);
80 void avdtp_sink_register_header_compression_category(uint8_t seid, uint8_t back_ch, uint8_t media, uint8_t recovery);
81 void avdtp_sink_register_multiplexing_category(uint8_t seid, uint8_t fragmentation);
82 
83 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);
84 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);
85 
86 /**
87  * @brief Register callback for the AVDTP Sink client.
88  * @param callback
89  */
90 void avdtp_sink_register_packet_handler(btstack_packet_handler_t callback);
91 
92 /**
93  * @brief Connect to device with a bluetooth address. (and perform configuration?)
94  * @param bd_addr
95  */
96 void avdtp_sink_connect(bd_addr_t bd_addr);
97 
98 void avdtp_sink_register_media_handler(void (*callback)(avdtp_stream_endpoint_t * stream_endpoint, uint8_t *packet, uint16_t size));
99 /**
100  * @brief Disconnect from device with connection handle.
101  * @param con_handle
102  */
103 void avdtp_sink_disconnect(uint16_t con_handle);
104 
105 /**
106  * @brief Discover stream endpoints
107  * @param con_handle
108  */
109 void avdtp_sink_discover_stream_endpoints(uint16_t con_handle);
110 
111 /**
112  * @brief Get capabilities
113  * @param con_handle
114  */
115 void avdtp_sink_get_capabilities(uint16_t con_handle, uint8_t acp_seid);
116 
117 /**
118  * @brief Get all capabilities
119  * @param con_handle
120  */
121 void avdtp_sink_get_all_capabilities(uint16_t con_handle, uint8_t acp_seid);
122 
123 /**
124  * @brief Set configuration
125  * @param con_handle
126  */
127 void avdtp_sink_set_configuration(uint16_t con_handle, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration);
128 
129 /**
130  * @brief Reconfigure stream
131  * @param con_handle
132  * @param seid
133  */
134 void avdtp_sink_reconfigure(uint16_t con_handle, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration);
135 
136 /**
137  * @brief Get configuration
138  * @param con_handle
139  */
140 void avdtp_sink_get_configuration(uint16_t con_handle, uint8_t acp_seid);
141 
142 /**
143  * @brief Suspend stream
144  * @param con_handle
145  * @param seid
146  */
147 void avdtp_sink_suspend(uint16_t con_handle, uint8_t acp_seid);
148 
149 
150 /**
151  * @brief Open stream
152  * @param con_handle
153  * @param seid
154  */
155 void avdtp_sink_open_stream(uint16_t con_handle, uint8_t acp_seid);
156 
157 /**
158  * @brief Start stream
159  * @param con_handle
160  * @param seid
161  */
162 void avdtp_sink_start_stream(uint16_t con_handle, uint8_t acp_seid);
163 
164 /**
165  * @brief Start stream
166  * @param con_handle
167  * @param seid
168  */
169 void avdtp_sink_abort_stream(uint16_t con_handle, uint8_t acp_seid);
170 
171 /**
172  * @brief Start stream
173  * @param con_handle
174  * @param seid
175  */
176 void avdtp_sink_stop_stream(uint16_t con_handle, uint8_t acp_seid);
177 
178 /* API_END */
179 
180 extern btstack_packet_handler_t avdtp_sink_callback;
181 extern btstack_linked_list_t stream_endpoints;
182 
183 #if defined __cplusplus
184 }
185 #endif
186 
187 #endif // __AVDTP_SINK_H