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 "stack/avrc_api.h" 30 #include "stack/avdt_api.h" 31 #include "stack/a2d_api.h" 32 #include "bta/bta_api.h" 33 34 #if (BTA_AV_INCLUDED == TRUE) 35 36 /***************************************************************************** 37 ** Constants and data types 38 *****************************************************************************/ 39 /* AV status values */ 40 #define BTA_AV_SUCCESS 0 /* successful operation */ 41 #define BTA_AV_FAIL 1 /* generic failure */ 42 #define BTA_AV_FAIL_SDP 2 /* service not found */ 43 #define BTA_AV_FAIL_STREAM 3 /* stream connection failed */ 44 #define BTA_AV_FAIL_RESOURCES 4 /* no resources */ 45 #define BTA_AV_FAIL_ROLE 5 /* failed due to role management related issues */ 46 #define BTA_AV_FAIL_GET_CAP 6 /* get capability failed due to no SEP availale on the peer */ 47 48 typedef UINT8 tBTA_AV_STATUS; 49 50 /* AV features masks */ 51 #define BTA_AV_FEAT_RCTG 0x0001 /* remote control target */ 52 #define BTA_AV_FEAT_RCCT 0x0002 /* remote control controller */ 53 #define BTA_AV_FEAT_PROTECT 0x0004 /* streaming media contect protection */ 54 #define BTA_AV_FEAT_VENDOR 0x0008 /* remote control vendor dependent commands */ 55 #define BTA_AV_FEAT_REPORT 0x0020 /* use reporting service for VDP */ 56 #define BTA_AV_FEAT_METADATA 0x0040 /* remote control Metadata Transfer command/response */ 57 #define BTA_AV_FEAT_MULTI_AV 0x0080 /* use multi-av, if controller supports it */ 58 #define BTA_AV_FEAT_BROWSE 0x0010 /* use browsing channel */ 59 #define BTA_AV_FEAT_MASTER 0x0100 /* stream only as master role */ 60 #define BTA_AV_FEAT_ADV_CTRL 0x0200 /* remote control Advanced Control command/response */ 61 #define BTA_AV_FEAT_DELAY_RPT 0x0400 /* allow delay reporting */ 62 #define BTA_AV_FEAT_ACP_START 0x0800 /* start stream when 2nd SNK was accepted */ 63 64 /* Internal features */ 65 #define BTA_AV_FEAT_NO_SCO_SSPD 0x8000 /* Do not suspend av streaming as to AG events(SCO or Call) */ 66 67 /* Protocol service capabilities mask*/ 68 #define BTA_AV_PSC_DEALY_RPT (1<<0) /* Delay Report */ 69 70 typedef UINT16 tBTA_AV_FEAT; 71 72 /* AV channel values */ 73 #define BTA_AV_CHNL_MSK 0xC0 74 #define BTA_AV_CHNL_AUDIO 0x40 /* audio channel */ 75 #define BTA_AV_CHNL_VIDEO 0x80 /* video channel */ 76 typedef UINT8 tBTA_AV_CHNL; 77 78 79 #define BTA_AV_HNDL_MSK 0x3F 80 typedef UINT8 tBTA_AV_HNDL; 81 /* handle index to mask */ 82 #define BTA_AV_HNDL_TO_MSK(h) ((UINT8)(1 << (h))) 83 84 /* tBTA_AV_HNDL to mask */ 85 #define BTA_AV_HNDL_TYPE_TO_MSK(h) ((UINT8)(1 << (h&BTA_AV_HNDL_MSK))) 86 87 /* offset of codec type in codec info byte array */ 88 #define BTA_AV_CODEC_TYPE_IDX AVDT_CODEC_TYPE_INDEX /* 2 */ 89 90 91 92 /* maximum number of streams created: 1 for audio, 1 for video */ 93 #ifndef BTA_AV_NUM_STRS 94 #define BTA_AV_NUM_STRS 2 95 #endif 96 97 #ifndef BTA_AV_MAX_SEPS 98 #define BTA_AV_MAX_SEPS 1 99 #endif 100 101 #ifndef BTA_AV_MAX_A2DP_MTU 102 /*#define BTA_AV_MAX_A2DP_MTU 668 //224 (DM5) * 3 - 4(L2CAP header) */ 103 #define BTA_AV_MAX_A2DP_MTU 1008 104 #endif 105 106 #ifndef BTA_AV_MAX_VDP_MTU 107 #define BTA_AV_MAX_VDP_MTU 1008 108 #endif 109 110 111 /* codec type */ 112 #define BTA_AV_CODEC_SBC A2D_MEDIA_CT_SBC /* SBC media codec type */ 113 #define BTA_AV_CODEC_M12 A2D_MEDIA_CT_M12 /* MPEG-1, 2 Audio media codec type */ 114 #define BTA_AV_CODEC_M24 A2D_MEDIA_CT_M24 /* MPEG-2, 4 AAC media codec type */ 115 #define BTA_AV_CODEC_ATRAC A2D_MEDIA_CT_ATRAC /* ATRAC family media codec type */ 116 #define BTA_AV_CODEC_H263_P0 VDP_MEDIA_CT_H263_P0 /* H.263 baseline (profile 0) */ 117 #define BTA_AV_CODEC_MPEG4 VDP_MEDIA_CT_MPEG4 /* MPEG-4 Visual Simple Profile */ 118 #define BTA_AV_CODEC_H263_P3 VDP_MEDIA_CT_H263_P3 /* H.263 profile 3 */ 119 #define BTA_AV_CODEC_H263_P8 VDP_MEDIA_CT_H263_P8 /* H.263 profile 8 */ 120 #define BTA_AV_CODEC_VEND VDP_MEDIA_CT_VEND /* Non-VDP */ 121 122 typedef UINT8 tBTA_AV_CODEC; 123 124 /* Company ID in BT assigned numbers */ 125 #define BTA_AV_BT_VENDOR_ID VDP_BT_VENDOR_ID /* Broadcom Corporation */ 126 127 /* vendor specific codec ID */ 128 #define BTA_AV_CODEC_ID_H264 VDP_CODEC_ID_H264 /* Non-VDP codec ID - H.264 */ 129 #define BTA_AV_CODEC_ID_IMG VDP_CODEC_ID_IMG /* Non-VDP codec ID - images/slideshow */ 130 131 /* operation id list for BTA_AvRemoteCmd */ 132 #define BTA_AV_RC_SELECT AVRC_ID_SELECT /* select */ 133 #define BTA_AV_RC_UP AVRC_ID_UP /* up */ 134 #define BTA_AV_RC_DOWN AVRC_ID_DOWN /* down */ 135 #define BTA_AV_RC_LEFT AVRC_ID_LEFT /* left */ 136 #define BTA_AV_RC_RIGHT AVRC_ID_RIGHT /* right */ 137 #define BTA_AV_RC_RIGHT_UP AVRC_ID_RIGHT_UP /* right-up */ 138 #define BTA_AV_RC_RIGHT_DOWN AVRC_ID_RIGHT_DOWN /* right-down */ 139 #define BTA_AV_RC_LEFT_UP AVRC_ID_LEFT_UP /* left-up */ 140 #define BTA_AV_RC_LEFT_DOWN AVRC_ID_LEFT_DOWN /* left-down */ 141 #define BTA_AV_RC_ROOT_MENU AVRC_ID_ROOT_MENU /* root menu */ 142 #define BTA_AV_RC_SETUP_MENU AVRC_ID_SETUP_MENU /* setup menu */ 143 #define BTA_AV_RC_CONT_MENU AVRC_ID_CONT_MENU /* contents menu */ 144 #define BTA_AV_RC_FAV_MENU AVRC_ID_FAV_MENU /* favorite menu */ 145 #define BTA_AV_RC_EXIT AVRC_ID_EXIT /* exit */ 146 #define BTA_AV_RC_0 AVRC_ID_0 /* 0 */ 147 #define BTA_AV_RC_1 AVRC_ID_1 /* 1 */ 148 #define BTA_AV_RC_2 AVRC_ID_2 /* 2 */ 149 #define BTA_AV_RC_3 AVRC_ID_3 /* 3 */ 150 #define BTA_AV_RC_4 AVRC_ID_4 /* 4 */ 151 #define BTA_AV_RC_5 AVRC_ID_5 /* 5 */ 152 #define BTA_AV_RC_6 AVRC_ID_6 /* 6 */ 153 #define BTA_AV_RC_7 AVRC_ID_7 /* 7 */ 154 #define BTA_AV_RC_8 AVRC_ID_8 /* 8 */ 155 #define BTA_AV_RC_9 AVRC_ID_9 /* 9 */ 156 #define BTA_AV_RC_DOT AVRC_ID_DOT /* dot */ 157 #define BTA_AV_RC_ENTER AVRC_ID_ENTER /* enter */ 158 #define BTA_AV_RC_CLEAR AVRC_ID_CLEAR /* clear */ 159 #define BTA_AV_RC_CHAN_UP AVRC_ID_CHAN_UP /* channel up */ 160 #define BTA_AV_RC_CHAN_DOWN AVRC_ID_CHAN_DOWN /* channel down */ 161 #define BTA_AV_RC_PREV_CHAN AVRC_ID_PREV_CHAN /* previous channel */ 162 #define BTA_AV_RC_SOUND_SEL AVRC_ID_SOUND_SEL /* sound select */ 163 #define BTA_AV_RC_INPUT_SEL AVRC_ID_INPUT_SEL /* input select */ 164 #define BTA_AV_RC_DISP_INFO AVRC_ID_DISP_INFO /* display information */ 165 #define BTA_AV_RC_HELP AVRC_ID_HELP /* help */ 166 #define BTA_AV_RC_PAGE_UP AVRC_ID_PAGE_UP /* page up */ 167 #define BTA_AV_RC_PAGE_DOWN AVRC_ID_PAGE_DOWN /* page down */ 168 #define BTA_AV_RC_POWER AVRC_ID_POWER /* power */ 169 #define BTA_AV_RC_VOL_UP AVRC_ID_VOL_UP /* volume up */ 170 #define BTA_AV_RC_VOL_DOWN AVRC_ID_VOL_DOWN /* volume down */ 171 #define BTA_AV_RC_MUTE AVRC_ID_MUTE /* mute */ 172 #define BTA_AV_RC_PLAY AVRC_ID_PLAY /* play */ 173 #define BTA_AV_RC_STOP AVRC_ID_STOP /* stop */ 174 #define BTA_AV_RC_PAUSE AVRC_ID_PAUSE /* pause */ 175 #define BTA_AV_RC_RECORD AVRC_ID_RECORD /* record */ 176 #define BTA_AV_RC_REWIND AVRC_ID_REWIND /* rewind */ 177 #define BTA_AV_RC_FAST_FOR AVRC_ID_FAST_FOR /* fast forward */ 178 #define BTA_AV_RC_EJECT AVRC_ID_EJECT /* eject */ 179 #define BTA_AV_RC_FORWARD AVRC_ID_FORWARD /* forward */ 180 #define BTA_AV_RC_BACKWARD AVRC_ID_BACKWARD /* backward */ 181 #define BTA_AV_RC_ANGLE AVRC_ID_ANGLE /* angle */ 182 #define BTA_AV_RC_SUBPICT AVRC_ID_SUBPICT /* subpicture */ 183 #define BTA_AV_RC_F1 AVRC_ID_F1 /* F1 */ 184 #define BTA_AV_RC_F2 AVRC_ID_F2 /* F2 */ 185 #define BTA_AV_RC_F3 AVRC_ID_F3 /* F3 */ 186 #define BTA_AV_RC_F4 AVRC_ID_F4 /* F4 */ 187 #define BTA_AV_RC_F5 AVRC_ID_F5 /* F5 */ 188 #define BTA_AV_VENDOR AVRC_ID_VENDOR /* vendor unique */ 189 190 typedef UINT8 tBTA_AV_RC; 191 192 /* state flag for pass through command */ 193 #define BTA_AV_STATE_PRESS AVRC_STATE_PRESS /* key pressed */ 194 #define BTA_AV_STATE_RELEASE AVRC_STATE_RELEASE /* key released */ 195 196 typedef UINT8 tBTA_AV_STATE; 197 198 /* command codes for BTA_AvVendorCmd */ 199 #define BTA_AV_CMD_CTRL AVRC_CMD_CTRL 200 #define BTA_AV_CMD_STATUS AVRC_CMD_STATUS 201 #define BTA_AV_CMD_SPEC_INQ AVRC_CMD_SPEC_INQ 202 #define BTA_AV_CMD_NOTIF AVRC_CMD_NOTIF 203 #define BTA_AV_CMD_GEN_INQ AVRC_CMD_GEN_INQ 204 205 typedef UINT8 tBTA_AV_CMD; 206 207 /* response codes for BTA_AvVendorRsp */ 208 #define BTA_AV_RSP_NOT_IMPL AVRC_RSP_NOT_IMPL 209 #define BTA_AV_RSP_ACCEPT AVRC_RSP_ACCEPT 210 #define BTA_AV_RSP_REJ AVRC_RSP_REJ 211 #define BTA_AV_RSP_IN_TRANS AVRC_RSP_IN_TRANS 212 #define BTA_AV_RSP_IMPL_STBL AVRC_RSP_IMPL_STBL 213 #define BTA_AV_RSP_CHANGED AVRC_RSP_CHANGED 214 #define BTA_AV_RSP_INTERIM AVRC_RSP_INTERIM 215 216 typedef UINT8 tBTA_AV_CODE; 217 218 /* error codes for BTA_AvProtectRsp */ 219 #define BTA_AV_ERR_NONE A2D_SUCCESS /* Success, no error */ 220 #define BTA_AV_ERR_BAD_STATE AVDT_ERR_BAD_STATE /* Message cannot be processed in this state */ 221 #define BTA_AV_ERR_RESOURCE AVDT_ERR_RESOURCE /* Insufficient resources */ 222 #define BTA_AV_ERR_BAD_CP_TYPE A2D_BAD_CP_TYPE /* The requested Content Protection Type is not supported */ 223 #define BTA_AV_ERR_BAD_CP_FORMAT A2D_BAD_CP_FORMAT /* The format of Content Protection Data is not correct */ 224 225 typedef UINT8 tBTA_AV_ERR; 226 227 228 /* AV callback events */ 229 #define BTA_AV_ENABLE_EVT 0 /* AV enabled */ 230 #define BTA_AV_REGISTER_EVT 1 /* registered to AVDT */ 231 #define BTA_AV_OPEN_EVT 2 /* connection opened */ 232 #define BTA_AV_CLOSE_EVT 3 /* connection closed */ 233 #define BTA_AV_START_EVT 4 /* stream data transfer started */ 234 #define BTA_AV_STOP_EVT 5 /* stream data transfer stopped */ 235 #define BTA_AV_PROTECT_REQ_EVT 6 /* content protection request */ 236 #define BTA_AV_PROTECT_RSP_EVT 7 /* content protection response */ 237 #define BTA_AV_RC_OPEN_EVT 8 /* remote control channel open */ 238 #define BTA_AV_RC_CLOSE_EVT 9 /* remote control channel closed */ 239 #define BTA_AV_REMOTE_CMD_EVT 10 /* remote control command */ 240 #define BTA_AV_REMOTE_RSP_EVT 11 /* remote control response */ 241 #define BTA_AV_VENDOR_CMD_EVT 12 /* vendor dependent remote control command */ 242 #define BTA_AV_VENDOR_RSP_EVT 13 /* vendor dependent remote control response */ 243 #define BTA_AV_RECONFIG_EVT 14 /* reconfigure response */ 244 #define BTA_AV_SUSPEND_EVT 15 /* suspend response */ 245 #define BTA_AV_PENDING_EVT 16 /* incoming connection pending: 246 * signal channel is open and stream is not open 247 * after BTA_AV_SIG_TIME_VAL ms */ 248 #define BTA_AV_META_MSG_EVT 17 /* metadata messages */ 249 #define BTA_AV_REJECT_EVT 18 /* incoming connection rejected */ 250 #define BTA_AV_RC_FEAT_EVT 19 /* remote control channel peer supported features update */ 251 #define BTA_AV_MEDIA_SINK_CFG_EVT 20 /* command to configure codec */ 252 #define BTA_AV_MEDIA_DATA_EVT 21 /* sending data to Media Task */ 253 #define BTA_AV_SET_DELAY_VALUE_EVT 22 /* set delay reporting value */ 254 #define BTA_AV_GET_DELAY_VALUE_EVT 23 /* get delay reporting value */ 255 #define BTA_AV_SNK_PSC_CFG_EVT 24 /* Protocol service capabilities. */ 256 /* Max BTA event */ 257 #define BTA_AV_MAX_EVT 25 258 259 260 /* function types for call-out functions */ 261 typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info, 262 UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 tsep); 263 typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps, 264 UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local); 265 typedef void (*tBTA_AV_CO_CFG_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps, 266 UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local); 267 typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 268 UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, 269 UINT8 *p_num_protect, UINT8 *p_protect_info); 270 typedef void (*tBTA_AV_CO_SETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 271 UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, 272 UINT8 num_protect, UINT8 *p_protect_info, 273 UINT8 t_local_sep, UINT8 avdt_handle); 274 typedef void (*tBTA_AV_CO_OPEN) (tBTA_AV_HNDL hndl, 275 tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, 276 UINT16 mtu); 277 typedef void (*tBTA_AV_CO_CLOSE) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT16 mtu); 278 typedef void (*tBTA_AV_CO_START) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr); 279 typedef void (*tBTA_AV_CO_STOP) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type); 280 typedef void *(*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type, 281 UINT32 *p_len, UINT32 *p_timestamp); 282 typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay); 283 284 /// AVRCP call-out function 285 // check whether PASSTHROUGH command is supported 286 typedef BOOLEAN (*tBTA_AVRC_CO_CMD_ALLOWED) (tBTA_AV_RC rc_id); 287 // get the event notification capabilities 288 typedef UINT8 (*tBTA_AVRC_CO_RN_EVT_CAP) (UINT8 *event_ids); 289 // check whether the event_id is supported 290 typedef BOOLEAN (*tBTA_AVRC_CO_RN_EVT_SUPPORTED) (UINT8 event_id); 291 292 /* the call-out functions for one stream */ 293 typedef struct { 294 tBTA_AV_CO_INIT init; 295 tBTA_AV_CO_DISC_RES disc_res; 296 tBTA_AV_CO_CFG_RES cfg_res; 297 tBTA_AV_CO_GETCFG getcfg; 298 tBTA_AV_CO_SETCFG setcfg; 299 tBTA_AV_CO_OPEN open; 300 tBTA_AV_CO_CLOSE close; 301 tBTA_AV_CO_START start; 302 tBTA_AV_CO_STOP stop; 303 tBTA_AV_CO_DATAPATH data; 304 tBTA_AV_CO_DELAY delay; 305 } tBTA_AV_CO_FUNCTS; 306 307 /* the call-out functions for AVRCP */ 308 typedef struct { 309 tBTA_AVRC_CO_CMD_ALLOWED rc_cmd; 310 tBTA_AVRC_CO_RN_EVT_CAP rn_evt_cap; 311 tBTA_AVRC_CO_RN_EVT_SUPPORTED rn_evt_supported; 312 } tBTA_AVRC_CO_FUNCTS; 313 314 typedef UINT8 tBTA_AV_EVT; 315 316 /* Event associated with BTA_AV_ENABLE_EVT */ 317 typedef struct { 318 tBTA_AV_FEAT features; 319 } tBTA_AV_ENABLE; 320 321 /* Event associated with BTA_AV_REGISTER_EVT */ 322 typedef struct { 323 tBTA_AV_CHNL chnl; /* audio/video */ 324 tBTA_AV_HNDL hndl; /* Handle associated with the stream. */ 325 UINT8 app_id; /* ID associated with call to BTA_AvRegister() */ 326 tBTA_AV_STATUS status; 327 tBTA_AV_CO_FUNCTS *p_bta_av_cos; 328 tBTA_AVRC_CO_FUNCTS *p_bta_avrc_cos; 329 } tBTA_AV_REGISTER; 330 331 /* data associated with BTA_AV_OPEN_EVT */ 332 #define BTA_AV_EDR_2MBPS 0x01 333 #define BTA_AV_EDR_3MBPS 0x02 334 typedef UINT8 tBTA_AV_EDR; 335 336 typedef struct { 337 tBTA_AV_CHNL chnl; 338 tBTA_AV_HNDL hndl; 339 BD_ADDR bd_addr; 340 tBTA_AV_STATUS status; 341 BOOLEAN starting; 342 tBTA_AV_EDR edr; /* 0, if peer device does not support EDR */ 343 UINT8 sep; /* sep type of peer device */ 344 } tBTA_AV_OPEN; 345 346 /* data associated with BTA_AV_CLOSE_EVT */ 347 typedef struct { 348 tBTA_AV_CHNL chnl; 349 tBTA_AV_HNDL hndl; 350 UINT8 disc_rsn; /* disconnection reason */ 351 } tBTA_AV_CLOSE; 352 353 /* data associated with BTA_AV_START_EVT */ 354 typedef struct { 355 tBTA_AV_CHNL chnl; 356 tBTA_AV_HNDL hndl; 357 tBTA_AV_STATUS status; 358 BOOLEAN initiator; /* TRUE, if local device initiates the START */ 359 BOOLEAN suspending; 360 } tBTA_AV_START; 361 362 /* data associated with BTA_AV_SUSPEND_EVT */ 363 typedef struct { 364 tBTA_AV_CHNL chnl; 365 tBTA_AV_HNDL hndl; 366 BOOLEAN initiator; /* TRUE, if local device initiates the SUSPEND */ 367 tBTA_AV_STATUS status; 368 } tBTA_AV_SUSPEND; 369 370 /* data associated with BTA_AV_RECONFIG_EVT */ 371 typedef struct { 372 tBTA_AV_CHNL chnl; 373 tBTA_AV_HNDL hndl; 374 tBTA_AV_STATUS status; 375 } tBTA_AV_RECONFIG; 376 377 /* data associated with BTA_AV_PROTECT_REQ_EVT */ 378 typedef struct { 379 tBTA_AV_CHNL chnl; 380 tBTA_AV_HNDL hndl; 381 UINT8 *p_data; 382 UINT16 len; 383 } tBTA_AV_PROTECT_REQ; 384 385 /* data associated with BTA_AV_PROTECT_RSP_EVT */ 386 typedef struct { 387 tBTA_AV_CHNL chnl; 388 tBTA_AV_HNDL hndl; 389 UINT8 *p_data; 390 UINT16 len; 391 tBTA_AV_ERR err_code; 392 } tBTA_AV_PROTECT_RSP; 393 394 /* data associated with BTA_AV_RC_OPEN_EVT */ 395 typedef struct { 396 UINT8 rc_handle; 397 BOOLEAN sdp_disc_done; 398 tBTA_AV_FEAT peer_features; 399 UINT16 peer_ct_features; 400 UINT16 peer_tg_features; 401 BD_ADDR peer_addr; 402 tBTA_AV_STATUS status; 403 } tBTA_AV_RC_OPEN; 404 405 /* data associated with BTA_AV_RC_CLOSE_EVT */ 406 typedef struct { 407 UINT8 rc_handle; 408 BD_ADDR peer_addr; 409 } tBTA_AV_RC_CLOSE; 410 411 /* data associated with BTA_AV_RC_FEAT_EVT */ 412 typedef struct { 413 UINT8 rc_handle; 414 tBTA_AV_FEAT peer_features; 415 UINT16 peer_ct_features; 416 UINT16 peer_tg_features; 417 } tBTA_AV_RC_FEAT; 418 419 /* data associated with BTA_AV_REMOTE_CMD_EVT */ 420 typedef struct { 421 UINT8 rc_handle; 422 tBTA_AV_RC rc_id; 423 tBTA_AV_STATE key_state; 424 UINT8 len; 425 UINT8 *p_data; 426 tAVRC_HDR hdr; /* Message header. */ 427 UINT8 label; 428 } tBTA_AV_REMOTE_CMD; 429 430 /* data associated with BTA_AV_REMOTE_RSP_EVT */ 431 typedef struct { 432 UINT8 rc_handle; 433 tBTA_AV_RC rc_id; 434 tBTA_AV_STATE key_state; 435 UINT8 len; 436 UINT8 *p_data; 437 tBTA_AV_CODE rsp_code; 438 UINT8 label; 439 } tBTA_AV_REMOTE_RSP; 440 441 /* data associated with BTA_AV_VENDOR_CMD_EVT, BTA_AV_VENDOR_RSP_EVT */ 442 typedef struct { 443 UINT8 rc_handle; 444 UINT16 len; /* Max vendor dependent message is 512 */ 445 UINT8 label; 446 tBTA_AV_CODE code; 447 UINT32 company_id; 448 UINT8 *p_data; 449 } tBTA_AV_VENDOR; 450 451 /* data associated with BTA_AV_META_MSG_EVT */ 452 typedef struct { 453 UINT8 rc_handle; 454 UINT16 len; 455 UINT8 label; 456 tBTA_AV_CODE code; 457 UINT32 company_id; 458 UINT8 *p_data; 459 tAVRC_MSG *p_msg; 460 } tBTA_AV_META_MSG; 461 462 /* data associated with BTA_AV_PENDING_EVT */ 463 typedef struct { 464 BD_ADDR bd_addr; 465 } tBTA_AV_PEND; 466 467 /* data associated with BTA_AV_REJECT_EVT */ 468 typedef struct { 469 BD_ADDR bd_addr; 470 tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the connection. */ 471 } tBTA_AV_REJECT; 472 473 /* data associated with BTA_AV_SET_DELAY_VALUE_EVT/BTA_AV_GET_DELAY_VALUE_EVT */ 474 typedef struct { 475 tBTA_AV_STATUS status; 476 UINT16 delay_value; 477 } tBTA_AV_DELAY; 478 479 /* data associated with BTA_AV_SNK_PSC_CFG_EVT */ 480 typedef struct { 481 UINT16 psc_mask; 482 } tBTA_AV_SNK_PSC_CFG; 483 484 485 /* union of data associated with AV callback */ 486 typedef union { 487 tBTA_AV_CHNL chnl; 488 tBTA_AV_ENABLE enable; 489 tBTA_AV_REGISTER registr; 490 tBTA_AV_OPEN open; 491 tBTA_AV_CLOSE close; 492 tBTA_AV_START start; 493 tBTA_AV_PROTECT_REQ protect_req; 494 tBTA_AV_PROTECT_RSP protect_rsp; 495 tBTA_AV_RC_OPEN rc_open; 496 tBTA_AV_RC_CLOSE rc_close; 497 tBTA_AV_REMOTE_CMD remote_cmd; 498 tBTA_AV_REMOTE_RSP remote_rsp; 499 tBTA_AV_VENDOR vendor_cmd; 500 tBTA_AV_VENDOR vendor_rsp; 501 tBTA_AV_RECONFIG reconfig; 502 tBTA_AV_SUSPEND suspend; 503 tBTA_AV_PEND pend; 504 tBTA_AV_META_MSG meta_msg; 505 tBTA_AV_REJECT reject; 506 tBTA_AV_RC_FEAT rc_feat; 507 tBTA_AV_DELAY delay; 508 tBTA_AV_SNK_PSC_CFG psc; 509 } tBTA_AV; 510 511 /* union of data associated with AV Media callback */ 512 typedef union { 513 BT_HDR *p_data; 514 UINT8 *codec_info; 515 } tBTA_AV_MEDIA; 516 517 518 #define BTA_AVC_PACKET_LEN AVRC_PACKET_LEN 519 #define BTA_VENDOR_DATA_OFFSET 6 520 #define BTA_VENDOR_HEADER_LEN 4 521 #define BTA_MAX_VENDOR_DEPENDENT_DATA_LEN (BTA_AVC_PACKET_LEN-BTA_VENDOR_DATA_OFFSET-BTA_VENDOR_HEADER_LEN) 522 #define BTA_GROUP_NAVI_MSG_OP_DATA_LEN 5 523 524 #define BTA_ERROR_INVALID_CMD AVRC_STS_BAD_CMD 525 #define BTA_ERROR_INVALID_PARAM AVRC_STS_BAD_PARAM 526 #define BTA_ERROR_BAD_CONTENTS AVRC_STS_NOT_FOUND 527 #define BTA_ERROR_INTERNAL AVRC_STS_INTERNAL_ERR 528 529 #define BTA_AV_META_SINGLE_PACKET AVRC_PKT_SINGLE 530 531 #define BTA_AV_CO_METADATA AVRC_CO_METADATA 532 533 /* AV callback */ 534 typedef void (tBTA_AV_CBACK)(tBTA_AV_EVT event, tBTA_AV *p_data); 535 typedef void (tBTA_AV_DATA_CBACK)(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data); 536 537 /* type for stream state machine action functions */ 538 typedef void (*tBTA_AV_ACT)(void *p_cb, void *p_data); 539 540 /* type for registering VDP */ 541 typedef void (tBTA_AV_REG) (tAVDT_CS *p_cs, char *p_service_name, void *p_data); 542 543 /* AV configuration structure */ 544 typedef struct { 545 UINT32 company_id; /* AVRCP Company ID */ 546 UINT16 avrc_mtu; /* AVRCP MTU at L2CAP for control channel */ 547 UINT16 avrc_br_mtu; /* AVRCP MTU at L2CAP for browsing channel */ 548 UINT16 avrc_snk_ct_cat; /* AVRCP controller categories as SNK */ 549 UINT16 avrc_snk_tg_cat; /* AVRCP target categories SNK */ 550 UINT16 avrc_src_ct_cat; /* AVRCP controller categories as SRC */ 551 UINT16 avrc_src_tg_cat; /* AVRCP target categories as SRC */ 552 UINT16 sig_mtu; /* AVDTP signaling channel MTU at L2CAP */ 553 UINT16 audio_mtu; /* AVDTP audio transport channel MTU at L2CAP */ 554 const UINT16 *p_audio_flush_to;/* AVDTP audio transport channel flush timeout */ 555 UINT16 audio_mqs; /* AVDTP audio channel max data queue size */ 556 UINT16 video_mtu; /* AVDTP video transport channel MTU at L2CAP */ 557 UINT16 video_flush_to; /* AVDTP video transport channel flush timeout */ 558 BOOLEAN avrc_group; /* TRUE, to accept AVRC 1.3 group nevigation command */ 559 BOOLEAN avrc_br; /* FALSE, does not support browsing channel */ 560 UINT8 num_co_ids; /* company id count in p_meta_co_ids */ 561 tBTA_AV_CODE rc_pass_rsp; /* the default response code for pass through commands */ 562 const UINT32 *p_meta_co_ids;/* the metadata Get Capabilities response for company id */ 563 const tBTA_AV_ACT *p_act_tbl;/* the action function table for VDP stream */ 564 tBTA_AV_REG *p_reg; /* action function to register VDP */ 565 char avrc_controller_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP controller name */ 566 char avrc_target_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP target name*/ 567 } tBTA_AV_CFG; 568 569 #ifdef __cplusplus 570 extern "C" 571 { 572 #endif 573 574 /***************************************************************************** 575 ** External Function Declarations 576 *****************************************************************************/ 577 578 /******************************************************************************* 579 ** 580 ** Function BTA_AvEnable 581 ** 582 ** Description Enable the advanced audio/video service. When the enable 583 ** operation is complete the callback function will be 584 ** called with a BTA_AV_ENABLE_EVT. This function must 585 ** be called before other function in the AV API are 586 ** called. 587 ** 588 ** Returns void 589 ** 590 *******************************************************************************/ 591 void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features, 592 tBTA_AV_CBACK *p_cback); 593 594 /******************************************************************************* 595 ** 596 ** Function BTA_AvDisable 597 ** 598 ** Description Disable the advanced audio/video service. 599 ** 600 ** 601 ** Returns void 602 ** 603 *******************************************************************************/ 604 void BTA_AvDisable(void); 605 606 /******************************************************************************* 607 ** 608 ** Function BTA_AvRegister 609 ** 610 ** Description Register the audio or video service to stack. When the 611 ** operation is complete the callback function will be 612 ** called with a BTA_AV_REGISTER_EVT. This function must 613 ** be called before AVDT stream is open. 614 ** 615 ** 616 ** Returns void 617 ** 618 *******************************************************************************/ 619 void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, 620 UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, 621 tBTA_AV_CO_FUNCTS *bta_av_cos, tBTA_AVRC_CO_FUNCTS *bta_avrc_cos, 622 UINT8 tsep); 623 624 /******************************************************************************* 625 ** 626 ** Function BTA_AvDeregister 627 ** 628 ** Description Deregister the audio or video service 629 ** 630 ** Returns void 631 ** 632 *******************************************************************************/ 633 void BTA_AvDeregister(tBTA_AV_HNDL hndl); 634 635 /******************************************************************************* 636 ** 637 ** Function BTA_AvOpen 638 ** 639 ** Description Opens an advanced audio/video connection to a peer device. 640 ** When connection is open callback function is called 641 ** with a BTA_AV_OPEN_EVT. 642 ** 643 ** Returns void 644 ** 645 *******************************************************************************/ 646 void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, 647 BOOLEAN use_rc, tBTA_SEC sec_mask, UINT16 uuid); 648 649 /******************************************************************************* 650 ** 651 ** Function BTA_AvClose 652 ** 653 ** Description Close the current streams. 654 ** 655 ** Returns void 656 ** 657 *******************************************************************************/ 658 void BTA_AvClose(tBTA_AV_HNDL handle); 659 660 /******************************************************************************* 661 ** 662 ** Function BTA_AvDisconnect 663 ** 664 ** Description Close the connection to the address. 665 ** 666 ** Returns void 667 ** 668 *******************************************************************************/ 669 void BTA_AvDisconnect(BD_ADDR bd_addr); 670 671 /******************************************************************************* 672 ** 673 ** Function BTA_AvEnable_Sink 674 ** 675 ** Description Enable/Disable A2DP Sink. 676 ** 677 ** Returns void 678 ** 679 *******************************************************************************/ 680 void BTA_AvEnable_Sink(int enable); 681 682 /******************************************************************************* 683 ** 684 ** Function BTA_AvStart 685 ** 686 ** Description Start audio/video stream data transfer. 687 ** 688 ** Returns void 689 ** 690 *******************************************************************************/ 691 void BTA_AvStart(void); 692 693 /******************************************************************************* 694 ** 695 ** Function BTA_AvStop 696 ** 697 ** Description Stop audio/video stream data transfer. 698 ** If suspend is TRUE, this function sends AVDT suspend signal 699 ** to the connected peer(s). 700 ** 701 ** Returns void 702 ** 703 *******************************************************************************/ 704 void BTA_AvStop(BOOLEAN suspend); 705 706 /******************************************************************************* 707 ** 708 ** Function BTA_AvReconfig 709 ** 710 ** Description Reconfigure the audio/video stream. 711 ** If suspend is TRUE, this function tries the suspend/reconfigure 712 ** procedure first. 713 ** If suspend is FALSE or when suspend/reconfigure fails, 714 ** this function closes and re-opens the AVDT connection. 715 ** 716 ** Returns void 717 ** 718 *******************************************************************************/ 719 void BTA_AvReconfig(tBTA_AV_HNDL hndl, BOOLEAN suspend, UINT8 sep_info_idx, 720 UINT8 *p_codec_info, UINT8 num_protect, UINT8 *p_protect_info); 721 722 /******************************************************************************* 723 ** 724 ** Function BTA_AvProtectReq 725 ** 726 ** Description Send a content protection request. This function can only 727 ** be used if AV is enabled with feature BTA_AV_FEAT_PROTECT. 728 ** 729 ** Returns void 730 ** 731 *******************************************************************************/ 732 void BTA_AvProtectReq(tBTA_AV_HNDL hndl, UINT8 *p_data, UINT16 len); 733 734 /******************************************************************************* 735 ** 736 ** Function BTA_AvProtectRsp 737 ** 738 ** Description Send a content protection response. This function must 739 ** be called if a BTA_AV_PROTECT_REQ_EVT is received. 740 ** This function can only be used if AV is enabled with 741 ** feature BTA_AV_FEAT_PROTECT. 742 ** 743 ** Returns void 744 ** 745 *******************************************************************************/ 746 void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, UINT8 error_code, UINT8 *p_data, 747 UINT16 len); 748 749 /******************************************************************************* 750 ** 751 ** Function BTA_SetDelayValue 752 ** 753 ** Description Set delay report value 754 ** 755 ** Returns void 756 ** 757 *******************************************************************************/ 758 void BTA_SetDelayValue(UINT16 delay_value); 759 760 /******************************************************************************* 761 ** 762 ** Function BTA_GetDelayValue 763 ** 764 ** Description Get delay report value 765 ** 766 ** Returns void 767 ** 768 *******************************************************************************/ 769 void BTA_GetDelayValue(void); 770 771 /******************************************************************************* 772 ** 773 ** Function BTA_AvRemoteCmd 774 ** 775 ** Description Send a remote control command. This function can only 776 ** be used if AV is enabled with feature BTA_AV_FEAT_RCCT. 777 ** 778 ** Returns void 779 ** 780 *******************************************************************************/ 781 void BTA_AvRemoteCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_RC rc_id, 782 tBTA_AV_STATE key_state); 783 784 /******************************************************************************* 785 ** 786 ** Function BTA_AvVendorCmd 787 ** 788 ** Description Send a vendor dependent remote control command. This 789 ** function can only be used if AV is enabled with feature 790 ** BTA_AV_FEAT_VENDOR. 791 ** 792 ** Returns void 793 ** 794 *******************************************************************************/ 795 void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code, 796 UINT8 *p_data, UINT16 len); 797 798 /******************************************************************************* 799 ** 800 ** Function BTA_AvVendorRsp 801 ** 802 ** Description Send a vendor dependent remote control response. 803 ** This function must be called if a BTA_AV_VENDOR_CMD_EVT 804 ** is received. This function can only be used if AV is 805 ** enabled with feature BTA_AV_FEAT_VENDOR. 806 ** 807 ** Returns void 808 ** 809 *******************************************************************************/ 810 void BTA_AvVendorRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code, 811 UINT8 *p_data, UINT16 len, UINT32 company_id); 812 813 814 /******************************************************************************* 815 ** 816 ** Function BTA_AvOpenRc 817 ** 818 ** Description Open an AVRCP connection toward the device with the 819 ** specified handle 820 ** 821 ** Returns void 822 ** 823 *******************************************************************************/ 824 void BTA_AvOpenRc(tBTA_AV_HNDL handle); 825 826 /******************************************************************************* 827 ** 828 ** Function BTA_AvCloseRc 829 ** 830 ** Description Close an AVRCP connection 831 ** 832 ** Returns void 833 ** 834 *******************************************************************************/ 835 void BTA_AvCloseRc(UINT8 rc_handle); 836 837 /******************************************************************************* 838 ** 839 ** Function BTA_AvMetaRsp 840 ** 841 ** Description Send a Metadata command/response. The message contained 842 ** in p_pkt can be composed with AVRC utility functions. 843 ** This function can only be used if AV is enabled with feature 844 ** BTA_AV_FEAT_METADATA. 845 ** 846 ** Returns void 847 ** 848 *******************************************************************************/ 849 void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code, 850 BT_HDR *p_pkt); 851 852 /******************************************************************************* 853 ** 854 ** Function BTA_AvMetaCmd 855 ** 856 ** Description Send a Metadata/Advanced Control command. The message contained 857 ** in p_pkt can be composed with AVRC utility functions. 858 ** This function can only be used if AV is enabled with feature 859 ** BTA_AV_FEAT_METADATA. 860 ** This message is sent only when the peer supports the TG role. 861 *8 The only command makes sense right now is the absolute volume command. 862 ** 863 ** Returns void 864 ** 865 *******************************************************************************/ 866 void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p_pkt); 867 868 #ifdef __cplusplus 869 } 870 #endif 871 872 #endif ///BTA_AV_INCLUDED == TRUE 873 874 #endif /* BTA_AV_API_H */ 875