xref: /btstack/src/classic/avdtp_source.h (revision 78d08d098e6ff52f427176938ca867d697552cad)
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_source.h
40  *
41  * Audio/Video Distribution Transport Protocol Source
42  *
43  * AVDTP Source is a device that streames media data.
44  */
45 
46 #ifndef __AVDTP_SOURCE_H
47 #define __AVDTP_SOURCE_H
48 
49 #include <stdint.h>
50 
51 #if defined __cplusplus
52 extern "C" {
53 #endif
54 
55 /* API_START */
56 
57 /**
58  * @brief AVDTP Source service record.
59  * @param service
60  * @param service_record_handle
61  * @param supported_features 16-bit bitmap, see AVDTP_SOURCE_SF_* values in avdtp.h
62  * @param service_name
63  * @param service_provider_name
64  */
65 void a2dp_source_create_sdp_record(uint8_t * service,  uint32_t service_record_handle, uint16_t supported_features, const char * service_name, const char * service_provider_name);
66 
67 void avdtp_source_register_media_transport_category(uint8_t seid);
68 void avdtp_source_register_reporting_category(uint8_t seid);
69 void avdtp_source_register_delay_reporting_category(uint8_t seid);
70 void avdtp_source_register_recovery_category(uint8_t seid, uint8_t maximum_recovery_window_size, uint8_t maximum_number_media_packets);
71 void avdtp_source_register_content_protection_category(uint8_t seid, uint16_t cp_type, const uint8_t * cp_type_value, uint8_t cp_type_value_len);
72 void avdtp_source_register_header_compression_category(uint8_t seid, uint8_t back_ch, uint8_t media, uint8_t recovery);
73 void avdtp_source_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);
74 void avdtp_source_register_multiplexing_category(uint8_t seid, uint8_t fragmentation);
75 
76 
77 void avdtp_source_init(void);
78 void avdtp_source_register_packet_handler(btstack_packet_handler_t callback);
79 
80 /**
81  * @brief Connect to device with a bluetooth address. (and perform configuration?)
82  * @param bd_addr
83  */
84 void avdtp_source_connect(bd_addr_t bd_addr);
85 
86 void avdtp_source_register_media_handler(void (*callback)(avdtp_stream_endpoint_t * stream_endpoint, uint8_t *packet, uint16_t size));
87 /**
88  * @brief Disconnect from device with connection handle.
89  * @param avdtp_cid
90  */
91 void avdtp_source_disconnect(uint16_t avdtp_cid);
92 
93 /**
94  * @brief Discover stream endpoints
95  * @param avdtp_cid
96  */
97 void avdtp_source_discover_stream_endpoints(uint16_t avdtp_cid);
98 
99 /**
100  * @brief Get capabilities
101  * @param avdtp_cid
102  */
103 void avdtp_source_get_capabilities(uint16_t avdtp_cid, uint8_t acp_seid);
104 
105 /**
106  * @brief Get all capabilities
107  * @param avdtp_cid
108  */
109 void avdtp_source_get_all_capabilities(uint16_t avdtp_cid, uint8_t acp_seid);
110 
111 /**
112  * @brief Set configuration
113  * @param avdtp_cid
114  */
115 void avdtp_source_set_configuration(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration);
116 
117 /**
118  * @brief Reconfigure stream
119  * @param avdtp_cid
120  * @param seid
121  */
122 void avdtp_source_reconfigure(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration);
123 
124 /**
125  * @brief Get configuration
126  * @param avdtp_cid
127  */
128 void avdtp_source_get_configuration(uint16_t avdtp_cid, uint8_t acp_seid);
129 
130 /**
131  * @brief Suspend stream
132  * @param avdtp_cid
133  * @param seid
134  */
135 void avdtp_source_suspend(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid);
136 
137 
138 /**
139  * @brief Open stream
140  * @param avdtp_cid
141  * @param seid
142  */
143 void avdtp_source_open_stream(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid);
144 
145 /**
146  * @brief Start stream
147  * @param avdtp_cid
148  * @param seid
149  */
150 void avdtp_source_start_stream(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid);
151 
152 /**
153  * @brief Start stream
154  * @param avdtp_cid
155  * @param seid
156  */
157 void avdtp_source_abort_stream(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid);
158 
159 /**
160  * @brief Start stream
161  * @param avdtp_cid
162  * @param seid
163  */
164 void avdtp_source_stop_stream(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid);
165 
166 avdtp_stream_endpoint_t * avdtp_source_create_stream_endpoint(avdtp_sep_type_t sep_type, avdtp_media_type_t media_type);
167 
168 void avdtp_source_stream_endpoint_request_can_send_now(avdtp_stream_endpoint_t * stream_endpoint);
169 int  avdtp_source_stream_endpoint_ready(avdtp_stream_endpoint_t * stream_endpoint);
170 void avdtp_source_stream_send_media_payload(uint16_t l2cap_media_cid, btstack_ring_buffer_t * sbc_ring_buffer, uint8_t marker);
171 
172 uint8_t avdtp_source_remote_seps_num(uint16_t avdtp_cid);
173 avdtp_sep_t * avdtp_source_remote_sep(uint16_t avdtp_cid, uint8_t index);
174 /* API_END */
175 
176 #if defined __cplusplus
177 }
178 #endif
179 
180 #endif // __AVDTP_SOURCE_H