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