Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright 2004-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 is the public interface file for the advanced audio/video streaming
     22  *  (AV) subsystem of BTA, Broadcom's Bluetooth application layer for mobile
     23  *  phones.
     24  *
     25  ******************************************************************************/
     26 #ifndef BTA_AV_API_H
     27 #define BTA_AV_API_H
     28 
     29 #include "a2dp_codec_api.h"
     30 #include "avdt_api.h"
     31 #include "avrc_api.h"
     32 #include "bta_api.h"
     33 
     34 /*****************************************************************************
     35  *  Constants and data types
     36  ****************************************************************************/
     37 /* Set to TRUE if seperate authorization prompt desired for AVCTP besides A2DP
     38  * authorization */
     39 /* Typically FALSE when AVRCP is used in conjunction with A2DP */
     40 #ifndef BTA_AV_WITH_AVCTP_AUTHORIZATION
     41 #define BTA_AV_WITH_AVCTP_AUTHORIZATION FALSE
     42 #endif
     43 
     44 /* AV status values */
     45 #define BTA_AV_SUCCESS 0        /* successful operation */
     46 #define BTA_AV_FAIL 1           /* generic failure */
     47 #define BTA_AV_FAIL_SDP 2       /* service not found */
     48 #define BTA_AV_FAIL_STREAM 3    /* stream connection failed */
     49 #define BTA_AV_FAIL_RESOURCES 4 /* no resources */
     50 #define BTA_AV_FAIL_ROLE 5 /* failed due to role management related issues */
     51 #define BTA_AV_FAIL_GET_CAP \
     52   6 /* get capability failed due to no SEP availale on the peer  */
     53 
     54 typedef uint8_t tBTA_AV_STATUS;
     55 
     56 /* AV features masks */
     57 #define BTA_AV_FEAT_RCTG 0x0001    /* remote control target */
     58 #define BTA_AV_FEAT_RCCT 0x0002    /* remote control controller */
     59 #define BTA_AV_FEAT_PROTECT 0x0004 /* streaming media contect protection */
     60 #define BTA_AV_FEAT_VENDOR                                                    \
     61   0x0008                          /* remote control vendor dependent commands \
     62                                      */
     63 #define BTA_AV_FEAT_REPORT 0x0020 /* use reporting service for VDP */
     64 #define BTA_AV_FEAT_METADATA \
     65   0x0040 /* remote control Metadata Transfer command/response */
     66 #define BTA_AV_FEAT_MULTI_AV \
     67   0x0080                          /* use multi-av, if controller supports it */
     68 #define BTA_AV_FEAT_BROWSE 0x0010 /* use browsing channel */
     69 #define BTA_AV_FEAT_MASTER 0x0100 /* stream only as master role */
     70 #define BTA_AV_FEAT_ADV_CTRL \
     71   0x0200 /* remote control Advanced Control command/response */
     72 #define BTA_AV_FEAT_DELAY_RPT 0x0400 /* allow delay reporting */
     73 #define BTA_AV_FEAT_ACP_START \
     74   0x0800 /* start stream when 2nd SNK was accepted   */
     75 #define BTA_AV_FEAT_APP_SETTING 0x2000 /* Player app setting support */
     76 
     77 /* Internal features */
     78 #define BTA_AV_FEAT_NO_SCO_SSPD \
     79   0x8000 /* Do not suspend av streaming as to AG events(SCO or Call) */
     80 
     81 typedef uint16_t tBTA_AV_FEAT;
     82 
     83 /* AV channel values */
     84 #define BTA_AV_CHNL_MSK 0xC0
     85 #define BTA_AV_CHNL_AUDIO 0x40 /* audio channel */
     86 #define BTA_AV_CHNL_VIDEO 0x80 /* video channel */
     87 typedef uint8_t tBTA_AV_CHNL;
     88 
     89 #define BTA_AV_HNDL_MSK 0x3F
     90 typedef uint8_t tBTA_AV_HNDL;
     91 /* handle index to mask */
     92 #define BTA_AV_HNDL_TO_MSK(h) ((uint8_t)(1 << (h)))
     93 
     94 /* maximum number of streams created */
     95 #ifndef BTA_AV_NUM_STRS
     96 #define BTA_AV_NUM_STRS 6
     97 #endif
     98 
     99 #ifndef BTA_AV_MAX_A2DP_MTU
    100 /*#define BTA_AV_MAX_A2DP_MTU     668 //224 (DM5) * 3 - 4(L2CAP header) */
    101 #define BTA_AV_MAX_A2DP_MTU 1008
    102 #endif
    103 
    104 /* operation id list for BTA_AvRemoteCmd */
    105 typedef uint8_t tBTA_AV_RC;
    106 
    107 /* state flag for pass through command */
    108 typedef uint8_t tBTA_AV_STATE;
    109 
    110 /* command codes for BTA_AvVendorCmd */
    111 typedef uint8_t tBTA_AV_CMD;
    112 
    113 /* response codes for BTA_AvVendorRsp */
    114 typedef uint8_t tBTA_AV_CODE;
    115 
    116 /* error codes for BTA_AvProtectRsp */
    117 typedef uint8_t tBTA_AV_ERR;
    118 
    119 /* AV callback events */
    120 #define BTA_AV_ENABLE_EVT 0      /* AV enabled */
    121 #define BTA_AV_REGISTER_EVT 1    /* registered to AVDT */
    122 #define BTA_AV_OPEN_EVT 2        /* connection opened */
    123 #define BTA_AV_CLOSE_EVT 3       /* connection closed */
    124 #define BTA_AV_START_EVT 4       /* stream data transfer started */
    125 #define BTA_AV_STOP_EVT 5        /* stream data transfer stopped */
    126 #define BTA_AV_PROTECT_REQ_EVT 6 /* content protection request */
    127 #define BTA_AV_PROTECT_RSP_EVT 7 /* content protection response */
    128 #define BTA_AV_RC_OPEN_EVT 8     /* remote control channel open */
    129 #define BTA_AV_RC_CLOSE_EVT 9    /* remote control channel closed */
    130 #define BTA_AV_REMOTE_CMD_EVT 10 /* remote control command */
    131 #define BTA_AV_REMOTE_RSP_EVT 11 /* remote control response */
    132 #define BTA_AV_VENDOR_CMD_EVT 12 /* vendor dependent remote control command */
    133 #define BTA_AV_VENDOR_RSP_EVT                                              \
    134   13                           /* vendor dependent remote control response \
    135                                   */
    136 #define BTA_AV_RECONFIG_EVT 14 /* reconfigure response */
    137 #define BTA_AV_SUSPEND_EVT 15  /* suspend response */
    138 #define BTA_AV_PENDING_EVT                                             \
    139   16                           /* incoming connection pending:         \
    140                                 * signal channel is open and stream is \
    141                                 * not open after                       \
    142                                 * BTA_AV_SIGNALLING_TIMEOUT_MS */
    143 #define BTA_AV_META_MSG_EVT 17 /* metadata messages */
    144 #define BTA_AV_REJECT_EVT 18   /* incoming connection rejected */
    145 #define BTA_AV_RC_FEAT_EVT \
    146   19 /* remote control channel peer supported features update */
    147 #define BTA_AV_SINK_MEDIA_CFG_EVT 20    /* command to configure codec */
    148 #define BTA_AV_SINK_MEDIA_DATA_EVT 21   /* sending data to Media Task */
    149 #define BTA_AV_OFFLOAD_START_RSP_EVT 22 /* a2dp offload start response */
    150 #define BTA_AV_RC_BROWSE_OPEN_EVT 23    /* remote control channel open */
    151 #define BTA_AV_RC_BROWSE_CLOSE_EVT 24   /* remote control channel closed */
    152 /* Max BTA event */
    153 #define BTA_AV_MAX_EVT 25
    154 
    155 typedef uint8_t tBTA_AV_EVT;
    156 
    157 typedef enum {
    158   BTA_AV_CODEC_TYPE_UNKNOWN = 0x00,
    159   BTA_AV_CODEC_TYPE_SBC = 0x01,
    160   BTA_AV_CODEC_TYPE_AAC = 0x02,
    161   BTA_AV_CODEC_TYPE_APTX = 0x04,
    162   BTA_AV_CODEC_TYPE_APTXHD = 0x08,
    163   BTA_AV_CODEC_TYPE_LDAC = 0x10
    164 } tBTA_AV_CODEC_TYPE;
    165 
    166 /* Event associated with BTA_AV_ENABLE_EVT */
    167 typedef struct { tBTA_AV_FEAT features; } tBTA_AV_ENABLE;
    168 
    169 /* Event associated with BTA_AV_REGISTER_EVT */
    170 typedef struct {
    171   tBTA_AV_CHNL chnl; /* audio/video */
    172   tBTA_AV_HNDL hndl; /* Handle associated with the stream. */
    173   uint8_t app_id;    /* ID associated with call to BTA_AvRegister() */
    174   tBTA_AV_STATUS status;
    175 } tBTA_AV_REGISTER;
    176 
    177 /* data associated with BTA_AV_OPEN_EVT */
    178 #define BTA_AV_EDR_2MBPS 0x01
    179 #define BTA_AV_EDR_3MBPS 0x02
    180 typedef uint8_t tBTA_AV_EDR;
    181 
    182 typedef struct {
    183   tBTA_AV_CHNL chnl;
    184   tBTA_AV_HNDL hndl;
    185   RawAddress bd_addr;
    186   tBTA_AV_STATUS status;
    187   bool starting;
    188   tBTA_AV_EDR edr; /* 0, if peer device does not support EDR */
    189   uint8_t sep;     /*  sep type of peer device */
    190 } tBTA_AV_OPEN;
    191 
    192 /* data associated with BTA_AV_CLOSE_EVT */
    193 typedef struct {
    194   tBTA_AV_CHNL chnl;
    195   tBTA_AV_HNDL hndl;
    196 } tBTA_AV_CLOSE;
    197 
    198 /* data associated with BTA_AV_START_EVT */
    199 typedef struct {
    200   tBTA_AV_CHNL chnl;
    201   tBTA_AV_HNDL hndl;
    202   tBTA_AV_STATUS status;
    203   bool initiator; /* true, if local device initiates the START */
    204   bool suspending;
    205 } tBTA_AV_START;
    206 
    207 /* data associated with BTA_AV_SUSPEND_EVT, BTA_AV_STOP_EVT */
    208 typedef struct {
    209   tBTA_AV_CHNL chnl;
    210   tBTA_AV_HNDL hndl;
    211   bool initiator; /* true, if local device initiates the SUSPEND */
    212   tBTA_AV_STATUS status;
    213 } tBTA_AV_SUSPEND;
    214 
    215 /* data associated with BTA_AV_RECONFIG_EVT */
    216 typedef struct {
    217   tBTA_AV_CHNL chnl;
    218   tBTA_AV_HNDL hndl;
    219   tBTA_AV_STATUS status;
    220 } tBTA_AV_RECONFIG;
    221 
    222 /* data associated with BTA_AV_PROTECT_REQ_EVT */
    223 typedef struct {
    224   tBTA_AV_CHNL chnl;
    225   tBTA_AV_HNDL hndl;
    226   uint8_t* p_data;
    227   uint16_t len;
    228 } tBTA_AV_PROTECT_REQ;
    229 
    230 /* data associated with BTA_AV_PROTECT_RSP_EVT */
    231 typedef struct {
    232   tBTA_AV_CHNL chnl;
    233   tBTA_AV_HNDL hndl;
    234   uint8_t* p_data;
    235   uint16_t len;
    236   tBTA_AV_ERR err_code;
    237 } tBTA_AV_PROTECT_RSP;
    238 
    239 /* data associated with BTA_AV_RC_OPEN_EVT */
    240 typedef struct {
    241   uint8_t rc_handle;
    242   tBTA_AV_FEAT peer_features;
    243   RawAddress peer_addr;
    244   tBTA_AV_STATUS status;
    245 } tBTA_AV_RC_OPEN;
    246 
    247 /* data associated with BTA_AV_RC_CLOSE_EVT */
    248 typedef struct {
    249   uint8_t rc_handle;
    250   RawAddress peer_addr;
    251 } tBTA_AV_RC_CLOSE;
    252 
    253 /* data associated with BTA_AV_RC_BROWSE_OPEN_EVT */
    254 typedef struct {
    255   uint8_t rc_handle;
    256   RawAddress peer_addr;
    257   tBTA_AV_STATUS status;
    258 } tBTA_AV_RC_BROWSE_OPEN;
    259 
    260 /* data associated with BTA_AV_RC_BROWSE_CLOSE_EVT */
    261 typedef struct {
    262   uint8_t rc_handle;
    263   RawAddress peer_addr;
    264 } tBTA_AV_RC_BROWSE_CLOSE;
    265 
    266 /* data associated with BTA_AV_RC_FEAT_EVT */
    267 typedef struct {
    268   uint8_t rc_handle;
    269   tBTA_AV_FEAT peer_features;
    270   RawAddress peer_addr;
    271 } tBTA_AV_RC_FEAT;
    272 
    273 /* data associated with BTA_AV_REMOTE_CMD_EVT */
    274 typedef struct {
    275   uint8_t rc_handle;
    276   tBTA_AV_RC rc_id;
    277   tBTA_AV_STATE key_state;
    278   uint8_t len;
    279   uint8_t* p_data;
    280   tAVRC_HDR hdr; /* Message header. */
    281   uint8_t label;
    282 } tBTA_AV_REMOTE_CMD;
    283 
    284 /* data associated with BTA_AV_REMOTE_RSP_EVT */
    285 typedef struct {
    286   uint8_t rc_handle;
    287   tBTA_AV_RC rc_id;
    288   tBTA_AV_STATE key_state;
    289   uint8_t len;
    290   uint8_t* p_data;
    291   tBTA_AV_CODE rsp_code;
    292   uint8_t label;
    293 } tBTA_AV_REMOTE_RSP;
    294 
    295 /* data associated with BTA_AV_VENDOR_CMD_EVT, BTA_AV_VENDOR_RSP_EVT */
    296 typedef struct {
    297   uint8_t rc_handle;
    298   uint16_t len; /* Max vendor dependent message is 512 */
    299   uint8_t label;
    300   tBTA_AV_CODE code;
    301   uint32_t company_id;
    302   uint8_t* p_data;
    303 } tBTA_AV_VENDOR;
    304 
    305 /* data associated with BTA_AV_META_MSG_EVT */
    306 typedef struct {
    307   uint8_t rc_handle;
    308   uint16_t len;
    309   uint8_t label;
    310   tBTA_AV_CODE code;
    311   uint32_t company_id;
    312   uint8_t* p_data;
    313   tAVRC_MSG* p_msg;
    314 } tBTA_AV_META_MSG;
    315 
    316 /* data associated with BTA_AV_PENDING_EVT */
    317 typedef struct { RawAddress bd_addr; } tBTA_AV_PEND;
    318 
    319 /* data associated with BTA_AV_REJECT_EVT */
    320 typedef struct {
    321   RawAddress bd_addr;
    322   tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the
    323                         connection. */
    324 } tBTA_AV_REJECT;
    325 
    326 /* union of data associated with AV callback */
    327 typedef union {
    328   tBTA_AV_CHNL chnl;
    329   tBTA_AV_ENABLE enable;
    330   tBTA_AV_REGISTER registr;
    331   tBTA_AV_OPEN open;
    332   tBTA_AV_CLOSE close;
    333   tBTA_AV_START start;
    334   tBTA_AV_PROTECT_REQ protect_req;
    335   tBTA_AV_PROTECT_RSP protect_rsp;
    336   tBTA_AV_RC_OPEN rc_open;
    337   tBTA_AV_RC_CLOSE rc_close;
    338   tBTA_AV_RC_BROWSE_OPEN rc_browse_open;
    339   tBTA_AV_RC_BROWSE_CLOSE rc_browse_close;
    340   tBTA_AV_REMOTE_CMD remote_cmd;
    341   tBTA_AV_REMOTE_RSP remote_rsp;
    342   tBTA_AV_VENDOR vendor_cmd;
    343   tBTA_AV_VENDOR vendor_rsp;
    344   tBTA_AV_RECONFIG reconfig;
    345   tBTA_AV_SUSPEND suspend;
    346   tBTA_AV_PEND pend;
    347   tBTA_AV_META_MSG meta_msg;
    348   tBTA_AV_REJECT reject;
    349   tBTA_AV_RC_FEAT rc_feat;
    350   tBTA_AV_STATUS status;
    351 } tBTA_AV;
    352 
    353 typedef struct {
    354   uint8_t* codec_info;
    355   RawAddress bd_addr;
    356 } tBTA_AVK_CONFIG;
    357 
    358 /* union of data associated with AV Media callback */
    359 typedef union {
    360   BT_HDR* p_data;
    361   tBTA_AVK_CONFIG avk_config;
    362 } tBTA_AV_MEDIA;
    363 
    364 #define BTA_GROUP_NAVI_MSG_OP_DATA_LEN 5
    365 
    366 /* AV callback */
    367 typedef void(tBTA_AV_CBACK)(tBTA_AV_EVT event, tBTA_AV* p_data);
    368 typedef void(tBTA_AV_SINK_DATA_CBACK)(tBTA_AV_EVT event, tBTA_AV_MEDIA* p_data);
    369 
    370 /* type for stream state machine action functions */
    371 struct tBTA_AV_SCB;
    372 union tBTA_AV_DATA;
    373 typedef void (*tBTA_AV_ACT)(tBTA_AV_SCB* p_cb, tBTA_AV_DATA* p_data);
    374 
    375 /* AV configuration structure */
    376 typedef struct {
    377   uint32_t company_id;  /* AVRCP Company ID */
    378   uint16_t avrc_mtu;    /* AVRCP MTU at L2CAP for control channel */
    379   uint16_t avrc_br_mtu; /* AVRCP MTU at L2CAP for browsing channel */
    380   uint16_t avrc_ct_cat; /* AVRCP controller categories */
    381   uint16_t avrc_tg_cat; /* AVRCP target categories */
    382   uint16_t sig_mtu;     /* AVDTP signaling channel MTU at L2CAP */
    383   uint16_t audio_mtu;   /* AVDTP audio transport channel MTU at L2CAP */
    384   const uint16_t*
    385       p_audio_flush_to;    /* AVDTP audio transport channel flush timeout */
    386   uint16_t audio_mqs;      /* AVDTP audio channel max data queue size */
    387   bool avrc_group;     /* true, to accept AVRC 1.3 group nevigation command */
    388   uint8_t num_co_ids;  /* company id count in p_meta_co_ids */
    389   uint8_t num_evt_ids; /* event id count in p_meta_evt_ids */
    390   tBTA_AV_CODE
    391       rc_pass_rsp; /* the default response code for pass through commands */
    392   const uint32_t*
    393       p_meta_co_ids; /* the metadata Get Capabilities response for company id */
    394   const uint8_t* p_meta_evt_ids; /* the the metadata Get Capabilities response
    395                                     for event id */
    396   const tBTA_AV_ACT* p_act_tbl;  /* action function table for audio stream */
    397   char avrc_controller_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP controller
    398                                                       name */
    399   char avrc_target_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP target name*/
    400 } tBTA_AV_CFG;
    401 
    402 /*****************************************************************************
    403  *  External Function Declarations
    404  ****************************************************************************/
    405 
    406 /*******************************************************************************
    407  *
    408  * Function         BTA_AvEnable
    409  *
    410  * Description      Enable the advanced audio/video service. When the enable
    411  *                  operation is complete the callback function will be
    412  *                  called with a BTA_AV_ENABLE_EVT. This function must
    413  *                  be called before other function in the AV API are
    414  *                  called.
    415  *
    416  * Returns          void
    417  *
    418  ******************************************************************************/
    419 void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features,
    420                   tBTA_AV_CBACK* p_cback);
    421 
    422 /*******************************************************************************
    423  *
    424  * Function         BTA_AvDisable
    425  *
    426  * Description      Disable the advanced audio/video service.
    427  *
    428  *
    429  * Returns          void
    430  *
    431  ******************************************************************************/
    432 void BTA_AvDisable(void);
    433 
    434 /*******************************************************************************
    435  *
    436  * Function         BTA_AvRegister
    437  *
    438  * Description      Register the audio or video service to stack. When the
    439  *                  operation is complete the callback function will be
    440  *                  called with a BTA_AV_REGISTER_EVT. This function must
    441  *                  be called before AVDT stream is open.
    442  *
    443  *
    444  * Returns          void
    445  *
    446  ******************************************************************************/
    447 void BTA_AvRegister(tBTA_AV_CHNL chnl, const char* p_service_name,
    448                     uint8_t app_id, tBTA_AV_SINK_DATA_CBACK* p_sink_data_cback,
    449                     uint16_t service_uuid);
    450 
    451 /*******************************************************************************
    452  *
    453  * Function         BTA_AvDeregister
    454  *
    455  * Description      Deregister the audio or video service
    456  *
    457  * Returns          void
    458  *
    459  ******************************************************************************/
    460 void BTA_AvDeregister(tBTA_AV_HNDL hndl);
    461 
    462 /*******************************************************************************
    463  *
    464  * Function         BTA_AvOpen
    465  *
    466  * Description      Opens an advanced audio/video connection to a peer device.
    467  *                  When connection is open callback function is called
    468  *                  with a BTA_AV_OPEN_EVT.
    469  *
    470  * Returns          void
    471  *
    472  ******************************************************************************/
    473 void BTA_AvOpen(const RawAddress& bd_addr, tBTA_AV_HNDL handle, bool use_rc,
    474                 tBTA_SEC sec_mask, uint16_t uuid);
    475 
    476 /*******************************************************************************
    477  *
    478  * Function         BTA_AvClose
    479  *
    480  * Description      Close the current streams.
    481  *
    482  * Returns          void
    483  *
    484  ******************************************************************************/
    485 void BTA_AvClose(tBTA_AV_HNDL handle);
    486 
    487 /*******************************************************************************
    488  *
    489  * Function         BTA_AvDisconnect
    490  *
    491  * Description      Close the connection to the address.
    492  *
    493  * Returns          void
    494  *
    495  ******************************************************************************/
    496 void BTA_AvDisconnect(const RawAddress& bd_addr);
    497 
    498 /*******************************************************************************
    499  *
    500  * Function         BTA_AvStart
    501  *
    502  * Description      Start audio/video stream data transfer.
    503  *
    504  * Returns          void
    505  *
    506  ******************************************************************************/
    507 void BTA_AvStart(tBTA_AV_HNDL handle);
    508 
    509 /*******************************************************************************
    510  *
    511  * Function         BTA_AvStop
    512  *
    513  * Description      Stop audio/video stream data transfer.
    514  *                  If suspend is true, this function sends AVDT suspend signal
    515  *                  to the connected peer(s).
    516  *
    517  * Returns          void
    518  *
    519  ******************************************************************************/
    520 void BTA_AvStop(tBTA_AV_HNDL handle, bool suspend);
    521 
    522 /*******************************************************************************
    523  *
    524  * Function         BTA_AvReconfig
    525  *
    526  * Description      Reconfigure the audio/video stream.
    527  *                  If suspend is true, this function tries the
    528  *                  suspend/reconfigure procedure first.
    529  *                  If suspend is false or when suspend/reconfigure fails,
    530  *                  this function closes and re-opens the AVDT connection.
    531  *
    532  * Returns          void
    533  *
    534  ******************************************************************************/
    535 void BTA_AvReconfig(tBTA_AV_HNDL hndl, bool suspend, uint8_t sep_info_idx,
    536                     uint8_t* p_codec_info, uint8_t num_protect,
    537                     const uint8_t* p_protect_info);
    538 
    539 /*******************************************************************************
    540  *
    541  * Function         BTA_AvProtectReq
    542  *
    543  * Description      Send a content protection request.  This function can only
    544  *                  be used if AV is enabled with feature BTA_AV_FEAT_PROTECT.
    545  *
    546  * Returns          void
    547  *
    548  ******************************************************************************/
    549 void BTA_AvProtectReq(tBTA_AV_HNDL hndl, uint8_t* p_data, uint16_t len);
    550 
    551 /*******************************************************************************
    552  *
    553  * Function         BTA_AvProtectRsp
    554  *
    555  * Description      Send a content protection response.  This function must
    556  *                  be called if a BTA_AV_PROTECT_REQ_EVT is received.
    557  *                  This function can only be used if AV is enabled with
    558  *                  feature BTA_AV_FEAT_PROTECT.
    559  *
    560  * Returns          void
    561  *
    562  ******************************************************************************/
    563 void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, uint8_t error_code, uint8_t* p_data,
    564                       uint16_t len);
    565 
    566 /*******************************************************************************
    567  *
    568  * Function         BTA_AvRemoteCmd
    569  *
    570  * Description      Send a remote control command.  This function can only
    571  *                  be used if AV is enabled with feature BTA_AV_FEAT_RCCT.
    572  *
    573  * Returns          void
    574  *
    575  ******************************************************************************/
    576 void BTA_AvRemoteCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_RC rc_id,
    577                      tBTA_AV_STATE key_state);
    578 
    579 /*******************************************************************************
    580  *
    581  * Function         BTA_AvRemoteVendorUniqueCmd
    582  *
    583  * Description      Send a remote control command with Vendor Unique rc_id.
    584  *                  This function can only be used if AV is enabled with
    585  *                  feature BTA_AV_FEAT_RCCT.
    586  *
    587  * Returns          void
    588  *
    589  ******************************************************************************/
    590 void BTA_AvRemoteVendorUniqueCmd(uint8_t rc_handle, uint8_t label,
    591                                  tBTA_AV_STATE key_state, uint8_t* p_msg,
    592                                  uint8_t buf_len);
    593 
    594 /*******************************************************************************
    595  *
    596  * Function         BTA_AvVendorCmd
    597  *
    598  * Description      Send a vendor dependent remote control command.  This
    599  *                  function can only be used if AV is enabled with feature
    600  *                  BTA_AV_FEAT_VENDOR.
    601  *
    602  * Returns          void
    603  *
    604  ******************************************************************************/
    605 void BTA_AvVendorCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE cmd_code,
    606                      uint8_t* p_data, uint16_t len);
    607 
    608 /*******************************************************************************
    609  *
    610  * Function         BTA_AvVendorRsp
    611  *
    612  * Description      Send a vendor dependent remote control response.
    613  *                  This function must be called if a BTA_AV_VENDOR_CMD_EVT
    614  *                  is received. This function can only be used if AV is
    615  *                  enabled with feature BTA_AV_FEAT_VENDOR.
    616  *
    617  * Returns          void
    618  *
    619  ******************************************************************************/
    620 void BTA_AvVendorRsp(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE rsp_code,
    621                      uint8_t* p_data, uint16_t len, uint32_t company_id);
    622 
    623 /*******************************************************************************
    624  *
    625  * Function         BTA_AvOpenRc
    626  *
    627  * Description      Open an AVRCP connection toward the device with the
    628  *                  specified handle
    629  *
    630  * Returns          void
    631  *
    632  ******************************************************************************/
    633 void BTA_AvOpenRc(tBTA_AV_HNDL handle);
    634 
    635 /*******************************************************************************
    636  *
    637  * Function         BTA_AvCloseRc
    638  *
    639  * Description      Close an AVRCP connection
    640  *
    641  * Returns          void
    642  *
    643  ******************************************************************************/
    644 void BTA_AvCloseRc(uint8_t rc_handle);
    645 
    646 /*******************************************************************************
    647  *
    648  * Function         BTA_AvMetaRsp
    649  *
    650  * Description      Send a Metadata command/response. The message contained
    651  *                  in p_pkt can be composed with AVRC utility functions.
    652  *                  This function can only be used if AV is enabled with feature
    653  *                  BTA_AV_FEAT_METADATA.
    654  *
    655  * Returns          void
    656  *
    657  ******************************************************************************/
    658 void BTA_AvMetaRsp(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE rsp_code,
    659                    BT_HDR* p_pkt);
    660 
    661 /*******************************************************************************
    662  *
    663  * Function         BTA_AvMetaCmd
    664  *
    665  * Description      Send a Metadata/Advanced Control command. The message
    666 *contained
    667  *                  in p_pkt can be composed with AVRC utility functions.
    668  *                  This function can only be used if AV is enabled with feature
    669  *                  BTA_AV_FEAT_METADATA.
    670  *                  This message is sent only when the peer supports the TG
    671 *role.
    672 *8                  The only command makes sense right now is the absolute
    673 *volume command.
    674  *
    675  * Returns          void
    676  *
    677  ******************************************************************************/
    678 void BTA_AvMetaCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_CMD cmd_code,
    679                    BT_HDR* p_pkt);
    680 
    681 /*******************************************************************************
    682  *
    683  * Function         BTA_AvOffloadStart
    684  *
    685  * Description      Request Starting of A2DP Offload.
    686  *                  This function is used to start A2DP offload if vendor lib
    687  *                  has the feature enabled.
    688  *
    689  * Returns          void
    690  *
    691  ******************************************************************************/
    692 void BTA_AvOffloadStart(tBTA_AV_HNDL hndl);
    693 
    694 /*******************************************************************************
    695  *
    696  * Function         BTA_AvOffloadStartRsp
    697  *
    698  * Description      Response from vendor library indicating response for
    699  *                  OffloadStart.
    700  *
    701  * Returns          void
    702  *
    703  ******************************************************************************/
    704 void BTA_AvOffloadStartRsp(tBTA_AV_HNDL hndl, tBTA_AV_STATUS status);
    705 
    706 /**
    707  * Obtain the Channel Index for a peer.
    708  * If the peer already has associated internal state, the corresponding
    709  * Channel Index for that state is returned. Otherwise, the Channel Index
    710  * for unused internal state is returned instead.
    711  *
    712  * @param peer_address the peer address
    713  * @return the peer Channel Index index if obtained, otherwise -1
    714  */
    715 int BTA_AvObtainPeerChannelIndex(const RawAddress& peer_address);
    716 
    717 /**
    718  * Dump debug-related information for the BTA AV module.
    719  *
    720  * @param fd the file descriptor to use for writing the ASCII formatted
    721  * information
    722  */
    723 void bta_debug_av_dump(int fd);
    724 
    725 #endif /* BTA_AV_API_H */
    726