• 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 /* AVDT data option mask is used in the write request */
411 #define AVDT_DATA_OPT_NONE      0x00         /* No option still add RTP header */
412 #define AVDT_DATA_OPT_NO_RTP   (0x01 << 0)   /* Skip adding RTP header */
413 
414 typedef UINT8 tAVDT_DATA_OPT_MASK;
415 
416 
417 
418 /*****************************************************************************
419 **  External Function Declarations
420 *****************************************************************************/
421 #ifdef __cplusplus
422 extern "C"
423 {
424 #endif
425 
426 /*******************************************************************************
427 **
428 ** Function         AVDT_Register
429 **
430 ** Description      This is the system level registration function for the
431 **                  AVDTP protocol.  This function initializes AVDTP and
432 **                  prepares the protocol stack for its use.  This function
433 **                  must be called once by the system or platform using AVDTP
434 **                  before the other functions of the API an be used.
435 **
436 **
437 ** Returns          void
438 **
439 *******************************************************************************/
440 AVDT_API extern void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback);
441 
442 /*******************************************************************************
443 **
444 ** Function         AVDT_Deregister
445 **
446 ** Description      This function is called to deregister use AVDTP protocol.
447 **                  It is called when AVDTP is no longer being used by any
448 **                  application in the system.  Before this function can be
449 **                  called, all streams must be removed with AVDT_RemoveStream().
450 **
451 **
452 ** Returns          void
453 **
454 *******************************************************************************/
455 AVDT_API extern void AVDT_Deregister(void);
456 
457 
458 /*******************************************************************************
459 **
460 ** Function         AVDT_SINK_Activate
461 **
462 ** Description      Activate SEP of A2DP Sink. In Use parameter is adjusted.
463 **                  In Use will be made false in case of activation. A2DP SRC
464 **                  will receive in_use as false and can open A2DP Sink
465 **                  connection
466 **
467 ** Returns          void
468 **
469 *******************************************************************************/
470 AVDT_API extern void AVDT_SINK_Activate(void);
471 
472 /*******************************************************************************
473 **
474 ** Function         AVDT_SINK_Deactivate
475 **
476 ** Description      Deactivate SEP of A2DP Sink. In Use parameter is adjusted.
477 **                  In Use will be made TRUE in case of activation. A2DP SRC
478 **                  will receive in_use as true and will not open A2DP Sink
479 **                  connection
480 **
481 ** Returns          void.
482 **
483 *******************************************************************************/
484 AVDT_API extern void AVDT_SINK_Deactivate(void);
485 
486 /*******************************************************************************
487 **
488 ** Function         AVDT_CreateStream
489 **
490 ** Description      Create a stream endpoint.  After a stream endpoint is
491 **                  created an application can initiate a connection between
492 **                  this endpoint and an endpoint on a peer device.  In
493 **                  addition, a peer device can discover, get the capabilities,
494 **                  and connect to this endpoint.
495 **
496 **
497 ** Returns          AVDT_SUCCESS if successful, otherwise error.
498 **
499 *******************************************************************************/
500 AVDT_API extern UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs);
501 
502 /*******************************************************************************
503 **
504 ** Function         AVDT_RemoveStream
505 **
506 ** Description      Remove a stream endpoint.  This function is called when
507 **                  the application is no longer using a stream endpoint.
508 **                  If this function is called when the endpoint is connected
509 **                  the connection is closed and then the stream endpoint
510 **                  is removed.
511 **
512 **
513 ** Returns          AVDT_SUCCESS if successful, otherwise error.
514 **
515 *******************************************************************************/
516 AVDT_API extern UINT16 AVDT_RemoveStream(UINT8 handle);
517 
518 /*******************************************************************************
519 **
520 ** Function         AVDT_DiscoverReq
521 **
522 ** Description      This function initiates a connection to the AVDTP service
523 **                  on the peer device, if not already present, and discovers
524 **                  the stream endpoints on the peer device.  (Please note
525 **                  that AVDTP discovery is unrelated to SDP discovery).
526 **                  This function can be called at any time regardless of whether
527 **                  there is an AVDTP connection to the peer device.
528 **
529 **                  When discovery is complete, an AVDT_DISCOVER_CFM_EVT
530 **                  is sent to the application via its callback function.
531 **                  The application must not call AVDT_GetCapReq() or
532 **                  AVDT_DiscoverReq() again to the same device until
533 **                  discovery is complete.
534 **
535 **                  The memory addressed by sep_info is allocated by the
536 **                  application.  This memory is written to by AVDTP as part
537 **                  of the discovery procedure.  This memory must remain
538 **                  accessible until the application receives the
539 **                  AVDT_DISCOVER_CFM_EVT.
540 **
541 ** Returns          AVDT_SUCCESS if successful, otherwise error.
542 **
543 *******************************************************************************/
544 AVDT_API extern UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_info,
545                                         UINT8 max_seps, tAVDT_CTRL_CBACK *p_cback);
546 
547 
548 /*******************************************************************************
549 **
550 ** Function         AVDT_GetCapReq
551 **
552 ** Description      This function initiates a connection to the AVDTP service
553 **                  on the peer device, if not already present, and gets the
554 **                  capabilities of a stream endpoint on the peer device.
555 **                  This function can be called at any time regardless of
556 **                  whether there is an AVDTP connection to the peer device.
557 **
558 **                  When the procedure is complete, an AVDT_GETCAP_CFM_EVT is
559 **                  sent to the application via its callback function.  The
560 **                  application must not call AVDT_GetCapReq() or
561 **                  AVDT_DiscoverReq() again until the procedure is complete.
562 **
563 **                  The memory pointed to by p_cfg is allocated by the
564 **                  application.  This memory is written to by AVDTP as part
565 **                  of the get capabilities procedure.  This memory must
566 **                  remain accessible until the application receives
567 **                  the AVDT_GETCAP_CFM_EVT.
568 **
569 ** Returns          AVDT_SUCCESS if successful, otherwise error.
570 **
571 *******************************************************************************/
572 AVDT_API extern UINT16 AVDT_GetCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg,
573                                       tAVDT_CTRL_CBACK *p_cback);
574 
575 /*******************************************************************************
576 **
577 ** Function         AVDT_GetAllCapReq
578 **
579 ** Description      This function initiates a connection to the AVDTP service
580 **                  on the peer device, if not already present, and gets the
581 **                  capabilities of a stream endpoint on the peer device.
582 **                  This function can be called at any time regardless of
583 **                  whether there is an AVDTP connection to the peer device.
584 **
585 **                  When the procedure is complete, an AVDT_GETCAP_CFM_EVT is
586 **                  sent to the application via its callback function.  The
587 **                  application must not call AVDT_GetCapReq() or
588 **                  AVDT_DiscoverReq() again until the procedure is complete.
589 **
590 **                  The memory pointed to by p_cfg is allocated by the
591 **                  application.  This memory is written to by AVDTP as part
592 **                  of the get capabilities procedure.  This memory must
593 **                  remain accessible until the application receives
594 **                  the AVDT_GETCAP_CFM_EVT.
595 **
596 ** Returns          AVDT_SUCCESS if successful, otherwise error.
597 **
598 *******************************************************************************/
599 AVDT_API extern UINT16 AVDT_GetAllCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg,
600                                       tAVDT_CTRL_CBACK *p_cback);
601 
602 /*******************************************************************************
603 **
604 ** Function         AVDT_DelayReport
605 **
606 ** Description      This functions sends a Delay Report to the peer device
607 **                  that is associated with a particular SEID.
608 **                  This function is called by SNK device.
609 **
610 ** Returns          AVDT_SUCCESS if successful, otherwise error.
611 **
612 *******************************************************************************/
613 AVDT_API extern UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay);
614 
615 /*******************************************************************************
616 **
617 ** Function         AVDT_OpenReq
618 **
619 ** Description      This function initiates a connection to the AVDTP service
620 **                  on the peer device, if not already present, and connects
621 **                  to a stream endpoint on a peer device.  When the connection
622 **                  is completed, an AVDT_OPEN_CFM_EVT is sent to the
623 **                  application via the control callback function for this handle.
624 **
625 ** Returns          AVDT_SUCCESS if successful, otherwise error.
626 **
627 *******************************************************************************/
628 AVDT_API extern UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid,
629                                     tAVDT_CFG *p_cfg);
630 
631 
632 /*******************************************************************************
633 **
634 ** Function         AVDT_ConfigRsp
635 **
636 ** Description      Respond to a configure request from the peer device.  This
637 **                  function must be called if the application receives an
638 **                  AVDT_CONFIG_IND_EVT through its control callback.
639 **
640 **
641 ** Returns          AVDT_SUCCESS if successful, otherwise error.
642 **
643 *******************************************************************************/
644 AVDT_API extern UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_code,
645                                       UINT8 category);
646 
647 /*******************************************************************************
648 **
649 ** Function         AVDT_StartReq
650 **
651 ** Description      Start one or more stream endpoints.  This initiates the
652 **                  transfer of media packets for the streams.  All stream
653 **                  endpoints must previously be opened.  When the streams
654 **                  are started, an AVDT_START_CFM_EVT is sent to the
655 **                  application via the control callback function for each stream.
656 **
657 **
658 ** Returns          AVDT_SUCCESS if successful, otherwise error.
659 **
660 *******************************************************************************/
661 AVDT_API extern UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles);
662 
663 /*******************************************************************************
664 **
665 ** Function         AVDT_SuspendReq
666 **
667 ** Description      Suspend one or more stream endpoints. This suspends the
668 **                  transfer of media packets for the streams.  All stream
669 **                  endpoints must previously be open and started.  When the
670 **                  streams are suspended, an AVDT_SUSPEND_CFM_EVT is sent to
671 **                  the application via the control callback function for
672 **                  each stream.
673 **
674 **
675 ** Returns          AVDT_SUCCESS if successful, otherwise error.
676 **
677 *******************************************************************************/
678 AVDT_API extern UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles);
679 
680 /*******************************************************************************
681 **
682 ** Function         AVDT_CloseReq
683 **
684 ** Description      Close a stream endpoint.  This stops the transfer of media
685 **                  packets and closes the transport channel associated with
686 **                  this stream endpoint.  When the stream is closed, an
687 **                  AVDT_CLOSE_CFM_EVT is sent to the application via the
688 **                  control callback function for this handle.
689 **
690 **
691 ** Returns          AVDT_SUCCESS if successful, otherwise error.
692 **
693 *******************************************************************************/
694 AVDT_API extern UINT16 AVDT_CloseReq(UINT8 handle);
695 
696 /*******************************************************************************
697 **
698 ** Function         AVDT_ReconfigReq
699 **
700 ** Description      Reconfigure a stream endpoint.  This allows the application
701 **                  to change the codec or content protection capabilities of
702 **                  a stream endpoint after it has been opened.  This function
703 **                  can only be called if the stream is opened but not started
704 **                  or if the stream has been suspended.  When the procedure
705 **                  is completed, an AVDT_RECONFIG_CFM_EVT is sent to the
706 **                  application via the control callback function for this handle.
707 **
708 **
709 ** Returns          AVDT_SUCCESS if successful, otherwise error.
710 **
711 *******************************************************************************/
712 AVDT_API extern UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg);
713 
714 /*******************************************************************************
715 **
716 ** Function         AVDT_ReconfigRsp
717 **
718 ** Description      Respond to a reconfigure request from the peer device.
719 **                  This function must be called if the application receives
720 **                  an AVDT_RECONFIG_IND_EVT through its control callback.
721 **
722 **
723 ** Returns          AVDT_SUCCESS if successful, otherwise error.
724 **
725 *******************************************************************************/
726 AVDT_API extern UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_code,
727                                         UINT8 category);
728 
729 /*******************************************************************************
730 **
731 ** Function         AVDT_SecurityReq
732 **
733 ** Description      Send a security request to the peer device.  When the
734 **                  security procedure is completed, an AVDT_SECURITY_CFM_EVT
735 **                  is sent to the application via the control callback function
736 **                  for this handle.  (Please note that AVDTP security procedures
737 **                  are unrelated to Bluetooth link level security.)
738 **
739 **
740 ** Returns          AVDT_SUCCESS if successful, otherwise error.
741 **
742 *******************************************************************************/
743 AVDT_API extern UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len);
744 
745 /*******************************************************************************
746 **
747 ** Function         AVDT_SecurityRsp
748 **
749 ** Description      Respond to a security request from the peer device.
750 **                  This function must be called if the application receives
751 **                  an AVDT_SECURITY_IND_EVT through its control callback.
752 **                  (Please note that AVDTP security procedures are unrelated
753 **                  to Bluetooth link level security.)
754 **
755 **
756 ** Returns          AVDT_SUCCESS if successful, otherwise error.
757 **
758 *******************************************************************************/
759 AVDT_API extern UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_code,
760                                         UINT8 *p_data, UINT16 len);
761 
762 /*******************************************************************************
763 **
764 ** Function         AVDT_WriteReq
765 **
766 ** Description      Send a media packet to the peer device.  The stream must
767 **                  be started before this function is called.  Also, this
768 **                  function can only be called if the stream is a SRC.
769 **
770 **                  When AVDTP has sent the media packet and is ready for the
771 **                  next packet, an AVDT_WRITE_CFM_EVT is sent to the
772 **                  application via the control callback.  The application must
773 **                  wait for the AVDT_WRITE_CFM_EVT before it makes the next
774 **                  call to AVDT_WriteReq().  If the applications calls
775 **                  AVDT_WriteReq() before it receives the event the packet
776 **                  will not be sent.  The application may make its first call
777 **                  to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT
778 **                  or AVDT_START_IND_EVT.
779 **
780 **                  The application passes the packet using the BT_HDR structure.
781 **                  This structure is described in section 2.1.  The offset
782 **                  field must be equal to or greater than AVDT_MEDIA_OFFSET.
783 **                  This allows enough space in the buffer for the L2CAP and
784 **                  AVDTP headers.
785 **
786 **                  The memory pointed to by p_pkt must be a GKI buffer
787 **                  allocated by the application.  This buffer will be freed
788 **                  by the protocol stack; the application must not free
789 **                  this buffer.
790 **
791 **
792 ** Returns          AVDT_SUCCESS if successful, otherwise error.
793 **
794 *******************************************************************************/
795 AVDT_API extern UINT16 AVDT_WriteReq(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
796                                      UINT8 m_pt);
797 /*******************************************************************************
798 **
799 ** Function         AVDT_WriteReqOpt
800 **
801 ** Description      Send a media packet to the peer device.  The stream must
802 **                  be started before this function is called.  Also, this
803 **                  function can only be called if the stream is a SRC
804 **
805 **                  When AVDTP has sent the media packet and is ready for the
806 **                  next packet, an AVDT_WRITE_CFM_EVT is sent to the
807 **                  application via the control callback.  The application must
808 **                  wait for the AVDT_WRITE_CFM_EVT before it makes the next
809 **                  call to AVDT_WriteReq().  If the applications calls
810 **                  AVDT_WriteReq() before it receives the event the packet
811 **                  will not be sent.  The application may make its first call
812 **                  to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT
813 **                  or AVDT_START_IND_EVT.
814 **
815 **                  The application passes the packet using the BT_HDR structure
816 **                  This structure is described in section 2.1.  The offset
817 **                  field must be equal to or greater than AVDT_MEDIA_OFFSET
818 **                  (if NO_RTP is specified, L2CAP_MIN_OFFSET can be used)
819 **                  This allows enough space in the buffer for the L2CAP and
820 **                  AVDTP headers.
821 **
822 **                  The memory pointed to by p_pkt must be a GKI buffer
823 **                  allocated by the application.  This buffer will be freed
824 **                  by the protocol stack; the application must not free
825 **                  this buffer.
826 **
827 **                  The opt parameter allows passing specific options like:
828 **                  - NO_RTP : do not add the RTP header to buffer
829 **
830 ** Returns          AVDT_SUCCESS if successful, otherwise error.
831 **
832 *******************************************************************************/
833 AVDT_API extern UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
834                                      UINT8 m_pt, tAVDT_DATA_OPT_MASK opt);
835 
836 /*******************************************************************************
837 **
838 ** Function         AVDT_ConnectReq
839 **
840 ** Description      This function initiates an AVDTP signaling connection
841 **                  to the peer device.  When the connection is completed, an
842 **                  AVDT_CONNECT_IND_EVT is sent to the application via its
843 **                  control callback function.  If the connection attempt fails
844 **                  an AVDT_DISCONNECT_IND_EVT is sent.  The security mask
845 **                  parameter overrides the outgoing security mask set in
846 **                  AVDT_Register().
847 **
848 ** Returns          AVDT_SUCCESS if successful, otherwise error.
849 **
850 *******************************************************************************/
851 AVDT_API extern UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask,
852                                        tAVDT_CTRL_CBACK *p_cback);
853 
854 /*******************************************************************************
855 **
856 ** Function         AVDT_DisconnectReq
857 **
858 ** Description      This function disconnect an AVDTP signaling connection
859 **                  to the peer device.  When disconnected an
860 **                  AVDT_DISCONNECT_IND_EVT is sent to the application via its
861 **                  control callback function.
862 **
863 ** Returns          AVDT_SUCCESS if successful, otherwise error.
864 **
865 *******************************************************************************/
866 AVDT_API extern UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_cback);
867 
868 /*******************************************************************************
869 **
870 ** Function         AVDT_GetL2CapChannel
871 **
872 ** Description      Get the L2CAP CID used by the handle.
873 **
874 ** Returns          CID if successful, otherwise 0.
875 **
876 *******************************************************************************/
877 AVDT_API extern UINT16 AVDT_GetL2CapChannel(UINT8 handle);
878 
879 /*******************************************************************************
880 **
881 ** Function         AVDT_GetSignalChannel
882 **
883 ** Description      Get the L2CAP CID used by the signal channel of the given handle.
884 **
885 ** Returns          CID if successful, otherwise 0.
886 **
887 *******************************************************************************/
888 AVDT_API extern UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr);
889 
890 /*******************************************************************************
891 **
892 ** Function         AVDT_WriteDataReq
893 **
894 ** Description      Send a media packet to the peer device.  The stream must
895 **                  be started before this function is called.  Also, this
896 **                  function can only be called if the stream is a SRC.
897 **
898 **                  When AVDTP has sent the media packet and is ready for the
899 **                  next packet, an AVDT_WRITE_CFM_EVT is sent to the
900 **                  application via the control callback.  The application must
901 **                  wait for the AVDT_WRITE_CFM_EVT before it makes the next
902 **                  call to AVDT_WriteDataReq().  If the applications calls
903 **                  AVDT_WriteDataReq() before it receives the event the packet
904 **                  will not be sent.  The application may make its first call
905 **                  to AVDT_WriteDataReq() after it receives an
906 **                  AVDT_START_CFM_EVT or AVDT_START_IND_EVT.
907 **
908 ** Returns          AVDT_SUCCESS if successful, otherwise error.
909 **
910 *******************************************************************************/
911 AVDT_API extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len,
912                                      UINT32 time_stamp, UINT8 m_pt, UINT8 marker);
913 
914 /*******************************************************************************
915 **
916 ** Function         AVDT_SetMediaBuf
917 **
918 ** Description      Assigns buffer for media packets or forbids using of assigned
919 **                  buffer if argument p_buf is NULL. This function can only
920 **                  be called if the stream is a SNK.
921 **
922 **                  AVDTP uses this buffer to reassemble fragmented media packets.
923 **                  When AVDTP receives a complete media packet, it calls the
924 **                  p_media_cback assigned by AVDT_CreateStream().
925 **                  This function can be called during callback to assign a
926 **                  different buffer for next media packet or can leave the current
927 **                  buffer for next packet.
928 **
929 ** Returns          AVDT_SUCCESS if successful, otherwise error.
930 **
931 *******************************************************************************/
932 AVDT_API extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len);
933 
934 /*******************************************************************************
935 **
936 ** Function         AVDT_SendReport
937 **
938 ** Description
939 **
940 **
941 **
942 ** Returns
943 **
944 *******************************************************************************/
945 AVDT_API extern UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
946                        tAVDT_REPORT_DATA *p_data);
947 
948 /******************************************************************************
949 **
950 ** Function         AVDT_SetTraceLevel
951 **
952 ** Description      Sets the trace level for AVDT. If 0xff is passed, the
953 **                  current trace level is returned.
954 **
955 **                  Input Parameters:
956 **                      new_level:  The level to set the AVDT tracing to:
957 **                      0xff-returns the current setting.
958 **                      0-turns off tracing.
959 **                      >= 1-Errors.
960 **                      >= 2-Warnings.
961 **                      >= 3-APIs.
962 **                      >= 4-Events.
963 **                      >= 5-Debug.
964 **
965 ** Returns          The new trace level or current trace level if
966 **                  the input parameter is 0xff.
967 **
968 ******************************************************************************/
969 AVDT_API extern UINT8 AVDT_SetTraceLevel (UINT8 new_level);
970 
971 #ifdef __cplusplus
972 }
973 #endif
974 
975 
976 #endif /* AVDT_API_H */
977