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