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