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