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