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) */ 94typedef 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 210typedef 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 220typedef 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 230typedef 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. */ 238typedef 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*/ 249typedef 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. */ 257typedef 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. */ 279typedef 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*/ 291typedef 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. */ 297typedef 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. */ 304typedef 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*/ 313typedef 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. */ 320typedef 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. */ 327typedef 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 */ 333typedef 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*/ 358typedef 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*/ 365typedef 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*/ 375typedef 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*/ 384typedef void (tAVDT_REPORT_CBACK)(UINT8 handle, AVDT_REPORT_TYPE type, 385 tAVDT_REPORT_DATA *p_data); 386#endif 387 388typedef 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*/ 393typedef 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 414typedef UINT8 tAVDT_DATA_OPT_MASK; 415 416 417 418/***************************************************************************** 419** External Function Declarations 420*****************************************************************************/ 421#ifdef __cplusplus 422extern "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*******************************************************************************/ 440extern 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*******************************************************************************/ 455extern void AVDT_Deregister(void); 456 457 458/******************************************************************************* 459** 460** Function AVDT_SINK_Activate 461** 462** Description Activate SEP of A2DP Sink. In Use parameter is adjusted. 463** In Use will be made false in case of activation. A2DP SRC 464** will receive in_use as false and can open A2DP Sink 465** connection 466** 467** Returns void 468** 469*******************************************************************************/ 470extern void AVDT_SINK_Activate(void); 471 472/******************************************************************************* 473** 474** Function AVDT_SINK_Deactivate 475** 476** Description Deactivate SEP of A2DP Sink. In Use parameter is adjusted. 477** In Use will be made TRUE in case of activation. A2DP SRC 478** will receive in_use as true and will not open A2DP Sink 479** connection 480** 481** Returns void. 482** 483*******************************************************************************/ 484extern void AVDT_SINK_Deactivate(void); 485 486/******************************************************************************* 487** 488** Function AVDT_AbortReq 489** 490** Description Trigger Abort request to pass AVDTP Abort related mandatory 491** PTS Test case. 492** 493** Returns void. 494** 495*******************************************************************************/ 496extern void AVDT_AbortReq(UINT8 handle); 497 498/******************************************************************************* 499** 500** Function AVDT_CreateStream 501** 502** Description Create a stream endpoint. After a stream endpoint is 503** created an application can initiate a connection between 504** this endpoint and an endpoint on a peer device. In 505** addition, a peer device can discover, get the capabilities, 506** and connect to this endpoint. 507** 508** 509** Returns AVDT_SUCCESS if successful, otherwise error. 510** 511*******************************************************************************/ 512extern UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs); 513 514/******************************************************************************* 515** 516** Function AVDT_RemoveStream 517** 518** Description Remove a stream endpoint. This function is called when 519** the application is no longer using a stream endpoint. 520** If this function is called when the endpoint is connected 521** the connection is closed and then the stream endpoint 522** is removed. 523** 524** 525** Returns AVDT_SUCCESS if successful, otherwise error. 526** 527*******************************************************************************/ 528extern UINT16 AVDT_RemoveStream(UINT8 handle); 529 530/******************************************************************************* 531** 532** Function AVDT_DiscoverReq 533** 534** Description This function initiates a connection to the AVDTP service 535** on the peer device, if not already present, and discovers 536** the stream endpoints on the peer device. (Please note 537** that AVDTP discovery is unrelated to SDP discovery). 538** This function can be called at any time regardless of whether 539** there is an AVDTP connection to the peer device. 540** 541** When discovery is complete, an AVDT_DISCOVER_CFM_EVT 542** is sent to the application via its callback function. 543** The application must not call AVDT_GetCapReq() or 544** AVDT_DiscoverReq() again to the same device until 545** discovery is complete. 546** 547** The memory addressed by sep_info is allocated by the 548** application. This memory is written to by AVDTP as part 549** of the discovery procedure. This memory must remain 550** accessible until the application receives the 551** AVDT_DISCOVER_CFM_EVT. 552** 553** Returns AVDT_SUCCESS if successful, otherwise error. 554** 555*******************************************************************************/ 556extern UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_info, 557 UINT8 max_seps, tAVDT_CTRL_CBACK *p_cback); 558 559 560/******************************************************************************* 561** 562** Function AVDT_GetCapReq 563** 564** Description This function initiates a connection to the AVDTP service 565** on the peer device, if not already present, and gets the 566** capabilities of a stream endpoint on the peer device. 567** This function can be called at any time regardless of 568** whether there is an AVDTP connection to the peer device. 569** 570** When the procedure is complete, an AVDT_GETCAP_CFM_EVT is 571** sent to the application via its callback function. The 572** application must not call AVDT_GetCapReq() or 573** AVDT_DiscoverReq() again until the procedure is complete. 574** 575** The memory pointed to by p_cfg is allocated by the 576** application. This memory is written to by AVDTP as part 577** of the get capabilities procedure. This memory must 578** remain accessible until the application receives 579** the AVDT_GETCAP_CFM_EVT. 580** 581** Returns AVDT_SUCCESS if successful, otherwise error. 582** 583*******************************************************************************/ 584extern UINT16 AVDT_GetCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, 585 tAVDT_CTRL_CBACK *p_cback); 586 587/******************************************************************************* 588** 589** Function AVDT_GetAllCapReq 590** 591** Description This function initiates a connection to the AVDTP service 592** on the peer device, if not already present, and gets the 593** capabilities of a stream endpoint on the peer device. 594** This function can be called at any time regardless of 595** whether there is an AVDTP connection to the peer device. 596** 597** When the procedure is complete, an AVDT_GETCAP_CFM_EVT is 598** sent to the application via its callback function. The 599** application must not call AVDT_GetCapReq() or 600** AVDT_DiscoverReq() again until the procedure is complete. 601** 602** The memory pointed to by p_cfg is allocated by the 603** application. This memory is written to by AVDTP as part 604** of the get capabilities procedure. This memory must 605** remain accessible until the application receives 606** the AVDT_GETCAP_CFM_EVT. 607** 608** Returns AVDT_SUCCESS if successful, otherwise error. 609** 610*******************************************************************************/ 611extern UINT16 AVDT_GetAllCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, 612 tAVDT_CTRL_CBACK *p_cback); 613 614/******************************************************************************* 615** 616** Function AVDT_DelayReport 617** 618** Description This functions sends a Delay Report to the peer device 619** that is associated with a particular SEID. 620** This function is called by SNK device. 621** 622** Returns AVDT_SUCCESS if successful, otherwise error. 623** 624*******************************************************************************/ 625extern UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay); 626 627/******************************************************************************* 628** 629** Function AVDT_OpenReq 630** 631** Description This function initiates a connection to the AVDTP service 632** on the peer device, if not already present, and connects 633** to a stream endpoint on a peer device. When the connection 634** is completed, an AVDT_OPEN_CFM_EVT is sent to the 635** application via the control callback function for this handle. 636** 637** Returns AVDT_SUCCESS if successful, otherwise error. 638** 639*******************************************************************************/ 640extern UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid, 641 tAVDT_CFG *p_cfg); 642 643 644/******************************************************************************* 645** 646** Function AVDT_ConfigRsp 647** 648** Description Respond to a configure request from the peer device. This 649** function must be called if the application receives an 650** AVDT_CONFIG_IND_EVT through its control callback. 651** 652** 653** Returns AVDT_SUCCESS if successful, otherwise error. 654** 655*******************************************************************************/ 656extern UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, 657 UINT8 category); 658 659/******************************************************************************* 660** 661** Function AVDT_StartReq 662** 663** Description Start one or more stream endpoints. This initiates the 664** transfer of media packets for the streams. All stream 665** endpoints must previously be opened. When the streams 666** are started, an AVDT_START_CFM_EVT is sent to the 667** application via the control callback function for each stream. 668** 669** 670** Returns AVDT_SUCCESS if successful, otherwise error. 671** 672*******************************************************************************/ 673extern UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles); 674 675/******************************************************************************* 676** 677** Function AVDT_SuspendReq 678** 679** Description Suspend one or more stream endpoints. This suspends the 680** transfer of media packets for the streams. All stream 681** endpoints must previously be open and started. When the 682** streams are suspended, an AVDT_SUSPEND_CFM_EVT is sent to 683** the application via the control callback function for 684** each stream. 685** 686** 687** Returns AVDT_SUCCESS if successful, otherwise error. 688** 689*******************************************************************************/ 690extern UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles); 691 692/******************************************************************************* 693** 694** Function AVDT_CloseReq 695** 696** Description Close a stream endpoint. This stops the transfer of media 697** packets and closes the transport channel associated with 698** this stream endpoint. When the stream is closed, an 699** AVDT_CLOSE_CFM_EVT is sent to the application via the 700** control callback function for this handle. 701** 702** 703** Returns AVDT_SUCCESS if successful, otherwise error. 704** 705*******************************************************************************/ 706extern UINT16 AVDT_CloseReq(UINT8 handle); 707 708/******************************************************************************* 709** 710** Function AVDT_ReconfigReq 711** 712** Description Reconfigure a stream endpoint. This allows the application 713** to change the codec or content protection capabilities of 714** a stream endpoint after it has been opened. This function 715** can only be called if the stream is opened but not started 716** or if the stream has been suspended. When the procedure 717** is completed, an AVDT_RECONFIG_CFM_EVT is sent to the 718** application via the control callback function for this handle. 719** 720** 721** Returns AVDT_SUCCESS if successful, otherwise error. 722** 723*******************************************************************************/ 724extern UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg); 725 726/******************************************************************************* 727** 728** Function AVDT_ReconfigRsp 729** 730** Description Respond to a reconfigure request from the peer device. 731** This function must be called if the application receives 732** an AVDT_RECONFIG_IND_EVT through its control callback. 733** 734** 735** Returns AVDT_SUCCESS if successful, otherwise error. 736** 737*******************************************************************************/ 738extern UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, 739 UINT8 category); 740 741/******************************************************************************* 742** 743** Function AVDT_SecurityReq 744** 745** Description Send a security request to the peer device. When the 746** security procedure is completed, an AVDT_SECURITY_CFM_EVT 747** is sent to the application via the control callback function 748** for this handle. (Please note that AVDTP security procedures 749** are unrelated to Bluetooth link level security.) 750** 751** 752** Returns AVDT_SUCCESS if successful, otherwise error. 753** 754*******************************************************************************/ 755extern UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len); 756 757/******************************************************************************* 758** 759** Function AVDT_SecurityRsp 760** 761** Description Respond to a security request from the peer device. 762** This function must be called if the application receives 763** an AVDT_SECURITY_IND_EVT through its control callback. 764** (Please note that AVDTP security procedures are unrelated 765** to Bluetooth link level security.) 766** 767** 768** Returns AVDT_SUCCESS if successful, otherwise error. 769** 770*******************************************************************************/ 771extern UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_code, 772 UINT8 *p_data, UINT16 len); 773 774/******************************************************************************* 775** 776** Function AVDT_WriteReq 777** 778** Description Send a media packet to the peer device. The stream must 779** be started before this function is called. Also, this 780** function can only be called if the stream is a SRC. 781** 782** When AVDTP has sent the media packet and is ready for the 783** next packet, an AVDT_WRITE_CFM_EVT is sent to the 784** application via the control callback. The application must 785** wait for the AVDT_WRITE_CFM_EVT before it makes the next 786** call to AVDT_WriteReq(). If the applications calls 787** AVDT_WriteReq() before it receives the event the packet 788** will not be sent. The application may make its first call 789** to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT 790** or AVDT_START_IND_EVT. 791** 792** The application passes the packet using the BT_HDR structure. 793** This structure is described in section 2.1. The offset 794** field must be equal to or greater than AVDT_MEDIA_OFFSET. 795** This allows enough space in the buffer for the L2CAP and 796** AVDTP headers. 797** 798** The memory pointed to by p_pkt must be a GKI buffer 799** allocated by the application. This buffer will be freed 800** by the protocol stack; the application must not free 801** this buffer. 802** 803** 804** Returns AVDT_SUCCESS if successful, otherwise error. 805** 806*******************************************************************************/ 807extern UINT16 AVDT_WriteReq(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, 808 UINT8 m_pt); 809/******************************************************************************* 810** 811** Function AVDT_WriteReqOpt 812** 813** Description Send a media packet to the peer device. The stream must 814** be started before this function is called. Also, this 815** function can only be called if the stream is a SRC 816** 817** When AVDTP has sent the media packet and is ready for the 818** next packet, an AVDT_WRITE_CFM_EVT is sent to the 819** application via the control callback. The application must 820** wait for the AVDT_WRITE_CFM_EVT before it makes the next 821** call to AVDT_WriteReq(). If the applications calls 822** AVDT_WriteReq() before it receives the event the packet 823** will not be sent. The application may make its first call 824** to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT 825** or AVDT_START_IND_EVT. 826** 827** The application passes the packet using the BT_HDR structure 828** This structure is described in section 2.1. The offset 829** field must be equal to or greater than AVDT_MEDIA_OFFSET 830** (if NO_RTP is specified, L2CAP_MIN_OFFSET can be used) 831** This allows enough space in the buffer for the L2CAP and 832** AVDTP headers. 833** 834** The memory pointed to by p_pkt must be a GKI buffer 835** allocated by the application. This buffer will be freed 836** by the protocol stack; the application must not free 837** this buffer. 838** 839** The opt parameter allows passing specific options like: 840** - NO_RTP : do not add the RTP header to buffer 841** 842** Returns AVDT_SUCCESS if successful, otherwise error. 843** 844*******************************************************************************/ 845extern UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, 846 UINT8 m_pt, tAVDT_DATA_OPT_MASK opt); 847 848/******************************************************************************* 849** 850** Function AVDT_ConnectReq 851** 852** Description This function initiates an AVDTP signaling connection 853** to the peer device. When the connection is completed, an 854** AVDT_CONNECT_IND_EVT is sent to the application via its 855** control callback function. If the connection attempt fails 856** an AVDT_DISCONNECT_IND_EVT is sent. The security mask 857** parameter overrides the outgoing security mask set in 858** AVDT_Register(). 859** 860** Returns AVDT_SUCCESS if successful, otherwise error. 861** 862*******************************************************************************/ 863extern UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask, 864 tAVDT_CTRL_CBACK *p_cback); 865 866/******************************************************************************* 867** 868** Function AVDT_DisconnectReq 869** 870** Description This function disconnect an AVDTP signaling connection 871** to the peer device. When disconnected an 872** AVDT_DISCONNECT_IND_EVT is sent to the application via its 873** control callback function. 874** 875** Returns AVDT_SUCCESS if successful, otherwise error. 876** 877*******************************************************************************/ 878extern UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_cback); 879 880/******************************************************************************* 881** 882** Function AVDT_GetL2CapChannel 883** 884** Description Get the L2CAP CID used by the handle. 885** 886** Returns CID if successful, otherwise 0. 887** 888*******************************************************************************/ 889extern UINT16 AVDT_GetL2CapChannel(UINT8 handle); 890 891/******************************************************************************* 892** 893** Function AVDT_GetSignalChannel 894** 895** Description Get the L2CAP CID used by the signal channel of the given handle. 896** 897** Returns CID if successful, otherwise 0. 898** 899*******************************************************************************/ 900extern UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr); 901 902/******************************************************************************* 903** 904** Function AVDT_WriteDataReq 905** 906** Description Send a media packet to the peer device. The stream must 907** be started before this function is called. Also, this 908** function can only be called if the stream is a SRC. 909** 910** When AVDTP has sent the media packet and is ready for the 911** next packet, an AVDT_WRITE_CFM_EVT is sent to the 912** application via the control callback. The application must 913** wait for the AVDT_WRITE_CFM_EVT before it makes the next 914** call to AVDT_WriteDataReq(). If the applications calls 915** AVDT_WriteDataReq() before it receives the event the packet 916** will not be sent. The application may make its first call 917** to AVDT_WriteDataReq() after it receives an 918** AVDT_START_CFM_EVT or AVDT_START_IND_EVT. 919** 920** Returns AVDT_SUCCESS if successful, otherwise error. 921** 922*******************************************************************************/ 923extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len, 924 UINT32 time_stamp, UINT8 m_pt, UINT8 marker); 925 926/******************************************************************************* 927** 928** Function AVDT_SetMediaBuf 929** 930** Description Assigns buffer for media packets or forbids using of assigned 931** buffer if argument p_buf is NULL. This function can only 932** be called if the stream is a SNK. 933** 934** AVDTP uses this buffer to reassemble fragmented media packets. 935** When AVDTP receives a complete media packet, it calls the 936** p_media_cback assigned by AVDT_CreateStream(). 937** This function can be called during callback to assign a 938** different buffer for next media packet or can leave the current 939** buffer for next packet. 940** 941** Returns AVDT_SUCCESS if successful, otherwise error. 942** 943*******************************************************************************/ 944extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len); 945 946/******************************************************************************* 947** 948** Function AVDT_SendReport 949** 950** Description 951** 952** 953** 954** Returns 955** 956*******************************************************************************/ 957extern UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type, 958 tAVDT_REPORT_DATA *p_data); 959 960/****************************************************************************** 961** 962** Function AVDT_SetTraceLevel 963** 964** Description Sets the trace level for AVDT. If 0xff is passed, the 965** current trace level is returned. 966** 967** Input Parameters: 968** new_level: The level to set the AVDT tracing to: 969** 0xff-returns the current setting. 970** 0-turns off tracing. 971** >= 1-Errors. 972** >= 2-Warnings. 973** >= 3-APIs. 974** >= 4-Events. 975** >= 5-Debug. 976** 977** Returns The new trace level or current trace level if 978** the input parameter is 0xff. 979** 980******************************************************************************/ 981extern UINT8 AVDT_SetTraceLevel (UINT8 new_level); 982 983#ifdef __cplusplus 984} 985#endif 986 987 988#endif /* AVDT_API_H */ 989