1 /****************************************************************************** 2 * 3 * Copyright (C) 2002-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 /****************************************************************************** 20 * 21 * This interface file contains the interface to the Audio Video 22 * Distribution Transport Protocol (AVDTP). 23 * 24 ******************************************************************************/ 25 #ifndef AVDT_API_H 26 #define AVDT_API_H 27 28 #include "stack/bt_types.h" 29 #include "common/bt_target.h" 30 31 /***************************************************************************** 32 ** Constants 33 *****************************************************************************/ 34 #ifndef AVDT_VERSION 35 #define AVDT_VERSION 0x0102 36 #endif 37 #define AVDT_VERSION_SYNC 0x0103 38 39 /* API function return value result codes. */ 40 #define AVDT_SUCCESS 0 /* Function successful */ 41 #define AVDT_BAD_PARAMS 1 /* Invalid parameters */ 42 #define AVDT_NO_RESOURCES 2 /* Not enough resources */ 43 #define AVDT_BAD_HANDLE 3 /* Bad handle */ 44 #define AVDT_BUSY 4 /* A procedure is already in progress */ 45 #define AVDT_WRITE_FAIL 5 /* Write failed */ 46 47 /* The index to access the codec type in codec_info[]. */ 48 #define AVDT_CODEC_TYPE_INDEX 2 49 50 /* The size in bytes of a Adaptation Layer header. */ 51 #define AVDT_AL_HDR_SIZE 3 52 53 /* The size in bytes of a media packet header. */ 54 #define AVDT_MEDIA_HDR_SIZE 12 55 56 /* AVDTP 7.5.3 Adaptation Layer Fragmentation 57 * original length of the un-fragmented transport packet should be specified by 58 * two bytes length field of Adaptation Layer Header */ 59 #define AVDT_MAX_MEDIA_SIZE (0xFFFF - AVDT_MEDIA_HDR_SIZE) 60 61 /* The handle is used when reporting MULTI_AV specific events */ 62 #define AVDT_MULTI_AV_HANDLE 0xFF 63 64 /* The number of bytes needed by the protocol stack for the protocol headers 65 ** of a media packet. This is the size of the media packet header, the 66 ** L2CAP packet header and HCI header. 67 */ 68 #define AVDT_MEDIA_OFFSET 23 69 70 /* The marker bit is used by the application to mark significant events such 71 ** as frame boundaries in the data stream. This constant is used to check or 72 ** set the marker bit in the m_pt parameter of an AVDT_WriteReq() 73 ** or AVDT_DATA_IND_EVT. 74 */ 75 #define AVDT_MARKER_SET 0x80 76 77 /* SEP Type. This indicates the stream endpoint type. */ 78 #define AVDT_TSEP_SRC 0 /* Source SEP */ 79 #define AVDT_TSEP_SNK 1 /* Sink SEP */ 80 81 /* initiator/acceptor role for adaption */ 82 #define AVDT_INT 0 /* initiator */ 83 #define AVDT_ACP 1 /* acceptor */ 84 85 /* Media Type. This indicates the media type of the stream endpoint. */ 86 #define AVDT_MEDIA_AUDIO 0 /* Audio SEP */ 87 #define AVDT_MEDIA_VIDEO 1 /* Video SEP */ 88 #define AVDT_MEDIA_MULTI 2 /* Multimedia SEP */ 89 90 /* for reporting packets */ 91 #define AVDT_RTCP_PT_SR 200 /* the packet type - SR (Sender Report) */ 92 #define AVDT_RTCP_PT_RR 201 /* the packet type - RR (Receiver Report) */ 93 #define AVDT_RTCP_PT_SDES 202 /* the packet type - SDES (Source Description) */ 94 typedef UINT8 AVDT_REPORT_TYPE; 95 96 #define AVDT_RTCP_SDES_CNAME 1 /* SDES item CNAME */ 97 #ifndef AVDT_MAX_CNAME_SIZE 98 #define AVDT_MAX_CNAME_SIZE 28 99 #endif 100 101 /* Protocol service capabilities. This indicates the protocol service 102 ** capabilities of a stream endpoint. This value is a mask. 103 ** Multiple values can be combined with a bitwise OR. 104 */ 105 #define AVDT_PSC_TRANS (1<<1) /* Media transport */ 106 #define AVDT_PSC_REPORT (1<<2) /* Reporting */ 107 #define AVDT_PSC_RECOV (1<<3) /* Recovery */ 108 #define AVDT_PSC_HDRCMP (1<<5) /* Header compression */ 109 #define AVDT_PSC_MUX (1<<6) /* Multiplexing */ 110 #define AVDT_PSC_DELAY_RPT (1<<8) /* Delay Report */ 111 112 /* Max audio per 3-DH5 EDR packet: 23.2ms 113 ** jitter buffer: 5(JITTER_BUFFER_WATER_LEVEL) 114 */ 115 #define AVDT_DELAY_RPT_DFT_VALUE 1200 /* 120 ms */ 116 #define AVDT_DELAY_RPT_TIMER_TICK_MS 2000 /* 2000 ms */ 117 118 /* Recovery type. This indicates the recovery type. */ 119 #define AVDT_RECOV_RFC2733 1 /* RFC2733 recovery */ 120 121 /* Header compression capabilities. This indicates the header compression 122 ** capabilities. This value is a mask. Multiple values can be combined 123 ** with a bitwise OR. 124 */ 125 #define AVDT_HDRCMP_MEDIA (1<<5) /* Available for media packets */ 126 #define AVDT_HDRCMP_RECOV (1<<6) /* Available for recovery packets */ 127 #define AVDT_HDRCMP_BACKCH (1<<7) /* Back channel supported */ 128 129 /* Multiplexing capabilities mask. */ 130 #define AVDT_MUX_FRAG (1<<7) /* Allow Adaptation Layer Fragmentation */ 131 132 /* Application service category. This indicates the application 133 ** service category. 134 */ 135 #define AVDT_ASC_PROTECT 4 /* Content protection */ 136 #define AVDT_ASC_CODEC 7 /* Codec */ 137 138 /* Error codes. The following are error codes defined in the AVDTP and GAVDP 139 ** specifications. These error codes communicate protocol errors between 140 ** AVDTP and the application. More detailed descriptions of the error codes 141 ** and their appropriate use can be found in the AVDTP and GAVDP specifications. 142 ** These error codes are unrelated to the result values returned by the 143 ** AVDTP API functions. 144 */ 145 #define AVDT_ERR_HEADER 0x01 /* Bad packet header format */ 146 #define AVDT_ERR_LENGTH 0x11 /* Bad packet length */ 147 #define AVDT_ERR_SEID 0x12 /* Invalid SEID */ 148 #define AVDT_ERR_IN_USE 0x13 /* The SEP is in use */ 149 #define AVDT_ERR_NOT_IN_USE 0x14 /* The SEP is not in use */ 150 #define AVDT_ERR_CATEGORY 0x17 /* Bad service category */ 151 #define AVDT_ERR_PAYLOAD 0x18 /* Bad payload format */ 152 #define AVDT_ERR_NSC 0x19 /* Requested command not supported */ 153 #define AVDT_ERR_INVALID_CAP 0x1A /* Reconfigure attempted invalid capabilities */ 154 #define AVDT_ERR_RECOV_TYPE 0x22 /* Requested recovery type not defined */ 155 #define AVDT_ERR_MEDIA_TRANS 0x23 /* Media transport capability not correct */ 156 #define AVDT_ERR_RECOV_FMT 0x25 /* Recovery service capability not correct */ 157 #define AVDT_ERR_ROHC_FMT 0x26 /* Header compression service capability not correct */ 158 #define AVDT_ERR_CP_FMT 0x27 /* Content protection service capability not correct */ 159 #define AVDT_ERR_MUX_FMT 0x28 /* Multiplexing service capability not correct */ 160 #define AVDT_ERR_UNSUP_CFG 0x29 /* Configuration not supported */ 161 #define AVDT_ERR_BAD_STATE 0x31 /* Message cannot be processed in this state */ 162 #define AVDT_ERR_REPORT_FMT 0x65 /* Report service capability not correct */ 163 #define AVDT_ERR_SERVICE 0x80 /* Invalid service category */ 164 #define AVDT_ERR_RESOURCE 0x81 /* Insufficient resources */ 165 #define AVDT_ERR_INVALID_MCT 0xC1 /* Invalid Media Codec Type */ 166 #define AVDT_ERR_UNSUP_MCT 0xC2 /* Unsupported Media Codec Type */ 167 #define AVDT_ERR_INVALID_LEVEL 0xC3 /* Invalid Level */ 168 #define AVDT_ERR_UNSUP_LEVEL 0xC4 /* Unsupported Level */ 169 #define AVDT_ERR_INVALID_CP 0xE0 /* Invalid Content Protection Type */ 170 #define AVDT_ERR_INVALID_FORMAT 0xE1 /* Invalid Content Protection format */ 171 172 /* Additional error codes. This indicates error codes used by AVDTP 173 ** in addition to the ones defined in the specifications. 174 */ 175 #define AVDT_ERR_CONNECT 0x07 /* Connection failed. */ 176 #define AVDT_ERR_TIMEOUT 0x08 /* Response timeout. */ 177 178 /* Control callback events. */ 179 #define AVDT_DISCOVER_CFM_EVT 0 /* Discover confirm */ 180 #define AVDT_GETCAP_CFM_EVT 1 /* Get capabilities confirm */ 181 #define AVDT_OPEN_CFM_EVT 2 /* Open confirm */ 182 #define AVDT_OPEN_IND_EVT 3 /* Open indication */ 183 #define AVDT_CONFIG_IND_EVT 4 /* Configuration indication */ 184 #define AVDT_START_CFM_EVT 5 /* Start confirm */ 185 #define AVDT_START_IND_EVT 6 /* Start indication */ 186 #define AVDT_SUSPEND_CFM_EVT 7 /* Suspend confirm */ 187 #define AVDT_SUSPEND_IND_EVT 8 /* Suspend indication */ 188 #define AVDT_CLOSE_CFM_EVT 9 /* Close confirm */ 189 #define AVDT_CLOSE_IND_EVT 10 /* Close indication */ 190 #define AVDT_RECONFIG_CFM_EVT 11 /* Reconfiguration confirm */ 191 #define AVDT_RECONFIG_IND_EVT 12 /* Reconfiguration indication */ 192 #define AVDT_SECURITY_CFM_EVT 13 /* Security confirm */ 193 #define AVDT_SECURITY_IND_EVT 14 /* Security indication */ 194 #define AVDT_WRITE_CFM_EVT 15 /* Write confirm */ 195 #define AVDT_CONNECT_IND_EVT 16 /* Signaling channel connected */ 196 #define AVDT_DISCONNECT_IND_EVT 17 /* Signaling channel disconnected */ 197 #define AVDT_REPORT_CONN_EVT 18 /* Reporting channel connected */ 198 #define AVDT_REPORT_DISCONN_EVT 19 /* Reporting channel disconnected */ 199 #define AVDT_DELAY_REPORT_EVT 20 /* Delay report received */ 200 #define AVDT_DELAY_REPORT_CFM_EVT 21 /* Delay report response received */ 201 202 #define AVDT_MAX_EVT (AVDT_DELAY_REPORT_CFM_EVT) 203 204 /* PSM for AVDT */ 205 #define AVDT_PSM 0x0019 206 207 /* Nonsupported protocol command messages. This value is used in tAVDT_CS */ 208 #define AVDT_NSC_SUSPEND 0x01 /* Suspend command not supported */ 209 #define AVDT_NSC_RECONFIG 0x02 /* Reconfigure command not supported */ 210 #define AVDT_NSC_SECURITY 0x04 /* Security command not supported */ 211 212 /* AVDT disconnection reason */ 213 #define AVDT_DISC_RSN_NORMAL 0 214 #define AVDT_DISC_RSN_ABNORMAL (0xce) /* unintentional disconnection */ 215 /***************************************************************************** 216 ** Type Definitions 217 *****************************************************************************/ 218 219 typedef struct { 220 UINT32 ntp_sec; /* NTP time: seconds relative to 0h UTC on 1 January 1900 */ 221 UINT32 ntp_frac; /* NTP time: the fractional part */ 222 UINT32 rtp_time; /* timestamp in RTP header */ 223 UINT32 pkt_count; /* sender's packet count: since starting transmission 224 * up until the time this SR packet was generated. */ 225 UINT32 octet_count; /* sender's octet count: same comment */ 226 } tAVDT_SENDER_INFO; 227 228 typedef struct { 229 UINT8 frag_lost; /* fraction lost since last RR */ 230 UINT32 packet_lost; /* cumulative number of packets lost since the beginning */ 231 UINT32 seq_num_rcvd; /* extended highest sequence number received */ 232 UINT32 jitter; /* interarrival jitter */ 233 UINT32 lsr; /* last SR timestamp */ 234 UINT32 dlsr; /* delay since last SR */ 235 } tAVDT_REPORT_BLK; 236 237 typedef union { 238 tAVDT_SENDER_INFO sr; 239 tAVDT_REPORT_BLK rr; 240 UINT8 cname[AVDT_MAX_CNAME_SIZE + 1]; 241 } tAVDT_REPORT_DATA; 242 243 /* This structure contains parameters which are set at registration. */ 244 typedef struct { 245 UINT16 ctrl_mtu; /* L2CAP MTU of the AVDTP signaling channel */ 246 UINT8 ret_tout; /* AVDTP signaling retransmission timeout */ 247 UINT8 sig_tout; /* AVDTP signaling message timeout */ 248 UINT8 idle_tout; /* AVDTP idle signaling channel timeout */ 249 UINT8 sec_mask; /* Security mask for BTM_SetSecurityLevel() */ 250 } tAVDT_REG; 251 252 /* This structure contains the SEP information. This information is 253 ** transferred during the discovery procedure. 254 */ 255 typedef struct { 256 BOOLEAN in_use; /* TRUE if stream is currently in use */ 257 UINT8 seid; /* Stream endpoint identifier */ 258 UINT8 media_type; /* Media type */ 259 UINT8 tsep; /* SEP type */ 260 } tAVDT_SEP_INFO; 261 262 /* This structure contains the SEP configuration. */ 263 typedef struct { 264 UINT8 codec_info[AVDT_CODEC_SIZE]; /* Codec capabilities array */ 265 UINT8 protect_info[AVDT_PROTECT_SIZE]; /* Content protection capabilities */ 266 UINT8 num_codec; /* Number of media codec information elements */ 267 UINT8 num_protect; /* Number of content protection information elements */ 268 UINT16 psc_mask; /* Protocol service capabilities mask */ 269 UINT8 recov_type; /* Recovery type */ 270 UINT8 recov_mrws; /* Maximum recovery window size */ 271 UINT8 recov_mnmp; /* Recovery maximum number of media packets */ 272 UINT8 hdrcmp_mask; /* Header compression capabilities */ 273 #if AVDT_MULTIPLEXING == TRUE 274 UINT8 mux_mask; /* Multiplexing capabilities. AVDT_MUX_XXX bits can be combined with a bitwise OR */ 275 UINT8 mux_tsid_media; /* TSID for media transport session */ 276 UINT8 mux_tcid_media; /* TCID for media transport session */ 277 UINT8 mux_tsid_report; /* TSID for reporting transport session */ 278 UINT8 mux_tcid_report; /* TCID for reporting transport session */ 279 UINT8 mux_tsid_recov; /* TSID for recovery transport session */ 280 UINT8 mux_tcid_recov; /* TCID for recovery transport session */ 281 #endif 282 } tAVDT_CFG; 283 284 /* Header structure for callback event parameters. */ 285 typedef struct { 286 UINT8 err_code; /* Zero if operation succeeded; nonzero if operation failed */ 287 UINT8 err_param; /* Error parameter included for some events */ 288 UINT8 label; /* Transaction label */ 289 UINT8 seid; /* For internal use only */ 290 UINT8 sig_id; /* For internal use only */ 291 UINT8 ccb_idx; /* For internal use only */ 292 } tAVDT_EVT_HDR; 293 294 /* This data structure is associated with the AVDT_GETCAP_CFM_EVT, 295 ** AVDT_RECONFIG_IND_EVT, and AVDT_RECONFIG_CFM_EVT. 296 */ 297 typedef struct { 298 tAVDT_EVT_HDR hdr; /* Event header */ 299 tAVDT_CFG *p_cfg; /* Pointer to configuration for this SEP */ 300 } tAVDT_CONFIG; 301 302 /* This data structure is associated with the AVDT_CONFIG_IND_EVT. */ 303 typedef struct { 304 tAVDT_EVT_HDR hdr; /* Event header */ 305 tAVDT_CFG *p_cfg; /* Pointer to configuration for this SEP */ 306 UINT8 int_seid; /* Stream endpoint ID of stream initiating the operation */ 307 } tAVDT_SETCONFIG; 308 309 /* This data structure is associated with the AVDT_OPEN_IND_EVT and AVDT_OPEN_CFM_EVT. */ 310 typedef struct { 311 tAVDT_EVT_HDR hdr; /* Event header */ 312 UINT16 peer_mtu; /* Transport channel L2CAP MTU of the peer */ 313 UINT16 lcid; /* L2CAP LCID for media channel */ 314 } tAVDT_OPEN; 315 316 /* This data structure is associated with the AVDT_SECURITY_IND_EVT 317 ** and AVDT_SECURITY_CFM_EVT. 318 */ 319 typedef struct { 320 tAVDT_EVT_HDR hdr; /* Event header */ 321 UINT8 *p_data; /* Pointer to security data */ 322 UINT16 len; /* Length in bytes of the security data */ 323 } tAVDT_SECURITY; 324 325 /* This data structure is associated with the AVDT_DISCOVER_CFM_EVT. */ 326 typedef struct { 327 tAVDT_EVT_HDR hdr; /* Event header */ 328 tAVDT_SEP_INFO *p_sep_info; /* Pointer to SEP information */ 329 UINT8 num_seps; /* Number of stream endpoints */ 330 } tAVDT_DISCOVER; 331 332 /* This data structure is associated with the AVDT_DELAY_REPORT_EVT. */ 333 typedef struct { 334 tAVDT_EVT_HDR hdr; /* Event header */ 335 UINT16 delay; /* Delay value */ 336 } tAVDT_DELAY_RPT; 337 338 /* Union of all control callback event data structures */ 339 typedef union { 340 tAVDT_EVT_HDR hdr; 341 tAVDT_DISCOVER discover_cfm; 342 tAVDT_CONFIG getcap_cfm; 343 tAVDT_OPEN open_cfm; 344 tAVDT_OPEN open_ind; 345 tAVDT_SETCONFIG config_ind; 346 tAVDT_EVT_HDR start_cfm; 347 tAVDT_EVT_HDR suspend_cfm; 348 tAVDT_EVT_HDR close_cfm; 349 tAVDT_CONFIG reconfig_cfm; 350 tAVDT_CONFIG reconfig_ind; 351 tAVDT_SECURITY security_cfm; 352 tAVDT_SECURITY security_ind; 353 tAVDT_EVT_HDR connect_ind; 354 tAVDT_EVT_HDR disconnect_ind; 355 tAVDT_EVT_HDR report_conn; 356 tAVDT_DELAY_RPT delay_rpt_cmd; 357 } tAVDT_CTRL; 358 359 /* This is the control callback function. This function passes control events 360 ** to the application. This function is required for all registered stream 361 ** endpoints and for the AVDT_DiscoverReq() and AVDT_GetCapReq() functions. 362 ** 363 */ 364 typedef void (tAVDT_CTRL_CBACK)(UINT8 handle, BD_ADDR bd_addr, UINT8 event, 365 tAVDT_CTRL *p_data); 366 367 /* This is the data callback function. It is executed when AVDTP has a media 368 ** packet ready for the application. This function is required for SNK 369 ** endpoints and not applicable for SRC endpoints. 370 */ 371 typedef void (tAVDT_DATA_CBACK)(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, 372 UINT8 m_pt); 373 374 #if AVDT_MULTIPLEXING == TRUE 375 /* This is the second version of the data callback function. This version uses 376 ** application buffer assigned by AVDT_SetMediaBuf. Caller can assign different 377 ** buffer during callback or can leave the current buffer for further using. 378 ** This callback is called when AVDTP has a media packet ready for the application. 379 ** This function is required for SNK endpoints and not applicable for SRC endpoints. 380 */ 381 typedef void (tAVDT_MEDIA_CBACK)(UINT8 handle, UINT8 *p_payload, UINT32 payload_len, 382 UINT32 time_stamp, UINT16 seq_num, UINT8 m_pt, UINT8 marker); 383 #endif 384 385 #if AVDT_REPORTING == TRUE 386 /* This is the report callback function. It is executed when AVDTP has a reporting 387 ** packet ready for the application. This function is required for streams 388 ** created with AVDT_PSC_REPORT. 389 */ 390 typedef void (tAVDT_REPORT_CBACK)(UINT8 handle, AVDT_REPORT_TYPE type, 391 tAVDT_REPORT_DATA *p_data); 392 #endif 393 394 typedef UINT16 (tAVDT_GETCAP_REQ) (BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, tAVDT_CTRL_CBACK *p_cback); 395 396 /* This structure contains information required when a stream is created. 397 ** It is passed to the AVDT_CreateStream() function. 398 */ 399 typedef struct { 400 tAVDT_CFG cfg; /* SEP configuration */ 401 tAVDT_CTRL_CBACK *p_ctrl_cback; /* Control callback function */ 402 tAVDT_DATA_CBACK *p_data_cback; /* Data callback function */ 403 #if AVDT_MULTIPLEXING == TRUE 404 tAVDT_MEDIA_CBACK *p_media_cback; /* Media callback function. It will be called only if p_data_cback is NULL */ 405 #endif 406 #if AVDT_REPORTING == TRUE 407 tAVDT_REPORT_CBACK *p_report_cback;/* Report callback function. */ 408 #endif 409 UINT16 mtu; /* The L2CAP MTU of the transport channel */ 410 UINT16 flush_to; /* The L2CAP flush timeout of the transport channel */ 411 UINT8 tsep; /* SEP type */ 412 UINT8 media_type; /* Media type */ 413 UINT16 nsc_mask; /* Nonsupported protocol command messages */ 414 } tAVDT_CS; 415 416 /* AVDT data option mask is used in the write request */ 417 #define AVDT_DATA_OPT_NONE 0x00 /* No option still add RTP header */ 418 #define AVDT_DATA_OPT_NO_RTP (0x01 << 0) /* Skip adding RTP header */ 419 420 typedef UINT8 tAVDT_DATA_OPT_MASK; 421 422 423 424 /***************************************************************************** 425 ** External Function Declarations 426 *****************************************************************************/ 427 #ifdef __cplusplus 428 extern "C" 429 { 430 #endif 431 432 /******************************************************************************* 433 ** 434 ** Function AVDT_Register 435 ** 436 ** Description This is the system level registration function for the 437 ** AVDTP protocol. This function initializes AVDTP and 438 ** prepares the protocol stack for its use. This function 439 ** must be called once by the system or platform using AVDTP 440 ** before the other functions of the API an be used. 441 ** 442 ** 443 ** Returns void 444 ** 445 *******************************************************************************/ 446 extern void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback); 447 448 /******************************************************************************* 449 ** 450 ** Function AVDT_Deregister 451 ** 452 ** Description This function is called to deregister use AVDTP protocol. 453 ** It is called when AVDTP is no longer being used by any 454 ** application in the system. Before this function can be 455 ** called, all streams must be removed with AVDT_RemoveStream(). 456 ** 457 ** 458 ** Returns void 459 ** 460 *******************************************************************************/ 461 extern void AVDT_Deregister(void); 462 463 464 /******************************************************************************* 465 ** 466 ** Function AVDT_SINK_Activate 467 ** 468 ** Description Activate SEP of A2DP Sink. In Use parameter is adjusted. 469 ** In Use will be made false in case of activation. A2DP SRC 470 ** will receive in_use as false and can open A2DP Sink 471 ** connection 472 ** 473 ** Returns void 474 ** 475 *******************************************************************************/ 476 extern void AVDT_SINK_Activate(void); 477 478 /******************************************************************************* 479 ** 480 ** Function AVDT_SINK_Deactivate 481 ** 482 ** Description Deactivate SEP of A2DP Sink. In Use parameter is adjusted. 483 ** In Use will be made TRUE in case of activation. A2DP SRC 484 ** will receive in_use as true and will not open A2DP Sink 485 ** connection 486 ** 487 ** Returns void. 488 ** 489 *******************************************************************************/ 490 extern void AVDT_SINK_Deactivate(void); 491 492 /******************************************************************************* 493 ** 494 ** Function AVDT_AbortReq 495 ** 496 ** Description Trigger Abort request to pass AVDTP Abort related mandatory 497 ** PTS Test case. 498 ** 499 ** Returns void. 500 ** 501 *******************************************************************************/ 502 extern void AVDT_AbortReq(UINT8 handle); 503 504 /******************************************************************************* 505 ** 506 ** Function AVDT_CreateStream 507 ** 508 ** Description Create a stream endpoint. After a stream endpoint is 509 ** created an application can initiate a connection between 510 ** this endpoint and an endpoint on a peer device. In 511 ** addition, a peer device can discover, get the capabilities, 512 ** and connect to this endpoint. 513 ** 514 ** 515 ** Returns AVDT_SUCCESS if successful, otherwise error. 516 ** 517 *******************************************************************************/ 518 extern UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs); 519 520 /******************************************************************************* 521 ** 522 ** Function AVDT_RemoveStream 523 ** 524 ** Description Remove a stream endpoint. This function is called when 525 ** the application is no longer using a stream endpoint. 526 ** If this function is called when the endpoint is connected 527 ** the connection is closed and then the stream endpoint 528 ** is removed. 529 ** 530 ** 531 ** Returns AVDT_SUCCESS if successful, otherwise error. 532 ** 533 *******************************************************************************/ 534 extern UINT16 AVDT_RemoveStream(UINT8 handle); 535 536 /******************************************************************************* 537 ** 538 ** Function AVDT_DiscoverReq 539 ** 540 ** Description This function initiates a connection to the AVDTP service 541 ** on the peer device, if not already present, and discovers 542 ** the stream endpoints on the peer device. (Please note 543 ** that AVDTP discovery is unrelated to SDP discovery). 544 ** This function can be called at any time regardless of whether 545 ** there is an AVDTP connection to the peer device. 546 ** 547 ** When discovery is complete, an AVDT_DISCOVER_CFM_EVT 548 ** is sent to the application via its callback function. 549 ** The application must not call AVDT_GetCapReq() or 550 ** AVDT_DiscoverReq() again to the same device until 551 ** discovery is complete. 552 ** 553 ** The memory addressed by sep_info is allocated by the 554 ** application. This memory is written to by AVDTP as part 555 ** of the discovery procedure. This memory must remain 556 ** accessible until the application receives the 557 ** AVDT_DISCOVER_CFM_EVT. 558 ** 559 ** Returns AVDT_SUCCESS if successful, otherwise error. 560 ** 561 *******************************************************************************/ 562 extern UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_info, 563 UINT8 max_seps, tAVDT_CTRL_CBACK *p_cback); 564 565 566 /******************************************************************************* 567 ** 568 ** Function AVDT_GetCapReq 569 ** 570 ** Description This function initiates a connection to the AVDTP service 571 ** on the peer device, if not already present, and gets the 572 ** capabilities of a stream endpoint on the peer device. 573 ** This function can be called at any time regardless of 574 ** whether there is an AVDTP connection to the peer device. 575 ** 576 ** When the procedure is complete, an AVDT_GETCAP_CFM_EVT is 577 ** sent to the application via its callback function. The 578 ** application must not call AVDT_GetCapReq() or 579 ** AVDT_DiscoverReq() again until the procedure is complete. 580 ** 581 ** The memory pointed to by p_cfg is allocated by the 582 ** application. This memory is written to by AVDTP as part 583 ** of the get capabilities procedure. This memory must 584 ** remain accessible until the application receives 585 ** the AVDT_GETCAP_CFM_EVT. 586 ** 587 ** Returns AVDT_SUCCESS if successful, otherwise error. 588 ** 589 *******************************************************************************/ 590 extern UINT16 AVDT_GetCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, 591 tAVDT_CTRL_CBACK *p_cback); 592 593 /******************************************************************************* 594 ** 595 ** Function AVDT_GetAllCapReq 596 ** 597 ** Description This function initiates a connection to the AVDTP service 598 ** on the peer device, if not already present, and gets the 599 ** capabilities of a stream endpoint on the peer device. 600 ** This function can be called at any time regardless of 601 ** whether there is an AVDTP connection to the peer device. 602 ** 603 ** When the procedure is complete, an AVDT_GETCAP_CFM_EVT is 604 ** sent to the application via its callback function. The 605 ** application must not call AVDT_GetCapReq() or 606 ** AVDT_DiscoverReq() again until the procedure is complete. 607 ** 608 ** The memory pointed to by p_cfg is allocated by the 609 ** application. This memory is written to by AVDTP as part 610 ** of the get capabilities procedure. This memory must 611 ** remain accessible until the application receives 612 ** the AVDT_GETCAP_CFM_EVT. 613 ** 614 ** Returns AVDT_SUCCESS if successful, otherwise error. 615 ** 616 *******************************************************************************/ 617 extern UINT16 AVDT_GetAllCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, 618 tAVDT_CTRL_CBACK *p_cback); 619 620 /******************************************************************************* 621 ** 622 ** Function AVDT_DelayReport 623 ** 624 ** Description This functions sends a Delay Report to the peer device 625 ** that is associated with a particular SEID. 626 ** This function is called by SNK device. 627 ** 628 ** Returns AVDT_SUCCESS if successful, otherwise error. 629 ** 630 *******************************************************************************/ 631 extern UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay); 632 633 /******************************************************************************* 634 ** 635 ** Function AVDT_OpenReq 636 ** 637 ** Description This function initiates a connection to the AVDTP service 638 ** on the peer device, if not already present, and connects 639 ** to a stream endpoint on a peer device. When the connection 640 ** is completed, an AVDT_OPEN_CFM_EVT is sent to the 641 ** application via the control callback function for this handle. 642 ** 643 ** Returns AVDT_SUCCESS if successful, otherwise error. 644 ** 645 *******************************************************************************/ 646 extern UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid, 647 tAVDT_CFG *p_cfg); 648 649 650 /******************************************************************************* 651 ** 652 ** Function AVDT_ConfigRsp 653 ** 654 ** Description Respond to a configure request from the peer device. This 655 ** function must be called if the application receives an 656 ** AVDT_CONFIG_IND_EVT through its control callback. 657 ** 658 ** 659 ** Returns AVDT_SUCCESS if successful, otherwise error. 660 ** 661 *******************************************************************************/ 662 extern UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, 663 UINT8 category); 664 665 /******************************************************************************* 666 ** 667 ** Function AVDT_StartReq 668 ** 669 ** Description Start one or more stream endpoints. This initiates the 670 ** transfer of media packets for the streams. All stream 671 ** endpoints must previously be opened. When the streams 672 ** are started, an AVDT_START_CFM_EVT is sent to the 673 ** application via the control callback function for each stream. 674 ** 675 ** 676 ** Returns AVDT_SUCCESS if successful, otherwise error. 677 ** 678 *******************************************************************************/ 679 extern UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles); 680 681 /******************************************************************************* 682 ** 683 ** Function AVDT_SuspendReq 684 ** 685 ** Description Suspend one or more stream endpoints. This suspends the 686 ** transfer of media packets for the streams. All stream 687 ** endpoints must previously be open and started. When the 688 ** streams are suspended, an AVDT_SUSPEND_CFM_EVT is sent to 689 ** the application via the control callback function for 690 ** each stream. 691 ** 692 ** 693 ** Returns AVDT_SUCCESS if successful, otherwise error. 694 ** 695 *******************************************************************************/ 696 extern UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles); 697 698 /******************************************************************************* 699 ** 700 ** Function AVDT_CloseReq 701 ** 702 ** Description Close a stream endpoint. This stops the transfer of media 703 ** packets and closes the transport channel associated with 704 ** this stream endpoint. When the stream is closed, an 705 ** AVDT_CLOSE_CFM_EVT is sent to the application via the 706 ** control callback function for this handle. 707 ** 708 ** 709 ** Returns AVDT_SUCCESS if successful, otherwise error. 710 ** 711 *******************************************************************************/ 712 extern UINT16 AVDT_CloseReq(UINT8 handle); 713 714 /******************************************************************************* 715 ** 716 ** Function AVDT_ReconfigReq 717 ** 718 ** Description Reconfigure a stream endpoint. This allows the application 719 ** to change the codec or content protection capabilities of 720 ** a stream endpoint after it has been opened. This function 721 ** can only be called if the stream is opened but not started 722 ** or if the stream has been suspended. When the procedure 723 ** is completed, an AVDT_RECONFIG_CFM_EVT is sent to the 724 ** application via the control callback function for this handle. 725 ** 726 ** 727 ** Returns AVDT_SUCCESS if successful, otherwise error. 728 ** 729 *******************************************************************************/ 730 extern UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg); 731 732 /******************************************************************************* 733 ** 734 ** Function AVDT_ReconfigRsp 735 ** 736 ** Description Respond to a reconfigure request from the peer device. 737 ** This function must be called if the application receives 738 ** an AVDT_RECONFIG_IND_EVT through its control callback. 739 ** 740 ** 741 ** Returns AVDT_SUCCESS if successful, otherwise error. 742 ** 743 *******************************************************************************/ 744 extern UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, 745 UINT8 category); 746 747 /******************************************************************************* 748 ** 749 ** Function AVDT_SecurityReq 750 ** 751 ** Description Send a security request to the peer device. When the 752 ** security procedure is completed, an AVDT_SECURITY_CFM_EVT 753 ** is sent to the application via the control callback function 754 ** for this handle. (Please note that AVDTP security procedures 755 ** are unrelated to Bluetooth link level security.) 756 ** 757 ** 758 ** Returns AVDT_SUCCESS if successful, otherwise error. 759 ** 760 *******************************************************************************/ 761 extern UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len); 762 763 /******************************************************************************* 764 ** 765 ** Function AVDT_SecurityRsp 766 ** 767 ** Description Respond to a security request from the peer device. 768 ** This function must be called if the application receives 769 ** an AVDT_SECURITY_IND_EVT through its control callback. 770 ** (Please note that AVDTP security procedures are unrelated 771 ** to Bluetooth link level security.) 772 ** 773 ** 774 ** Returns AVDT_SUCCESS if successful, otherwise error. 775 ** 776 *******************************************************************************/ 777 extern UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_code, 778 UINT8 *p_data, UINT16 len); 779 780 /******************************************************************************* 781 ** 782 ** Function AVDT_WriteReq 783 ** 784 ** Description Send a media packet to the peer device. The stream must 785 ** be started before this function is called. Also, this 786 ** function can only be called if the stream is a SRC. 787 ** 788 ** When AVDTP has sent the media packet and is ready for the 789 ** next packet, an AVDT_WRITE_CFM_EVT is sent to the 790 ** application via the control callback. The application must 791 ** wait for the AVDT_WRITE_CFM_EVT before it makes the next 792 ** call to AVDT_WriteReq(). If the applications calls 793 ** AVDT_WriteReq() before it receives the event the packet 794 ** will not be sent. The application may make its first call 795 ** to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT 796 ** or AVDT_START_IND_EVT. 797 ** 798 ** The application passes the packet using the BT_HDR structure. 799 ** This structure is described in section 2.1. The offset 800 ** field must be equal to or greater than AVDT_MEDIA_OFFSET. 801 ** This allows enough space in the buffer for the L2CAP and 802 ** AVDTP headers. 803 ** 804 ** The memory pointed to by p_pkt must be a GKI buffer 805 ** allocated by the application. This buffer will be freed 806 ** by the protocol stack; the application must not free 807 ** this buffer. 808 ** 809 ** 810 ** Returns AVDT_SUCCESS if successful, otherwise error. 811 ** 812 *******************************************************************************/ 813 extern UINT16 AVDT_WriteReq(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, 814 UINT8 m_pt); 815 /******************************************************************************* 816 ** 817 ** Function AVDT_WriteReqOpt 818 ** 819 ** Description Send a media packet to the peer device. The stream must 820 ** be started before this function is called. Also, this 821 ** function can only be called if the stream is a SRC 822 ** 823 ** When AVDTP has sent the media packet and is ready for the 824 ** next packet, an AVDT_WRITE_CFM_EVT is sent to the 825 ** application via the control callback. The application must 826 ** wait for the AVDT_WRITE_CFM_EVT before it makes the next 827 ** call to AVDT_WriteReq(). If the applications calls 828 ** AVDT_WriteReq() before it receives the event the packet 829 ** will not be sent. The application may make its first call 830 ** to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT 831 ** or AVDT_START_IND_EVT. 832 ** 833 ** The application passes the packet using the BT_HDR structure 834 ** This structure is described in section 2.1. The offset 835 ** field must be equal to or greater than AVDT_MEDIA_OFFSET 836 ** (if NO_RTP is specified, L2CAP_MIN_OFFSET can be used) 837 ** This allows enough space in the buffer for the L2CAP and 838 ** AVDTP headers. 839 ** 840 ** The memory pointed to by p_pkt must be a GKI buffer 841 ** allocated by the application. This buffer will be freed 842 ** by the protocol stack; the application must not free 843 ** this buffer. 844 ** 845 ** The opt parameter allows passing specific options like: 846 ** - NO_RTP : do not add the RTP header to buffer 847 ** 848 ** Returns AVDT_SUCCESS if successful, otherwise error. 849 ** 850 *******************************************************************************/ 851 extern UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, 852 UINT8 m_pt, tAVDT_DATA_OPT_MASK opt); 853 854 /******************************************************************************* 855 ** 856 ** Function AVDT_ConnectReq 857 ** 858 ** Description This function initiates an AVDTP signaling connection 859 ** to the peer device. When the connection is completed, an 860 ** AVDT_CONNECT_IND_EVT is sent to the application via its 861 ** control callback function. If the connection attempt fails 862 ** an AVDT_DISCONNECT_IND_EVT is sent. The security mask 863 ** parameter overrides the outgoing security mask set in 864 ** AVDT_Register(). 865 ** 866 ** Returns AVDT_SUCCESS if successful, otherwise error. 867 ** 868 *******************************************************************************/ 869 extern UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask, 870 tAVDT_CTRL_CBACK *p_cback); 871 872 /******************************************************************************* 873 ** 874 ** Function AVDT_DisconnectReq 875 ** 876 ** Description This function disconnect an AVDTP signaling connection 877 ** to the peer device. When disconnected an 878 ** AVDT_DISCONNECT_IND_EVT is sent to the application via its 879 ** control callback function. 880 ** 881 ** Returns AVDT_SUCCESS if successful, otherwise error. 882 ** 883 *******************************************************************************/ 884 extern UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_cback); 885 886 /******************************************************************************* 887 ** 888 ** Function AVDT_GetL2CapChannel 889 ** 890 ** Description Get the L2CAP CID used by the handle. 891 ** 892 ** Returns CID if successful, otherwise 0. 893 ** 894 *******************************************************************************/ 895 extern UINT16 AVDT_GetL2CapChannel(UINT8 handle); 896 897 /******************************************************************************* 898 ** 899 ** Function AVDT_GetSignalChannel 900 ** 901 ** Description Get the L2CAP CID used by the signal channel of the given handle. 902 ** 903 ** Returns CID if successful, otherwise 0. 904 ** 905 *******************************************************************************/ 906 extern UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr); 907 908 /******************************************************************************* 909 ** 910 ** Function AVDT_WriteDataReq 911 ** 912 ** Description Send a media packet to the peer device. The stream must 913 ** be started before this function is called. Also, this 914 ** function can only be called if the stream is a SRC. 915 ** 916 ** When AVDTP has sent the media packet and is ready for the 917 ** next packet, an AVDT_WRITE_CFM_EVT is sent to the 918 ** application via the control callback. The application must 919 ** wait for the AVDT_WRITE_CFM_EVT before it makes the next 920 ** call to AVDT_WriteDataReq(). If the applications calls 921 ** AVDT_WriteDataReq() before it receives the event the packet 922 ** will not be sent. The application may make its first call 923 ** to AVDT_WriteDataReq() after it receives an 924 ** AVDT_START_CFM_EVT or AVDT_START_IND_EVT. 925 ** 926 ** Returns AVDT_SUCCESS if successful, otherwise error. 927 ** 928 *******************************************************************************/ 929 extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len, 930 UINT32 time_stamp, UINT8 m_pt, UINT8 marker); 931 932 /******************************************************************************* 933 ** 934 ** Function AVDT_SetMediaBuf 935 ** 936 ** Description Assigns buffer for media packets or forbids using of assigned 937 ** buffer if argument p_buf is NULL. This function can only 938 ** be called if the stream is a SNK. 939 ** 940 ** AVDTP uses this buffer to reassemble fragmented media packets. 941 ** When AVDTP receives a complete media packet, it calls the 942 ** p_media_cback assigned by AVDT_CreateStream(). 943 ** This function can be called during callback to assign a 944 ** different buffer for next media packet or can leave the current 945 ** buffer for next packet. 946 ** 947 ** Returns AVDT_SUCCESS if successful, otherwise error. 948 ** 949 *******************************************************************************/ 950 extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len); 951 952 /******************************************************************************* 953 ** 954 ** Function AVDT_SendReport 955 ** 956 ** Description 957 ** 958 ** 959 ** 960 ** Returns 961 ** 962 *******************************************************************************/ 963 extern UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type, 964 tAVDT_REPORT_DATA *p_data); 965 966 /****************************************************************************** 967 ** 968 ** Function AVDT_SetTraceLevel 969 ** 970 ** Description Sets the trace level for AVDT. If 0xff is passed, the 971 ** current trace level is returned. 972 ** 973 ** Input Parameters: 974 ** new_level: The level to set the AVDT tracing to: 975 ** 0xff-returns the current setting. 976 ** 0-turns off tracing. 977 ** >= 1-Errors. 978 ** >= 2-Warnings. 979 ** >= 3-APIs. 980 ** >= 4-Events. 981 ** >= 5-Debug. 982 ** 983 ** Returns The new trace level or current trace level if 984 ** the input parameter is 0xff. 985 ** 986 ******************************************************************************/ 987 extern UINT8 AVDT_SetTraceLevel (UINT8 new_level); 988 989 /******************************************************************************* 990 ** 991 ** Function AVDT_SetDelayValue 992 ** 993 ** Description Set delay reporting value. 994 ** 995 ** Returns void 996 ** 997 *******************************************************************************/ 998 extern void AVDT_SetDelayValue(UINT16 delay_value); 999 1000 /******************************************************************************* 1001 ** 1002 ** Function AVDT_GetDelayValue 1003 ** 1004 ** Description Get delay reporting value. 1005 ** 1006 ** Returns delay value 1007 ** 1008 *******************************************************************************/ 1009 extern UINT16 AVDT_GetDelayValue(void); 1010 1011 #ifdef __cplusplus 1012 } 1013 #endif 1014 1015 1016 #endif /* AVDT_API_H */ 1017