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 private interface file for the BTA advanced audio/video. 22 * 23 ******************************************************************************/ 24 #ifndef BTA_AV_INT_H 25 #define BTA_AV_INT_H 26 27 #include "bta_sys.h" 28 #include "bta_api.h" 29 #include "bta_av_api.h" 30 #include "avdt_api.h" 31 #include "bta_av_co.h" 32 33 #define BTA_AV_DEBUG TRUE 34 /***************************************************************************** 35 ** Constants 36 *****************************************************************************/ 37 38 enum 39 { 40 /* these events are handled by the AV main state machine */ 41 BTA_AV_API_DISABLE_EVT = BTA_SYS_EVT_START(BTA_ID_AV), 42 BTA_AV_API_REMOTE_CMD_EVT, 43 BTA_AV_API_VENDOR_CMD_EVT, 44 BTA_AV_API_VENDOR_RSP_EVT, 45 BTA_AV_API_META_RSP_EVT, 46 BTA_AV_API_RC_CLOSE_EVT, 47 BTA_AV_AVRC_OPEN_EVT, 48 BTA_AV_AVRC_MSG_EVT, 49 BTA_AV_AVRC_NONE_EVT, 50 51 /* these events are handled by the AV stream state machine */ 52 BTA_AV_API_OPEN_EVT, 53 BTA_AV_API_CLOSE_EVT, 54 BTA_AV_AP_START_EVT, /* the following 2 events must be in the same order as the *API_*EVT */ 55 BTA_AV_AP_STOP_EVT, 56 BTA_AV_API_RECONFIG_EVT, 57 BTA_AV_API_PROTECT_REQ_EVT, 58 BTA_AV_API_PROTECT_RSP_EVT, 59 BTA_AV_API_RC_OPEN_EVT, 60 BTA_AV_SRC_DATA_READY_EVT, 61 BTA_AV_CI_SETCONFIG_OK_EVT, 62 BTA_AV_CI_SETCONFIG_FAIL_EVT, 63 BTA_AV_SDP_DISC_OK_EVT, 64 BTA_AV_SDP_DISC_FAIL_EVT, 65 BTA_AV_STR_DISC_OK_EVT, 66 BTA_AV_STR_DISC_FAIL_EVT, 67 BTA_AV_STR_GETCAP_OK_EVT, 68 BTA_AV_STR_GETCAP_FAIL_EVT, 69 BTA_AV_STR_OPEN_OK_EVT, 70 BTA_AV_STR_OPEN_FAIL_EVT, 71 BTA_AV_STR_START_OK_EVT, 72 BTA_AV_STR_START_FAIL_EVT, 73 BTA_AV_STR_CLOSE_EVT, 74 BTA_AV_STR_CONFIG_IND_EVT, 75 BTA_AV_STR_SECURITY_IND_EVT, 76 BTA_AV_STR_SECURITY_CFM_EVT, 77 BTA_AV_STR_WRITE_CFM_EVT, 78 BTA_AV_STR_SUSPEND_CFM_EVT, 79 BTA_AV_STR_RECONFIG_CFM_EVT, 80 BTA_AV_AVRC_TIMER_EVT, 81 BTA_AV_AVDT_CONNECT_EVT, 82 BTA_AV_AVDT_DISCONNECT_EVT, 83 BTA_AV_ROLE_CHANGE_EVT, 84 BTA_AV_AVDT_DELAY_RPT_EVT, 85 BTA_AV_ACP_CONNECT_EVT, 86 87 /* these events are handled outside of the state machine */ 88 BTA_AV_API_ENABLE_EVT, 89 BTA_AV_API_REGISTER_EVT, 90 BTA_AV_API_DEREGISTER_EVT, 91 BTA_AV_API_DISCONNECT_EVT, 92 BTA_AV_CI_SRC_DATA_READY_EVT, 93 BTA_AV_SIG_CHG_EVT, 94 BTA_AV_SIG_TIMER_EVT, 95 BTA_AV_SDP_AVRC_DISC_EVT, 96 BTA_AV_AVRC_CLOSE_EVT, 97 BTA_AV_CONN_CHG_EVT, 98 BTA_AV_DEREG_COMP_EVT, 99 #if (AVDT_REPORTING == TRUE) 100 BTA_AV_AVDT_RPT_CONN_EVT, 101 #endif 102 BTA_AV_API_START_EVT, /* the following 2 events must be in the same order as the *AP_*EVT */ 103 BTA_AV_API_STOP_EVT 104 }; 105 106 /* events for AV control block state machine */ 107 #define BTA_AV_FIRST_SM_EVT BTA_AV_API_DISABLE_EVT 108 #define BTA_AV_LAST_SM_EVT BTA_AV_AVRC_NONE_EVT 109 110 /* events for AV stream control block state machine */ 111 #define BTA_AV_FIRST_SSM_EVT BTA_AV_API_OPEN_EVT 112 113 /* events that do not go through state machine */ 114 #define BTA_AV_FIRST_NSM_EVT BTA_AV_API_ENABLE_EVT 115 #define BTA_AV_LAST_NSM_EVT BTA_AV_API_STOP_EVT 116 117 /* API events passed to both SSMs (by bta_av_api_to_ssm) */ 118 #define BTA_AV_FIRST_A2S_API_EVT BTA_AV_API_START_EVT 119 #define BTA_AV_FIRST_A2S_SSM_EVT BTA_AV_AP_START_EVT 120 121 #define BTA_AV_LAST_EVT BTA_AV_API_STOP_EVT 122 123 /* maximum number of SEPS in stream discovery results */ 124 #define BTA_AV_NUM_SEPS 32 125 126 /* initialization value for AVRC handle */ 127 #define BTA_AV_RC_HANDLE_NONE 0xFF 128 129 /* size of database for service discovery */ 130 #define BTA_AV_DISC_BUF_SIZE 1000 131 132 /* offset of media type in codec info byte array */ 133 #define BTA_AV_MEDIA_TYPE_IDX 1 134 135 /* maximum length of AVDTP security data */ 136 #define BTA_AV_SECURITY_MAX_LEN 400 137 138 /* check number of buffers queued at L2CAP when this amount of buffers are queued to L2CAP */ 139 #define BTA_AV_QUEUE_DATA_CHK_NUM L2CAP_HIGH_PRI_MIN_XMIT_QUOTA 140 141 /* the number of ACL links with AVDT */ 142 #define BTA_AV_NUM_LINKS AVDT_NUM_LINKS 143 144 #define BTA_AV_CO_ID_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); } 145 #define BTA_AV_BE_STREAM_TO_CO_ID(u32, p) {u32 = (((UINT32)(*((p) + 2))) + (((UINT32)(*((p) + 1))) << 8) + (((UINT32)(*(p))) << 16)); (p) += 3;} 146 147 /* these bits are defined for bta_av_cb.multi_av */ 148 #define BTA_AV_MULTI_AV_SUPPORTED 0x01 149 #define BTA_AV_MULTI_AV_IN_USE 0x02 150 151 152 /***************************************************************************** 153 ** Data types 154 *****************************************************************************/ 155 156 /* function types for call-out functions */ 157 typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info, 158 UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index); 159 160 typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps, 161 UINT8 num_snk, BD_ADDR addr); 162 163 typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 164 UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, 165 UINT8 *p_num_protect, UINT8 *p_protect_info); 166 typedef void (*tBTA_AV_CO_SETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 167 UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, 168 UINT8 num_protect, UINT8 *p_protect_info); 169 typedef void (*tBTA_AV_CO_OPEN) (tBTA_AV_HNDL hndl, 170 tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, 171 UINT16 mtu); 172 typedef void (*tBTA_AV_CO_CLOSE) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT16 mtu); 173 typedef void (*tBTA_AV_CO_START) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr); 174 typedef void (*tBTA_AV_CO_STOP) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type); 175 typedef void * (*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type, 176 UINT32 *p_len, UINT32 *p_timestamp); 177 typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay); 178 179 /* the call-out functions for one stream */ 180 typedef struct 181 { 182 tBTA_AV_CO_INIT init; 183 tBTA_AV_CO_DISC_RES disc_res; 184 tBTA_AV_CO_GETCFG getcfg; 185 tBTA_AV_CO_SETCFG setcfg; 186 tBTA_AV_CO_OPEN open; 187 tBTA_AV_CO_CLOSE close; 188 tBTA_AV_CO_START start; 189 tBTA_AV_CO_STOP stop; 190 tBTA_AV_CO_DATAPATH data; 191 tBTA_AV_CO_DELAY delay; 192 } tBTA_AV_CO_FUNCTS; 193 194 /* data type for BTA_AV_API_ENABLE_EVT */ 195 typedef struct 196 { 197 BT_HDR hdr; 198 tBTA_AV_CBACK *p_cback; 199 tBTA_AV_FEAT features; 200 tBTA_SEC sec_mask; 201 } tBTA_AV_API_ENABLE; 202 203 /* data type for BTA_AV_API_REG_EVT */ 204 typedef struct 205 { 206 BT_HDR hdr; 207 char p_service_name[BTA_SERVICE_NAME_LEN+1]; 208 UINT8 app_id; 209 } tBTA_AV_API_REG; 210 211 212 enum 213 { 214 BTA_AV_RS_NONE, /* straight API call */ 215 BTA_AV_RS_OK, /* the role switch result - successful */ 216 BTA_AV_RS_FAIL, /* the role switch result - failed */ 217 BTA_AV_RS_DONE /* the role switch is done - continue */ 218 }; 219 typedef UINT8 tBTA_AV_RS_RES; 220 /* data type for BTA_AV_API_OPEN_EVT */ 221 typedef struct 222 { 223 BT_HDR hdr; 224 BD_ADDR bd_addr; 225 BOOLEAN use_rc; 226 tBTA_SEC sec_mask; 227 tBTA_AV_RS_RES switch_res; 228 } tBTA_AV_API_OPEN; 229 230 /* data type for BTA_AV_API_STOP_EVT */ 231 typedef struct 232 { 233 BT_HDR hdr; 234 BOOLEAN suspend; 235 BOOLEAN flush; 236 } tBTA_AV_API_STOP; 237 238 /* data type for BTA_AV_API_DISCONNECT_EVT */ 239 typedef struct 240 { 241 BT_HDR hdr; 242 BD_ADDR bd_addr; 243 } tBTA_AV_API_DISCNT; 244 245 /* data type for BTA_AV_API_PROTECT_REQ_EVT */ 246 typedef struct 247 { 248 BT_HDR hdr; 249 UINT8 *p_data; 250 UINT16 len; 251 } tBTA_AV_API_PROTECT_REQ; 252 253 /* data type for BTA_AV_API_PROTECT_RSP_EVT */ 254 typedef struct 255 { 256 BT_HDR hdr; 257 UINT8 *p_data; 258 UINT16 len; 259 UINT8 error_code; 260 } tBTA_AV_API_PROTECT_RSP; 261 262 /* data type for BTA_AV_API_REMOTE_CMD_EVT */ 263 typedef struct 264 { 265 BT_HDR hdr; 266 tAVRC_MSG_PASS msg; 267 UINT8 label; 268 } tBTA_AV_API_REMOTE_CMD; 269 270 /* data type for BTA_AV_API_VENDOR_CMD_EVT and RSP */ 271 typedef struct 272 { 273 BT_HDR hdr; 274 tAVRC_MSG_VENDOR msg; 275 UINT8 label; 276 } tBTA_AV_API_VENDOR; 277 278 /* data type for BTA_AV_API_RC_OPEN_EVT */ 279 typedef struct 280 { 281 BT_HDR hdr; 282 } tBTA_AV_API_OPEN_RC; 283 284 /* data type for BTA_AV_API_RC_CLOSE_EVT */ 285 typedef struct 286 { 287 BT_HDR hdr; 288 } tBTA_AV_API_CLOSE_RC; 289 290 /* data type for BTA_AV_API_META_RSP_EVT */ 291 typedef struct 292 { 293 BT_HDR hdr; 294 BOOLEAN is_rsp; 295 UINT8 label; 296 tBTA_AV_CODE rsp_code; 297 BT_HDR *p_pkt; 298 } tBTA_AV_API_META_RSP; 299 300 301 /* data type for BTA_AV_API_RECONFIG_EVT */ 302 typedef struct 303 { 304 BT_HDR hdr; 305 UINT8 codec_info[AVDT_CODEC_SIZE]; /* codec configuration */ 306 UINT8 *p_protect_info; 307 UINT8 num_protect; 308 BOOLEAN suspend; 309 UINT8 sep_info_idx; 310 } tBTA_AV_API_RCFG; 311 312 /* data type for BTA_AV_CI_SETCONFIG_OK_EVT and BTA_AV_CI_SETCONFIG_FAIL_EVT */ 313 typedef struct 314 { 315 BT_HDR hdr; 316 tBTA_AV_HNDL hndl; 317 UINT8 err_code; 318 UINT8 category; 319 UINT8 num_seid; 320 UINT8 *p_seid; 321 BOOLEAN recfg_needed; 322 } tBTA_AV_CI_SETCONFIG; 323 324 /* data type for all stream events from AVDTP */ 325 typedef struct { 326 BT_HDR hdr; 327 tAVDT_CFG cfg; /* configuration/capabilities parameters */ 328 tAVDT_CTRL msg; /* AVDTP callback message parameters */ 329 BD_ADDR bd_addr; /* bd address */ 330 UINT8 handle; 331 UINT8 avdt_event; 332 BOOLEAN initiator; /* TRUE, if local device initiates the SUSPEND */ 333 } tBTA_AV_STR_MSG; 334 335 /* data type for BTA_AV_AVRC_MSG_EVT */ 336 typedef struct 337 { 338 BT_HDR hdr; 339 tAVRC_MSG msg; 340 UINT8 handle; 341 UINT8 label; 342 UINT8 opcode; 343 } tBTA_AV_RC_MSG; 344 345 /* data type for BTA_AV_AVRC_OPEN_EVT, BTA_AV_AVRC_CLOSE_EVT */ 346 typedef struct 347 { 348 BT_HDR hdr; 349 BD_ADDR peer_addr; 350 UINT8 handle; 351 } tBTA_AV_RC_CONN_CHG; 352 353 /* data type for BTA_AV_CONN_CHG_EVT */ 354 typedef struct 355 { 356 BT_HDR hdr; 357 BD_ADDR peer_addr; 358 BOOLEAN is_up; 359 } tBTA_AV_CONN_CHG; 360 361 /* data type for BTA_AV_ROLE_CHANGE_EVT */ 362 typedef struct 363 { 364 BT_HDR hdr; 365 UINT8 new_role; 366 UINT8 hci_status; 367 } tBTA_AV_ROLE_RES; 368 369 /* data type for BTA_AV_SDP_DISC_OK_EVT */ 370 typedef struct 371 { 372 BT_HDR hdr; 373 UINT16 avdt_version; /* AVDTP protocol version */ 374 } tBTA_AV_SDP_RES; 375 376 /* type for SEP control block */ 377 typedef struct 378 { 379 UINT8 av_handle; /* AVDTP handle */ 380 tBTA_AV_CODEC codec_type; /* codec type */ 381 } tBTA_AV_SEP; 382 383 384 /* initiator/acceptor role for adaption */ 385 #define BTA_AV_ROLE_AD_INT 0x00 /* initiator */ 386 #define BTA_AV_ROLE_AD_ACP 0x01 /* acceptor */ 387 388 /* initiator/acceptor signaling roles */ 389 #define BTA_AV_ROLE_START_ACP 0x00 390 #define BTA_AV_ROLE_START_INT 0x10 /* do not change this value */ 391 392 #define BTA_AV_ROLE_SUSPEND 0x20 /* suspending on start */ 393 #define BTA_AV_ROLE_SUSPEND_OPT 0x40 /* Suspend on Start option is set */ 394 395 /* union of all event datatypes */ 396 typedef union 397 { 398 BT_HDR hdr; 399 tBTA_AV_API_ENABLE api_enable; 400 tBTA_AV_API_REG api_reg; 401 tBTA_AV_API_OPEN api_open; 402 tBTA_AV_API_STOP api_stop; 403 tBTA_AV_API_DISCNT api_discnt; 404 tBTA_AV_API_PROTECT_REQ api_protect_req; 405 tBTA_AV_API_PROTECT_RSP api_protect_rsp; 406 tBTA_AV_API_REMOTE_CMD api_remote_cmd; 407 tBTA_AV_API_VENDOR api_vendor; 408 tBTA_AV_API_RCFG api_reconfig; 409 tBTA_AV_CI_SETCONFIG ci_setconfig; 410 tBTA_AV_STR_MSG str_msg; 411 tBTA_AV_RC_MSG rc_msg; 412 tBTA_AV_RC_CONN_CHG rc_conn_chg; 413 tBTA_AV_CONN_CHG conn_chg; 414 tBTA_AV_ROLE_RES role_res; 415 tBTA_AV_SDP_RES sdp_res; 416 tBTA_AV_API_META_RSP api_meta_rsp; 417 } tBTA_AV_DATA; 418 419 typedef void (tBTA_AV_VDP_DATA_ACT)(void *p_scb); 420 421 typedef struct 422 { 423 tBTA_AV_VDP_DATA_ACT *p_act; 424 UINT8 *p_frame; 425 UINT16 buf_size; 426 UINT32 len; 427 UINT32 offset; 428 UINT32 timestamp; 429 } tBTA_AV_VF_INFO; 430 431 typedef union 432 { 433 BUFFER_Q a2d; /* used for audio channels only */ 434 tBTA_AV_VF_INFO vdp; /* used for video channels only */ 435 tBTA_AV_API_OPEN open; /* used only before open and role switch 436 is needed on another AV channel */ 437 } tBTA_AV_Q_INFO; 438 439 #define BTA_AV_Q_TAG_OPEN 0x01 /* after API_OPEN, before STR_OPENED */ 440 #define BTA_AV_Q_TAG_START 0x02 /* before start sending media packets */ 441 #define BTA_AV_Q_TAG_STREAM 0x03 /* during streaming */ 442 443 #define BTA_AV_WAIT_ACP_CAPS_ON 0x01 /* retriving the peer capabilities */ 444 #define BTA_AV_WAIT_ACP_CAPS_STARTED 0x02 /* started while retriving peer capabilities */ 445 #define BTA_AV_WAIT_ROLE_SW_RES_OPEN 0x04 /* waiting for role switch result after API_OPEN, before STR_OPENED */ 446 #define BTA_AV_WAIT_ROLE_SW_RES_START 0x08 /* waiting for role switch result before streaming */ 447 #define BTA_AV_WAIT_ROLE_SW_STARTED 0x10 /* started while waiting for role switch result */ 448 #define BTA_AV_WAIT_ROLE_SW_RETRY 0x20 /* set when retry on timeout */ 449 #define BTA_AV_WAIT_CHECK_RC 0x40 /* set when the timer is used by role switch */ 450 #define BTA_AV_WAIT_ROLE_SW_FAILED 0x80 /* role switch failed */ 451 452 #define BTA_AV_WAIT_ROLE_SW_BITS (BTA_AV_WAIT_ROLE_SW_RES_OPEN|BTA_AV_WAIT_ROLE_SW_RES_START|BTA_AV_WAIT_ROLE_SW_STARTED|BTA_AV_WAIT_ROLE_SW_RETRY) 453 454 /* Bitmap for collision, coll_mask */ 455 #define BTA_AV_COLL_INC_TMR 0x01 /* Timer is running for incoming L2C connection */ 456 #define BTA_AV_COLL_API_CALLED 0x02 /* API open was called while incoming timer is running */ 457 458 /* type for AV stream control block */ 459 typedef struct 460 { 461 const tBTA_AV_ACT *p_act_tbl; /* the action table for stream state machine */ 462 const tBTA_AV_CO_FUNCTS *p_cos; /* the associated callout functions */ 463 tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */ 464 tBTA_AV_SEP seps[BTA_AV_MAX_SEPS]; 465 tAVDT_CFG *p_cap; /* buffer used for get capabilities */ 466 tBTA_AV_Q_INFO q_info; 467 tAVDT_SEP_INFO sep_info[BTA_AV_NUM_SEPS]; /* stream discovery results */ 468 tAVDT_CFG cfg; /* local SEP configuration */ 469 TIMER_LIST_ENT timer; /* delay timer for AVRC CT */ 470 BD_ADDR peer_addr; /* peer BD address */ 471 UINT16 l2c_cid; /* L2CAP channel ID */ 472 UINT16 stream_mtu; /* MTU of stream */ 473 UINT16 avdt_version; /* the avdt version of peer device */ 474 tBTA_SEC sec_mask; /* security mask */ 475 tBTA_AV_CODEC codec_type; /* codec type */ 476 UINT8 media_type; /* Media type */ 477 BOOLEAN cong; /* TRUE if AVDTP congested */ 478 tBTA_AV_STATUS open_status; /* open failure status */ 479 tBTA_AV_CHNL chnl; /* the channel: audio/video */ 480 tBTA_AV_HNDL hndl; /* the handle: ((hdi + 1)|chnl) */ 481 UINT16 cur_psc_mask; /* Protocol service capabilities mask for current connection */ 482 UINT8 avdt_handle; /* AVDTP handle */ 483 UINT8 hdi; /* the index to SCB[] */ 484 UINT8 num_seps; /* number of seps returned by stream discovery */ 485 UINT8 num_disc_snks; /* number of discovered snks */ 486 UINT8 sep_info_idx; /* current index into sep_info */ 487 UINT8 sep_idx; /* current index into local seps[] */ 488 UINT8 rcfg_idx; /* reconfig requested index into sep_info */ 489 UINT8 state; /* state machine state */ 490 UINT8 avdt_label; /* AVDTP label */ 491 UINT8 app_id; /* application id */ 492 UINT8 num_recfg; /* number of reconfigure sent */ 493 UINT8 role; 494 UINT8 l2c_bufs; /* the number of buffers queued to L2CAP */ 495 UINT8 rc_handle; /* connected AVRCP handle */ 496 BOOLEAN use_rc; /* TRUE if AVRCP is allowed */ 497 BOOLEAN started; /* TRUE if stream started */ 498 UINT8 co_started; /* non-zero, if stream started from call-out perspective */ 499 BOOLEAN recfg_sup; /* TRUE if the first attempt to reconfigure the stream was successfull, else False if command fails */ 500 BOOLEAN suspend_sup; /* TRUE if Suspend stream is supported, else FALSE if suspend command fails */ 501 BOOLEAN deregistring; /* TRUE if deregistering */ 502 BOOLEAN sco_suspend; /* TRUE if SUSPEND is issued automatically for SCO */ 503 UINT8 coll_mask; /* Mask to check incoming and outgoing collision */ 504 tBTA_AV_API_OPEN open_api; /* Saved OPEN api message */ 505 UINT8 wait; /* set 0x1, when getting Caps as ACP, set 0x2, when started */ 506 UINT8 q_tag; /* identify the associated q_info union member */ 507 BOOLEAN no_rtp_hdr; /* TRUE if add no RTP header*/ 508 } tBTA_AV_SCB; 509 510 #define BTA_AV_RC_ROLE_MASK 0x10 511 #define BTA_AV_RC_ROLE_INT 0x00 512 #define BTA_AV_RC_ROLE_ACP 0x10 513 514 #define BTA_AV_RC_CONN_MASK 0x20 515 516 /* type for AV RCP control block */ 517 /* index to this control block is the rc handle */ 518 typedef struct 519 { 520 UINT8 status; 521 UINT8 handle; 522 UINT8 shdl; /* stream handle (hdi + 1) */ 523 UINT8 lidx; /* (index+1) to LCB */ 524 tBTA_AV_FEAT peer_features; /* peer features mask */ 525 } tBTA_AV_RCB; 526 #define BTA_AV_NUM_RCB (BTA_AV_NUM_STRS + 2) 527 528 enum 529 { 530 BTA_AV_LCB_FREE, 531 BTA_AV_LCB_FIND 532 }; 533 534 /* type for AV ACL Link control block */ 535 typedef struct 536 { 537 BD_ADDR addr; /* peer BD address */ 538 UINT8 conn_msk; /* handle mask of connected stream handle */ 539 UINT8 lidx; /* index + 1 */ 540 } tBTA_AV_LCB; 541 542 /* type for stream state machine action functions */ 543 typedef void (*tBTA_AV_SACT)(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 544 545 546 /* type for AV control block */ 547 typedef struct 548 { 549 tBTA_AV_SCB *p_scb[BTA_AV_NUM_STRS]; /* stream control block */ 550 tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */ 551 tBTA_AV_CBACK *p_cback; /* application callback function */ 552 tBTA_AV_RCB rcb[BTA_AV_NUM_RCB]; /* RCB control block */ 553 tBTA_AV_LCB lcb[BTA_AV_NUM_LINKS+1]; /* link control block */ 554 TIMER_LIST_ENT sig_tmr; /* link timer */ 555 TIMER_LIST_ENT acp_sig_tmr; /* timer to monitor signalling when accepting */ 556 UINT32 sdp_a2d_handle; /* SDP record handle for audio src */ 557 UINT32 sdp_vdp_handle; /* SDP record handle for video src */ 558 tBTA_AV_FEAT features; /* features mask */ 559 tBTA_SEC sec_mask; /* security mask */ 560 tBTA_AV_HNDL handle; /* the handle for SDP activity */ 561 BOOLEAN disabling; /* TRUE if api disabled called */ 562 UINT8 disc; /* (hdi+1) or (rc_handle|BTA_AV_CHNL_MSK) if p_disc_db is in use */ 563 UINT8 state; /* state machine state */ 564 UINT8 conn_rc; /* handle mask of connected RCP channels */ 565 UINT8 conn_audio; /* handle mask of connected audio channels */ 566 UINT8 conn_video; /* handle mask of connected video channels */ 567 UINT8 conn_lcb; /* index mask of used LCBs */ 568 UINT8 audio_open_cnt; /* number of connected audio channels */ 569 UINT8 reg_audio; /* handle mask of registered audio channels */ 570 UINT8 reg_video; /* handle mask of registered video channels */ 571 UINT8 rc_acp_handle; 572 UINT8 rc_acp_idx; /* (index + 1) to RCB */ 573 UINT8 rs_idx; /* (index + 1) to SCB for the one waiting for RS on open */ 574 BOOLEAN sco_occupied; /* TRUE if SCO is being used or call is in progress */ 575 UINT8 audio_streams; /* handle mask of streaming audio channels */ 576 UINT8 video_streams; /* handle mask of streaming video channels */ 577 } tBTA_AV_CB; 578 579 580 581 /***************************************************************************** 582 ** Global data 583 *****************************************************************************/ 584 585 /* control block declaration */ 586 #if BTA_DYNAMIC_MEMORY == FALSE 587 extern tBTA_AV_CB bta_av_cb; 588 #else 589 extern tBTA_AV_CB *bta_av_cb_ptr; 590 #define bta_av_cb (*bta_av_cb_ptr) 591 #endif 592 593 /* config struct */ 594 extern tBTA_AV_CFG *p_bta_av_cfg; 595 596 /* rc id config struct */ 597 extern UINT16 *p_bta_av_rc_id; 598 extern UINT16 *p_bta_av_rc_id_ac; 599 600 extern const tBTA_AV_SACT bta_av_a2d_action[]; 601 extern const tBTA_AV_CO_FUNCTS bta_av_a2d_cos; 602 extern const tBTA_AV_SACT bta_av_vdp_action[]; 603 extern tAVDT_CTRL_CBACK * const bta_av_dt_cback[]; 604 605 /***************************************************************************** 606 ** Function prototypes 607 *****************************************************************************/ 608 /* utility functions */ 609 extern tBTA_AV_SCB *bta_av_hndl_to_scb(UINT16 handle); 610 extern BOOLEAN bta_av_chk_start(tBTA_AV_SCB *p_scb); 611 extern void bta_av_restore_switch (void); 612 extern UINT16 bta_av_chk_mtu(tBTA_AV_SCB *p_scb, UINT16 mtu); 613 extern void bta_av_conn_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data); 614 extern UINT8 bta_av_rc_create(tBTA_AV_CB *p_cb, UINT8 role, UINT8 shdl, UINT8 lidx); 615 extern void bta_av_proc_stream_evt(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data, int index); 616 extern void bta_av_stream_chg(tBTA_AV_SCB *p_scb, BOOLEAN started); 617 extern BOOLEAN bta_av_is_scb_opening (tBTA_AV_SCB *p_scb); 618 extern BOOLEAN bta_av_is_scb_incoming (tBTA_AV_SCB *p_scb); 619 extern void bta_av_set_scb_sst_init (tBTA_AV_SCB *p_scb); 620 extern BOOLEAN bta_av_is_scb_init (tBTA_AV_SCB *p_scb); 621 extern void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb); 622 extern tBTA_AV_LCB * bta_av_find_lcb(BD_ADDR addr, UINT8 op); 623 624 625 /* main functions */ 626 extern void bta_av_api_deregister(tBTA_AV_DATA *p_data); 627 extern void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf); 628 extern void bta_av_sm_execute(tBTA_AV_CB *p_cb, UINT16 event, tBTA_AV_DATA *p_data); 629 extern void bta_av_ssm_execute(tBTA_AV_SCB *p_scb, UINT16 event, tBTA_AV_DATA *p_data); 630 extern BOOLEAN bta_av_hdl_event(BT_HDR *p_msg); 631 #if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE) 632 extern char *bta_av_evt_code(UINT16 evt_code); 633 #endif 634 extern BOOLEAN bta_av_switch_if_needed(tBTA_AV_SCB *p_scb); 635 extern BOOLEAN bta_av_link_role_ok(tBTA_AV_SCB *p_scb, UINT8 bits); 636 extern BOOLEAN bta_av_is_rcfg_sst(tBTA_AV_SCB *p_scb); 637 638 /* nsm action functions */ 639 extern void bta_av_api_disconnect(tBTA_AV_DATA *p_data); 640 extern void bta_av_sig_chg(tBTA_AV_DATA *p_data); 641 extern void bta_av_sig_timer(tBTA_AV_DATA *p_data); 642 extern void bta_av_rc_disc_done(tBTA_AV_DATA *p_data); 643 extern void bta_av_rc_closed(tBTA_AV_DATA *p_data); 644 extern void bta_av_rc_disc(UINT8 disc); 645 extern void bta_av_conn_chg(tBTA_AV_DATA *p_data); 646 extern void bta_av_dereg_comp(tBTA_AV_DATA *p_data); 647 648 /* sm action functions */ 649 extern void bta_av_disable (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); 650 extern void bta_av_rc_opened (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); 651 extern void bta_av_rc_remote_cmd (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); 652 extern void bta_av_rc_vendor_cmd (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); 653 extern void bta_av_rc_vendor_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); 654 extern void bta_av_rc_msg (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); 655 extern void bta_av_rc_close (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); 656 extern void bta_av_rc_meta_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); 657 extern void bta_av_rc_free_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); 658 extern void bta_av_rc_free_msg (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); 659 660 extern tBTA_AV_RCB * bta_av_get_rcb_by_shdl(UINT8 shdl); 661 extern void bta_av_del_rc(tBTA_AV_RCB *p_rcb); 662 663 /* ssm action functions */ 664 extern void bta_av_do_disc_a2d (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 665 extern void bta_av_cleanup (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 666 extern void bta_av_free_sdb (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 667 extern void bta_av_config_ind (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 668 extern void bta_av_disconnect_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 669 extern void bta_av_security_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 670 extern void bta_av_security_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 671 extern void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 672 extern void bta_av_st_rc_timer(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 673 extern void bta_av_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 674 extern void bta_av_security_ind (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 675 extern void bta_av_security_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 676 extern void bta_av_do_close (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 677 extern void bta_av_connect_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 678 extern void bta_av_sdp_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 679 extern void bta_av_disc_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 680 extern void bta_av_disc_res_as_acp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 681 extern void bta_av_open_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 682 extern void bta_av_getcap_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 683 extern void bta_av_setconfig_rej (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 684 extern void bta_av_discover_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 685 extern void bta_av_conn_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 686 extern void bta_av_do_start (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 687 extern void bta_av_str_stopped (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 688 extern void bta_av_reconfig (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 689 extern void bta_av_data_path (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 690 extern void bta_av_start_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 691 extern void bta_av_start_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 692 extern void bta_av_str_closed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 693 extern void bta_av_clr_cong (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 694 extern void bta_av_suspend_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 695 extern void bta_av_rcfg_str_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 696 extern void bta_av_rcfg_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 697 extern void bta_av_rcfg_connect (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 698 extern void bta_av_rcfg_discntd (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 699 extern void bta_av_suspend_cont (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 700 extern void bta_av_rcfg_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 701 extern void bta_av_rcfg_open (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 702 extern void bta_av_security_rej (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 703 extern void bta_av_open_rc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 704 extern void bta_av_chk_2nd_start (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 705 extern void bta_av_save_caps (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 706 extern void bta_av_rej_conn (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 707 extern void bta_av_rej_conn (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 708 extern void bta_av_set_use_rc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 709 extern void bta_av_cco_close (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 710 extern void bta_av_switch_role (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 711 extern void bta_av_role_res (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 712 extern void bta_av_delay_co (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 713 extern void bta_av_open_at_inc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 714 715 /* ssm action functions - vdp specific */ 716 extern void bta_av_do_disc_vdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 717 extern void bta_av_vdp_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); 718 extern void bta_av_reg_vdp (tAVDT_CS *p_cs, char *p_service_name, void *p_data); 719 720 #endif /* BTA_AV_INT_H */ 721