avdt_api.h 45 KB

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