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