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   RawAddress 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   RawAddress 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   RawAddress 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   RawAddress 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   RawAddress 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   RawAddress 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 { RawAddress bd_addr; } tBTA_AV_PEND;
    399 
    400 /* data associated with BTA_AV_REJECT_EVT */
    401 typedef struct {
    402   RawAddress 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   RawAddress bd_addr;
    437 } tBTA_AVK_CONFIG;
    438 
    439 /* union of data associated with AV Media callback */
    440 typedef union {
    441   BT_HDR* p_data;
    442   tBTA_AVK_CONFIG avk_config;
    443 } tBTA_AV_MEDIA;
    444 
    445 #define BTA_GROUP_NAVI_MSG_OP_DATA_LEN 5
    446 
    447 /* AV callback */
    448 typedef void(tBTA_AV_CBACK)(tBTA_AV_EVT event, tBTA_AV* p_data);
    449 typedef void(tBTA_AV_SINK_DATA_CBACK)(tBTA_AV_EVT event, tBTA_AV_MEDIA* p_data);
    450 
    451 /* type for stream state machine action functions */
    452 typedef void (*tBTA_AV_ACT)(void* p_cb, void* p_data);
    453 
    454 /* type for registering VDP */
    455 typedef void(tBTA_AV_REG)(tAVDT_CS* p_cs, char* p_service_name, void* p_data);
    456 
    457 /* AV configuration structure */
    458 typedef struct {
    459   uint32_t company_id;  /* AVRCP Company ID */
    460   uint16_t avrc_mtu;    /* AVRCP MTU at L2CAP for control channel */
    461   uint16_t avrc_br_mtu; /* AVRCP MTU at L2CAP for browsing channel */
    462   uint16_t avrc_ct_cat; /* AVRCP controller categories */
    463   uint16_t avrc_tg_cat; /* AVRCP target categories */
    464   uint16_t sig_mtu;     /* AVDTP signaling channel MTU at L2CAP */
    465   uint16_t audio_mtu;   /* AVDTP audio transport channel MTU at L2CAP */
    466   const uint16_t*
    467       p_audio_flush_to;    /* AVDTP audio transport channel flush timeout */
    468   uint16_t audio_mqs;      /* AVDTP audio channel max data queue size */
    469   uint16_t video_mtu;      /* AVDTP video transport channel MTU at L2CAP */
    470   uint16_t video_flush_to; /* AVDTP video transport channel flush timeout */
    471   bool avrc_group;     /* true, to accept AVRC 1.3 group nevigation command */
    472   uint8_t num_co_ids;  /* company id count in p_meta_co_ids */
    473   uint8_t num_evt_ids; /* event id count in p_meta_evt_ids */
    474   tBTA_AV_CODE
    475       rc_pass_rsp; /* the default response code for pass through commands */
    476   const uint32_t*
    477       p_meta_co_ids; /* the metadata Get Capabilities response for company id */
    478   const uint8_t* p_meta_evt_ids; /* the the metadata Get Capabilities response
    479                                     for event id */
    480   const tBTA_AV_ACT* p_act_tbl;  /* the action function table for VDP stream */
    481   tBTA_AV_REG* p_reg;            /* action function to register VDP */
    482   char avrc_controller_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP controller
    483                                                       name */
    484   char avrc_target_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP target name*/
    485 } tBTA_AV_CFG;
    486 
    487 /*****************************************************************************
    488  *  External Function Declarations
    489  ****************************************************************************/
    490 
    491 /*******************************************************************************
    492  *
    493  * Function         BTA_AvEnable
    494  *
    495  * Description      Enable the advanced audio/video service. When the enable
    496  *                  operation is complete the callback function will be
    497  *                  called with a BTA_AV_ENABLE_EVT. This function must
    498  *                  be called before other function in the AV API are
    499  *                  called.
    500  *
    501  * Returns          void
    502  *
    503  ******************************************************************************/
    504 void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features,
    505                   tBTA_AV_CBACK* p_cback);
    506 
    507 /*******************************************************************************
    508  *
    509  * Function         BTA_AvDisable
    510  *
    511  * Description      Disable the advanced audio/video service.
    512  *
    513  *
    514  * Returns          void
    515  *
    516  ******************************************************************************/
    517 void BTA_AvDisable(void);
    518 
    519 /*******************************************************************************
    520  *
    521  * Function         BTA_AvRegister
    522  *
    523  * Description      Register the audio or video service to stack. When the
    524  *                  operation is complete the callback function will be
    525  *                  called with a BTA_AV_REGISTER_EVT. This function must
    526  *                  be called before AVDT stream is open.
    527  *
    528  *
    529  * Returns          void
    530  *
    531  ******************************************************************************/
    532 void BTA_AvRegister(tBTA_AV_CHNL chnl, const char* p_service_name,
    533                     uint8_t app_id, tBTA_AV_SINK_DATA_CBACK* p_sink_data_cback,
    534                     uint16_t service_uuid);
    535 
    536 /*******************************************************************************
    537  *
    538  * Function         BTA_AvDeregister
    539  *
    540  * Description      Deregister the audio or video service
    541  *
    542  * Returns          void
    543  *
    544  ******************************************************************************/
    545 void BTA_AvDeregister(tBTA_AV_HNDL hndl);
    546 
    547 /*******************************************************************************
    548  *
    549  * Function         BTA_AvOpen
    550  *
    551  * Description      Opens an advanced audio/video connection to a peer device.
    552  *                  When connection is open callback function is called
    553  *                  with a BTA_AV_OPEN_EVT.
    554  *
    555  * Returns          void
    556  *
    557  ******************************************************************************/
    558 void BTA_AvOpen(const RawAddress& bd_addr, tBTA_AV_HNDL handle, bool use_rc,
    559                 tBTA_SEC sec_mask, uint16_t uuid);
    560 
    561 /*******************************************************************************
    562  *
    563  * Function         BTA_AvClose
    564  *
    565  * Description      Close the current streams.
    566  *
    567  * Returns          void
    568  *
    569  ******************************************************************************/
    570 void BTA_AvClose(tBTA_AV_HNDL handle);
    571 
    572 /*******************************************************************************
    573  *
    574  * Function         BTA_AvDisconnect
    575  *
    576  * Description      Close the connection to the address.
    577  *
    578  * Returns          void
    579  *
    580  ******************************************************************************/
    581 void BTA_AvDisconnect(const RawAddress& bd_addr);
    582 
    583 /*******************************************************************************
    584  *
    585  * Function         BTA_AvStart
    586  *
    587  * Description      Start audio/video stream data transfer.
    588  *
    589  * Returns          void
    590  *
    591  ******************************************************************************/
    592 void BTA_AvStart(void);
    593 
    594 /*******************************************************************************
    595  *
    596  * Function         BTA_AvStop
    597  *
    598  * Description      Stop audio/video stream data transfer.
    599  *                  If suspend is true, this function sends AVDT suspend signal
    600  *                  to the connected peer(s).
    601  *
    602  * Returns          void
    603  *
    604  ******************************************************************************/
    605 void BTA_AvStop(bool suspend);
    606 
    607 /*******************************************************************************
    608  *
    609  * Function         BTA_AvReconfig
    610  *
    611  * Description      Reconfigure the audio/video stream.
    612  *                  If suspend is true, this function tries the
    613  *                  suspend/reconfigure procedure first.
    614  *                  If suspend is false or when suspend/reconfigure fails,
    615  *                  this function closes and re-opens the AVDT connection.
    616  *
    617  * Returns          void
    618  *
    619  ******************************************************************************/
    620 void BTA_AvReconfig(tBTA_AV_HNDL hndl, bool suspend, uint8_t sep_info_idx,
    621                     uint8_t* p_codec_info, uint8_t num_protect,
    622                     const uint8_t* p_protect_info);
    623 
    624 /*******************************************************************************
    625  *
    626  * Function         BTA_AvProtectReq
    627  *
    628  * Description      Send a content protection request.  This function can only
    629  *                  be used if AV is enabled with feature BTA_AV_FEAT_PROTECT.
    630  *
    631  * Returns          void
    632  *
    633  ******************************************************************************/
    634 void BTA_AvProtectReq(tBTA_AV_HNDL hndl, uint8_t* p_data, uint16_t len);
    635 
    636 /*******************************************************************************
    637  *
    638  * Function         BTA_AvProtectRsp
    639  *
    640  * Description      Send a content protection response.  This function must
    641  *                  be called if a BTA_AV_PROTECT_REQ_EVT is received.
    642  *                  This function can only be used if AV is enabled with
    643  *                  feature BTA_AV_FEAT_PROTECT.
    644  *
    645  * Returns          void
    646  *
    647  ******************************************************************************/
    648 void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, uint8_t error_code, uint8_t* p_data,
    649                       uint16_t len);
    650 
    651 /*******************************************************************************
    652  *
    653  * Function         BTA_AvRemoteCmd
    654  *
    655  * Description      Send a remote control command.  This function can only
    656  *                  be used if AV is enabled with feature BTA_AV_FEAT_RCCT.
    657  *
    658  * Returns          void
    659  *
    660  ******************************************************************************/
    661 void BTA_AvRemoteCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_RC rc_id,
    662                      tBTA_AV_STATE key_state);
    663 
    664 /*******************************************************************************
    665  *
    666  * Function         BTA_AvRemoteVendorUniqueCmd
    667  *
    668  * Description      Send a remote control command with Vendor Unique rc_id.
    669  *                  This function can only be used if AV is enabled with
    670  *                  feature BTA_AV_FEAT_RCCT.
    671  *
    672  * Returns          void
    673  *
    674  ******************************************************************************/
    675 void BTA_AvRemoteVendorUniqueCmd(uint8_t rc_handle, uint8_t label,
    676                                  tBTA_AV_STATE key_state, uint8_t* p_msg,
    677                                  uint8_t buf_len);
    678 
    679 /*******************************************************************************
    680  *
    681  * Function         BTA_AvVendorCmd
    682  *
    683  * Description      Send a vendor dependent remote control command.  This
    684  *                  function can only be used if AV is enabled with feature
    685  *                  BTA_AV_FEAT_VENDOR.
    686  *
    687  * Returns          void
    688  *
    689  ******************************************************************************/
    690 void BTA_AvVendorCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE cmd_code,
    691                      uint8_t* p_data, uint16_t len);
    692 
    693 /*******************************************************************************
    694  *
    695  * Function         BTA_AvVendorRsp
    696  *
    697  * Description      Send a vendor dependent remote control response.
    698  *                  This function must be called if a BTA_AV_VENDOR_CMD_EVT
    699  *                  is received. This function can only be used if AV is
    700  *                  enabled with feature BTA_AV_FEAT_VENDOR.
    701  *
    702  * Returns          void
    703  *
    704  ******************************************************************************/
    705 void BTA_AvVendorRsp(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE rsp_code,
    706                      uint8_t* p_data, uint16_t len, uint32_t company_id);
    707 
    708 /*******************************************************************************
    709  *
    710  * Function         BTA_AvOpenRc
    711  *
    712  * Description      Open an AVRCP connection toward the device with the
    713  *                  specified handle
    714  *
    715  * Returns          void
    716  *
    717  ******************************************************************************/
    718 void BTA_AvOpenRc(tBTA_AV_HNDL handle);
    719 
    720 /*******************************************************************************
    721  *
    722  * Function         BTA_AvCloseRc
    723  *
    724  * Description      Close an AVRCP connection
    725  *
    726  * Returns          void
    727  *
    728  ******************************************************************************/
    729 void BTA_AvCloseRc(uint8_t rc_handle);
    730 
    731 /*******************************************************************************
    732  *
    733  * Function         BTA_AvMetaRsp
    734  *
    735  * Description      Send a Metadata command/response. The message contained
    736  *                  in p_pkt can be composed with AVRC utility functions.
    737  *                  This function can only be used if AV is enabled with feature
    738  *                  BTA_AV_FEAT_METADATA.
    739  *
    740  * Returns          void
    741  *
    742  ******************************************************************************/
    743 void BTA_AvMetaRsp(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE rsp_code,
    744                    BT_HDR* p_pkt);
    745 
    746 /*******************************************************************************
    747  *
    748  * Function         BTA_AvMetaCmd
    749  *
    750  * Description      Send a Metadata/Advanced Control command. The message
    751 *contained
    752  *                  in p_pkt can be composed with AVRC utility functions.
    753  *                  This function can only be used if AV is enabled with feature
    754  *                  BTA_AV_FEAT_METADATA.
    755  *                  This message is sent only when the peer supports the TG
    756 *role.
    757 *8                  The only command makes sense right now is the absolute
    758 *volume command.
    759  *
    760  * Returns          void
    761  *
    762  ******************************************************************************/
    763 void BTA_AvMetaCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_CMD cmd_code,
    764                    BT_HDR* p_pkt);
    765 
    766 /*******************************************************************************
    767  *
    768  * Function         BTA_AvOffloadStart
    769  *
    770  * Description      Request Starting of A2DP Offload.
    771  *                  This function is used to start A2DP offload if vendor lib
    772  *                  has the feature enabled.
    773  *
    774  * Returns          void
    775  *
    776  ******************************************************************************/
    777 void BTA_AvOffloadStart(tBTA_AV_HNDL hndl);
    778 
    779 /*******************************************************************************
    780  *
    781  * Function         BTA_AvOffloadStartRsp
    782  *
    783  * Description      Response from vendor library indicating response for
    784  *                  OffloadStart.
    785  *
    786  * Returns          void
    787  *
    788  ******************************************************************************/
    789 void BTA_AvOffloadStartRsp(tBTA_AV_HNDL hndl, tBTA_AV_STATUS status);
    790 
    791 #endif /* BTA_AV_API_H */
    792