xref: /btstack/src/classic/avdtp.h (revision a15efc861737d1da360dc5169bcf7780f5e7e649)
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.h
40  *
41  * Audio/Video Distribution Transport Protocol
42  *
43  * This protocol defines A/V stream negotiation, establishment, and transmission
44  * procedures. Also specified are the message formats that are exchanged between
45  * such devices to transport their A/V streams in A/V distribution applications.
46  *
47  * Media packets are unidirectional, they travel downstream from AVDTP Source to AVDTP Sink.
48  */
49 
50 #ifndef __AVDTP_H
51 #define __AVDTP_H
52 
53 #include <stdint.h>
54 #include "hci.h"
55 #include "btstack_ring_buffer.h"
56 
57 #if defined __cplusplus
58 extern "C" {
59 #endif
60 
61 #define MAX_NUM_SEPS 10
62 #define MAX_CSRC_NUM 15
63 
64 // Supported Features
65 #define AVDTP_SOURCE_SF_Player      0x0001
66 #define AVDTP_SOURCE_SF_Microphone  0x0002
67 #define AVDTP_SOURCE_SF_Tuner       0x0004
68 #define AVDTP_SOURCE_SF_Mixer       0x0008
69 
70 #define AVDTP_SINK_SF_Headphone     0x0001
71 #define AVDTP_SINK_SF_Speaker       0x0002
72 #define AVDTP_SINK_SF_Recorder      0x0004
73 #define AVDTP_SINK_SF_Amplifier     0x0008
74 
75 // ACP to INT, Signal Response Header Error Codes
76 #define BAD_HEADER_FORMAT 0x01
77 
78 // ACP to INT, Signal Response Payload Format Error Codes
79 #define BAD_LENGTH 0x11
80 #define BAD_ACP_SEID 0x12
81 #define SEP_IN_USE 0x13
82 #define SEP_NOT_IN_USE 0x14
83 #define BAD_SERV_CATEGORY 0x17
84 #define BAD_PAYLOAD_FORMAT 0x18
85 #define NOT_SUPPORTED_COMMAND 0x19
86 #define INVALID_CAPABILITIES 0x1A
87 
88 // ACP to INT, Signal Response Transport Service Capabilities Error Codes
89 #define BAD_RECOVERY_TYPE 0x22
90 #define BAD_MEDIA_TRANSPORT_FORMAT 0x23
91 #define BAD_RECOVERY_FORMAT 0x25
92 #define BAD_ROHC_FORMAT 0x26
93 #define BAD_CP_FORMAT 0x27
94 #define BAD_MULTIPLEXING_FORMAT 0x28
95 #define UNSUPPORTED_CONFIGURATION 0x29
96 
97 // ACP to INT, Procedure Error Codes
98 #define BAD_STATE 0x31
99 // Signal Identifier fields
100 typedef enum {
101     AVDTP_SI_NONE = 0x00,
102     AVDTP_SI_DISCOVER = 0x01,
103     AVDTP_SI_GET_CAPABILITIES,
104     AVDTP_SI_SET_CONFIGURATION,
105     AVDTP_SI_GET_CONFIGURATION,
106     AVDTP_SI_RECONFIGURE, //5
107     AVDTP_SI_OPEN,  //6
108     AVDTP_SI_START, //7
109     AVDTP_SI_CLOSE,
110     AVDTP_SI_SUSPEND,
111     AVDTP_SI_ABORT, //10
112     AVDTP_SI_SECURITY_CONTROL,
113     AVDTP_SI_GET_ALL_CAPABILITIES, //12
114     AVDTP_SI_DELAYREPORT
115 } avdtp_signal_identifier_t;
116 
117 typedef enum {
118     AVDTP_SINGLE_PACKET= 0,
119     AVDTP_START_PACKET    ,
120     AVDTP_CONTINUE_PACKET ,
121     AVDTP_END_PACKET
122 } avdtp_packet_type_t;
123 
124 typedef enum {
125     AVDTP_CMD_MSG = 0,
126     AVDTP_GENERAL_REJECT_MSG   ,
127     AVDTP_RESPONSE_ACCEPT_MSG ,
128     AVDTP_RESPONSE_REJECT_MSG
129 } avdtp_message_type_t;
130 
131 typedef enum{
132     AVDTP_AUDIO = 0,
133     AVDTP_VIDEO,
134     AVDTP_MULTIMEDIA
135 } avdtp_media_type_t;
136 
137 typedef enum{
138     AVDTP_CODEC_SBC             = 0x00,
139     AVDTP_CODEC_MPEG_1_2_AUDIO  = 0x01,
140     AVDTP_CODEC_MPEG_2_4_AAC    = 0x02,
141     AVDTP_CODEC_ATRAC_FAMILY    = 0x04,
142     AVDTP_CODEC_NON_A2DP        = 0xFF
143 } avdtp_media_codec_type_t;
144 
145 typedef enum{
146     AVDTP_CONTENT_PROTECTION_DTCP = 0x0001,
147     AVDTP_CONTENT_PROTECTION_SCMS_T = 0x0002
148 } avdtp_content_protection_type_t;
149 
150 typedef enum{
151     AVDTP_SOURCE = 0,
152     AVDTP_SINK
153 } avdtp_sep_type_t;
154 
155 typedef enum {
156     AVDTP_SERVICE_CATEGORY_INVALID_0 = 0x00,
157     AVDTP_MEDIA_TRANSPORT = 0X01,
158     AVDTP_REPORTING,
159     AVDTP_RECOVERY,
160     AVDTP_CONTENT_PROTECTION, //4
161     AVDTP_HEADER_COMPRESSION, //5
162     AVDTP_MULTIPLEXING,       //6
163     AVDTP_MEDIA_CODEC,        //7
164     AVDTP_DELAY_REPORTING,    //8
165     AVDTP_SERVICE_CATEGORY_INVALID_FF = 0xFF
166 } avdtp_service_category_t;
167 
168 typedef struct {
169     uint8_t recovery_type;                  // 0x01 = RFC2733
170     uint8_t maximum_recovery_window_size;   // 0x01 to 0x18, for a Transport Packet
171     uint8_t maximum_number_media_packets;   // 0x01 to 0x18, The maximum number of media packets a specific parity code covers
172 } avdtp_recovery_capabilities_t;
173 
174 typedef struct {
175     avdtp_media_type_t       media_type;
176     avdtp_media_codec_type_t media_codec_type;
177     uint16_t  media_codec_information_len;
178     uint8_t * media_codec_information;
179 } adtvp_media_codec_capabilities_t;
180 
181 
182 typedef struct {
183     uint16_t cp_type;
184     uint16_t cp_type_value_len;
185     const uint8_t * cp_type_value;
186 } adtvp_content_protection_t;
187 
188 typedef struct{
189     uint8_t back_ch;  // byte0 - bit 8; 0=Not Available/Not Used; 1=Available/In Use
190     uint8_t media;    // byte0 - bit 7
191     uint8_t recovery; // byte0 - bit 6
192 } avdtp_header_compression_capabilities_t;
193 
194 typedef struct{
195     uint8_t fragmentation; // byte0 - bit 8, Allow Adaptation Layer Fragmentation, 0 no, 1 yes
196     // Request/indicate value of the Transport Session Identifier for a media, reporting, or recovery transport sessions, respectively
197     uint8_t transport_identifiers_num;
198     uint8_t transport_session_identifiers[3];   // byte1, upper 5bits, 0x01 to 0x1E
199     // Request/indicate value for TCID for a media, reporting, or transport session
200     uint8_t tcid[3];         // byte2 0x01 to 0x1E
201 } avdtp_multiplexing_mode_capabilities_t;
202 
203 typedef struct{
204     avdtp_recovery_capabilities_t recovery;
205     adtvp_media_codec_capabilities_t media_codec;
206     adtvp_content_protection_t content_protection;
207     avdtp_header_compression_capabilities_t header_compression;
208     avdtp_multiplexing_mode_capabilities_t multiplexing_mode;
209 } avdtp_capabilities_t;
210 
211 typedef enum{
212     AVDTP_SBC_48000 = 1,
213     AVDTP_SBC_44100 = 2,
214     AVDTP_SBC_32000 = 4,
215     AVDTP_SBC_16000 = 8
216 } avdtp_sbc_sampling_frequency_t;
217 
218 typedef enum{
219     AVDTP_SBC_JOINT_STEREO  = 1,
220     AVDTP_SBC_STEREO        = 2,
221     AVDTP_SBC_DUAL_CHANNEL  = 4,
222     AVDTP_SBC_MONO          = 8
223 } avdtp_sbc_channel_mode_t;
224 
225 typedef enum{
226     AVDTP_SBC_BLOCK_LENGTH_16 = 1,
227     AVDTP_SBC_BLOCK_LENGTH_12 = 2,
228     AVDTP_SBC_BLOCK_LENGTH_8  = 4,
229     AVDTP_SBC_BLOCK_LENGTH_4  = 8
230 } avdtp_sbc_block_length_t;
231 
232 typedef enum{
233     AVDTP_SBC_SUBBANDS_8 = 1,
234     AVDTP_SBC_SUBBANDS_4 = 2
235 } avdtp_sbc_subbands_t;
236 
237 typedef enum{
238     AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS = 1,
239     AVDTP_SBC_ALLOCATION_METHOD_SNR      = 2
240 } avdtp_sbc_allocation_method_t;
241 
242 typedef struct {
243     uint8_t fragmentation;
244     uint8_t starting_packet; // of fragmented SBC frame
245     uint8_t last_packet;     // of fragmented SBC frame
246     uint8_t num_frames;
247 } avdtp_sbc_codec_header_t;
248 
249 // typedef struct {
250 //     uint8_t transaction_label;
251 //     avdtp_packet_type_t packet_type;
252 //     avdtp_message_type_t message_type;
253 //     uint8_t signal_identifier;
254 // } avdtp_signaling_packet_header_t;
255 
256 typedef struct {
257     uint8_t version;
258     uint8_t padding;
259     uint8_t extension;
260     uint8_t csrc_count;
261     uint8_t marker;
262     uint8_t payload_type;
263 
264     uint16_t sequence_number;
265     uint32_t timestamp;
266     uint32_t synchronization_source;
267 
268     uint32_t csrc_list[MAX_CSRC_NUM];
269 } avdtp_media_packet_header_t;
270 
271 typedef enum {
272     AVDTP_BASIC_SERVICE_MODE,
273     AVDTP_MULTIPLEXING_SERVICE_MODE
274 } avdtp_service_mode_t;
275 
276 typedef enum {
277     AVDTP_STREAM_ENDPOINT_IDLE,
278     AVDTP_STREAM_ENDPOINT_CONFIGURATION_SUBSTATEMACHINE,
279     AVDTP_STREAM_ENDPOINT_CONFIGURED,
280 
281     AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM,
282     AVDTP_STREAM_ENDPOINT_W4_L2CAP_FOR_MEDIA_CONNECTED,
283 
284     AVDTP_STREAM_ENDPOINT_OPENED,
285     AVDTP_STREAM_ENDPOINT_STREAMING,
286 
287     AVDTP_STREAM_ENDPOINT_CLOSING,
288     AVDTP_STREAM_ENDPOINT_ABORTING,
289     AVDTP_STREAM_ENDPOINT_W4_L2CAP_FOR_MEDIA_DISCONNECTED
290 } avdtp_stream_endpoint_state_t;
291 
292 typedef enum {
293     AVDTP_INITIATOR_STREAM_CONFIG_IDLE,
294     AVDTP_INITIATOR_W2_SET_CONFIGURATION,
295     AVDTP_INITIATOR_W2_SUSPEND_STREAM_WITH_SEID,
296     AVDTP_INITIATOR_W2_RECONFIGURE_STREAM_WITH_SEID,
297 
298     AVDTP_INITIATOR_W2_OPEN_STREAM,
299 
300     AVDTP_INITIATOR_W2_STREAMING_ABORT,
301     AVDTP_INITIATOR_FRAGMENTATED_COMMAND,
302     AVDTP_INITIATOR_W4_ANSWER
303 } avdtp_initiator_stream_endpoint_state_t;
304 
305 typedef enum {
306     AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE,
307     AVDTP_ACCEPTOR_W2_ANSWER_GET_CAPABILITIES,
308     AVDTP_ACCEPTOR_W2_ANSWER_GET_ALL_CAPABILITIES,
309     AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION,
310     AVDTP_ACCEPTOR_W2_ANSWER_RECONFIGURE,
311     AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION,
312     AVDTP_ACCEPTOR_W2_ANSWER_OPEN_STREAM,
313     AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM,
314     AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM,
315     AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM,
316     AVDTP_ACCEPTOR_W2_SUSPEND_STREAM_WITH_SEID,
317     AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM,
318     AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE,
319     AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE,
320     AVDTP_ACCEPTOR_W2_REJECT_UNKNOWN_CMD,
321     AVDTP_ACCEPTOR_STREAMING
322 } avdtp_acceptor_stream_endpoint_state_t;
323 
324 typedef struct {
325     uint8_t seid;           // 0x01 – 0x3E, 6bit
326     uint8_t in_use;         // 1 bit, 0 - not in use, 1 - in use
327     avdtp_media_type_t media_type;     // 4 bit
328     avdtp_sep_type_t   type;       // 1 bit, 0 - SRC, 1 - SNK
329 
330     uint16_t registered_service_categories;
331     avdtp_capabilities_t capabilities;
332 
333     uint16_t configured_service_categories;
334     avdtp_capabilities_t configuration;
335 } avdtp_sep_t;
336 
337 
338 typedef enum {
339     AVDTP_SIGNALING_CONNECTION_IDLE,
340     AVDTP_SIGNALING_W4_SDP_QUERY_COMPLETE,
341     AVDTP_SIGNALING_CONNECTION_W4_L2CAP_CONNECTED,
342     AVDTP_SIGNALING_CONNECTION_OPENED,
343     AVDTP_SIGNALING_CONNECTION_W4_L2CAP_DISCONNECTED
344 } avdtp_connection_state_t;
345 
346 typedef enum {
347     AVDTP_SIGNALING_CONNECTION_ACCEPTOR_IDLE,
348     AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_ANSWER_DISCOVER_SEPS,
349     AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE,
350     AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE,
351     AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_GENERAL_REJECT_WITH_ERROR_CODE
352 } avdtp_acceptor_connection_state_t;
353 
354 typedef enum {
355     AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE,
356     AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_DISCOVER_SEPS,
357     AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CAPABILITIES,
358     AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_ALL_CAPABILITIES,
359     AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CONFIGURATION,
360     AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER
361 } avdtp_initiator_connection_state_t;
362 
363 typedef struct {
364     uint8_t  command[200];
365     uint16_t size;
366     uint16_t offset;
367     uint8_t  acp_seid;
368     uint8_t  int_seid;
369     uint16_t transaction_label;
370     uint16_t num_packets;
371     avdtp_signal_identifier_t   signal_identifier;
372     avdtp_message_type_t        message_type;
373     avdtp_packet_type_t         packet_type;
374 } avdtp_signaling_packet_t;
375 
376 
377 typedef struct {
378     btstack_linked_item_t    item;
379     bd_addr_t remote_addr;
380 
381     uint16_t avdtp_cid;
382     uint16_t l2cap_signaling_cid;
383     avdtp_service_mode_t service_mode;
384 
385     avdtp_connection_state_t state;
386     avdtp_acceptor_connection_state_t  acceptor_connection_state;
387     avdtp_initiator_connection_state_t initiator_connection_state;
388 
389     // used for fragmentation
390     // avdtp_signaling_packet_header_t signaling_header;
391     avdtp_signaling_packet_t signaling_packet;
392 
393     uint8_t disconnect;
394 
395     uint8_t local_seid;
396     uint8_t remote_seid;
397 
398     uint8_t initiator_transaction_label;
399     uint8_t acceptor_transaction_label;
400     uint8_t wait_to_send_acceptor;
401     uint8_t wait_to_send_initiator;
402     uint8_t wait_to_send_self;
403 
404     uint8_t suspended_seids[MAX_NUM_SEPS];
405     uint8_t num_suspended_seids;
406 
407     uint8_t reject_service_category;
408     avdtp_signal_identifier_t reject_signal_identifier;
409     uint8_t error_code;
410 
411     // store configurations with remote seps
412     avdtp_sep_t remote_seps[MAX_NUM_SEPS];
413     uint8_t remote_seps_num;
414 
415     // store current role
416     uint8_t is_initiator;
417     uint8_t is_configuration_initiated_locally;
418     btstack_timer_source_t configuration_timer;
419 } avdtp_connection_t;
420 
421 typedef enum {
422     A2DP_IDLE,
423     A2DP_CONNECTED,
424     A2DP_W2_DISCOVER_SEPS,
425     A2DP_W2_GET_CAPABILITIES,
426     A2DP_W2_GET_ALL_CAPABILITIES,
427     A2DP_W2_SET_CONFIGURATION,      //5
428     A2DP_W4_GET_CONFIGURATION,
429     A2DP_W4_SET_CONFIGURATION,
430     A2DP_W2_SUSPEND_STREAM_WITH_SEID,
431     A2DP_W2_RECONFIGURE_WITH_SEID,
432     A2DP_W2_OPEN_STREAM_WITH_SEID,   //10
433     A2DP_W4_OPEN_STREAM_WITH_SEID,
434     A2DP_W2_START_STREAM_WITH_SEID,
435     A2DP_W2_ABORT_STREAM_WITH_SEID,
436     A2DP_W2_STOP_STREAM_WITH_SEID,
437     A2DP_STREAMING_OPENED
438 } a2dp_state_t;
439 
440 typedef struct avdtp_stream_endpoint {
441     btstack_linked_item_t    item;
442 
443     // original capabilities
444     avdtp_sep_t sep;
445     hci_con_handle_t media_con_handle;
446     uint16_t l2cap_media_cid;
447     uint16_t l2cap_reporting_cid;
448     uint16_t l2cap_recovery_cid;
449 
450     avdtp_stream_endpoint_state_t  state;
451     avdtp_acceptor_stream_endpoint_state_t  acceptor_config_state;
452     avdtp_initiator_stream_endpoint_state_t initiator_config_state;
453     a2dp_state_t a2dp_state;
454     // active connection
455     avdtp_connection_t * connection;
456     // currently active remote seid
457     uint8_t remote_sep_index;
458     avdtp_capabilities_t remote_capabilities;
459     uint16_t remote_capabilities_bitmap;
460 
461     uint16_t remote_configuration_bitmap;
462     avdtp_capabilities_t remote_configuration;
463 
464     // temporary SBC config
465     avdtp_media_codec_type_t media_codec_type;
466     avdtp_media_type_t media_type;
467     uint8_t media_codec_sbc_info[4];
468 
469     // register request for media L2cap connection release
470     uint8_t media_disconnect;
471     uint8_t media_connect;
472     uint8_t start_stream;
473     uint8_t stop_stream;
474     uint8_t send_stream;
475     uint8_t abort_stream;
476     uint8_t suspend_stream;
477 
478     uint16_t sequence_number;
479 
480 } avdtp_stream_endpoint_t;
481 
482 typedef struct {
483 // to app
484     bd_addr_t remote_addr;
485 
486     uint32_t fill_audio_ring_buffer_timeout_ms;
487     uint32_t time_audio_data_sent; // msstream
488     uint32_t acc_num_missed_samples;
489     uint32_t samples_ready;
490     btstack_timer_source_t fill_audio_ring_buffer_timer;
491     btstack_ring_buffer_t sbc_ring_buffer;
492 
493     int reconfigure;
494     int num_channels;
495     int sampling_frequency;
496     int channel_mode;
497     int block_length;
498     int subbands;
499     int allocation_method;
500     int min_bitpool_value;
501     int max_bitpool_value;
502     avdtp_stream_endpoint_t * local_stream_endpoint;
503     avdtp_sep_t * active_remote_sep;
504 } avdtp_stream_endpoint_context_t;
505 
506 typedef struct {
507     btstack_linked_list_t connections;
508     btstack_linked_list_t stream_endpoints;
509     uint16_t stream_endpoints_id_counter;
510     uint16_t initiator_transaction_id_counter;
511     btstack_packet_handler_t avdtp_callback;
512     btstack_packet_handler_t a2dp_callback;
513     void (*handle_media_data)(uint8_t local_seid, uint8_t *packet, uint16_t size);
514     btstack_packet_handler_t packet_handler;
515 
516     avdtp_sep_type_t query_role;
517 
518     // SDP query
519     uint16_t avdtp_cid;
520     uint16_t avdtp_l2cap_psm;
521     uint16_t avdtp_version;
522     uint8_t  role_supported;
523 } avdtp_context_t;
524 
525 void avdtp_register_media_transport_category(avdtp_stream_endpoint_t * stream_endpoint);
526 void avdtp_register_reporting_category(avdtp_stream_endpoint_t * stream_endpoint);
527 void avdtp_register_delay_reporting_category(avdtp_stream_endpoint_t * stream_endpoint);
528 void avdtp_register_recovery_category(avdtp_stream_endpoint_t * stream_endpoint, uint8_t maximum_recovery_window_size, uint8_t maximum_number_media_packets);
529 void avdtp_register_content_protection_category(avdtp_stream_endpoint_t * stream_endpoint, uint16_t cp_type, const uint8_t * cp_type_value, uint8_t cp_type_value_len);
530 void avdtp_register_header_compression_category(avdtp_stream_endpoint_t * stream_endpoint, uint8_t back_ch, uint8_t media, uint8_t recovery);
531 void avdtp_register_media_codec_category(avdtp_stream_endpoint_t * stream_endpoint, 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);
532 void avdtp_register_multiplexing_category(avdtp_stream_endpoint_t * stream_endpoint, uint8_t fragmentation);
533 void avdtp_handle_can_send_now(avdtp_connection_t * connection, uint16_t l2cap_cid, avdtp_context_t * context);
534 
535 void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, avdtp_context_t * context);
536 avdtp_connection_t * avdtp_create_connection(bd_addr_t remote_addr, avdtp_context_t * context);
537 avdtp_stream_endpoint_t * avdtp_create_stream_endpoint(avdtp_sep_type_t sep_type, avdtp_media_type_t media_type, avdtp_context_t * context);
538 
539 uint8_t avdtp_connect(bd_addr_t remote, avdtp_sep_type_t query_role, avdtp_context_t * context, uint16_t * avdtp_cid);
540 uint8_t avdtp_disconnect(uint16_t avdtp_cid, avdtp_context_t * context);
541 uint8_t avdtp_open_stream(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote_seid, avdtp_context_t * context);
542 uint8_t avdtp_start_stream(uint16_t avdtp_cid, uint8_t local_seid, avdtp_context_t * context);
543 uint8_t avdtp_stop_stream (uint16_t avdtp_cid, uint8_t local_seid, avdtp_context_t * context);
544 uint8_t avdtp_abort_stream(uint16_t avdtp_cid, uint8_t local_seid, avdtp_context_t * context);
545 uint8_t avdtp_suspend_stream(uint16_t avdtp_cid, uint8_t local_seid, avdtp_context_t * context);
546 
547 void avdtp_discover_stream_endpoints(uint16_t avdtp_cid, avdtp_context_t * context);
548 void avdtp_get_capabilities(uint16_t avdtp_cid, uint8_t remote_seid, avdtp_context_t * context);
549 void avdtp_get_all_capabilities(uint16_t avdtp_cid, uint8_t remote_seid, avdtp_context_t * context);
550 void avdtp_get_configuration(uint16_t avdtp_cid, uint8_t remote_seid, avdtp_context_t * context);
551 void avdtp_set_configuration(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context);
552 void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context);
553 uint8_t avdtp_remote_seps_num(uint16_t avdtp_cid, avdtp_context_t * context);
554 avdtp_sep_t * avdtp_remote_sep(uint16_t avdtp_cid, uint8_t index, avdtp_context_t * context);
555 
556 void avdtp_initialize_sbc_configuration_storage(avdtp_stream_endpoint_t * stream_endpoint, uint8_t * config_storage, uint16_t storage_size, uint8_t * packet, uint16_t packet_size);
557 uint8_t avdtp_choose_sbc_channel_mode(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_channel_mode_bitmap);
558 uint8_t avdtp_choose_sbc_allocation_method(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_allocation_method_bitmap);
559 
560 uint8_t avdtp_choose_sbc_subbands(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_subbands_bitmap);
561 uint8_t avdtp_choose_sbc_block_length(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_block_length_bitmap);
562 uint8_t avdtp_choose_sbc_sampling_frequency(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_sampling_frequency_bitmap);
563 uint8_t avdtp_choose_sbc_max_bitpool_value(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_max_bitpool_value);
564 uint8_t avdtp_choose_sbc_min_bitpool_value(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_min_bitpool_value);
565 
566 uint8_t avdtp_stream_endpoint_seid(avdtp_stream_endpoint_t * stream_endpoint);
567 void avdtp_configuration_timeout_handler(btstack_timer_source_t * timer);
568 void avdtp_configuration_timer_start(avdtp_connection_t * connection);
569 void avdtp_configuration_timer_stop(avdtp_connection_t * connection);
570 
571 #if defined __cplusplus
572 }
573 #endif
574 
575 #endif // __AVDTP_H