avdt_api.h 46 KB

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