Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 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: 1 for audio, 1 for video */
     95 #ifndef BTA_AV_NUM_STRS
     96 #define BTA_AV_NUM_STRS 2
     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 #ifndef BTA_AV_MAX_VDP_MTU
    105 #define BTA_AV_MAX_VDP_MTU 1008
    106 #endif
    107 
    108 /* operation id list for BTA_AvRemoteCmd */
    109 #define BTA_AV_RC_SELECT AVRC_ID_SELECT         /* select */
    110 #define BTA_AV_RC_UP AVRC_ID_UP                 /* up */
    111 #define BTA_AV_RC_DOWN AVRC_ID_DOWN             /* down */
    112 #define BTA_AV_RC_LEFT AVRC_ID_LEFT             /* left */
    113 #define BTA_AV_RC_RIGHT AVRC_ID_RIGHT           /* right */
    114 #define BTA_AV_RC_RIGHT_UP AVRC_ID_RIGHT_UP     /* right-up */
    115 #define BTA_AV_RC_RIGHT_DOWN AVRC_ID_RIGHT_DOWN /* right-down */
    116 #define BTA_AV_RC_LEFT_UP AVRC_ID_LEFT_UP       /* left-up */
    117 #define BTA_AV_RC_LEFT_DOWN AVRC_ID_LEFT_DOWN   /* left-down */
    118 #define BTA_AV_RC_ROOT_MENU AVRC_ID_ROOT_MENU   /* root menu */
    119 #define BTA_AV_RC_SETUP_MENU AVRC_ID_SETUP_MENU /* setup menu */
    120 #define BTA_AV_RC_CONT_MENU AVRC_ID_CONT_MENU   /* contents menu */
    121 #define BTA_AV_RC_FAV_MENU AVRC_ID_FAV_MENU     /* favorite menu */
    122 #define BTA_AV_RC_EXIT AVRC_ID_EXIT             /* exit */
    123 #define BTA_AV_RC_0 AVRC_ID_0                   /* 0 */
    124 #define BTA_AV_RC_1 AVRC_ID_1                   /* 1 */
    125 #define BTA_AV_RC_2 AVRC_ID_2                   /* 2 */
    126 #define BTA_AV_RC_3 AVRC_ID_3                   /* 3 */
    127 #define BTA_AV_RC_4 AVRC_ID_4                   /* 4 */
    128 #define BTA_AV_RC_5 AVRC_ID_5                   /* 5 */
    129 #define BTA_AV_RC_6 AVRC_ID_6                   /* 6 */
    130 #define BTA_AV_RC_7 AVRC_ID_7                   /* 7 */
    131 #define BTA_AV_RC_8 AVRC_ID_8                   /* 8 */
    132 #define BTA_AV_RC_9 AVRC_ID_9                   /* 9 */
    133 #define BTA_AV_RC_DOT AVRC_ID_DOT               /* dot */
    134 #define BTA_AV_RC_ENTER AVRC_ID_ENTER           /* enter */
    135 #define BTA_AV_RC_CLEAR AVRC_ID_CLEAR           /* clear */
    136 #define BTA_AV_RC_CHAN_UP AVRC_ID_CHAN_UP       /* channel up */
    137 #define BTA_AV_RC_CHAN_DOWN AVRC_ID_CHAN_DOWN   /* channel down */
    138 #define BTA_AV_RC_PREV_CHAN AVRC_ID_PREV_CHAN   /* previous channel */
    139 #define BTA_AV_RC_SOUND_SEL AVRC_ID_SOUND_SEL   /* sound select */
    140 #define BTA_AV_RC_INPUT_SEL AVRC_ID_INPUT_SEL   /* input select */
    141 #define BTA_AV_RC_DISP_INFO AVRC_ID_DISP_INFO   /* display information */
    142 #define BTA_AV_RC_HELP AVRC_ID_HELP             /* help */
    143 #define BTA_AV_RC_PAGE_UP AVRC_ID_PAGE_UP       /* page up */
    144 #define BTA_AV_RC_PAGE_DOWN AVRC_ID_PAGE_DOWN   /* page down */
    145 #define BTA_AV_RC_POWER AVRC_ID_POWER           /* power */
    146 #define BTA_AV_RC_VOL_UP AVRC_ID_VOL_UP         /* volume up */
    147 #define BTA_AV_RC_VOL_DOWN AVRC_ID_VOL_DOWN     /* volume down */
    148 #define BTA_AV_RC_MUTE AVRC_ID_MUTE             /* mute */
    149 #define BTA_AV_RC_PLAY AVRC_ID_PLAY             /* play */
    150 #define BTA_AV_RC_STOP AVRC_ID_STOP             /* stop */
    151 #define BTA_AV_RC_PAUSE AVRC_ID_PAUSE           /* pause */
    152 #define BTA_AV_RC_RECORD AVRC_ID_RECORD         /* record */
    153 #define BTA_AV_RC_REWIND AVRC_ID_REWIND         /* rewind */
    154 #define BTA_AV_RC_FAST_FOR AVRC_ID_FAST_FOR     /* fast forward */
    155 #define BTA_AV_RC_EJECT AVRC_ID_EJECT           /* eject */
    156 #define BTA_AV_RC_FORWARD AVRC_ID_FORWARD       /* forward */
    157 #define BTA_AV_RC_BACKWARD AVRC_ID_BACKWARD     /* backward */
    158 #define BTA_AV_RC_ANGLE AVRC_ID_ANGLE           /* angle */
    159 #define BTA_AV_RC_SUBPICT AVRC_ID_SUBPICT       /* subpicture */
    160 #define BTA_AV_RC_F1 AVRC_ID_F1                 /* F1 */
    161 #define BTA_AV_RC_F2 AVRC_ID_F2                 /* F2 */
    162 #define BTA_AV_RC_F3 AVRC_ID_F3                 /* F3 */
    163 #define BTA_AV_RC_F4 AVRC_ID_F4                 /* F4 */
    164 #define BTA_AV_RC_F5 AVRC_ID_F5                 /* F5 */
    165 #define BTA_AV_VENDOR AVRC_ID_VENDOR            /* vendor unique */
    166 
    167 typedef uint8_t tBTA_AV_RC;
    168 
    169 /* state flag for pass through command */
    170 #define BTA_AV_STATE_PRESS AVRC_STATE_PRESS     /* key pressed */
    171 #define BTA_AV_STATE_RELEASE AVRC_STATE_RELEASE /* key released */
    172 
    173 typedef uint8_t tBTA_AV_STATE;
    174 
    175 /* command codes for BTA_AvVendorCmd */
    176 #define BTA_AV_CMD_CTRL AVRC_CMD_CTRL
    177 #define BTA_AV_CMD_STATUS AVRC_CMD_STATUS
    178 #define BTA_AV_CMD_SPEC_INQ AVRC_CMD_SPEC_INQ
    179 #define BTA_AV_CMD_NOTIF AVRC_CMD_NOTIF
    180 #define BTA_AV_CMD_GEN_INQ AVRC_CMD_GEN_INQ
    181 
    182 typedef uint8_t tBTA_AV_CMD;
    183 
    184 /* response codes for BTA_AvVendorRsp */
    185 #define BTA_AV_RSP_NOT_IMPL AVRC_RSP_NOT_IMPL
    186 #define BTA_AV_RSP_ACCEPT AVRC_RSP_ACCEPT
    187 #define BTA_AV_RSP_REJ AVRC_RSP_REJ
    188 #define BTA_AV_RSP_IN_TRANS AVRC_RSP_IN_TRANS
    189 #define BTA_AV_RSP_IMPL_STBL AVRC_RSP_IMPL_STBL
    190 #define BTA_AV_RSP_CHANGED AVRC_RSP_CHANGED
    191 #define BTA_AV_RSP_INTERIM AVRC_RSP_INTERIM
    192 
    193 typedef uint8_t tBTA_AV_CODE;
    194 
    195 /* error codes for BTA_AvProtectRsp */
    196 #define BTA_AV_ERR_NONE A2DP_SUCCESS /* Success, no error */
    197 #define BTA_AV_ERR_BAD_STATE \
    198   AVDT_ERR_BAD_STATE /* Message cannot be processed in this state */
    199 #define BTA_AV_ERR_RESOURCE AVDT_ERR_RESOURCE /* Insufficient resources */
    200 #define BTA_AV_ERR_BAD_CP_TYPE                                               \
    201   A2DP_BAD_CP_TYPE /* The requested Content Protection Type is not supported \
    202                       */
    203 #define BTA_AV_ERR_BAD_CP_FORMAT                                             \
    204   A2DP_BAD_CP_FORMAT /* The format of Content Protection Data is not correct \
    205                         */
    206 
    207 typedef uint8_t tBTA_AV_ERR;
    208 
    209 /* AV callback events */
    210 #define BTA_AV_ENABLE_EVT 0      /* AV enabled */
    211 #define BTA_AV_REGISTER_EVT 1    /* registered to AVDT */
    212 #define BTA_AV_OPEN_EVT 2        /* connection opened */
    213 #define BTA_AV_CLOSE_EVT 3       /* connection closed */
    214 #define BTA_AV_START_EVT 4       /* stream data transfer started */
    215 #define BTA_AV_STOP_EVT 5        /* stream data transfer stopped */
    216 #define BTA_AV_PROTECT_REQ_EVT 6 /* content protection request */
    217 #define BTA_AV_PROTECT_RSP_EVT 7 /* content protection response */
    218 #define BTA_AV_RC_OPEN_EVT 8     /* remote control channel open */
    219 #define BTA_AV_RC_CLOSE_EVT 9    /* remote control channel closed */
    220 #define BTA_AV_REMOTE_CMD_EVT 10 /* remote control command */
    221 #define BTA_AV_REMOTE_RSP_EVT 11 /* remote control response */
    222 #define BTA_AV_VENDOR_CMD_EVT 12 /* vendor dependent remote control command */
    223 #define BTA_AV_VENDOR_RSP_EVT                                              \
    224   13                           /* vendor dependent remote control response \
    225                                   */
    226 #define BTA_AV_RECONFIG_EVT 14 /* reconfigure response */
    227 #define BTA_AV_SUSPEND_EVT 15  /* suspend response */
    228 #define BTA_AV_PENDING_EVT                                             \
    229   16                           /* incoming connection pending:         \
    230                                 * signal channel is open and stream is \
    231                                 * not open after                       \
    232                                 * BTA_AV_SIGNALLING_TIMEOUT_MS */
    233 #define BTA_AV_META_MSG_EVT 17 /* metadata messages */
    234 #define BTA_AV_REJECT_EVT 18   /* incoming connection rejected */
    235 #define BTA_AV_RC_FEAT_EVT \
    236   19 /* remote control channel peer supported features update */
    237 #define BTA_AV_SINK_MEDIA_CFG_EVT 20    /* command to configure codec */
    238 #define BTA_AV_SINK_MEDIA_DATA_EVT 21   /* sending data to Media Task */
    239 #define BTA_AV_OFFLOAD_START_RSP_EVT 22 /* a2dp offload start response */
    240 #define BTA_AV_RC_BROWSE_OPEN_EVT 23    /* remote control channel open */
    241 #define BTA_AV_RC_BROWSE_CLOSE_EVT 24   /* remote control channel closed */
    242 /* Max BTA event */
    243 #define BTA_AV_MAX_EVT 25
    244 
    245 typedef uint8_t tBTA_AV_EVT;
    246 
    247 /* Event associated with BTA_AV_ENABLE_EVT */
    248 typedef struct { tBTA_AV_FEAT features; } tBTA_AV_ENABLE;
    249 
    250 /* Event associated with BTA_AV_REGISTER_EVT */
    251 typedef struct {
    252   tBTA_AV_CHNL chnl; /* audio/video */
    253   tBTA_AV_HNDL hndl; /* Handle associated with the stream. */
    254   uint8_t app_id;    /* ID associated with call to BTA_AvRegister() */
    255   tBTA_AV_STATUS status;
    256 } tBTA_AV_REGISTER;
    257 
    258 /* data associated with BTA_AV_OPEN_EVT */
    259 #define BTA_AV_EDR_2MBPS 0x01
    260 #define BTA_AV_EDR_3MBPS 0x02
    261 typedef uint8_t tBTA_AV_EDR;
    262 
    263 typedef struct {
    264   tBTA_AV_CHNL chnl;
    265   tBTA_AV_HNDL hndl;
    266   BD_ADDR bd_addr;
    267   tBTA_AV_STATUS status;
    268   bool starting;
    269   tBTA_AV_EDR edr; /* 0, if peer device does not support EDR */
    270   uint8_t sep;     /*  sep type of peer device */
    271 } tBTA_AV_OPEN;
    272 
    273 /* data associated with BTA_AV_CLOSE_EVT */
    274 typedef struct {
    275   tBTA_AV_CHNL chnl;
    276   tBTA_AV_HNDL hndl;
    277 } tBTA_AV_CLOSE;
    278 
    279 /* data associated with BTA_AV_START_EVT */
    280 typedef struct {
    281   tBTA_AV_CHNL chnl;
    282   tBTA_AV_HNDL hndl;
    283   tBTA_AV_STATUS status;
    284   bool initiator; /* true, if local device initiates the START */
    285   bool suspending;
    286 } tBTA_AV_START;
    287 
    288 /* data associated with BTA_AV_SUSPEND_EVT */
    289 typedef struct {
    290   tBTA_AV_CHNL chnl;
    291   tBTA_AV_HNDL hndl;
    292   bool initiator; /* true, if local device initiates the SUSPEND */
    293   tBTA_AV_STATUS status;
    294 } tBTA_AV_SUSPEND;
    295 
    296 /* data associated with BTA_AV_RECONFIG_EVT */
    297 typedef struct {
    298   tBTA_AV_CHNL chnl;
    299   tBTA_AV_HNDL hndl;
    300   tBTA_AV_STATUS status;
    301 } tBTA_AV_RECONFIG;
    302 
    303 /* data associated with BTA_AV_PROTECT_REQ_EVT */
    304 typedef struct {
    305   tBTA_AV_CHNL chnl;
    306   tBTA_AV_HNDL hndl;
    307   uint8_t* p_data;
    308   uint16_t len;
    309 } tBTA_AV_PROTECT_REQ;
    310 
    311 /* data associated with BTA_AV_PROTECT_RSP_EVT */
    312 typedef struct {
    313   tBTA_AV_CHNL chnl;
    314   tBTA_AV_HNDL hndl;
    315   uint8_t* p_data;
    316   uint16_t len;
    317   tBTA_AV_ERR err_code;
    318 } tBTA_AV_PROTECT_RSP;
    319 
    320 /* data associated with BTA_AV_RC_OPEN_EVT */
    321 typedef struct {
    322   uint8_t rc_handle;
    323   tBTA_AV_FEAT peer_features;
    324   BD_ADDR peer_addr;
    325   tBTA_AV_STATUS status;
    326 } tBTA_AV_RC_OPEN;
    327 
    328 /* data associated with BTA_AV_RC_CLOSE_EVT */
    329 typedef struct {
    330   uint8_t rc_handle;
    331   BD_ADDR peer_addr;
    332 } tBTA_AV_RC_CLOSE;
    333 
    334 /* data associated with BTA_AV_RC_BROWSE_OPEN_EVT */
    335 typedef struct {
    336   uint8_t rc_handle;
    337   BD_ADDR peer_addr;
    338   tBTA_AV_STATUS status;
    339 } tBTA_AV_RC_BROWSE_OPEN;
    340 
    341 /* data associated with BTA_AV_RC_BROWSE_CLOSE_EVT */
    342 typedef struct {
    343   uint8_t rc_handle;
    344   BD_ADDR peer_addr;
    345 } tBTA_AV_RC_BROWSE_CLOSE;
    346 
    347 /* data associated with BTA_AV_RC_FEAT_EVT */
    348 typedef struct {
    349   uint8_t rc_handle;
    350   tBTA_AV_FEAT peer_features;
    351   BD_ADDR peer_addr;
    352 } tBTA_AV_RC_FEAT;
    353 
    354 /* data associated with BTA_AV_REMOTE_CMD_EVT */
    355 typedef struct {
    356   uint8_t rc_handle;
    357   tBTA_AV_RC rc_id;
    358   tBTA_AV_STATE key_state;
    359   uint8_t len;
    360   uint8_t* p_data;
    361   tAVRC_HDR hdr; /* Message header. */
    362   uint8_t label;
    363 } tBTA_AV_REMOTE_CMD;
    364 
    365 /* data associated with BTA_AV_REMOTE_RSP_EVT */
    366 typedef struct {
    367   uint8_t rc_handle;
    368   tBTA_AV_RC rc_id;
    369   tBTA_AV_STATE key_state;
    370   uint8_t len;
    371   uint8_t* p_data;
    372   tBTA_AV_CODE rsp_code;
    373   uint8_t label;
    374 } tBTA_AV_REMOTE_RSP;
    375 
    376 /* data associated with BTA_AV_VENDOR_CMD_EVT, BTA_AV_VENDOR_RSP_EVT */
    377 typedef struct {
    378   uint8_t rc_handle;
    379   uint16_t len; /* Max vendor dependent message is 512 */
    380   uint8_t label;
    381   tBTA_AV_CODE code;
    382   uint32_t company_id;
    383   uint8_t* p_data;
    384 } tBTA_AV_VENDOR;
    385 
    386 /* data associated with BTA_AV_META_MSG_EVT */
    387 typedef struct {
    388   uint8_t rc_handle;
    389   uint16_t len;
    390   uint8_t label;
    391   tBTA_AV_CODE code;
    392   uint32_t company_id;
    393   uint8_t* p_data;
    394   tAVRC_MSG* p_msg;
    395 } tBTA_AV_META_MSG;
    396 
    397 /* data associated with BTA_AV_PENDING_EVT */
    398 typedef struct { BD_ADDR bd_addr; } tBTA_AV_PEND;
    399 
    400 /* data associated with BTA_AV_REJECT_EVT */
    401 typedef struct {
    402   BD_ADDR bd_addr;
    403   tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the
    404                         connection. */
    405 } tBTA_AV_REJECT;
    406 
    407 /* union of data associated with AV callback */
    408 typedef union {
    409   tBTA_AV_CHNL chnl;
    410   tBTA_AV_ENABLE enable;
    411   tBTA_AV_REGISTER registr;
    412   tBTA_AV_OPEN open;
    413   tBTA_AV_CLOSE close;
    414   tBTA_AV_START start;
    415   tBTA_AV_PROTECT_REQ protect_req;
    416   tBTA_AV_PROTECT_RSP protect_rsp;
    417   tBTA_AV_RC_OPEN rc_open;
    418   tBTA_AV_RC_CLOSE rc_close;
    419   tBTA_AV_RC_BROWSE_OPEN rc_browse_open;
    420   tBTA_AV_RC_BROWSE_CLOSE rc_browse_close;
    421   tBTA_AV_REMOTE_CMD remote_cmd;
    422   tBTA_AV_REMOTE_RSP remote_rsp;
    423   tBTA_AV_VENDOR vendor_cmd;
    424   tBTA_AV_VENDOR vendor_rsp;
    425   tBTA_AV_RECONFIG reconfig;
    426   tBTA_AV_SUSPEND suspend;
    427   tBTA_AV_PEND pend;
    428   tBTA_AV_META_MSG meta_msg;
    429   tBTA_AV_REJECT reject;
    430   tBTA_AV_RC_FEAT rc_feat;
    431   tBTA_AV_STATUS status;
    432 } tBTA_AV;
    433 
    434 typedef struct {
    435   uint8_t* codec_info;
    436   BD_ADDR bd_addr;
    437   ;
    438 } tBTA_AVK_CONFIG;
    439 
    440 /* union of data associated with AV Media callback */
    441 typedef union {
    442   BT_HDR* p_data;
    443   tBTA_AVK_CONFIG avk_config;
    444 } tBTA_AV_MEDIA;
    445 
    446 #define BTA_GROUP_NAVI_MSG_OP_DATA_LEN 5
    447 
    448 /* AV callback */
    449 typedef void(tBTA_AV_CBACK)(tBTA_AV_EVT event, tBTA_AV* p_data);
    450 typedef void(tBTA_AV_SINK_DATA_CBACK)(tBTA_AV_EVT event, tBTA_AV_MEDIA* p_data);
    451 
    452 /* type for stream state machine action functions */
    453 typedef void (*tBTA_AV_ACT)(void* p_cb, void* p_data);
    454 
    455 /* type for registering VDP */
    456 typedef void(tBTA_AV_REG)(tAVDT_CS* p_cs, char* p_service_name, void* p_data);
    457 
    458 /* AV configuration structure */
    459 typedef struct {
    460   uint32_t company_id;  /* AVRCP Company ID */
    461   uint16_t avrc_mtu;    /* AVRCP MTU at L2CAP for control channel */
    462   uint16_t avrc_br_mtu; /* AVRCP MTU at L2CAP for browsing channel */
    463   uint16_t avrc_ct_cat; /* AVRCP controller categories */
    464   uint16_t avrc_tg_cat; /* AVRCP target categories */
    465   uint16_t sig_mtu;     /* AVDTP signaling channel MTU at L2CAP */
    466   uint16_t audio_mtu;   /* AVDTP audio transport channel MTU at L2CAP */
    467   const uint16_t*
    468       p_audio_flush_to;    /* AVDTP audio transport channel flush timeout */
    469   uint16_t audio_mqs;      /* AVDTP audio channel max data queue size */
    470   uint16_t video_mtu;      /* AVDTP video transport channel MTU at L2CAP */
    471   uint16_t video_flush_to; /* AVDTP video transport channel flush timeout */
    472   bool avrc_group;     /* true, to accept AVRC 1.3 group nevigation command */
    473   uint8_t num_co_ids;  /* company id count in p_meta_co_ids */
    474   uint8_t num_evt_ids; /* event id count in p_meta_evt_ids */
    475   tBTA_AV_CODE
    476       rc_pass_rsp; /* the default response code for pass through commands */
    477   const uint32_t*
    478       p_meta_co_ids; /* the metadata Get Capabilities response for company id */
    479   const uint8_t* p_meta_evt_ids; /* the the metadata Get Capabilities response
    480                                     for event id */
    481   const tBTA_AV_ACT* p_act_tbl;  /* the action function table for VDP stream */
    482   tBTA_AV_REG* p_reg;            /* action function to register VDP */
    483   char avrc_controller_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP controller
    484                                                       name */
    485   char avrc_target_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP target name*/
    486 } tBTA_AV_CFG;
    487 
    488 /*****************************************************************************
    489  *  External Function Declarations
    490  ****************************************************************************/
    491 
    492 /*******************************************************************************
    493  *
    494  * Function         BTA_AvEnable
    495  *
    496  * Description      Enable the advanced audio/video service. When the enable
    497  *                  operation is complete the callback function will be
    498  *                  called with a BTA_AV_ENABLE_EVT. This function must
    499  *                  be called before other function in the AV API are
    500  *                  called.
    501  *
    502  * Returns          void
    503  *
    504  ******************************************************************************/
    505 void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features,
    506                   tBTA_AV_CBACK* p_cback);
    507 
    508 /*******************************************************************************
    509  *
    510  * Function         BTA_AvDisable
    511  *
    512  * Description      Disable the advanced audio/video service.
    513  *
    514  *
    515  * Returns          void
    516  *
    517  ******************************************************************************/
    518 void BTA_AvDisable(void);
    519 
    520 /*******************************************************************************
    521  *
    522  * Function         BTA_AvRegister
    523  *
    524  * Description      Register the audio or video service to stack. When the
    525  *                  operation is complete the callback function will be
    526  *                  called with a BTA_AV_REGISTER_EVT. This function must
    527  *                  be called before AVDT stream is open.
    528  *
    529  *
    530  * Returns          void
    531  *
    532  ******************************************************************************/
    533 void BTA_AvRegister(tBTA_AV_CHNL chnl, const char* p_service_name,
    534                     uint8_t app_id, tBTA_AV_SINK_DATA_CBACK* p_sink_data_cback,
    535                     uint16_t service_uuid);
    536 
    537 /*******************************************************************************
    538  *
    539  * Function         BTA_AvDeregister
    540  *
    541  * Description      Deregister the audio or video service
    542  *
    543  * Returns          void
    544  *
    545  ******************************************************************************/
    546 void BTA_AvDeregister(tBTA_AV_HNDL hndl);
    547 
    548 /*******************************************************************************
    549  *
    550  * Function         BTA_AvOpen
    551  *
    552  * Description      Opens an advanced audio/video connection to a peer device.
    553  *                  When connection is open callback function is called
    554  *                  with a BTA_AV_OPEN_EVT.
    555  *
    556  * Returns          void
    557  *
    558  ******************************************************************************/
    559 void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, bool use_rc,
    560                 tBTA_SEC sec_mask, uint16_t uuid);
    561 
    562 /*******************************************************************************
    563  *
    564  * Function         BTA_AvClose
    565  *
    566  * Description      Close the current streams.
    567  *
    568  * Returns          void
    569  *
    570  ******************************************************************************/
    571 void BTA_AvClose(tBTA_AV_HNDL handle);
    572 
    573 /*******************************************************************************
    574  *
    575  * Function         BTA_AvDisconnect
    576  *
    577  * Description      Close the connection to the address.
    578  *
    579  * Returns          void
    580  *
    581  ******************************************************************************/
    582 void BTA_AvDisconnect(BD_ADDR bd_addr);
    583 
    584 /*******************************************************************************
    585  *
    586  * Function         BTA_AvStart
    587  *
    588  * Description      Start audio/video stream data transfer.
    589  *
    590  * Returns          void
    591  *
    592  ******************************************************************************/
    593 void BTA_AvStart(void);
    594 
    595 /*******************************************************************************
    596  *
    597  * Function         BTA_AvStop
    598  *
    599  * Description      Stop audio/video stream data transfer.
    600  *                  If suspend is true, this function sends AVDT suspend signal
    601  *                  to the connected peer(s).
    602  *
    603  * Returns          void
    604  *
    605  ******************************************************************************/
    606 void BTA_AvStop(bool suspend);
    607 
    608 /*******************************************************************************
    609  *
    610  * Function         BTA_AvReconfig
    611  *
    612  * Description      Reconfigure the audio/video stream.
    613  *                  If suspend is true, this function tries the
    614  *                  suspend/reconfigure procedure first.
    615  *                  If suspend is false or when suspend/reconfigure fails,
    616  *                  this function closes and re-opens the AVDT connection.
    617  *
    618  * Returns          void
    619  *
    620  ******************************************************************************/
    621 void BTA_AvReconfig(tBTA_AV_HNDL hndl, bool suspend, uint8_t sep_info_idx,
    622                     uint8_t* p_codec_info, uint8_t num_protect,
    623                     const uint8_t* p_protect_info);
    624 
    625 /*******************************************************************************
    626  *
    627  * Function         BTA_AvProtectReq
    628  *
    629  * Description      Send a content protection request.  This function can only
    630  *                  be used if AV is enabled with feature BTA_AV_FEAT_PROTECT.
    631  *
    632  * Returns          void
    633  *
    634  ******************************************************************************/
    635 void BTA_AvProtectReq(tBTA_AV_HNDL hndl, uint8_t* p_data, uint16_t len);
    636 
    637 /*******************************************************************************
    638  *
    639  * Function         BTA_AvProtectRsp
    640  *
    641  * Description      Send a content protection response.  This function must
    642  *                  be called if a BTA_AV_PROTECT_REQ_EVT is received.
    643  *                  This function can only be used if AV is enabled with
    644  *                  feature BTA_AV_FEAT_PROTECT.
    645  *
    646  * Returns          void
    647  *
    648  ******************************************************************************/
    649 void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, uint8_t error_code, uint8_t* p_data,
    650                       uint16_t len);
    651 
    652 /*******************************************************************************
    653  *
    654  * Function         BTA_AvRemoteCmd
    655  *
    656  * Description      Send a remote control command.  This function can only
    657  *                  be used if AV is enabled with feature BTA_AV_FEAT_RCCT.
    658  *
    659  * Returns          void
    660  *
    661  ******************************************************************************/
    662 void BTA_AvRemoteCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_RC rc_id,
    663                      tBTA_AV_STATE key_state);
    664 
    665 /*******************************************************************************
    666  *
    667  * Function         BTA_AvRemoteVendorUniqueCmd
    668  *
    669  * Description      Send a remote control command with Vendor Unique rc_id.
    670  *                  This function can only be used if AV is enabled with
    671  *                  feature BTA_AV_FEAT_RCCT.
    672  *
    673  * Returns          void
    674  *
    675  ******************************************************************************/
    676 void BTA_AvRemoteVendorUniqueCmd(uint8_t rc_handle, uint8_t label,
    677                                  tBTA_AV_STATE key_state, uint8_t* p_msg,
    678                                  uint8_t buf_len);
    679 
    680 /*******************************************************************************
    681  *
    682  * Function         BTA_AvVendorCmd
    683  *
    684  * Description      Send a vendor dependent remote control command.  This
    685  *                  function can only be used if AV is enabled with feature
    686  *                  BTA_AV_FEAT_VENDOR.
    687  *
    688  * Returns          void
    689  *
    690  ******************************************************************************/
    691 void BTA_AvVendorCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE cmd_code,
    692                      uint8_t* p_data, uint16_t len);
    693 
    694 /*******************************************************************************
    695  *
    696  * Function         BTA_AvVendorRsp
    697  *
    698  * Description      Send a vendor dependent remote control response.
    699  *                  This function must be called if a BTA_AV_VENDOR_CMD_EVT
    700  *                  is received. This function can only be used if AV is
    701  *                  enabled with feature BTA_AV_FEAT_VENDOR.
    702  *
    703  * Returns          void
    704  *
    705  ******************************************************************************/
    706 void BTA_AvVendorRsp(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE rsp_code,
    707                      uint8_t* p_data, uint16_t len, uint32_t company_id);
    708 
    709 /*******************************************************************************
    710  *
    711  * Function         BTA_AvOpenRc
    712  *
    713  * Description      Open an AVRCP connection toward the device with the
    714  *                  specified handle
    715  *
    716  * Returns          void
    717  *
    718  ******************************************************************************/
    719 void BTA_AvOpenRc(tBTA_AV_HNDL handle);
    720 
    721 /*******************************************************************************
    722  *
    723  * Function         BTA_AvCloseRc
    724  *
    725  * Description      Close an AVRCP connection
    726  *
    727  * Returns          void
    728  *
    729  ******************************************************************************/
    730 void BTA_AvCloseRc(uint8_t rc_handle);
    731 
    732 /*******************************************************************************
    733  *
    734  * Function         BTA_AvMetaRsp
    735  *
    736  * Description      Send a Metadata command/response. The message contained
    737  *                  in p_pkt can be composed with AVRC utility functions.
    738  *                  This function can only be used if AV is enabled with feature
    739  *                  BTA_AV_FEAT_METADATA.
    740  *
    741  * Returns          void
    742  *
    743  ******************************************************************************/
    744 void BTA_AvMetaRsp(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE rsp_code,
    745                    BT_HDR* p_pkt);
    746 
    747 /*******************************************************************************
    748  *
    749  * Function         BTA_AvMetaCmd
    750  *
    751  * Description      Send a Metadata/Advanced Control command. The message
    752 *contained
    753  *                  in p_pkt can be composed with AVRC utility functions.
    754  *                  This function can only be used if AV is enabled with feature
    755  *                  BTA_AV_FEAT_METADATA.
    756  *                  This message is sent only when the peer supports the TG
    757 *role.
    758 *8                  The only command makes sense right now is the absolute
    759 *volume command.
    760  *
    761  * Returns          void
    762  *
    763  ******************************************************************************/
    764 void BTA_AvMetaCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_CMD cmd_code,
    765                    BT_HDR* p_pkt);
    766 
    767 /*******************************************************************************
    768  *
    769  * Function         BTA_AvOffloadStart
    770  *
    771  * Description      Request Starting of A2DP Offload.
    772  *                  This function is used to start A2DP offload if vendor lib
    773  *                  has the feature enabled.
    774  *
    775  * Returns          void
    776  *
    777  ******************************************************************************/
    778 void BTA_AvOffloadStart(tBTA_AV_HNDL hndl);
    779 
    780 /*******************************************************************************
    781  *
    782  * Function         BTA_AvOffloadStartRsp
    783  *
    784  * Description      Response from vendor library indicating response for
    785  *                  OffloadStart.
    786  *
    787  * Returns          void
    788  *
    789  ******************************************************************************/
    790 void BTA_AvOffloadStartRsp(tBTA_AV_HNDL hndl, tBTA_AV_STATUS status);
    791 
    792 #endif /* BTA_AV_API_H */
    793