avct_api.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2003-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 Control
  21. * Transport Protocol (AVCTP).
  22. *
  23. ******************************************************************************/
  24. #ifndef AVCT_API_H
  25. #define AVCT_API_H
  26. #include "bt_types.h"
  27. #include "bt_target.h"
  28. /*****************************************************************************
  29. ** Constants
  30. *****************************************************************************/
  31. /* API function return value result codes. */
  32. #define AVCT_SUCCESS 0 /* Function successful */
  33. #define AVCT_NO_RESOURCES 1 /* Not enough resources */
  34. #define AVCT_BAD_HANDLE 2 /* Bad handle */
  35. #define AVCT_PID_IN_USE 3 /* PID already in use */
  36. #define AVCT_NOT_OPEN 4 /* Connection not open */
  37. /* PSM for AVCT. */
  38. #define AVCT_PSM 0x0017
  39. #define AVCT_BR_PSM 0x001B
  40. /* Protocol revision numbers */
  41. #define AVCT_REV_1_0 0x0100
  42. #define AVCT_REV_1_2 0x0102
  43. #define AVCT_REV_1_3 0x0103
  44. #define AVCT_REV_1_4 0x0104
  45. /* the layer_specific settings */
  46. #define AVCT_DATA_CTRL 0x0001 /* for the control channel */
  47. #define AVCT_DATA_BROWSE 0x0002 /* for the browsing channel */
  48. #define AVCT_DATA_PARTIAL 0x0100 /* Only have room for a partial message */
  49. #define AVCT_MIN_CONTROL_MTU 48 /* Per the AVRC spec, minimum MTU for the control channel */
  50. #define AVCT_MIN_BROWSE_MTU 335 /* Per the AVRC spec, minimum MTU for the browsing channel */
  51. /* Message offset. The number of bytes needed by the protocol stack for the
  52. ** protocol headers of an AVCTP message packet.
  53. */
  54. #define AVCT_MSG_OFFSET 15
  55. #define AVCT_BROWSE_OFFSET 17 /* the default offset for browsing channel */
  56. /* Connection role. */
  57. #define AVCT_INT 0 /* Initiator connection */
  58. #define AVCT_ACP 1 /* Acceptor connection */
  59. /* Control role. */
  60. #define AVCT_TARGET 1 /* target */
  61. #define AVCT_CONTROL 2 /* controller */
  62. #define AVCT_PASSIVE 4 /* If conflict, allow the other side to succeed */
  63. /* Command/Response indicator. */
  64. #define AVCT_CMD 0 /* Command message */
  65. #define AVCT_RSP 2 /* Response message */
  66. #define AVCT_REJ 3 /* Message rejected */
  67. /* Control callback events. */
  68. #define AVCT_CONNECT_CFM_EVT 0 /* Connection confirm */
  69. #define AVCT_CONNECT_IND_EVT 1 /* Connection indication */
  70. #define AVCT_DISCONNECT_CFM_EVT 2 /* Disconnect confirm */
  71. #define AVCT_DISCONNECT_IND_EVT 3 /* Disconnect indication */
  72. #define AVCT_CONG_IND_EVT 4 /* Congestion indication */
  73. #define AVCT_UNCONG_IND_EVT 5 /* Uncongestion indication */
  74. #define AVCT_BROWSE_CONN_CFM_EVT 6 /* Browse Connection confirm */
  75. #define AVCT_BROWSE_CONN_IND_EVT 7 /* Browse Connection indication */
  76. #define AVCT_BROWSE_DISCONN_CFM_EVT 8 /* Browse Disconnect confirm */
  77. #define AVCT_BROWSE_DISCONN_IND_EVT 9 /* Browse Disconnect indication */
  78. #define AVCT_BROWSE_CONG_IND_EVT 10 /* Congestion indication */
  79. #define AVCT_BROWSE_UNCONG_IND_EVT 11 /* Uncongestion indication */
  80. /* General purpose failure result code for callback events. */
  81. #define AVCT_RESULT_FAIL 5
  82. /*****************************************************************************
  83. ** Type Definitions
  84. *****************************************************************************/
  85. /* Control callback function. */
  86. typedef void (tAVCT_CTRL_CBACK)(UINT8 handle, UINT8 event, UINT16 result,
  87. BD_ADDR peer_addr);
  88. /* Message callback function */
  89. /* p_pkt->layer_specific is AVCT_DATA_CTRL or AVCT_DATA_BROWSE */
  90. typedef void (tAVCT_MSG_CBACK)(UINT8 handle, UINT8 label, UINT8 cr,
  91. BT_HDR *p_pkt);
  92. /* Structure used by AVCT_CreateConn. */
  93. typedef struct {
  94. tAVCT_CTRL_CBACK *p_ctrl_cback; /* Control callback */
  95. tAVCT_MSG_CBACK *p_msg_cback; /* Message callback */
  96. UINT16 pid; /* Profile ID */
  97. UINT8 role; /* Initiator/acceptor role */
  98. UINT8 control; /* Control role (Control/Target) */
  99. } tAVCT_CC;
  100. /*****************************************************************************
  101. ** External Function Declarations
  102. *****************************************************************************/
  103. #ifdef __cplusplus
  104. extern "C"
  105. {
  106. #endif
  107. /*******************************************************************************
  108. **
  109. ** Function AVCT_Register
  110. **
  111. ** Description This is the system level registration function for the
  112. ** AVCTP protocol. This function initializes AVCTP and
  113. ** prepares the protocol stack for its use. This function
  114. ** must be called once by the system or platform using AVCTP
  115. ** before the other functions of the API an be used.
  116. **
  117. **
  118. ** Returns void
  119. **
  120. *******************************************************************************/
  121. extern void AVCT_Register(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask);
  122. /*******************************************************************************
  123. **
  124. ** Function AVCT_Deregister
  125. **
  126. ** Description This function is called to deregister use AVCTP protocol.
  127. ** It is called when AVCTP is no longer being used by any
  128. ** application in the system. Before this function can be
  129. ** called, all connections must be removed with
  130. ** AVCT_RemoveConn().
  131. **
  132. **
  133. ** Returns void
  134. **
  135. *******************************************************************************/
  136. extern void AVCT_Deregister(void);
  137. /*******************************************************************************
  138. **
  139. ** Function AVCT_CreateConn
  140. **
  141. ** Description Create an AVCTP connection. There are two types of
  142. ** connections, initiator and acceptor, as determined by
  143. ** the p_cc->role parameter. When this function is called to
  144. ** create an initiator connection, an AVCTP connection to
  145. ** the peer device is initiated if one does not already exist.
  146. ** If an acceptor connection is created, the connection waits
  147. ** passively for an incoming AVCTP connection from a peer device.
  148. **
  149. **
  150. ** Returns AVCT_SUCCESS if successful, otherwise error.
  151. **
  152. *******************************************************************************/
  153. extern UINT16 AVCT_CreateConn(UINT8 *p_handle, tAVCT_CC *p_cc,
  154. BD_ADDR peer_addr);
  155. /*******************************************************************************
  156. **
  157. ** Function AVCT_RemoveConn
  158. **
  159. ** Description Remove an AVCTP connection. This function is called when
  160. ** the application is no longer using a connection. If this
  161. ** is the last connection to a peer the L2CAP channel for AVCTP
  162. ** will be closed.
  163. **
  164. **
  165. ** Returns AVCT_SUCCESS if successful, otherwise error.
  166. **
  167. *******************************************************************************/
  168. extern UINT16 AVCT_RemoveConn(UINT8 handle);
  169. /*******************************************************************************
  170. **
  171. ** Function AVCT_CreateBrowse
  172. **
  173. ** Description Create an AVCTP connection. There are two types of
  174. ** connections, initiator and acceptor, as determined by
  175. ** the p_cc->role parameter. When this function is called to
  176. ** create an initiator connection, an AVCTP connection to
  177. ** the peer device is initiated if one does not already exist.
  178. ** If an acceptor connection is created, the connection waits
  179. ** passively for an incoming AVCTP connection from a peer device.
  180. **
  181. **
  182. ** Returns AVCT_SUCCESS if successful, otherwise error.
  183. **
  184. *******************************************************************************/
  185. extern UINT16 AVCT_CreateBrowse(UINT8 handle, UINT8 role);
  186. /*******************************************************************************
  187. **
  188. ** Function AVCT_RemoveBrowse
  189. **
  190. ** Description Remove an AVCTP connection. This function is called when
  191. ** the application is no longer using a connection. If this
  192. ** is the last connection to a peer the L2CAP channel for AVCTP
  193. ** will be closed.
  194. **
  195. **
  196. ** Returns AVCT_SUCCESS if successful, otherwise error.
  197. **
  198. *******************************************************************************/
  199. extern UINT16 AVCT_RemoveBrowse(UINT8 handle);
  200. /*******************************************************************************
  201. **
  202. ** Function AVCT_GetBrowseMtu
  203. **
  204. ** Description Get the peer_mtu for the AVCTP Browse channel of the given
  205. ** connection.
  206. **
  207. ** Returns the peer browsing channel MTU.
  208. **
  209. *******************************************************************************/
  210. extern UINT16 AVCT_GetBrowseMtu (UINT8 handle);
  211. /*******************************************************************************
  212. **
  213. ** Function AVCT_GetPeerMtu
  214. **
  215. ** Description Get the peer_mtu for the AVCTP channel of the given
  216. ** connection.
  217. **
  218. ** Returns the peer MTU size.
  219. **
  220. *******************************************************************************/
  221. extern UINT16 AVCT_GetPeerMtu (UINT8 handle);
  222. /*******************************************************************************
  223. **
  224. ** Function AVCT_MsgReq
  225. **
  226. ** Description Send an AVCTP message to a peer device. In calling
  227. ** AVCT_MsgReq(), the application should keep track of the
  228. ** congestion state of AVCTP as communicated with events
  229. ** AVCT_CONG_IND_EVT and AVCT_UNCONG_IND_EVT. If the
  230. ** application calls AVCT_MsgReq() when AVCTP is congested
  231. ** the message may be discarded. The application may make its
  232. ** first call to AVCT_MsgReq() after it receives an
  233. ** AVCT_CONNECT_CFM_EVT or AVCT_CONNECT_IND_EVT on control channel or
  234. ** AVCT_BROWSE_CONN_CFM_EVT or AVCT_BROWSE_CONN_IND_EVT on browsing channel.
  235. **
  236. ** p_msg->layer_specific must be set to
  237. ** AVCT_DATA_CTRL for control channel traffic;
  238. ** AVCT_DATA_BROWSE for for browse channel traffic.
  239. **
  240. ** Returns AVCT_SUCCESS if successful, otherwise error.
  241. **
  242. *******************************************************************************/
  243. extern UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg);
  244. #ifdef __cplusplus
  245. }
  246. #endif
  247. #endif /* AVCT_API_H */