Fork ESP-IDF's bluetooth component
i want better sbc encoding, and no cla will stop me
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,616 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2011-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the implementation of the API for the advanced audio/video (AV)
|
||||
* subsystem of BTA, Broadcom's Bluetooth application layer for mobile
|
||||
* phones.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_av_api.h"
|
||||
#include "bta_av_int.h"
|
||||
#include <string.h>
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
static const tBTA_SYS_REG bta_av_reg = {
|
||||
bta_av_hdl_event,
|
||||
BTA_AvDisable
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvEnable
|
||||
**
|
||||
** Description Enable the advanced audio/video service. When the enable
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_AV_ENABLE_EVT. This function must
|
||||
** be called before other function in the AV API are
|
||||
** called.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features, tBTA_AV_CBACK *p_cback)
|
||||
{
|
||||
tBTA_AV_API_ENABLE *p_buf;
|
||||
|
||||
/* register with BTA system manager */
|
||||
bta_sys_register(BTA_ID_AV, &bta_av_reg);
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_ENABLE *) osi_malloc(sizeof(tBTA_AV_API_ENABLE))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_ENABLE_EVT;
|
||||
p_buf->p_cback = p_cback;
|
||||
p_buf->features = features;
|
||||
p_buf->sec_mask = sec_mask;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvDisable
|
||||
**
|
||||
** Description Disable the advanced audio/video service.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvDisable(void)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
bta_sys_deregister(BTA_ID_AV);
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_AV_API_DISABLE_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvRegister
|
||||
**
|
||||
** Description Register the audio or video service to stack. When the
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_AV_REGISTER_EVT. This function must
|
||||
** be called before AVDT stream is open.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id,
|
||||
tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos,
|
||||
tBTA_AVRC_CO_FUNCTS *bta_avrc_cos, UINT8 tsep)
|
||||
{
|
||||
tBTA_AV_API_REG *p_buf;
|
||||
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_REG *) osi_malloc(sizeof(tBTA_AV_API_REG))) != NULL) {
|
||||
p_buf->hdr.layer_specific = chnl;
|
||||
p_buf->hdr.event = BTA_AV_API_REGISTER_EVT;
|
||||
if (p_service_name) {
|
||||
BCM_STRNCPY_S(p_buf->p_service_name, p_service_name, BTA_SERVICE_NAME_LEN);
|
||||
} else {
|
||||
p_buf->p_service_name[0] = '\0';
|
||||
}
|
||||
p_buf->app_id = app_id;
|
||||
p_buf->p_app_data_cback = p_data_cback;
|
||||
p_buf->bta_av_cos = bta_av_cos;
|
||||
p_buf->bta_avrc_cos = bta_avrc_cos;
|
||||
p_buf->tsep = tsep;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvDeregister
|
||||
**
|
||||
** Description Deregister the audio or video service
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvDeregister(tBTA_AV_HNDL hndl)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->layer_specific = hndl;
|
||||
p_buf->event = BTA_AV_API_DEREGISTER_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvOpen
|
||||
**
|
||||
** Description Opens an advanced audio/video connection to a peer device.
|
||||
** When connection is open callback function is called
|
||||
** with a BTA_AV_OPEN_EVT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, BOOLEAN use_rc, tBTA_SEC sec_mask,
|
||||
UINT16 uuid)
|
||||
{
|
||||
tBTA_AV_API_OPEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_OPEN *) osi_malloc(sizeof(tBTA_AV_API_OPEN))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_OPEN_EVT;
|
||||
p_buf->hdr.layer_specific = handle;
|
||||
bdcpy(p_buf->bd_addr, bd_addr);
|
||||
p_buf->use_rc = use_rc;
|
||||
p_buf->sec_mask = sec_mask;
|
||||
p_buf->switch_res = BTA_AV_RS_NONE;
|
||||
p_buf->uuid = uuid;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvClose
|
||||
**
|
||||
** Description Close the current streams.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvClose(tBTA_AV_HNDL handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_AV_API_CLOSE_EVT;
|
||||
p_buf->layer_specific = handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvDisconnect
|
||||
**
|
||||
** Description Close the connection to the address.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvDisconnect(BD_ADDR bd_addr)
|
||||
{
|
||||
tBTA_AV_API_DISCNT *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_DISCNT *) osi_malloc(sizeof(tBTA_AV_API_DISCNT))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_DISCONNECT_EVT;
|
||||
bdcpy(p_buf->bd_addr, bd_addr);
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvStart
|
||||
**
|
||||
** Description Start audio/video stream data transfer.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvStart(void)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_AV_API_START_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvEnable_Sink
|
||||
**
|
||||
** Description Enable/Disable A2DP Sink..
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvEnable_Sink(int enable)
|
||||
{
|
||||
#if (BTA_AV_SINK_INCLUDED == TRUE)
|
||||
BT_HDR *p_buf;
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_AV_API_SINK_ENABLE_EVT;
|
||||
p_buf->layer_specific = enable;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvStop
|
||||
**
|
||||
** Description Stop audio/video stream data transfer.
|
||||
** If suspend is TRUE, this function sends AVDT suspend signal
|
||||
** to the connected peer(s).
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvStop(BOOLEAN suspend)
|
||||
{
|
||||
tBTA_AV_API_STOP *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_STOP *) osi_malloc(sizeof(tBTA_AV_API_STOP))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_STOP_EVT;
|
||||
p_buf->flush = TRUE;
|
||||
p_buf->suspend = suspend;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvReconfig
|
||||
**
|
||||
** Description Reconfigure the audio/video stream.
|
||||
** If suspend is TRUE, this function tries the suspend/reconfigure
|
||||
** procedure first.
|
||||
** If suspend is FALSE or when suspend/reconfigure fails,
|
||||
** this function closes and re-opens the AVDT connection.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvReconfig(tBTA_AV_HNDL hndl, BOOLEAN suspend, UINT8 sep_info_idx,
|
||||
UINT8 *p_codec_info, UINT8 num_protect, UINT8 *p_protect_info)
|
||||
{
|
||||
tBTA_AV_API_RCFG *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_RCFG *) osi_malloc((UINT16) (sizeof(tBTA_AV_API_RCFG) + num_protect))) != NULL) {
|
||||
p_buf->hdr.layer_specific = hndl;
|
||||
p_buf->hdr.event = BTA_AV_API_RECONFIG_EVT;
|
||||
p_buf->num_protect = num_protect;
|
||||
p_buf->suspend = suspend;
|
||||
p_buf->sep_info_idx = sep_info_idx;
|
||||
memcpy(p_buf->codec_info, p_codec_info, AVDT_CODEC_SIZE);
|
||||
if (p_protect_info && num_protect) {
|
||||
memcpy(p_buf->p_protect_info, p_protect_info, num_protect);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvProtectReq
|
||||
**
|
||||
** Description Send a content protection request. This function can only
|
||||
** be used if AV is enabled with feature BTA_AV_FEAT_PROTECT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvProtectReq(tBTA_AV_HNDL hndl, UINT8 *p_data, UINT16 len)
|
||||
{
|
||||
tBTA_AV_API_PROTECT_REQ *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_PROTECT_REQ *) osi_malloc((UINT16) (sizeof(tBTA_AV_API_PROTECT_REQ) + len))) != NULL) {
|
||||
p_buf->hdr.layer_specific = hndl;
|
||||
p_buf->hdr.event = BTA_AV_API_PROTECT_REQ_EVT;
|
||||
p_buf->len = len;
|
||||
if (p_data == NULL) {
|
||||
p_buf->p_data = NULL;
|
||||
} else {
|
||||
p_buf->p_data = (UINT8 *) (p_buf + 1);
|
||||
memcpy(p_buf->p_data, p_data, len);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvProtectRsp
|
||||
**
|
||||
** Description Send a content protection response. This function must
|
||||
** be called if a BTA_AV_PROTECT_REQ_EVT is received.
|
||||
** This function can only be used if AV is enabled with
|
||||
** feature BTA_AV_FEAT_PROTECT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, UINT8 error_code, UINT8 *p_data, UINT16 len)
|
||||
{
|
||||
tBTA_AV_API_PROTECT_RSP *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_PROTECT_RSP *) osi_malloc((UINT16) (sizeof(tBTA_AV_API_PROTECT_RSP) + len))) != NULL) {
|
||||
p_buf->hdr.layer_specific = hndl;
|
||||
p_buf->hdr.event = BTA_AV_API_PROTECT_RSP_EVT;
|
||||
p_buf->len = len;
|
||||
p_buf->error_code = error_code;
|
||||
if (p_data == NULL) {
|
||||
p_buf->p_data = NULL;
|
||||
} else {
|
||||
p_buf->p_data = (UINT8 *) (p_buf + 1);
|
||||
memcpy(p_buf->p_data, p_data, len);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_SetDelayValue
|
||||
**
|
||||
** Description Set delay report value
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_SetDelayValue(UINT16 delay_value)
|
||||
{
|
||||
tBTA_AV_API_SET_DELAY_VALUE *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_SET_DELAY_VALUE *) osi_malloc(sizeof(tBTA_AV_API_SET_DELAY_VALUE))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_SET_DELAY_VALUE_EVT;
|
||||
p_buf->delay_value = delay_value;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GetDelayValue
|
||||
**
|
||||
** Description Get delay report value
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_GetDelayValue(void)
|
||||
{
|
||||
tBTA_AV_API_GET_DELAY_VALUE *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_GET_DELAY_VALUE *) osi_malloc(sizeof(tBTA_AV_API_GET_DELAY_VALUE))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_GET_DELAY_VALUE_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvRemoteCmd
|
||||
**
|
||||
** Description Send a remote control command. This function can only
|
||||
** be used if AV is enabled with feature BTA_AV_FEAT_RCCT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvRemoteCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_RC rc_id, tBTA_AV_STATE key_state)
|
||||
{
|
||||
tBTA_AV_API_REMOTE_CMD *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_REMOTE_CMD *) osi_malloc(sizeof(tBTA_AV_API_REMOTE_CMD))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_REMOTE_CMD_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
p_buf->msg.op_id = rc_id;
|
||||
p_buf->msg.state = key_state;
|
||||
p_buf->msg.p_pass_data = NULL;
|
||||
p_buf->msg.pass_len = 0;
|
||||
p_buf->label = label;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvVendorCmd
|
||||
**
|
||||
** Description Send a vendor dependent remote control command. This
|
||||
** function can only be used if AV is enabled with feature
|
||||
** BTA_AV_FEAT_VENDOR.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code, UINT8 *p_data, UINT16 len)
|
||||
{
|
||||
tBTA_AV_API_VENDOR *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_VENDOR *) osi_malloc((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_VENDOR_CMD_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
p_buf->msg.hdr.ctype = cmd_code;
|
||||
p_buf->msg.hdr.subunit_type = AVRC_SUB_PANEL;
|
||||
p_buf->msg.hdr.subunit_id = 0;
|
||||
p_buf->msg.company_id = p_bta_av_cfg->company_id;
|
||||
p_buf->label = label;
|
||||
p_buf->msg.vendor_len = len;
|
||||
if (p_data == NULL) {
|
||||
p_buf->msg.p_vendor_data = NULL;
|
||||
} else {
|
||||
p_buf->msg.p_vendor_data = (UINT8 *) (p_buf + 1);
|
||||
memcpy(p_buf->msg.p_vendor_data, p_data, len);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvVendorRsp
|
||||
**
|
||||
** Description Send a vendor dependent remote control response.
|
||||
** This function must be called if a BTA_AV_VENDOR_CMD_EVT
|
||||
** is received. This function can only be used if AV is
|
||||
** enabled with feature BTA_AV_FEAT_VENDOR.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvVendorRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code, UINT8 *p_data, UINT16 len, UINT32 company_id)
|
||||
{
|
||||
tBTA_AV_API_VENDOR *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_VENDOR *) osi_malloc((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_VENDOR_RSP_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
p_buf->msg.hdr.ctype = rsp_code;
|
||||
p_buf->msg.hdr.subunit_type = AVRC_SUB_PANEL;
|
||||
p_buf->msg.hdr.subunit_id = 0;
|
||||
if (company_id) {
|
||||
p_buf->msg.company_id = company_id;
|
||||
} else {
|
||||
p_buf->msg.company_id = p_bta_av_cfg->company_id;
|
||||
}
|
||||
p_buf->label = label;
|
||||
p_buf->msg.vendor_len = len;
|
||||
if (p_data == NULL) {
|
||||
p_buf->msg.p_vendor_data = NULL;
|
||||
} else {
|
||||
p_buf->msg.p_vendor_data = (UINT8 *) (p_buf + 1);
|
||||
memcpy(p_buf->msg.p_vendor_data, p_data, len);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvOpenRc
|
||||
**
|
||||
** Description Open an AVRCP connection toward the device with the
|
||||
** specified handle
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvOpenRc(tBTA_AV_HNDL handle)
|
||||
{
|
||||
tBTA_AV_API_OPEN_RC *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_OPEN_RC *) osi_malloc(sizeof(tBTA_AV_API_OPEN_RC))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_RC_OPEN_EVT;
|
||||
p_buf->hdr.layer_specific = handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvCloseRc
|
||||
**
|
||||
** Description Close an AVRCP connection
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvCloseRc(UINT8 rc_handle)
|
||||
{
|
||||
tBTA_AV_API_CLOSE_RC *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_CLOSE_RC *) osi_malloc(sizeof(tBTA_AV_API_CLOSE_RC))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_RC_CLOSE_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvMetaRsp
|
||||
**
|
||||
** Description Send a Metadata/Advanced Control response. The message contained
|
||||
** in p_pkt can be composed with AVRC utility functions.
|
||||
** This function can only be used if AV is enabled with feature
|
||||
** BTA_AV_FEAT_METADATA.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
|
||||
BT_HDR *p_pkt)
|
||||
{
|
||||
tBTA_AV_API_META_RSP *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_META_RSP *) osi_malloc((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
p_buf->rsp_code = rsp_code;
|
||||
p_buf->p_pkt = p_pkt;
|
||||
p_buf->is_rsp = TRUE;
|
||||
p_buf->label = label;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
} else if (p_pkt) {
|
||||
osi_free(p_pkt);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvMetaCmd
|
||||
**
|
||||
** Description Send a Metadata/Advanced Control command. The message contained
|
||||
** in p_pkt can be composed with AVRC utility functions.
|
||||
** This function can only be used if AV is enabled with feature
|
||||
** BTA_AV_FEAT_METADATA.
|
||||
** This message is sent only when the peer supports the TG role.
|
||||
*8 The only command makes sense right now is the absolute volume command.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p_pkt)
|
||||
{
|
||||
tBTA_AV_API_META_RSP *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_META_RSP *) osi_malloc((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
p_buf->p_pkt = p_pkt;
|
||||
p_buf->rsp_code = cmd_code;
|
||||
p_buf->is_rsp = FALSE;
|
||||
p_buf->label = label;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BTA_AV_INCLUDED */
|
||||
@@ -0,0 +1,110 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains compile-time configurable constants for advanced
|
||||
* audio/video
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta_av_int.h"
|
||||
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
#ifndef BTA_AV_RC_PASS_RSP_CODE
|
||||
#define BTA_AV_RC_PASS_RSP_CODE BTA_AV_RSP_NOT_IMPL
|
||||
#endif
|
||||
|
||||
const UINT32 bta_av_meta_caps_co_ids[] = {
|
||||
AVRC_CO_METADATA,
|
||||
AVRC_CO_BROADCOM
|
||||
};
|
||||
|
||||
/* AVRCP supported categories */
|
||||
#define BTA_AV_RC_SNK_SUPF_CT (AVRC_SUPF_CT_CAT1)
|
||||
#define BTA_AV_RC_SRC_SUPF_CT (AVRC_SUPF_CT_CAT2)
|
||||
|
||||
|
||||
/* Added to modify
|
||||
** 1. flush timeout
|
||||
** 2. Remove Group navigation support in SupportedFeatures
|
||||
** 3. GetCapabilities supported event_ids list
|
||||
** 4. GetCapabilities supported event_ids count
|
||||
*/
|
||||
/* Flushing partial avdtp packets can cause some headsets to disconnect the link
|
||||
if receiving partial a2dp frames */
|
||||
const UINT16 bta_av_audio_flush_to[] = {
|
||||
0, /* 1 stream */
|
||||
0, /* 2 streams */
|
||||
0, /* 3 streams */
|
||||
0, /* 4 streams */
|
||||
0 /* 5 streams */
|
||||
}; /* AVDTP audio transport channel flush timeout */
|
||||
|
||||
/* Note: Android doesnt support AVRC_SUPF_TG_GROUP_NAVI */
|
||||
/* Note: if AVRC_SUPF_TG_GROUP_NAVI is set, bta_av_cfg.avrc_group should be TRUE */
|
||||
#if AVRC_METADATA_INCLUDED == TRUE
|
||||
#define BTA_AV_RC_SNK_SUPF_TG (AVRC_SUPF_TG_CAT2) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */
|
||||
#define BTA_AV_RC_SRC_SUPF_TG (AVRC_SUPF_TG_CAT1) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */
|
||||
#else
|
||||
#define BTA_AV_RC_SNK_SUPF_TG (AVRC_SUPF_TG_CAT2)
|
||||
#define BTA_AV_RC_SRC_SUPF_TG (AVRC_SUPF_TG_CAT1)
|
||||
#endif
|
||||
|
||||
/* the MTU for the AVRCP browsing channel */
|
||||
#ifndef BTA_AV_MAX_RC_BR_MTU
|
||||
#define BTA_AV_MAX_RC_BR_MTU 1008
|
||||
#endif
|
||||
|
||||
const tBTA_AV_CFG bta_av_cfg = {
|
||||
AVRC_CO_BROADCOM, /* AVRCP Company ID */
|
||||
#if AVRC_METADATA_INCLUDED == TRUE
|
||||
512, /* AVRCP MTU at L2CAP for control channel */
|
||||
#else
|
||||
48, /* AVRCP MTU at L2CAP for control channel */
|
||||
#endif
|
||||
BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */
|
||||
BTA_AV_RC_SNK_SUPF_CT, /* AVRCP controller categories as SNK */
|
||||
BTA_AV_RC_SNK_SUPF_TG, /* AVRCP target categories as SNK */
|
||||
BTA_AV_RC_SRC_SUPF_CT, /* AVRCP controller categories as SRC */
|
||||
BTA_AV_RC_SRC_SUPF_TG, /* AVRCP target categories as SRC */
|
||||
672, /* AVDTP signaling channel MTU at L2CAP */
|
||||
BTA_AV_MAX_A2DP_MTU, /* AVDTP audio transport channel MTU at L2CAP */
|
||||
bta_av_audio_flush_to, /* AVDTP audio transport channel flush timeout */
|
||||
6, /* AVDTP audio channel max data queue size */
|
||||
BTA_AV_MAX_VDP_MTU, /* AVDTP video transport channel MTU at L2CAP */
|
||||
600, /* AVDTP video transport channel flush timeout */
|
||||
FALSE, /* TRUE, to accept AVRC 1.3 group nevigation command */
|
||||
FALSE, /* FALSE, does not support browsing channel */
|
||||
2, /* company id count in p_meta_co_ids */
|
||||
BTA_AV_RC_PASS_RSP_CODE,/* the default response code for pass through commands */
|
||||
bta_av_meta_caps_co_ids,/* the metadata Get Capabilities response for company id */
|
||||
NULL, /* the action function table for VDP stream */
|
||||
NULL, /* action function to register VDP */
|
||||
{0}, /* Default AVRCP controller name */
|
||||
{0}, /* Default AVRCP target name */
|
||||
};
|
||||
|
||||
tBTA_AV_CFG *p_bta_av_cfg = (tBTA_AV_CFG *) &bta_av_cfg;
|
||||
|
||||
#endif /* if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE) */
|
||||
@@ -0,0 +1,94 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the implementation file for advanced audio/video call-in
|
||||
* functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta_av_int.h"
|
||||
#include "bta/bta_av_ci.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_ci_src_data_ready
|
||||
**
|
||||
** Description This function sends an event to the AV indicating that
|
||||
** the phone has audio stream data ready to send and AV
|
||||
** should call bta_av_co_audio_src_data_path() or
|
||||
** bta_av_co_video_src_data_path().
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->layer_specific = chnl;
|
||||
p_buf->event = BTA_AV_CI_SRC_DATA_READY_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_ci_setconfig
|
||||
**
|
||||
** Description This function must be called in response to function
|
||||
** bta_av_co_audio_setconfig() or bta_av_co_video_setconfig.
|
||||
** Parameter err_code is set to an AVDTP status value;
|
||||
** AVDT_SUCCESS if the codec configuration is ok,
|
||||
** otherwise error.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, UINT8 category,
|
||||
UINT8 num_seid, UINT8 *p_seid, BOOLEAN recfg_needed, UINT8 avdt_handle)
|
||||
{
|
||||
tBTA_AV_CI_SETCONFIG *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_CI_SETCONFIG *) osi_malloc(sizeof(tBTA_AV_CI_SETCONFIG) + num_seid)) != NULL) {
|
||||
p_buf->hdr.layer_specific = hndl;
|
||||
p_buf->hdr.event = (err_code == AVDT_SUCCESS) ?
|
||||
BTA_AV_CI_SETCONFIG_OK_EVT : BTA_AV_CI_SETCONFIG_FAIL_EVT;
|
||||
p_buf->err_code = err_code;
|
||||
p_buf->category = category;
|
||||
p_buf->recfg_needed = recfg_needed;
|
||||
p_buf->avdt_handle = avdt_handle;
|
||||
p_buf->num_seid = num_seid;
|
||||
if (p_seid && num_seid) {
|
||||
memcpy(p_buf->p_seid, p_seid, num_seid);
|
||||
}
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* #if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE) */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,603 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2004-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This module contains utility functions for dealing with SBC data frames
|
||||
* and codec capabilities.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "stack/a2d_api.h"
|
||||
#include "stack/a2d_sbc.h"
|
||||
#include "bta/bta_av_sbc.h"
|
||||
#include "bta/utl.h"
|
||||
#include "common/bt_defs.h"
|
||||
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
#include "bta_av_int.h"
|
||||
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
static tBTA_AV_SBC_UPS_CB bta_av_sbc_ups_cb;
|
||||
#else
|
||||
tBTA_AV_SBC_UPS_CB *bta_av_sbc_ups_cb_ptr;
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_init_up_sample
|
||||
**
|
||||
** Description initialize the up sample
|
||||
**
|
||||
** src_sps: samples per second (source audio data)
|
||||
** dst_sps: samples per second (converted audio data)
|
||||
** bits: number of bits per pcm sample
|
||||
** n_channels: number of channels (i.e. mono(1), stereo(2)...)
|
||||
**
|
||||
** Returns none
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_sbc_init_up_sample (UINT32 src_sps, UINT32 dst_sps, UINT16 bits, UINT16 n_channels)
|
||||
{
|
||||
bta_av_sbc_ups_cb.cur_pos = -1;
|
||||
bta_av_sbc_ups_cb.src_sps = src_sps;
|
||||
bta_av_sbc_ups_cb.dst_sps = dst_sps;
|
||||
bta_av_sbc_ups_cb.bits = bits;
|
||||
bta_av_sbc_ups_cb.n_channels = n_channels;
|
||||
|
||||
if (n_channels == 1) {
|
||||
/* mono */
|
||||
if (bits == 8) {
|
||||
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_8m;
|
||||
bta_av_sbc_ups_cb.div = 1;
|
||||
} else {
|
||||
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_16m;
|
||||
bta_av_sbc_ups_cb.div = 2;
|
||||
}
|
||||
} else {
|
||||
/* stereo */
|
||||
if (bits == 8) {
|
||||
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_8s;
|
||||
bta_av_sbc_ups_cb.div = 2;
|
||||
} else {
|
||||
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_16s;
|
||||
bta_av_sbc_ups_cb.div = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (number of bytes)
|
||||
** dst_samples: The size of p_dst (number of bytes)
|
||||
**
|
||||
** Note: An AE reported an issue with this function.
|
||||
** When called with bta_av_sbc_up_sample(src, uint8_array_dst..)
|
||||
** the byte before uint8_array_dst may get overwritten.
|
||||
** Using uint16_array_dst avoids the problem.
|
||||
** This issue is related to endian-ness and is hard to resolve
|
||||
** in a generic manner.
|
||||
** **************** Please use uint16 array as dst.
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
int bta_av_sbc_up_sample (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret)
|
||||
{
|
||||
UINT32 src;
|
||||
UINT32 dst;
|
||||
|
||||
if (bta_av_sbc_ups_cb.p_act) {
|
||||
src = src_samples / bta_av_sbc_ups_cb.div;
|
||||
dst = dst_samples / bta_av_sbc_ups_cb.div;
|
||||
return (*bta_av_sbc_ups_cb.p_act)(p_src, p_dst, src, dst, p_ret);
|
||||
} else {
|
||||
*p_ret = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_16s (16bits-stereo)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (in uint of 4 bytes)
|
||||
** dst_samples: The size of p_dst (in uint of 4 bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
int bta_av_sbc_up_sample_16s (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret)
|
||||
{
|
||||
INT16 *p_src_tmp = (INT16 *)p_src;
|
||||
INT16 *p_dst_tmp = (INT16 *)p_dst;
|
||||
INT16 *p_worker1 = &bta_av_sbc_ups_cb.worker1;
|
||||
INT16 *p_worker2 = &bta_av_sbc_ups_cb.worker2;
|
||||
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
|
||||
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
|
||||
|
||||
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
|
||||
*p_dst_tmp++ = *p_worker1;
|
||||
*p_dst_tmp++ = *p_worker2;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
}
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos = dst_sps;
|
||||
|
||||
while (src_samples-- && dst_samples) {
|
||||
*p_worker1 = *p_src_tmp++;
|
||||
*p_worker2 = *p_src_tmp++;
|
||||
|
||||
do {
|
||||
*p_dst_tmp++ = *p_worker1;
|
||||
*p_dst_tmp++ = *p_worker2;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
} while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples);
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos += dst_sps;
|
||||
}
|
||||
|
||||
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
|
||||
bta_av_sbc_ups_cb.cur_pos = 0;
|
||||
}
|
||||
|
||||
*p_ret = ((char *)p_src_tmp - (char *)p_src);
|
||||
return ((char *)p_dst_tmp - (char *)p_dst);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_16m (16bits-mono)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (in uint of 2 bytes)
|
||||
** dst_samples: The size of p_dst (in uint of 2 bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
int bta_av_sbc_up_sample_16m (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret)
|
||||
{
|
||||
INT16 *p_src_tmp = (INT16 *)p_src;
|
||||
INT16 *p_dst_tmp = (INT16 *)p_dst;
|
||||
INT16 *p_worker = &bta_av_sbc_ups_cb.worker1;
|
||||
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
|
||||
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
|
||||
|
||||
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
dst_samples--;
|
||||
}
|
||||
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos = dst_sps;
|
||||
|
||||
while (src_samples-- && dst_samples) {
|
||||
*p_worker = *p_src_tmp++;
|
||||
|
||||
do {
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
dst_samples--;
|
||||
|
||||
} while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples);
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos += dst_sps;
|
||||
}
|
||||
|
||||
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
|
||||
bta_av_sbc_ups_cb.cur_pos = 0;
|
||||
}
|
||||
|
||||
*p_ret = ((char *)p_src_tmp - (char *)p_src);
|
||||
return ((char *)p_dst_tmp - (char *)p_dst);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_8s (8bits-stereo)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (in uint of 2 bytes)
|
||||
** dst_samples: The size of p_dst (in uint of 2 bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret)
|
||||
{
|
||||
UINT8 *p_src_tmp = (UINT8 *)p_src;
|
||||
INT16 *p_dst_tmp = (INT16 *)p_dst;
|
||||
INT16 *p_worker1 = &bta_av_sbc_ups_cb.worker1;
|
||||
INT16 *p_worker2 = &bta_av_sbc_ups_cb.worker2;
|
||||
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
|
||||
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
|
||||
|
||||
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
|
||||
*p_dst_tmp++ = *p_worker1;
|
||||
*p_dst_tmp++ = *p_worker2;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
dst_samples--;
|
||||
}
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos = dst_sps;
|
||||
|
||||
while (src_samples -- && dst_samples) {
|
||||
*p_worker1 = *(UINT8 *)p_src_tmp++;
|
||||
*p_worker1 -= 0x80;
|
||||
*p_worker1 <<= 8;
|
||||
*p_worker2 = *(UINT8 *)p_src_tmp++;
|
||||
*p_worker2 -= 0x80;
|
||||
*p_worker2 <<= 8;
|
||||
|
||||
do {
|
||||
*p_dst_tmp++ = *p_worker1;
|
||||
*p_dst_tmp++ = *p_worker2;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
dst_samples--;
|
||||
} while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples);
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos += dst_sps;
|
||||
}
|
||||
|
||||
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
|
||||
bta_av_sbc_ups_cb.cur_pos = 0;
|
||||
}
|
||||
|
||||
*p_ret = ((char *)p_src_tmp - (char *)p_src);
|
||||
return ((char *)p_dst_tmp - (char *)p_dst);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_8m (8bits-mono)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (number of bytes)
|
||||
** dst_samples: The size of p_dst (number of bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
int bta_av_sbc_up_sample_8m (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret)
|
||||
{
|
||||
UINT8 *p_src_tmp = (UINT8 *)p_src;
|
||||
INT16 *p_dst_tmp = (INT16 *)p_dst;
|
||||
INT16 *p_worker = &bta_av_sbc_ups_cb.worker1;
|
||||
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
|
||||
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
|
||||
|
||||
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples -= 4;
|
||||
}
|
||||
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos = dst_sps;
|
||||
|
||||
while (src_samples-- && dst_samples) {
|
||||
*p_worker = *(UINT8 *)p_src_tmp++;
|
||||
*p_worker -= 0x80;
|
||||
*p_worker <<= 8;
|
||||
|
||||
do {
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples -= 4;
|
||||
|
||||
} while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples);
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos += dst_sps;
|
||||
}
|
||||
|
||||
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
|
||||
bta_av_sbc_ups_cb.cur_pos = 0;
|
||||
}
|
||||
|
||||
*p_ret = ((char *)p_src_tmp - (char *)p_src);
|
||||
return ((char *)p_dst_tmp - (char *)p_dst);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_cfg_for_cap
|
||||
**
|
||||
** Description Determine the preferred SBC codec configuration for the
|
||||
** given codec capabilities. The function is passed the
|
||||
** preferred codec configuration and the peer codec
|
||||
** capabilities for the stream. The function attempts to
|
||||
** match the preferred capabilities with the configuration
|
||||
** as best it can. The resulting codec configuration is
|
||||
** returned in the same memory used for the capabilities.
|
||||
**
|
||||
** Returns 0 if ok, nonzero if error.
|
||||
** Codec configuration in p_cap.
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 bta_av_sbc_cfg_for_cap(UINT8 *p_peer, tA2D_SBC_CIE *p_cap, tA2D_SBC_CIE *p_pref)
|
||||
{
|
||||
UINT8 status = A2D_SUCCESS;
|
||||
tA2D_SBC_CIE peer_cie;
|
||||
UNUSED(p_cap);
|
||||
|
||||
/* parse peer capabilities */
|
||||
if ((status = A2D_ParsSbcInfo(&peer_cie, p_peer, TRUE)) != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Check if the peer supports our channel mode */
|
||||
if (peer_cie.ch_mode & p_pref->ch_mode) {
|
||||
peer_cie.ch_mode = p_pref->ch_mode;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: ch_mode(0x%02X) not supported", p_pref->ch_mode);
|
||||
return A2D_FAIL;
|
||||
}
|
||||
|
||||
/* Check if the peer supports our sampling freq */
|
||||
if (peer_cie.samp_freq & p_pref->samp_freq) {
|
||||
peer_cie.samp_freq = p_pref->samp_freq;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: samp_freq(0x%02X) not supported", p_pref->samp_freq);
|
||||
return A2D_FAIL;
|
||||
}
|
||||
|
||||
/* Check if the peer supports our block len */
|
||||
if (peer_cie.block_len & p_pref->block_len) {
|
||||
peer_cie.block_len = p_pref->block_len;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: block_len(0x%02X) not supported", p_pref->block_len);
|
||||
return A2D_FAIL;
|
||||
}
|
||||
|
||||
/* Check if the peer supports our num subbands */
|
||||
if (peer_cie.num_subbands & p_pref->num_subbands) {
|
||||
peer_cie.num_subbands = p_pref->num_subbands;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: num_subbands(0x%02X) not supported", p_pref->num_subbands);
|
||||
return A2D_FAIL;
|
||||
}
|
||||
|
||||
/* Check if the peer supports our alloc method */
|
||||
if (peer_cie.alloc_mthd & p_pref->alloc_mthd) {
|
||||
peer_cie.alloc_mthd = p_pref->alloc_mthd;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: alloc_mthd(0x%02X) not supported", p_pref->alloc_mthd);
|
||||
return A2D_FAIL;
|
||||
}
|
||||
|
||||
/* max bitpool */
|
||||
if (p_pref->max_bitpool != 0 && p_pref->max_bitpool < peer_cie.max_bitpool) {
|
||||
peer_cie.max_bitpool = p_pref->max_bitpool;
|
||||
}
|
||||
|
||||
/* min bitpool */
|
||||
if (p_pref->min_bitpool != 0 && p_pref->min_bitpool > peer_cie.min_bitpool) {
|
||||
peer_cie.min_bitpool = p_pref->min_bitpool;
|
||||
}
|
||||
|
||||
if (status == A2D_SUCCESS) {
|
||||
/* build configuration */
|
||||
A2D_BldSbcInfo(A2D_MEDIA_TYPE_AUDIO, &peer_cie, p_peer);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_cfg_matches_cap
|
||||
**
|
||||
** Description This function checks whether an SBC codec configuration
|
||||
** matched with capabilities. Here we check subset.
|
||||
**
|
||||
** Returns 0 if ok, nonzero if error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap)
|
||||
{
|
||||
UINT8 status = 0;
|
||||
tA2D_SBC_CIE cfg_cie;
|
||||
|
||||
/* parse configuration */
|
||||
if ((status = A2D_ParsSbcInfo(&cfg_cie, p_cfg, TRUE)) != 0) {
|
||||
APPL_TRACE_ERROR(" bta_av_sbc_cfg_matches_cap Parsing Failed %d", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* verify that each parameter is in range */
|
||||
|
||||
APPL_TRACE_DEBUG(" FREQ peer: 0%x, capability 0%x", cfg_cie.samp_freq, p_cap->samp_freq);
|
||||
APPL_TRACE_DEBUG(" CH_MODE peer: 0%x, capability 0%x", cfg_cie.ch_mode, p_cap->ch_mode);
|
||||
APPL_TRACE_DEBUG(" BLOCK_LEN peer: 0%x, capability 0%x", cfg_cie.block_len, p_cap->block_len);
|
||||
APPL_TRACE_DEBUG(" SUB_BAND peer: 0%x, capability 0%x", cfg_cie.num_subbands, p_cap->num_subbands);
|
||||
APPL_TRACE_DEBUG(" ALLOC_MTHD peer: 0%x, capability 0%x", cfg_cie.alloc_mthd, p_cap->alloc_mthd);
|
||||
APPL_TRACE_DEBUG(" MAX_BitPool peer: 0%x, capability 0%x", cfg_cie.max_bitpool, p_cap->max_bitpool);
|
||||
APPL_TRACE_DEBUG(" Min_bitpool peer: 0%x, capability 0%x", cfg_cie.min_bitpool, p_cap->min_bitpool);
|
||||
|
||||
/* sampling frequency */
|
||||
if ((cfg_cie.samp_freq & p_cap->samp_freq) == 0) {
|
||||
status = A2D_NS_SAMP_FREQ;
|
||||
}
|
||||
/* channel mode */
|
||||
else if ((cfg_cie.ch_mode & p_cap->ch_mode) == 0) {
|
||||
status = A2D_NS_CH_MODE;
|
||||
}
|
||||
/* block length */
|
||||
else if ((cfg_cie.block_len & p_cap->block_len) == 0) {
|
||||
status = A2D_BAD_BLOCK_LEN;
|
||||
}
|
||||
/* subbands */
|
||||
else if ((cfg_cie.num_subbands & p_cap->num_subbands) == 0) {
|
||||
status = A2D_NS_SUBBANDS;
|
||||
}
|
||||
/* allocation method */
|
||||
else if ((cfg_cie.alloc_mthd & p_cap->alloc_mthd) == 0) {
|
||||
status = A2D_NS_ALLOC_MTHD;
|
||||
}
|
||||
/* max bitpool */
|
||||
else if (cfg_cie.max_bitpool > p_cap->max_bitpool) {
|
||||
status = A2D_NS_MAX_BITPOOL;
|
||||
}
|
||||
/* min bitpool */
|
||||
else if (cfg_cie.min_bitpool < p_cap->min_bitpool) {
|
||||
status = A2D_NS_MIN_BITPOOL;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_cfg_in_cap
|
||||
**
|
||||
** Description This function checks whether an SBC codec configuration
|
||||
** is allowable for the given codec capabilities.
|
||||
**
|
||||
** Returns 0 if ok, nonzero if error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 bta_av_sbc_cfg_in_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap)
|
||||
{
|
||||
UINT8 status = 0;
|
||||
tA2D_SBC_CIE cfg_cie;
|
||||
|
||||
/* parse configuration */
|
||||
if ((status = A2D_ParsSbcInfo(&cfg_cie, p_cfg, FALSE)) != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* verify that each parameter is in range */
|
||||
|
||||
|
||||
/* sampling frequency */
|
||||
if ((cfg_cie.samp_freq & p_cap->samp_freq) == 0) {
|
||||
status = A2D_NS_SAMP_FREQ;
|
||||
}
|
||||
/* channel mode */
|
||||
else if ((cfg_cie.ch_mode & p_cap->ch_mode) == 0) {
|
||||
status = A2D_NS_CH_MODE;
|
||||
}
|
||||
/* block length */
|
||||
else if ((cfg_cie.block_len & p_cap->block_len) == 0) {
|
||||
status = A2D_BAD_BLOCK_LEN;
|
||||
}
|
||||
/* subbands */
|
||||
else if ((cfg_cie.num_subbands & p_cap->num_subbands) == 0) {
|
||||
status = A2D_NS_SUBBANDS;
|
||||
}
|
||||
/* allocation method */
|
||||
else if ((cfg_cie.alloc_mthd & p_cap->alloc_mthd) == 0) {
|
||||
status = A2D_NS_ALLOC_MTHD;
|
||||
}
|
||||
/* max bitpool */
|
||||
else if (cfg_cie.max_bitpool > p_cap->max_bitpool) {
|
||||
status = A2D_NS_MAX_BITPOOL;
|
||||
}
|
||||
/* min bitpool */
|
||||
else if (cfg_cie.min_bitpool < p_cap->min_bitpool) {
|
||||
status = A2D_NS_MIN_BITPOOL;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_bld_hdr
|
||||
**
|
||||
** Description This function builds the packet header for MPF1.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_sbc_bld_hdr(BT_HDR *p_buf, UINT16 fr_per_pkt)
|
||||
{
|
||||
UINT8 *p;
|
||||
|
||||
p_buf->offset -= BTA_AV_SBC_HDR_SIZE;
|
||||
p = (UINT8 *) (p_buf + 1) + p_buf->offset;
|
||||
p_buf->len += BTA_AV_SBC_HDR_SIZE;
|
||||
A2D_BldSbcMplHdr(p, FALSE, FALSE, FALSE, (UINT8) fr_per_pkt);
|
||||
}
|
||||
|
||||
#endif /* #if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE) */
|
||||
@@ -0,0 +1,580 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2004-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the stream state machine for the BTA advanced audio/video.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "bta/bta_av_co.h"
|
||||
#include "bta_av_int.h"
|
||||
#include "osi/osi.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and types
|
||||
*****************************************************************************/
|
||||
|
||||
/* state machine states */
|
||||
enum {
|
||||
BTA_AV_INIT_SST,
|
||||
BTA_AV_INCOMING_SST,
|
||||
BTA_AV_OPENING_SST,
|
||||
BTA_AV_OPEN_SST,
|
||||
BTA_AV_RCFG_SST,
|
||||
BTA_AV_CLOSING_SST
|
||||
};
|
||||
|
||||
|
||||
/* state machine action enumeration list */
|
||||
enum {
|
||||
BTA_AV_DO_DISC,
|
||||
BTA_AV_CLEANUP,
|
||||
BTA_AV_FREE_SDB,
|
||||
BTA_AV_CONFIG_IND,
|
||||
BTA_AV_DISCONNECT_REQ,
|
||||
BTA_AV_SECURITY_REQ,
|
||||
BTA_AV_SECURITY_RSP,
|
||||
BTA_AV_SETCONFIG_RSP,
|
||||
BTA_AV_ST_RC_TIMER,
|
||||
BTA_AV_STR_OPENED,
|
||||
BTA_AV_SECURITY_IND,
|
||||
BTA_AV_SECURITY_CFM,
|
||||
BTA_AV_DO_CLOSE,
|
||||
BTA_AV_CONNECT_REQ,
|
||||
BTA_AV_SDP_FAILED,
|
||||
BTA_AV_DISC_RESULTS,
|
||||
BTA_AV_DISC_RES_AS_ACP,
|
||||
BTA_AV_OPEN_FAILED,
|
||||
BTA_AV_GETCAP_RESULTS,
|
||||
BTA_AV_SETCONFIG_REJ,
|
||||
BTA_AV_DISCOVER_REQ,
|
||||
BTA_AV_CONN_FAILED,
|
||||
BTA_AV_DO_START,
|
||||
BTA_AV_STR_STOPPED,
|
||||
BTA_AV_RECONFIG,
|
||||
BTA_AV_DATA_PATH,
|
||||
BTA_AV_START_OK,
|
||||
BTA_AV_START_FAILED,
|
||||
BTA_AV_STR_CLOSED,
|
||||
BTA_AV_CLR_CONG,
|
||||
BTA_AV_SUSPEND_CFM,
|
||||
BTA_AV_RCFG_STR_OK,
|
||||
BTA_AV_RCFG_FAILED,
|
||||
BTA_AV_RCFG_CONNECT,
|
||||
BTA_AV_RCFG_DISCNTD,
|
||||
BTA_AV_SUSPEND_CONT,
|
||||
BTA_AV_RCFG_CFM,
|
||||
BTA_AV_RCFG_OPEN,
|
||||
BTA_AV_SECURITY_REJ,
|
||||
BTA_AV_OPEN_RC,
|
||||
BTA_AV_CHK_2ND_START,
|
||||
BTA_AV_SAVE_CAPS,
|
||||
BTA_AV_SET_USE_RC,
|
||||
BTA_AV_CCO_CLOSE,
|
||||
BTA_AV_SWITCH_ROLE,
|
||||
BTA_AV_ROLE_RES,
|
||||
BTA_AV_DELAY_CO,
|
||||
BTA_AV_OPEN_AT_INC,
|
||||
BTA_AV_OPEN_FAIL_SDP,
|
||||
BTA_AV_SET_DELAY_VALUE,
|
||||
BTA_AV_NUM_SACTIONS
|
||||
};
|
||||
|
||||
#define BTA_AV_SIGNORE BTA_AV_NUM_SACTIONS
|
||||
|
||||
|
||||
/* state table information */
|
||||
/* #define BTA_AV_SACTION_COL 0 position of actions */
|
||||
#define BTA_AV_SACTIONS 2 /* number of actions */
|
||||
#define BTA_AV_SNEXT_STATE 2 /* position of next state */
|
||||
#define BTA_AV_NUM_COLS 3 /* number of columns in state tables */
|
||||
|
||||
/* state table for init state */
|
||||
static const UINT8 bta_av_sst_init[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_DO_DISC, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_CLEANUP, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AP_SET_DELAY_VALUE_EVT */{BTA_AV_SET_DELAY_VALUE,BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST }
|
||||
};
|
||||
|
||||
/* state table for incoming state */
|
||||
static const UINT8 bta_av_sst_incoming[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_OPEN_AT_INC, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_CCO_CLOSE, BTA_AV_DISCONNECT_REQ, BTA_AV_CLOSING_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AP_SET_DELAY_VALUE_EVT */{BTA_AV_SET_DELAY_VALUE,BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SETCONFIG_RSP, BTA_AV_ST_RC_TIMER, BTA_AV_INCOMING_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SETCONFIG_REJ, BTA_AV_CLEANUP, BTA_AV_INIT_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_DISC_RES_AS_ACP, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_SAVE_CAPS, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_STR_OPENED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_CCO_CLOSE, BTA_AV_CLEANUP, BTA_AV_INIT_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_CONFIG_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_CCO_CLOSE, BTA_AV_CLEANUP, BTA_AV_INIT_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST }
|
||||
};
|
||||
|
||||
/* state table for opening state */
|
||||
static const UINT8 bta_av_sst_opening[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AP_SET_DELAY_VALUE_EVT */{BTA_AV_SET_DELAY_VALUE,BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_OPEN_FAIL_SDP, BTA_AV_INIT_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_DISC_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_ST_RC_TIMER, BTA_AV_STR_OPENED, BTA_AV_OPEN_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_CONFIG_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_SWITCH_ROLE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_DISCOVER_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_CONN_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_ROLE_RES, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST }
|
||||
};
|
||||
|
||||
/* state table for open state */
|
||||
static const UINT8 bta_av_sst_open[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_DO_START, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_STR_STOPPED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* AP_SET_DELAY_VALUE_EVT */{BTA_AV_SET_DELAY_VALUE,BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_RECONFIG, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SET_USE_RC, BTA_AV_OPEN_RC, BTA_AV_OPEN_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_DATA_PATH, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_SAVE_CAPS, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_START_OK, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_START_FAILED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_CLR_CONG, BTA_AV_DATA_PATH, BTA_AV_OPEN_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SUSPEND_CFM, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_OPEN_RC, BTA_AV_CHK_2ND_START, BTA_AV_OPEN_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_ROLE_RES, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST }
|
||||
};
|
||||
|
||||
/* state table for reconfig state */
|
||||
static const UINT8 bta_av_sst_rcfg[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AP_SET_DELAY_VALUE_EVT */{BTA_AV_SET_DELAY_VALUE,BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_DISC_RESULTS, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_RCFG_STR_OK, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_RCFG_FAILED, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_RCFG_CONNECT, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SUSPEND_CONT, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_RCFG_CFM, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_RCFG_OPEN, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_RCFG_DISCNTD, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST }
|
||||
};
|
||||
|
||||
/* state table for closing state */
|
||||
static const UINT8 bta_av_sst_closing[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_SET_DELAY_VALUE_EVT */{BTA_AV_SET_DELAY_VALUE,BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_SDP_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_SDP_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SECURITY_REJ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST }
|
||||
};
|
||||
|
||||
/* type for state table */
|
||||
typedef const UINT8 (*tBTA_AV_SST_TBL)[BTA_AV_NUM_COLS];
|
||||
|
||||
/* state table */
|
||||
static const tBTA_AV_SST_TBL bta_av_sst_tbl[] = {
|
||||
bta_av_sst_init,
|
||||
bta_av_sst_incoming,
|
||||
bta_av_sst_opening,
|
||||
bta_av_sst_open,
|
||||
bta_av_sst_rcfg,
|
||||
bta_av_sst_closing
|
||||
};
|
||||
|
||||
static char *bta_av_sst_code(UINT8 state);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_is_rcfg_sst
|
||||
**
|
||||
** Description Check if stream state machine is in reconfig state.
|
||||
**
|
||||
**
|
||||
** Returns TRUE if stream state machine is in reconfig state.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_av_is_rcfg_sst (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
BOOLEAN is_rcfg_sst = FALSE;
|
||||
|
||||
if (p_scb != NULL) {
|
||||
if (p_scb->state == BTA_AV_RCFG_SST) {
|
||||
is_rcfg_sst = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return is_rcfg_sst;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_ssm_execute
|
||||
**
|
||||
** Description Stream state machine event handling function for AV
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_ssm_execute(tBTA_AV_SCB *p_scb, UINT16 event, tBTA_AV_DATA *p_data)
|
||||
{
|
||||
tBTA_AV_SST_TBL state_table;
|
||||
UINT8 action;
|
||||
int i, xx;
|
||||
|
||||
if (p_scb == NULL) {
|
||||
/* this stream is not registered */
|
||||
APPL_TRACE_EVENT("AV channel not registered");
|
||||
return;
|
||||
}
|
||||
|
||||
/* In case incoming connection is for VDP, we need to swap scb. */
|
||||
/* When ACP_CONNECT_EVT was received, we put first available scb to */
|
||||
/* to Incoming state. Later, when STR_CONFIG_IND_EVT is coming, we */
|
||||
/* know if it is A2DP or VDP. */
|
||||
if ((p_scb->state == BTA_AV_INIT_SST) && (event == BTA_AV_STR_CONFIG_IND_EVT)) {
|
||||
for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) {
|
||||
if (bta_av_cb.p_scb[xx]) {
|
||||
if (bta_av_cb.p_scb[xx]->state == BTA_AV_INCOMING_SST) {
|
||||
bta_av_cb.p_scb[xx]->state = BTA_AV_INIT_SST;
|
||||
bta_av_cb.p_scb[xx]->coll_mask = 0;
|
||||
p_scb->state = BTA_AV_INCOMING_SST;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
APPL_TRACE_VERBOSE("AV Sevent(0x%x)=0x%x(%s) state=%d(%s)",
|
||||
p_scb->hndl, event, bta_av_evt_code(event), p_scb->state, bta_av_sst_code(p_scb->state));
|
||||
|
||||
/* look up the state table for the current state */
|
||||
state_table = bta_av_sst_tbl[p_scb->state];
|
||||
|
||||
event -= BTA_AV_FIRST_SSM_EVT;
|
||||
|
||||
/* set next state */
|
||||
p_scb->state = state_table[event][BTA_AV_SNEXT_STATE];
|
||||
|
||||
/* execute action functions */
|
||||
for (i = 0; i < BTA_AV_SACTIONS; i++) {
|
||||
if ((action = state_table[event][i]) != BTA_AV_SIGNORE) {
|
||||
APPL_TRACE_VERBOSE("AV Sevent(0x%x)=%d(%s)", p_scb->hndl, event, bta_av_action_code(action));
|
||||
(*p_scb->p_act_tbl[action])(p_scb, p_data);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_is_scb_opening
|
||||
**
|
||||
** Description Returns TRUE is scb is in opening state.
|
||||
**
|
||||
**
|
||||
** Returns TRUE if scb is in opening state.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_av_is_scb_opening (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
BOOLEAN is_opening = FALSE;
|
||||
|
||||
if (p_scb) {
|
||||
if (p_scb->state == BTA_AV_OPENING_SST) {
|
||||
is_opening = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return is_opening;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_is_scb_incoming
|
||||
**
|
||||
** Description Returns TRUE is scb is in incoming state.
|
||||
**
|
||||
**
|
||||
** Returns TRUE if scb is in incoming state.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_av_is_scb_incoming (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
BOOLEAN is_incoming = FALSE;
|
||||
|
||||
if (p_scb) {
|
||||
if (p_scb->state == BTA_AV_INCOMING_SST) {
|
||||
is_incoming = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return is_incoming;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_set_scb_sst_init
|
||||
**
|
||||
** Description Set SST state to INIT.
|
||||
** Use this function to change SST outside of state machine.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_set_scb_sst_init (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
if (p_scb) {
|
||||
p_scb->state = BTA_AV_INIT_SST;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_is_scb_init
|
||||
**
|
||||
** Description Returns TRUE is scb is in init state.
|
||||
**
|
||||
**
|
||||
** Returns TRUE if scb is in incoming state.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_av_is_scb_init (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
BOOLEAN is_init = FALSE;
|
||||
|
||||
if (p_scb) {
|
||||
if (p_scb->state == BTA_AV_INIT_SST) {
|
||||
is_init = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return is_init;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_set_scb_sst_incoming
|
||||
**
|
||||
** Description Set SST state to incoming.
|
||||
** Use this function to change SST outside of state machine.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
if (p_scb) {
|
||||
p_scb->state = BTA_AV_INCOMING_SST;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Debug Functions
|
||||
*****************************************************************************/
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sst_code
|
||||
**
|
||||
** Description
|
||||
**
|
||||
** Returns char *
|
||||
**
|
||||
*******************************************************************************/
|
||||
UNUSED_ATTR static char *bta_av_sst_code(UINT8 state)
|
||||
{
|
||||
switch (state) {
|
||||
case BTA_AV_INIT_SST: return "INIT";
|
||||
case BTA_AV_INCOMING_SST: return "INCOMING";
|
||||
case BTA_AV_OPENING_SST: return "OPENING";
|
||||
case BTA_AV_OPEN_SST: return "OPEN";
|
||||
case BTA_AV_RCFG_SST: return "RCFG";
|
||||
case BTA_AV_CLOSING_SST: return "CLOSING";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BTA_AV_INCLUDED */
|
||||
@@ -0,0 +1,710 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2004-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the private interface file for the BTA advanced audio/video.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_AV_INT_H
|
||||
#define BTA_AV_INT_H
|
||||
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_av_api.h"
|
||||
#include "stack/avdt_api.h"
|
||||
#include "bta/bta_av_co.h"
|
||||
#include "osi/list.h"
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
enum {
|
||||
/* these events are handled by the AV main state machine */
|
||||
BTA_AV_API_DISABLE_EVT = BTA_SYS_EVT_START(BTA_ID_AV),
|
||||
BTA_AV_API_REMOTE_CMD_EVT,
|
||||
BTA_AV_API_VENDOR_CMD_EVT,
|
||||
BTA_AV_API_VENDOR_RSP_EVT,
|
||||
BTA_AV_API_META_RSP_EVT,
|
||||
BTA_AV_API_RC_CLOSE_EVT,
|
||||
BTA_AV_AVRC_OPEN_EVT,
|
||||
BTA_AV_AVRC_MSG_EVT,
|
||||
BTA_AV_AVRC_NONE_EVT,
|
||||
|
||||
/* these events are handled by the AV stream state machine */
|
||||
BTA_AV_API_OPEN_EVT,
|
||||
BTA_AV_API_CLOSE_EVT,
|
||||
BTA_AV_AP_START_EVT, /* the following 3 events must be in the same order as the *API_*EVT */
|
||||
BTA_AV_AP_STOP_EVT,
|
||||
BTA_AV_AP_SET_DELAY_VALUE_EVT,
|
||||
BTA_AV_API_RECONFIG_EVT,
|
||||
BTA_AV_API_PROTECT_REQ_EVT,
|
||||
BTA_AV_API_PROTECT_RSP_EVT,
|
||||
BTA_AV_API_RC_OPEN_EVT,
|
||||
BTA_AV_SRC_DATA_READY_EVT,
|
||||
BTA_AV_CI_SETCONFIG_OK_EVT,
|
||||
BTA_AV_CI_SETCONFIG_FAIL_EVT,
|
||||
BTA_AV_SDP_DISC_OK_EVT,
|
||||
BTA_AV_SDP_DISC_FAIL_EVT,
|
||||
BTA_AV_STR_DISC_OK_EVT,
|
||||
BTA_AV_STR_DISC_FAIL_EVT,
|
||||
BTA_AV_STR_GETCAP_OK_EVT,
|
||||
BTA_AV_STR_GETCAP_FAIL_EVT,
|
||||
BTA_AV_STR_OPEN_OK_EVT,
|
||||
BTA_AV_STR_OPEN_FAIL_EVT,
|
||||
BTA_AV_STR_START_OK_EVT,
|
||||
BTA_AV_STR_START_FAIL_EVT,
|
||||
BTA_AV_STR_CLOSE_EVT,
|
||||
BTA_AV_STR_CONFIG_IND_EVT,
|
||||
BTA_AV_STR_SECURITY_IND_EVT,
|
||||
BTA_AV_STR_SECURITY_CFM_EVT,
|
||||
BTA_AV_STR_WRITE_CFM_EVT,
|
||||
BTA_AV_STR_SUSPEND_CFM_EVT,
|
||||
BTA_AV_STR_RECONFIG_CFM_EVT,
|
||||
BTA_AV_AVRC_TIMER_EVT,
|
||||
BTA_AV_AVDT_CONNECT_EVT,
|
||||
BTA_AV_AVDT_DISCONNECT_EVT,
|
||||
BTA_AV_ROLE_CHANGE_EVT,
|
||||
BTA_AV_AVDT_DELAY_RPT_EVT,
|
||||
BTA_AV_ACP_CONNECT_EVT,
|
||||
|
||||
/* these events are handled outside of the state machine */
|
||||
BTA_AV_API_ENABLE_EVT,
|
||||
BTA_AV_API_REGISTER_EVT,
|
||||
BTA_AV_API_DEREGISTER_EVT,
|
||||
BTA_AV_API_DISCONNECT_EVT,
|
||||
BTA_AV_CI_SRC_DATA_READY_EVT,
|
||||
BTA_AV_SIG_CHG_EVT,
|
||||
BTA_AV_SIG_TIMER_EVT,
|
||||
BTA_AV_SDP_AVRC_DISC_EVT,
|
||||
BTA_AV_AVRC_CLOSE_EVT,
|
||||
BTA_AV_CONN_CHG_EVT,
|
||||
BTA_AV_DEREG_COMP_EVT,
|
||||
#if (BTA_AV_SINK_INCLUDED == TRUE)
|
||||
BTA_AV_API_SINK_ENABLE_EVT,
|
||||
// add
|
||||
BTA_AV_API_GET_DELAY_VALUE_EVT,
|
||||
#endif
|
||||
#if (AVDT_REPORTING == TRUE)
|
||||
BTA_AV_AVDT_RPT_CONN_EVT,
|
||||
#endif
|
||||
BTA_AV_API_START_EVT, /* the following 3 events must be in the same order as the *AP_*EVT */
|
||||
BTA_AV_API_STOP_EVT,
|
||||
BTA_AV_API_SET_DELAY_VALUE_EVT,
|
||||
};
|
||||
|
||||
/* events for AV control block state machine */
|
||||
#define BTA_AV_FIRST_SM_EVT BTA_AV_API_DISABLE_EVT
|
||||
#define BTA_AV_LAST_SM_EVT BTA_AV_AVRC_NONE_EVT
|
||||
|
||||
/* events for AV stream control block state machine */
|
||||
#define BTA_AV_FIRST_SSM_EVT BTA_AV_API_OPEN_EVT
|
||||
|
||||
/* events that do not go through state machine */
|
||||
#define BTA_AV_FIRST_NSM_EVT BTA_AV_API_ENABLE_EVT
|
||||
#define BTA_AV_LAST_NSM_EVT BTA_AV_API_SET_DELAY_VALUE_EVT
|
||||
|
||||
/* API events passed to both SSMs (by bta_av_api_to_ssm) */
|
||||
#define BTA_AV_FIRST_A2S_API_EVT BTA_AV_API_START_EVT
|
||||
#define BTA_AV_FIRST_A2S_SSM_EVT BTA_AV_AP_START_EVT
|
||||
|
||||
#define BTA_AV_LAST_EVT BTA_AV_API_SET_DELAY_VALUE_EVT
|
||||
|
||||
/* maximum number of SEPS in stream discovery results */
|
||||
#define BTA_AV_NUM_SEPS 32
|
||||
|
||||
/* initialization value for AVRC handle */
|
||||
#define BTA_AV_RC_HANDLE_NONE 0xFF
|
||||
|
||||
/* size of database for service discovery */
|
||||
#define BTA_AV_DISC_BUF_SIZE 1000
|
||||
|
||||
/* offset of media type in codec info byte array */
|
||||
#define BTA_AV_MEDIA_TYPE_IDX 1
|
||||
|
||||
/* maximum length of AVDTP security data */
|
||||
#define BTA_AV_SECURITY_MAX_LEN 400
|
||||
|
||||
/* check number of buffers queued at L2CAP when this amount of buffers are queued to L2CAP */
|
||||
#define BTA_AV_QUEUE_DATA_CHK_NUM L2CAP_HIGH_PRI_MIN_XMIT_QUOTA
|
||||
|
||||
/* the number of ACL links with AVDT */
|
||||
#define BTA_AV_NUM_LINKS AVDT_NUM_LINKS
|
||||
|
||||
#define BTA_AV_CO_ID_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); }
|
||||
#define BTA_AV_BE_STREAM_TO_CO_ID(u32, p) {u32 = (((UINT32)(*((p) + 2))) + (((UINT32)(*((p) + 1))) << 8) + (((UINT32)(*(p))) << 16)); (p) += 3;}
|
||||
|
||||
/* these bits are defined for bta_av_cb.multi_av */
|
||||
#define BTA_AV_MULTI_AV_SUPPORTED 0x01
|
||||
#define BTA_AV_MULTI_AV_IN_USE 0x02
|
||||
|
||||
#define TSEP_TO_SYS_ID(x) ((x) == AVDT_TSEP_SRC ? BTA_ID_AV : BTA_ID_AVK)
|
||||
|
||||
/*****************************************************************************
|
||||
** Data types
|
||||
*****************************************************************************/
|
||||
/* data type for BTA_AV_API_ENABLE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_AV_CBACK *p_cback;
|
||||
tBTA_AV_FEAT features;
|
||||
tBTA_SEC sec_mask;
|
||||
} tBTA_AV_API_ENABLE;
|
||||
|
||||
/* data type for BTA_AV_API_REG_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
char p_service_name[BTA_SERVICE_NAME_LEN + 1];
|
||||
UINT8 app_id;
|
||||
UINT8 tsep; // local SEP type
|
||||
tBTA_AV_DATA_CBACK *p_app_data_cback;
|
||||
tBTA_AV_CO_FUNCTS *bta_av_cos;
|
||||
tBTA_AVRC_CO_FUNCTS *bta_avrc_cos;
|
||||
} tBTA_AV_API_REG;
|
||||
|
||||
|
||||
enum {
|
||||
BTA_AV_RS_NONE, /* straight API call */
|
||||
BTA_AV_RS_OK, /* the role switch result - successful */
|
||||
BTA_AV_RS_FAIL, /* the role switch result - failed */
|
||||
BTA_AV_RS_DONE /* the role switch is done - continue */
|
||||
};
|
||||
typedef UINT8 tBTA_AV_RS_RES;
|
||||
/* data type for BTA_AV_API_OPEN_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
BOOLEAN use_rc;
|
||||
tBTA_SEC sec_mask;
|
||||
tBTA_AV_RS_RES switch_res;
|
||||
UINT16 uuid; /* uuid of initiator */
|
||||
} tBTA_AV_API_OPEN;
|
||||
|
||||
/* data type for BTA_AV_API_STOP_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN suspend;
|
||||
BOOLEAN flush;
|
||||
} tBTA_AV_API_STOP;
|
||||
|
||||
/* data type for BTA_AV_API_DISCONNECT_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
} tBTA_AV_API_DISCNT;
|
||||
|
||||
/* data type for BTA_AV_API_PROTECT_REQ_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 *p_data;
|
||||
UINT16 len;
|
||||
} tBTA_AV_API_PROTECT_REQ;
|
||||
|
||||
/* data type for BTA_AV_API_PROTECT_RSP_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 *p_data;
|
||||
UINT16 len;
|
||||
UINT8 error_code;
|
||||
} tBTA_AV_API_PROTECT_RSP;
|
||||
|
||||
/* data type for BTA_AV_API_REMOTE_CMD_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tAVRC_MSG_PASS msg;
|
||||
UINT8 label;
|
||||
} tBTA_AV_API_REMOTE_CMD;
|
||||
|
||||
/* data type for BTA_AV_API_VENDOR_CMD_EVT and RSP */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tAVRC_MSG_VENDOR msg;
|
||||
UINT8 label;
|
||||
} tBTA_AV_API_VENDOR;
|
||||
|
||||
/* data type for BTA_AV_API_RC_OPEN_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
} tBTA_AV_API_OPEN_RC;
|
||||
|
||||
/* data type for BTA_AV_API_RC_CLOSE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
} tBTA_AV_API_CLOSE_RC;
|
||||
|
||||
/* data type for BTA_AV_API_META_RSP_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN is_rsp;
|
||||
UINT8 label;
|
||||
tBTA_AV_CODE rsp_code;
|
||||
BT_HDR *p_pkt;
|
||||
} tBTA_AV_API_META_RSP;
|
||||
|
||||
|
||||
/* data type for BTA_AV_API_RECONFIG_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 codec_info[AVDT_CODEC_SIZE]; /* codec configuration */
|
||||
BOOLEAN suspend;
|
||||
UINT8 sep_info_idx;
|
||||
UINT8 num_protect;
|
||||
UINT8 p_protect_info[0];
|
||||
} tBTA_AV_API_RCFG;
|
||||
|
||||
/* data type for BTA_AV_CI_SETCONFIG_OK_EVT and BTA_AV_CI_SETCONFIG_FAIL_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_AV_HNDL hndl;
|
||||
UINT8 err_code;
|
||||
UINT8 category;
|
||||
BOOLEAN recfg_needed;
|
||||
UINT8 avdt_handle; /* local sep type for which this stream will be set up */
|
||||
UINT8 num_seid;
|
||||
UINT8 p_seid[0];
|
||||
} tBTA_AV_CI_SETCONFIG;
|
||||
|
||||
/* data type for all stream events from AVDTP */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tAVDT_CFG cfg; /* configuration/capabilities parameters */
|
||||
tAVDT_CTRL msg; /* AVDTP callback message parameters */
|
||||
BD_ADDR bd_addr; /* bd address */
|
||||
UINT8 handle;
|
||||
UINT8 avdt_event;
|
||||
BOOLEAN initiator; /* TRUE, if local device initiates the SUSPEND */
|
||||
} tBTA_AV_STR_MSG;
|
||||
|
||||
/* data type for BTA_AV_AVRC_MSG_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tAVRC_MSG msg;
|
||||
UINT8 handle;
|
||||
UINT8 label;
|
||||
UINT8 opcode;
|
||||
} tBTA_AV_RC_MSG;
|
||||
|
||||
/* data type for BTA_AV_AVRC_OPEN_EVT, BTA_AV_AVRC_CLOSE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR peer_addr;
|
||||
UINT8 handle;
|
||||
} tBTA_AV_RC_CONN_CHG;
|
||||
|
||||
/* data type for BTA_AV_CONN_CHG_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR peer_addr;
|
||||
BOOLEAN is_up;
|
||||
} tBTA_AV_CONN_CHG;
|
||||
|
||||
/* data type for BTA_AV_ROLE_CHANGE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 new_role;
|
||||
UINT8 hci_status;
|
||||
} tBTA_AV_ROLE_RES;
|
||||
|
||||
/* data type for BTA_AV_SDP_DISC_OK_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 avdt_version; /* AVDTP protocol version */
|
||||
} tBTA_AV_SDP_RES;
|
||||
|
||||
/* type for SEP control block */
|
||||
typedef struct {
|
||||
UINT8 av_handle; /* AVDTP handle */
|
||||
tBTA_AV_CODEC codec_type; /* codec type */
|
||||
UINT8 tsep; /* SEP type of local SEP */
|
||||
tBTA_AV_DATA_CBACK *p_app_data_cback; /* Application callback for media packets */
|
||||
} tBTA_AV_SEP;
|
||||
|
||||
/* data type for BTA_AV_API_SET_DELAY_VALUE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 delay_value;
|
||||
} tBTA_AV_API_SET_DELAY_VALUE;
|
||||
|
||||
/* data type for BTA_AV_API_GET_DELAY_VALUE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
} tBTA_AV_API_GET_DELAY_VALUE;
|
||||
|
||||
/* initiator/acceptor role for adaption */
|
||||
#define BTA_AV_ROLE_AD_INT 0x00 /* initiator */
|
||||
#define BTA_AV_ROLE_AD_ACP 0x01 /* acceptor */
|
||||
|
||||
/* initiator/acceptor signaling roles */
|
||||
#define BTA_AV_ROLE_START_ACP 0x00
|
||||
#define BTA_AV_ROLE_START_INT 0x10 /* do not change this value */
|
||||
|
||||
#define BTA_AV_ROLE_SUSPEND 0x20 /* suspending on start */
|
||||
#define BTA_AV_ROLE_SUSPEND_OPT 0x40 /* Suspend on Start option is set */
|
||||
|
||||
/* union of all event datatypes */
|
||||
typedef union {
|
||||
BT_HDR hdr;
|
||||
tBTA_AV_API_ENABLE api_enable;
|
||||
tBTA_AV_API_REG api_reg;
|
||||
tBTA_AV_API_OPEN api_open;
|
||||
tBTA_AV_API_STOP api_stop;
|
||||
tBTA_AV_API_DISCNT api_discnt;
|
||||
tBTA_AV_API_PROTECT_REQ api_protect_req;
|
||||
tBTA_AV_API_PROTECT_RSP api_protect_rsp;
|
||||
tBTA_AV_API_REMOTE_CMD api_remote_cmd;
|
||||
tBTA_AV_API_VENDOR api_vendor;
|
||||
tBTA_AV_API_RCFG api_reconfig;
|
||||
tBTA_AV_CI_SETCONFIG ci_setconfig;
|
||||
tBTA_AV_STR_MSG str_msg;
|
||||
tBTA_AV_RC_MSG rc_msg;
|
||||
tBTA_AV_RC_CONN_CHG rc_conn_chg;
|
||||
tBTA_AV_CONN_CHG conn_chg;
|
||||
tBTA_AV_ROLE_RES role_res;
|
||||
tBTA_AV_SDP_RES sdp_res;
|
||||
tBTA_AV_API_META_RSP api_meta_rsp;
|
||||
tBTA_AV_API_SET_DELAY_VALUE api_set_delay_vlaue;
|
||||
tBTA_AV_API_GET_DELAY_VALUE api_get_delay_value;
|
||||
} tBTA_AV_DATA;
|
||||
|
||||
typedef void (tBTA_AV_VDP_DATA_ACT)(void *p_scb);
|
||||
|
||||
typedef struct {
|
||||
tBTA_AV_VDP_DATA_ACT *p_act;
|
||||
UINT8 *p_frame;
|
||||
UINT16 buf_size;
|
||||
UINT32 len;
|
||||
UINT32 offset;
|
||||
UINT32 timestamp;
|
||||
} tBTA_AV_VF_INFO;
|
||||
|
||||
typedef union {
|
||||
tBTA_AV_VF_INFO vdp; /* used for video channels only */
|
||||
tBTA_AV_API_OPEN open; /* used only before open and role switch
|
||||
is needed on another AV channel */
|
||||
} tBTA_AV_Q_INFO;
|
||||
|
||||
#define BTA_AV_Q_TAG_OPEN 0x01 /* after API_OPEN, before STR_OPENED */
|
||||
#define BTA_AV_Q_TAG_START 0x02 /* before start sending media packets */
|
||||
#define BTA_AV_Q_TAG_STREAM 0x03 /* during streaming */
|
||||
|
||||
#define BTA_AV_WAIT_ACP_CAPS_ON 0x01 /* retriving the peer capabilities */
|
||||
#define BTA_AV_WAIT_ACP_CAPS_STARTED 0x02 /* started while retriving peer capabilities */
|
||||
#define BTA_AV_WAIT_ROLE_SW_RES_OPEN 0x04 /* waiting for role switch result after API_OPEN, before STR_OPENED */
|
||||
#define BTA_AV_WAIT_ROLE_SW_RES_START 0x08 /* waiting for role switch result before streaming */
|
||||
#define BTA_AV_WAIT_ROLE_SW_STARTED 0x10 /* started while waiting for role switch result */
|
||||
#define BTA_AV_WAIT_ROLE_SW_RETRY 0x20 /* set when retry on timeout */
|
||||
#define BTA_AV_WAIT_CHECK_RC 0x40 /* set when the timer is used by role switch */
|
||||
#define BTA_AV_WAIT_ROLE_SW_FAILED 0x80 /* role switch failed */
|
||||
|
||||
#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)
|
||||
|
||||
/* Bitmap for collision, coll_mask */
|
||||
#define BTA_AV_COLL_INC_TMR 0x01 /* Timer is running for incoming L2C connection */
|
||||
#define BTA_AV_COLL_API_CALLED 0x02 /* API open was called while incoming timer is running */
|
||||
|
||||
/* type for AV stream control block */
|
||||
typedef struct {
|
||||
const tBTA_AV_ACT *p_act_tbl; /* the action table for stream state machine */
|
||||
const tBTA_AV_CO_FUNCTS *p_cos; /* the associated callout functions */
|
||||
tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */
|
||||
tBTA_AV_SEP seps[BTA_AV_MAX_SEPS];
|
||||
tAVDT_CFG *p_cap; /* buffer used for get capabilities */
|
||||
list_t *a2d_list; /* used for audio channels only */
|
||||
tBTA_AV_Q_INFO q_info;
|
||||
tAVDT_SEP_INFO sep_info[BTA_AV_NUM_SEPS]; /* stream discovery results */
|
||||
tAVDT_CFG cfg; /* local SEP configuration */
|
||||
TIMER_LIST_ENT timer; /* delay timer for AVRC CT */
|
||||
BD_ADDR peer_addr; /* peer BD address */
|
||||
UINT16 l2c_cid; /* L2CAP channel ID */
|
||||
UINT16 stream_mtu; /* MTU of stream */
|
||||
UINT16 avdt_version; /* the avdt version of peer device */
|
||||
tBTA_SEC sec_mask; /* security mask */
|
||||
tBTA_AV_CODEC codec_type; /* codec type */
|
||||
UINT8 media_type; /* Media type */
|
||||
BOOLEAN cong; /* TRUE if AVDTP congested */
|
||||
tBTA_AV_STATUS open_status; /* open failure status */
|
||||
tBTA_AV_CHNL chnl; /* the channel: audio/video */
|
||||
tBTA_AV_HNDL hndl; /* the handle: ((hdi + 1)|chnl) */
|
||||
UINT16 cur_psc_mask; /* Protocol service capabilities mask for current connection */
|
||||
UINT8 avdt_handle; /* AVDTP handle */
|
||||
UINT8 hdi; /* the index to SCB[] */
|
||||
UINT8 num_seps; /* number of seps returned by stream discovery */
|
||||
UINT8 num_disc_snks; /* number of discovered snks */
|
||||
UINT8 num_disc_srcs; /* number of discovered srcs */
|
||||
UINT8 sep_info_idx; /* current index into sep_info */
|
||||
UINT8 sep_idx; /* current index into local seps[] */
|
||||
UINT8 rcfg_idx; /* reconfig requested index into sep_info */
|
||||
UINT8 state; /* state machine state */
|
||||
UINT8 avdt_label; /* AVDTP label */
|
||||
UINT8 app_id; /* application id */
|
||||
UINT8 num_recfg; /* number of reconfigure sent */
|
||||
UINT8 role;
|
||||
UINT8 l2c_bufs; /* the number of buffers queued to L2CAP */
|
||||
UINT8 rc_handle; /* connected AVRCP handle */
|
||||
BOOLEAN use_rc; /* TRUE if AVRCP is allowed */
|
||||
BOOLEAN started; /* TRUE if stream started */
|
||||
UINT8 co_started; /* non-zero, if stream started from call-out perspective */
|
||||
BOOLEAN recfg_sup; /* TRUE if the first attempt to reconfigure the stream was successfull, else False if command fails */
|
||||
BOOLEAN suspend_sup; /* TRUE if Suspend stream is supported, else FALSE if suspend command fails */
|
||||
BOOLEAN deregistring; /* TRUE if deregistering */
|
||||
BOOLEAN sco_suspend; /* TRUE if SUSPEND is issued automatically for SCO */
|
||||
UINT8 coll_mask; /* Mask to check incoming and outgoing collision */
|
||||
tBTA_AV_API_OPEN open_api; /* Saved OPEN api message */
|
||||
UINT8 wait; /* set 0x1, when getting Caps as ACP, set 0x2, when started */
|
||||
UINT8 q_tag; /* identify the associated q_info union member */
|
||||
BOOLEAN no_rtp_hdr; /* TRUE if add no RTP header*/
|
||||
UINT8 disc_rsn; /* disconenction reason */
|
||||
UINT16 uuid_int; /*intended UUID of Initiator to connect to */
|
||||
} tBTA_AV_SCB;
|
||||
|
||||
#define BTA_AV_RC_ROLE_MASK 0x10
|
||||
#define BTA_AV_RC_ROLE_INT 0x00
|
||||
#define BTA_AV_RC_ROLE_ACP 0x10
|
||||
|
||||
#define BTA_AV_RC_CONN_MASK 0x20
|
||||
|
||||
/* type for AV RCP control block */
|
||||
/* index to this control block is the rc handle */
|
||||
typedef struct {
|
||||
UINT8 status;
|
||||
UINT8 handle;
|
||||
UINT8 shdl; /* stream handle (hdi + 1) */
|
||||
UINT8 lidx; /* (index+1) to LCB */
|
||||
tBTA_AV_FEAT peer_features; /* peer features mask */
|
||||
UINT16 peer_ct_features;
|
||||
UINT16 peer_tg_features;
|
||||
} tBTA_AV_RCB;
|
||||
#define BTA_AV_NUM_RCB (BTA_AV_NUM_STRS + 2)
|
||||
|
||||
enum {
|
||||
BTA_AV_LCB_FREE,
|
||||
BTA_AV_LCB_FIND
|
||||
};
|
||||
|
||||
/* type for AV ACL Link control block */
|
||||
typedef struct {
|
||||
BD_ADDR addr; /* peer BD address */
|
||||
UINT8 conn_msk; /* handle mask of connected stream handle */
|
||||
UINT8 lidx; /* index + 1 */
|
||||
} tBTA_AV_LCB;
|
||||
|
||||
/* type for stream state machine action functions */
|
||||
typedef void (*tBTA_AV_SACT)(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
|
||||
|
||||
/* type for AV control block */
|
||||
typedef struct {
|
||||
tBTA_AV_SCB *p_scb[BTA_AV_NUM_STRS]; /* stream control block */
|
||||
tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */
|
||||
tBTA_AV_CBACK *p_cback; /* application callback function */
|
||||
tBTA_AV_RCB rcb[BTA_AV_NUM_RCB]; /* RCB control block */
|
||||
tBTA_AV_LCB lcb[BTA_AV_NUM_LINKS + 1]; /* link control block */
|
||||
TIMER_LIST_ENT sig_tmr; /* link timer */
|
||||
TIMER_LIST_ENT acp_sig_tmr; /* timer to monitor signalling when accepting */
|
||||
UINT32 sdp_a2d_handle; /* SDP record handle for audio src */
|
||||
#if (BTA_AV_SINK_INCLUDED == TRUE)
|
||||
UINT32 sdp_a2d_snk_handle; /* SDP record handle for audio snk */
|
||||
#endif
|
||||
UINT32 sdp_vdp_handle; /* SDP record handle for video src */
|
||||
tBTA_AV_FEAT features; /* features mask */
|
||||
tBTA_SEC sec_mask; /* security mask */
|
||||
tBTA_AV_HNDL handle; /* the handle for SDP activity */
|
||||
tBTA_AVRC_CO_FUNCTS *p_rc_cos; /* AVRCP call-out functions */
|
||||
BOOLEAN disabling; /* TRUE if api disabled called */
|
||||
UINT8 disc; /* (hdi+1) or (rc_handle|BTA_AV_CHNL_MSK) if p_disc_db is in use */
|
||||
UINT8 state; /* state machine state */
|
||||
UINT8 conn_rc; /* handle mask of connected RCP channels */
|
||||
UINT8 conn_audio; /* handle mask of connected audio channels */
|
||||
UINT8 conn_video; /* handle mask of connected video channels */
|
||||
UINT8 conn_lcb; /* index mask of used LCBs */
|
||||
UINT8 audio_open_cnt; /* number of connected audio channels */
|
||||
UINT8 reg_audio; /* handle mask of registered audio channels */
|
||||
UINT8 reg_video; /* handle mask of registered video channels */
|
||||
UINT8 rc_acp_handle;
|
||||
UINT8 rc_acp_idx; /* (index + 1) to RCB */
|
||||
UINT8 rs_idx; /* (index + 1) to SCB for the one waiting for RS on open */
|
||||
BOOLEAN sco_occupied; /* TRUE if SCO is being used or call is in progress */
|
||||
UINT8 audio_streams; /* handle mask of streaming audio channels */
|
||||
UINT8 video_streams; /* handle mask of streaming video channels */
|
||||
} tBTA_AV_CB;
|
||||
|
||||
/* type for dealing with SBC data frames and codec capabilities functions */
|
||||
typedef int (tBTA_AV_SBC_ACT)(void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret);
|
||||
|
||||
/* type for AV up sample control block */
|
||||
typedef struct {
|
||||
INT32 cur_pos; /* current position */
|
||||
UINT32 src_sps; /* samples per second (source audio data) */
|
||||
UINT32 dst_sps; /* samples per second (converted audio data) */
|
||||
tBTA_AV_SBC_ACT *p_act; /* the action function to do the conversion */
|
||||
UINT16 bits; /* number of bits per pcm sample */
|
||||
UINT16 n_channels; /* number of channels (i.e. mono(1), stereo(2)...) */
|
||||
INT16 worker1;
|
||||
INT16 worker2;
|
||||
UINT8 div;
|
||||
} tBTA_AV_SBC_UPS_CB;
|
||||
|
||||
/*****************************************************************************
|
||||
** Global data
|
||||
*****************************************************************************/
|
||||
/* control block declaration up sample */
|
||||
#if BTA_DYNAMIC_MEMORY == TRUE
|
||||
extern tBTA_AV_SBC_UPS_CB *bta_av_sbc_ups_cb_ptr;
|
||||
#define bta_av_sbc_ups_cb (*bta_av_sbc_ups_cb_ptr)
|
||||
#endif
|
||||
|
||||
/* control block declaration */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
extern tBTA_AV_CB bta_av_cb;
|
||||
#else
|
||||
extern tBTA_AV_CB *bta_av_cb_ptr;
|
||||
#define bta_av_cb (*bta_av_cb_ptr)
|
||||
#endif
|
||||
|
||||
/* config struct */
|
||||
extern tBTA_AV_CFG *p_bta_av_cfg;
|
||||
|
||||
extern const tBTA_AV_SACT bta_av_a2d_action[];
|
||||
extern const tBTA_AV_SACT bta_av_vdp_action[];
|
||||
extern tAVDT_CTRL_CBACK *const bta_av_dt_cback[];
|
||||
extern void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt);
|
||||
|
||||
/*****************************************************************************
|
||||
** Function prototypes
|
||||
*****************************************************************************/
|
||||
/* utility functions */
|
||||
extern tBTA_AV_SCB *bta_av_hndl_to_scb(UINT16 handle);
|
||||
extern BOOLEAN bta_av_chk_start(tBTA_AV_SCB *p_scb);
|
||||
extern void bta_av_restore_switch (void);
|
||||
extern UINT16 bta_av_chk_mtu(tBTA_AV_SCB *p_scb, UINT16 mtu);
|
||||
extern void bta_av_conn_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data);
|
||||
extern UINT8 bta_av_rc_create(tBTA_AV_CB *p_cb, UINT8 role, UINT8 shdl, UINT8 lidx);
|
||||
extern void bta_av_stream_chg(tBTA_AV_SCB *p_scb, BOOLEAN started);
|
||||
extern BOOLEAN bta_av_is_scb_opening (tBTA_AV_SCB *p_scb);
|
||||
extern BOOLEAN bta_av_is_scb_incoming (tBTA_AV_SCB *p_scb);
|
||||
extern void bta_av_set_scb_sst_init (tBTA_AV_SCB *p_scb);
|
||||
extern BOOLEAN bta_av_is_scb_init (tBTA_AV_SCB *p_scb);
|
||||
extern void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb);
|
||||
extern tBTA_AV_LCB *bta_av_find_lcb(BD_ADDR addr, UINT8 op);
|
||||
|
||||
|
||||
/* debug functions */
|
||||
extern char *bta_av_evt_code(UINT16 evt_code);
|
||||
extern char *bta_av_action_code(UINT16 action_code);
|
||||
|
||||
/* main functions */
|
||||
extern void bta_av_api_deregister(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf);
|
||||
extern void bta_av_sm_execute(tBTA_AV_CB *p_cb, UINT16 event, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_ssm_execute(tBTA_AV_SCB *p_scb, UINT16 event, tBTA_AV_DATA *p_data);
|
||||
extern BOOLEAN bta_av_hdl_event(BT_HDR *p_msg);
|
||||
extern BOOLEAN bta_av_switch_if_needed(tBTA_AV_SCB *p_scb);
|
||||
extern BOOLEAN bta_av_link_role_ok(tBTA_AV_SCB *p_scb, UINT8 bits);
|
||||
extern BOOLEAN bta_av_is_rcfg_sst(tBTA_AV_SCB *p_scb);
|
||||
|
||||
/* nsm action functions */
|
||||
extern void bta_av_api_disconnect(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_sig_chg(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_sig_timer(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_disc_done(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_closed(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_disc(UINT8 disc);
|
||||
extern void bta_av_conn_chg(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_dereg_comp(tBTA_AV_DATA *p_data);
|
||||
|
||||
/* sm action functions */
|
||||
extern void bta_av_disable (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_opened (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_remote_cmd (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_vendor_cmd (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_vendor_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_msg (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_close (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_meta_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_free_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_free_msg (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
|
||||
extern tBTA_AV_RCB *bta_av_get_rcb_by_shdl(UINT8 shdl);
|
||||
extern void bta_av_del_rc(tBTA_AV_RCB *p_rcb);
|
||||
|
||||
/* ssm action functions */
|
||||
extern void bta_av_do_disc_a2d (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_cleanup (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_free_sdb (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_config_ind (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_disconnect_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_security_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_security_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_security_ind (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_security_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_do_close (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_connect_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_sdp_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_disc_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_disc_res_as_acp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_open_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_getcap_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_setconfig_rej (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_discover_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_conn_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_do_start (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_str_stopped (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_reconfig (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_data_path (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_start_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_start_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_str_closed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_clr_cong (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_suspend_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_str_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_connect (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_discntd (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_suspend_cont (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_open (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_security_rej (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_open_rc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_chk_2nd_start (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_save_caps (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rej_conn (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rej_conn (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_set_use_rc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_cco_close (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_switch_role (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_role_res (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_delay_co (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_open_at_inc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_open_fail_sdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_set_delay_value (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
|
||||
/* ssm action functions - vdp specific */
|
||||
extern void bta_av_do_disc_vdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_vdp_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_reg_vdp (tAVDT_CS *p_cs, char *p_service_name, void *p_data);
|
||||
|
||||
#endif ///BTA_AV_INCLUDED == TRUE
|
||||
|
||||
#endif /* BTA_AV_INT_H */
|
||||
Reference in New Issue
Block a user