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