bta_av_act.c revision 9adddf4965e9ddb01e339b934c343fcbd842a977
19258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.org/****************************************************************************** 29a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * 39a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * Copyright (C) 2004-2012 Broadcom Corporation 49a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * 59a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * Licensed under the Apache License, Version 2.0 (the "License"); 69a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * you may not use this file except in compliance with the License. 79a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * You may obtain a copy of the License at: 89a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * 99a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * http://www.apache.org/licenses/LICENSE-2.0 109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * 119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * Unless required by applicable law or agreed to in writing, software 129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * distributed under the License is distributed on an "AS IS" BASIS, 139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * See the License for the specific language governing permissions and 159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * limitations under the License. 169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * 179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ******************************************************************************/ 189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/****************************************************************************** 209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * 219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * This file contains action functions for advanced audio/video main state 229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * machine. 239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * 249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ******************************************************************************/ 259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "bt_target.h" 279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE) 285ad5acef6bd4ebc785f946d8bcc2a88b1e031827ricow@chromium.org 295ad5acef6bd4ebc785f946d8bcc2a88b1e031827ricow@chromium.org#include <string.h> 309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "bta_av_api.h" 319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "bta_av_int.h" 329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "avdt_api.h" 339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "bd.h" 349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "utl.h" 35b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org#include "l2c_api.h" 369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE) 379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "bta_ar_api.h" 389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#endif 399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/***************************************************************************** 41b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org** Constants 42b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org*****************************************************************************/ 439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/* the timer in milliseconds to wait for open req after setconfig for incoming connections */ 449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#ifndef BTA_AV_SIG_TIME_VAL 459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#define BTA_AV_SIG_TIME_VAL 8000 469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#endif 475a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org 489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/* In millisec to wait for signalling from SNK when it is initiated from SNK. */ 499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/* If not, we will start signalling from SRC. */ 509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#ifndef BTA_AV_ACP_SIG_TIME_VAL 513a37e9b96c768f6b5b6b09542e1cb1a1ece7a022ager@chromium.org#define BTA_AV_ACP_SIG_TIME_VAL 2000 523a37e9b96c768f6b5b6b09542e1cb1a1ece7a022ager@chromium.org#endif 539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void bta_av_acp_sig_timer_cback (TIMER_LIST_ENT *p_tle); 559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 5765dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org** 58c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org** Function bta_av_get_rcb_by_shdl 599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description find the RCB associated with the given SCB handle. 619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns tBTA_AV_RCB 639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comtBTA_AV_RCB * bta_av_get_rcb_by_shdl(UINT8 shdl) 669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RCB *p_rcb = NULL; 689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int i; 699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (i=0; i<BTA_AV_NUM_RCB; i++) 719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (bta_av_cb.rcb[i].shdl == shdl && bta_av_cb.rcb[i].handle != BTA_AV_RC_HANDLE_NONE) 739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb = &bta_av_cb.rcb[i]; 759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break; 769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return p_rcb; 799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#define BTA_AV_STS_NO_RSP 0xFF /* a number not used by tAVRC_STS */ 819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_del_rc 859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description delete the given AVRC handle. 879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_del_rc(tBTA_AV_RCB *p_rcb) 929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_SCB *p_scb; 949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 rc_handle; /* connected AVRCP handle */ 959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_rcb->handle != BTA_AV_RC_HANDLE_NONE) 979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_rcb->shdl) 999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 1009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb = bta_av_cb.p_scb[p_rcb->shdl - 1]; 1019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_scb) 1029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 1039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG3("bta_av_del_rc shdl:%d, srch:%d rc_handle:%d", p_rcb->shdl, 1049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb->rc_handle, p_rcb->handle); 1059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_scb->rc_handle == p_rcb->handle) 1069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb->rc_handle = BTA_AV_RC_HANDLE_NONE; 1079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* just in case the RC timer is active 1089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(bta_av_cb.features & BTA_AV_FEAT_RCCT && p_scb->chnl == BTA_AV_CHNL_AUDIO) */ 1099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_stop_timer(&p_scb->timer); 1109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 1119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 1129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_EVENT4("bta_av_del_rc handle: %d status=0x%x, rc_acp_handle:%d, idx:%d", 1149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->handle, p_rcb->status, bta_av_cb.rc_acp_handle, bta_av_cb.rc_acp_idx); 1159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_handle = p_rcb->handle; 1169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(!(p_rcb->status & BTA_AV_RC_CONN_MASK) || 1179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ((p_rcb->status & BTA_AV_RC_ROLE_MASK) == BTA_AV_RC_ROLE_INT) ) 1189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 1199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->status = 0; 1209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->handle = BTA_AV_RC_HANDLE_NONE; 1219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->shdl = 0; 1229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->lidx = 0; 1239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 1249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* else ACP && connected. do not clear the handle yet */ 1259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com AVRC_Close(rc_handle); 1269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (rc_handle == bta_av_cb.rc_acp_handle) 1279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.rc_acp_handle = BTA_AV_RC_HANDLE_NONE; 1289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_EVENT4("end del_rc handle: %d status=0x%x, rc_acp_handle:%d, lidx:%d", 1299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->handle, p_rcb->status, bta_av_cb.rc_acp_handle, p_rcb->lidx); 1309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 1319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 1329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 1359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 1369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_close_all_rc 1379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 1389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description close the all AVRC handle. 1399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 1409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 1419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 1429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 1439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void bta_av_close_all_rc(tBTA_AV_CB *p_cb) 1449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 1459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int i; 1465a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org 1475a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org for(i=0; i<BTA_AV_NUM_RCB; i++) 1485a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org { 1495a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org if ((p_cb->disabling == TRUE) || (bta_av_cb.rcb[i].shdl != 0)) 1509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_del_rc(&bta_av_cb.rcb[i]); 1519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 1529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 1535a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org 1545a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org/******************************************************************************* 1559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 1569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_del_sdp_rec 1579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 1589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description delete the given SDP record handle. 1599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 1609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 1619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 1629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 1639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void bta_av_del_sdp_rec(UINT32 *p_sdp_handle) 1649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 1659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(*p_sdp_handle != 0) 1669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 1679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com SDP_DeleteRecord(*p_sdp_handle); 1689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com *p_sdp_handle = 0; 1699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 1709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 1719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 1739085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org** 1749085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org** Function bta_av_avrc_sdp_cback 1759085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org** 1769085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org** Description AVRCP service discovery callback. 1779085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org** 1789085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org** Returns void 1799085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org** 1809085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org*******************************************************************************/ 1819085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.orgstatic void bta_av_avrc_sdp_cback(UINT16 status) 1829085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org{ 1839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com BT_HDR *p_msg; 1849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) 1869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 1879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_msg->event = BTA_AV_SDP_AVRC_DISC_EVT; 1889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_sendmsg(p_msg); 1899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 1909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 1919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 1939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 1949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_rc_ctrl_cback 1959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 1969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description AVRCP control callback. 1975ad5acef6bd4ebc785f946d8bcc2a88b1e031827ricow@chromium.org** 1985ad5acef6bd4ebc785f946d8bcc2a88b1e031827ricow@chromium.org** Returns void 1995ad5acef6bd4ebc785f946d8bcc2a88b1e031827ricow@chromium.org** 2009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 2019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void bta_av_rc_ctrl_cback(UINT8 handle, UINT8 event, UINT16 result, BD_ADDR peer_addr) 2029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 2039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RC_CONN_CHG *p_msg; 2049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT16 msg_event = 0; 2059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if (defined(BTA_AV_MIN_DEBUG_TRACES) && BTA_AV_MIN_DEBUG_TRACES == TRUE) 2079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_EVENT2("rc_ctrl handle: %d event=0x%x", handle, event); 2089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#else 2099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_EVENT2("bta_av_rc_ctrl_cback handle: %d event=0x%x", handle, event); 2109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#endif 2119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (event == AVRC_OPEN_IND_EVT) 2129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 2139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* save handle of opened connection 2149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.rc_handle = handle;*/ 215b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org 216b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org msg_event = BTA_AV_AVRC_OPEN_EVT; 2179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 2189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else if (event == AVRC_CLOSE_IND_EVT) 2199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 220b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org msg_event = BTA_AV_AVRC_CLOSE_EVT; 221b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org } 2229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (msg_event) 2249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 2257be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if ((p_msg = (tBTA_AV_RC_CONN_CHG *) GKI_getbuf(sizeof(tBTA_AV_RC_CONN_CHG))) != NULL) 2267be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 227b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org p_msg->hdr.event = msg_event; 2289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_msg->handle = handle; 2299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(peer_addr) 230b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org bdcpy(p_msg->peer_addr, peer_addr); 2317be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org bta_sys_sendmsg(p_msg); 2327be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 2339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 2349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 235b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org 2367be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org/******************************************************************************* 2377be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 2387be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** Function bta_av_rc_msg_cback 2397be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 2407be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** Description AVRCP message callback. 2417be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 2427be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** Returns void 2437be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 2443a37e9b96c768f6b5b6b09542e1cb1a1ece7a022ager@chromium.org*******************************************************************************/ 2457be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.orgstatic void bta_av_rc_msg_cback(UINT8 handle, UINT8 label, UINT8 opcode, tAVRC_MSG *p_msg) 2467be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org{ 2477be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org tBTA_AV_RC_MSG *p_buf; 2487be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org UINT8 *p_data = NULL; 2497be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org UINT8 **p_p_data = NULL; 2507be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org UINT16 data_len = 0; 2517be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 2527be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org#if (defined(BTA_AV_MIN_DEBUG_TRACES) && BTA_AV_MIN_DEBUG_TRACES == TRUE) 2537be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org APPL_TRACE_ERROR2("rc_msg handle: %d opcode=0x%x", handle, opcode); 2547be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org#else 2557be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org APPL_TRACE_EVENT2("bta_av_rc_msg_cback handle: %d opcode=0x%x", handle, opcode); 2567be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org#endif 2577be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org /* determine size of buffer we need */ 2587be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if (opcode == AVRC_OP_VENDOR && p_msg->vendor.p_vendor_data != NULL) 2597be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 2607be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org p_data = p_msg->vendor.p_vendor_data; 2617be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org p_p_data = &p_msg->vendor.p_vendor_data; 2627be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org data_len = (UINT16) p_msg->vendor.vendor_len; 2637be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 2647be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org else if (opcode == AVRC_OP_PASS_THRU && p_msg->pass.p_pass_data != NULL) 2659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 2669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data = p_msg->pass.p_pass_data; 2675a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org p_p_data = &p_msg->pass.p_pass_data; 2685a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org data_len = (UINT16) p_msg->pass.pass_len; 2695a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org } 2705a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org 2713a37e9b96c768f6b5b6b09542e1cb1a1ece7a022ager@chromium.org if ((p_buf = (tBTA_AV_RC_MSG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_RC_MSG) + data_len))) != NULL) 2725a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org { 2735a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org p_buf->hdr.event = BTA_AV_AVRC_MSG_EVT; 2749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_buf->handle = handle; 2759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_buf->label = label; 2769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_buf->opcode = opcode; 2779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com memcpy(&p_buf->msg, p_msg, sizeof(tAVRC_MSG)); 2789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_data != NULL) 2799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 2809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com memcpy((UINT8 *)(p_buf + 1), p_data, data_len); 2819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com *p_p_data = (UINT8 *)(p_buf + 1); 2829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 2839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_sendmsg(p_buf); 2849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 2859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 286b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org 287b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org/******************************************************************************* 2889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 2899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_rc_create 2909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 291b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org** Description alloc RCB and call AVRC_Open 2929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 2939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns the created rc handle 2949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 2959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 296b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.orgUINT8 bta_av_rc_create(tBTA_AV_CB *p_cb, UINT8 role, UINT8 shdl, UINT8 lidx) 297b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org{ 2989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tAVRC_CONN_CB ccb; 2999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com BD_ADDR_PTR bda = (BD_ADDR_PTR)bd_addr_any; 3009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 status = BTA_AV_RC_ROLE_ACP; 301b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org tBTA_AV_SCB *p_scb = p_cb->p_scb[shdl - 1]; 3029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int i; 3039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 rc_handle; 3049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RCB *p_rcb; 3059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 306b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org if(role == AVCT_INT) 307b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org { 3089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bda = p_scb->peer_addr; 3099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com status = BTA_AV_RC_ROLE_INT; 3109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 311b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org else 3129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 3139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((p_rcb = bta_av_get_rcb_by_shdl(shdl)) != NULL ) 3149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 3159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_ERROR1("bta_av_rc_create ACP handle exist for shdl:%d", shdl); 3169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return p_rcb->handle; 317b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org } 318b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org } 3199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ccb.p_ctrl_cback = bta_av_rc_ctrl_cback; 3219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ccb.p_msg_cback = bta_av_rc_msg_cback; 322b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org ccb.company_id = p_bta_av_cfg->company_id; 3239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ccb.conn = role; 3249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* note: BTA_AV_FEAT_RCTG = AVRC_CT_TARGET, BTA_AV_FEAT_RCCT = AVRC_CT_CONTROL */ 3259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ccb.control = p_cb->features & (BTA_AV_FEAT_RCTG | BTA_AV_FEAT_RCCT | AVRC_CT_PASSIVE); 3269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 328b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org if (AVRC_Open(&rc_handle, &ccb, bda) != AVRC_SUCCESS) 329b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org return BTA_AV_RC_HANDLE_NONE; 3309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com i = rc_handle; 3329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb = &p_cb->rcb[i]; 333b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org 3349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_rcb->handle != BTA_AV_RC_HANDLE_NONE) 3359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 3369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_ERROR1("bta_av_rc_create found duplicated handle:%d", rc_handle); 3379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 3389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->handle = rc_handle; 3409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->status = status; 3419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->shdl = shdl; 3429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->lidx = lidx; 3439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->peer_features = 0; 3449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(lidx == (BTA_AV_NUM_LINKS + 1)) 3459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 3469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* this LIDX is reserved for the AVRCP ACP connection */ 3479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->rc_acp_handle = p_rcb->handle; 3489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->rc_acp_idx = (i + 1); 3499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG2("rc_acp_handle:%d idx:%d", p_cb->rc_acp_handle, p_cb->rc_acp_idx); 3509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 3519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG6("create %d, role: %d, shdl:%d, rc_handle:%d, lidx:%d, status:0x%x", 3529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com i, role, shdl, p_rcb->handle, lidx, p_rcb->status); 3539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return rc_handle; 3559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 3569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 3589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 3599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_valid_group_navi_msg 3609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 3619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description Check if it is Group Navigation Msg for Metadata 3629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 3639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns BTA_AV_RSP_ACCEPT or BTA_AV_RSP_NOT_IMPL. 3649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 3659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 3669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic tBTA_AV_CODE bta_av_group_navi_supported(UINT8 len, UINT8 *p_data, BOOLEAN is_inquiry) 3679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 3689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_CODE ret=BTA_AV_RSP_NOT_IMPL; 3699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 *p_ptr = p_data; 3709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT16 u16; 37171affb54842da76b24f0bb3184e9f0960523f89dkasperl@chromium.org UINT32 u32; 37271affb54842da76b24f0bb3184e9f0960523f89dkasperl@chromium.org 3739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_bta_av_cfg->avrc_group && len == BTA_GROUP_NAVI_MSG_OP_DATA_LEN) 3749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 3759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com BTA_AV_BE_STREAM_TO_CO_ID(u32, p_ptr); 3769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com BE_STREAM_TO_UINT16(u16, p_ptr); 3779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (u32 == AVRC_CO_METADATA) 3799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 3809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (is_inquiry) 3819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 3829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (u16 <= AVRC_PDU_PREV_GROUP) 3839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ret = BTA_AV_RSP_IMPL_STBL; 3849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 3859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 3869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 3879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (u16 <= AVRC_PDU_PREV_GROUP) 3889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ret = BTA_AV_RSP_ACCEPT; 3899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 3909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ret = BTA_AV_RSP_REJ; 3919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 3929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 3939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 3949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return ret; 3969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 3979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 3999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 4009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_op_supported 4011af7e1b5f676e5556c041fe09a5c4f5a906f27a0lrn@chromium.org** 4021af7e1b5f676e5556c041fe09a5c4f5a906f27a0lrn@chromium.org** Description Check if remote control operation is supported. 4031af7e1b5f676e5556c041fe09a5c4f5a906f27a0lrn@chromium.org** 4049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns BTA_AV_RSP_ACCEPT of supported, BTA_AV_RSP_NOT_IMPL if not. 4059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 406381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org*******************************************************************************/ 407381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.orgstatic tBTA_AV_CODE bta_av_op_supported(tBTA_AV_RC rc_id, BOOLEAN is_inquiry) 408381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org{ 409381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org tBTA_AV_CODE ret_code = BTA_AV_RSP_NOT_IMPL; 410381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 411381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org if (p_bta_av_rc_id) 412381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org { 413381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org if (is_inquiry) 414381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org { 415ab99eea3d9d0cc20698ebb39bf0fb80e3e66bffcager@chromium.org if (p_bta_av_rc_id[rc_id >> 4] & (1 << (rc_id & 0x0F))) 416ab99eea3d9d0cc20698ebb39bf0fb80e3e66bffcager@chromium.org { 417381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org ret_code = BTA_AV_RSP_IMPL_STBL; 418381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 419381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 420b302e56e5b70c4504faa2adf4ec3efb64a9d3e38sgjesse@chromium.org else 421381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org { 422381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org if (p_bta_av_rc_id[rc_id >> 4] & (1 << (rc_id & 0x0F))) 423381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org { 424381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org ret_code = BTA_AV_RSP_ACCEPT; 425381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 426381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org else if ((p_bta_av_cfg->rc_pass_rsp == BTA_AV_RSP_INTERIM) && p_bta_av_rc_id_ac) 427381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org { 428381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org if (p_bta_av_rc_id_ac[rc_id >> 4] & (1 << (rc_id & 0x0F))) 429381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org { 430381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org ret_code = BTA_AV_RSP_INTERIM; 431381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 432381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 433381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 434381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 435381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 436381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org return ret_code; 437381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org} 438381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 439381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org/******************************************************************************* 440381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org** 441381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org** Function bta_av_find_lcb 442381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org** 443c34f5802a37a9fa2ce8f3929d1d5159ddcf04ff3lrn@chromium.org** Description Given BD_addr, find the associated LCB. 444c34f5802a37a9fa2ce8f3929d1d5159ddcf04ff3lrn@chromium.org** 445c34f5802a37a9fa2ce8f3929d1d5159ddcf04ff3lrn@chromium.org** Returns NULL, if not found. 446c34f5802a37a9fa2ce8f3929d1d5159ddcf04ff3lrn@chromium.org** 447c34f5802a37a9fa2ce8f3929d1d5159ddcf04ff3lrn@chromium.org*******************************************************************************/ 448c34f5802a37a9fa2ce8f3929d1d5159ddcf04ff3lrn@chromium.orgtBTA_AV_LCB * bta_av_find_lcb(BD_ADDR addr, UINT8 op) 4499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 4509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_CB *p_cb = &bta_av_cb; 451381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org int xx; 452381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org UINT8 mask; 453381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org tBTA_AV_LCB *p_lcb = NULL; 454b302e56e5b70c4504faa2adf4ec3efb64a9d3e38sgjesse@chromium.org 455b302e56e5b70c4504faa2adf4ec3efb64a9d3e38sgjesse@chromium.org for(xx=0; xx<BTA_AV_NUM_LINKS; xx++) 456b302e56e5b70c4504faa2adf4ec3efb64a9d3e38sgjesse@chromium.org { 457381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org mask = 1 << xx; /* the used mask for this lcb */ 458381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org if((mask & p_cb->conn_lcb) && 0 ==( bdcmp(p_cb->lcb[xx].addr, addr))) 459381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org { 460381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org p_lcb = &p_cb->lcb[xx]; 4619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(op == BTA_AV_LCB_FREE) 4629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 4639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->conn_lcb &= ~mask; /* clear the connect mask */ 4649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("conn_lcb: 0x%x", p_cb->conn_lcb); 4659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 4669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break; 4679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 4689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 4699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return p_lcb; 4709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 4719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 4729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 4739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 4749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_rc_opened 4759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 4769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description Set AVRCP state to opened. 4779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 478236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org** Returns void 4799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 4809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 4819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_rc_opened(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 4829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 4839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RC_OPEN rc_open; 4849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_SCB *p_scb; 4859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int i; 4869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 shdl = 0; 4879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_LCB *p_lcb; 4889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RCB *p_rcb; 4899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 tmp; 4909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 disc = 0; 491236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org 4929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* find the SCB & stop the timer */ 4938bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org for(i=0; i<BTA_AV_NUM_STRS; i++) 4949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 495911335cff40a2630bbe1dfb77b1897be991241bfsgjesse@chromium.org p_scb = p_cb->p_scb[i]; 4969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_scb && bdcmp(p_scb->peer_addr, p_data->rc_conn_chg.peer_addr) == 0) 4979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 4989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb->rc_handle = p_data->rc_conn_chg.handle; 4999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG2("bta_av_rc_opened shdl:%d, srch %d", i + 1, p_scb->rc_handle); 5009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com shdl = i+1; 5019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_ERROR1("use_rc:%d", p_scb->use_rc); 5029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_stop_timer(&p_scb->timer); 5039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com disc = p_scb->hndl; 5049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break; 5059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 506236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org } 507911335cff40a2630bbe1dfb77b1897be991241bfsgjesse@chromium.org 5089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com i = p_data->rc_conn_chg.handle; 5099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_cb->rcb[i].handle == BTA_AV_RC_HANDLE_NONE) 5109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 5119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_ERROR1("not a valid handle:%d any more", i); 5129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return; 5139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 5149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 5159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 5169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_cb->rcb[i].lidx == (BTA_AV_NUM_LINKS + 1) && shdl != 0) 5179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 5182d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org /* rc is opened on the RC only ACP channel, but is for a specific 5199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * SCB -> need to switch RCBs */ 5209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb = bta_av_get_rcb_by_shdl(shdl); 5219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_rcb) 5229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 5239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->shdl = p_cb->rcb[i].shdl; 5249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tmp = p_rcb->lidx; 5259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->lidx = p_cb->rcb[i].lidx; 5268bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org p_cb->rcb[i].lidx = tmp; 5272d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org p_cb->rc_acp_handle = p_rcb->handle; 5282d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org p_cb->rc_acp_idx = (p_rcb - p_cb->rcb) + 1; 5292d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org APPL_TRACE_DEBUG2("switching RCB rc_acp_handle:%d idx:%d", 5302d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org p_cb->rc_acp_handle, p_cb->rc_acp_idx); 5312d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org } 5322d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org } 5332d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 5342d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org p_cb->rcb[i].shdl = shdl; 5352d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org rc_open.rc_handle = i; 5362d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org APPL_TRACE_ERROR4("bta_av_rc_opened rcb[%d] shdl:%d lidx:%d/%d", 5372d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org i, shdl, p_cb->rcb[i].lidx, p_cb->lcb[BTA_AV_NUM_LINKS].lidx); 5382d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org p_cb->rcb[i].status |= BTA_AV_RC_CONN_MASK; 5392d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 5402d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org if(!shdl && 0 == p_cb->lcb[BTA_AV_NUM_LINKS].lidx) 5412d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org { 5422d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org /* no associated SCB -> connected to an RC only device 5432d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org * update the index to the extra LCB */ 5442d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org p_lcb = &p_cb->lcb[BTA_AV_NUM_LINKS]; 54565dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org bdcpy(p_lcb->addr, p_data->rc_conn_chg.peer_addr); 54665dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org APPL_TRACE_DEBUG6("rc_only bd_addr:%02x-%02x-%02x-%02x-%02x-%02x", 54765dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org p_lcb->addr[0], p_lcb->addr[1], 54865dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org p_lcb->addr[2], p_lcb->addr[3], 54965dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org p_lcb->addr[4], p_lcb->addr[5]); 55065dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org p_lcb->lidx = BTA_AV_NUM_LINKS + 1; 55165dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org p_cb->rcb[i].lidx = p_lcb->lidx; 55265dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org p_lcb->conn_msk = 1; 55365dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org APPL_TRACE_ERROR3("rcb[%d].lidx=%d, lcb.conn_msk=x%x", 55465dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org i, p_cb->rcb[i].lidx, p_lcb->conn_msk); 55565dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org disc = p_data->rc_conn_chg.handle|BTA_AV_CHNL_MSK; 55665dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org } 55765dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org 55865dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org bdcpy(rc_open.peer_addr, p_data->rc_conn_chg.peer_addr); 55965dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org rc_open.peer_features = p_cb->rcb[i].peer_features; 56065dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org rc_open.status = BTA_AV_SUCCESS; 56165dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org APPL_TRACE_DEBUG2("local features:x%x peer_features:x%x", p_cb->features, 56265dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org rc_open.peer_features); 5635c838251403b0be9a882540f1922577abba4c872ager@chromium.org if(rc_open.peer_features == 0) 5645c838251403b0be9a882540f1922577abba4c872ager@chromium.org { 5655c838251403b0be9a882540f1922577abba4c872ager@chromium.org /* we have not done SDP on peer RC capabilities. 5665c838251403b0be9a882540f1922577abba4c872ager@chromium.org * peer must have initiated the RC connection */ 5675c838251403b0be9a882540f1922577abba4c872ager@chromium.org rc_open.peer_features = BTA_AV_FEAT_RCCT; 5685c838251403b0be9a882540f1922577abba4c872ager@chromium.org bta_av_rc_disc(disc); 5695c838251403b0be9a882540f1922577abba4c872ager@chromium.org } 5705c838251403b0be9a882540f1922577abba4c872ager@chromium.org (*p_cb->p_cback)(BTA_AV_RC_OPEN_EVT, (tBTA_AV *) &rc_open); 5715c838251403b0be9a882540f1922577abba4c872ager@chromium.org 5728bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org} 5738bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 5748bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 5758bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org/******************************************************************************* 5768bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org** 5778bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org** Function bta_av_rc_remote_cmd 5788bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org** 5798bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org** Description Send an AVRCP remote control command. 5809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 5819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 5829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 58365dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org*******************************************************************************/ 58465dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.orgvoid bta_av_rc_remote_cmd(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 58565dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org{ 58665dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org tBTA_AV_RCB *p_rcb; 58765dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org if (p_cb->features & BTA_AV_FEAT_RCCT) 5882d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org { 5892d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org if(p_data->hdr.layer_specific < BTA_AV_NUM_RCB) 5902d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org { 5912d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org p_rcb = &p_cb->rcb[p_data->hdr.layer_specific]; 5929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_rcb->status & BTA_AV_RC_CONN_MASK) 5939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 5949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com AVRC_PassCmd(p_rcb->handle, p_data->api_remote_cmd.label, 5959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com &p_data->api_remote_cmd.msg); 5969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 5979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 5988bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org } 5997be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org} 6008bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 6019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 6029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 6039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_rc_vendor_cmd 6049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 6059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description Send an AVRCP vendor specific command. 6069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 6079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 6089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 6099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 6109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_rc_vendor_cmd(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 6119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 6129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RCB *p_rcb; 6139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ( (p_cb->features & (BTA_AV_FEAT_RCCT | BTA_AV_FEAT_VENDOR)) == 6149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (BTA_AV_FEAT_RCCT | BTA_AV_FEAT_VENDOR)) 6159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 6169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_data->hdr.layer_specific < BTA_AV_NUM_RCB) 6179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 6182d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org p_rcb = &p_cb->rcb[p_data->hdr.layer_specific]; 6192d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org AVRC_VendorCmd(p_rcb->handle, p_data->api_vendor.label, &p_data->api_vendor.msg); 6202d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org } 6212d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org } 6222d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org} 6232d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 6242d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org/******************************************************************************* 6252d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org** 6262d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org** Function bta_av_rc_vendor_rsp 6272d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org** 6282d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org** Description Send an AVRCP vendor specific response. 6292d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org** 6302d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org** Returns void 6312d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org** 6322d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org*******************************************************************************/ 6332d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.orgvoid bta_av_rc_vendor_rsp(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 6342d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org{ 6352d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org tBTA_AV_RCB *p_rcb; 6362d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org if ( (p_cb->features & (BTA_AV_FEAT_RCTG | BTA_AV_FEAT_VENDOR)) == 6372d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org (BTA_AV_FEAT_RCTG | BTA_AV_FEAT_VENDOR)) 63865dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org { 63965dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org if(p_data->hdr.layer_specific < BTA_AV_NUM_RCB) 64065dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org { 64165dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org p_rcb = &p_cb->rcb[p_data->hdr.layer_specific]; 64265dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org AVRC_VendorRsp(p_rcb->handle, p_data->api_vendor.label, &p_data->api_vendor.msg); 64365dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org } 64465dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org } 64565dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org} 64665dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org 64765dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org/******************************************************************************* 64865dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org** 64965dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org** Function bta_av_rc_meta_rsp 65065dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org** 65165dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org** Description Send an AVRCP metadata/advanced control command/response. 65265dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org** 65365dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org** Returns void 65465dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org** 65565dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org*******************************************************************************/ 65665dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.orgvoid bta_av_rc_meta_rsp(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 65765dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org{ 65865dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org tBTA_AV_RCB *p_rcb; 65965dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org BOOLEAN free = TRUE; 66065dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org 66165dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org if ((p_cb->features & BTA_AV_FEAT_METADATA) && (p_data->hdr.layer_specific < BTA_AV_NUM_RCB)) 66265dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org { 66365dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org if ((p_data->api_meta_rsp.is_rsp && (p_cb->features & BTA_AV_FEAT_RCTG)) || 66465dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org (!p_data->api_meta_rsp.is_rsp && (p_cb->features & BTA_AV_FEAT_RCCT)) ) 66565dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org { 66665dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org p_rcb = &p_cb->rcb[p_data->hdr.layer_specific]; 66765dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org AVRC_MsgReq(p_rcb->handle, p_data->api_meta_rsp.label, p_data->api_meta_rsp.rsp_code, 66865dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org p_data->api_meta_rsp.p_pkt); 6695c838251403b0be9a882540f1922577abba4c872ager@chromium.org free = FALSE; 6705c838251403b0be9a882540f1922577abba4c872ager@chromium.org } 6715c838251403b0be9a882540f1922577abba4c872ager@chromium.org } 6725c838251403b0be9a882540f1922577abba4c872ager@chromium.org 6735c838251403b0be9a882540f1922577abba4c872ager@chromium.org if (free) 6745c838251403b0be9a882540f1922577abba4c872ager@chromium.org GKI_freebuf (p_data->api_meta_rsp.p_pkt); 6755c838251403b0be9a882540f1922577abba4c872ager@chromium.org} 6765c838251403b0be9a882540f1922577abba4c872ager@chromium.org 6775c838251403b0be9a882540f1922577abba4c872ager@chromium.org/******************************************************************************* 6785c838251403b0be9a882540f1922577abba4c872ager@chromium.org** 6795c838251403b0be9a882540f1922577abba4c872ager@chromium.org** Function bta_av_rc_free_rsp 6805c838251403b0be9a882540f1922577abba4c872ager@chromium.org** 6815c838251403b0be9a882540f1922577abba4c872ager@chromium.org** Description free an AVRCP metadata command buffer. 6829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 6839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 6849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 6859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 6868bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.orgvoid bta_av_rc_free_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 6878bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org{ 6889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com GKI_freebuf (p_data->api_meta_rsp.p_pkt); 6899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 6908bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 6919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 6929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 6939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_rc_meta_req 6949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 6959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description Send an AVRCP metadata command. 6969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 6979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 6989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 6999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 7009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_rc_free_msg (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 7019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 7028bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org} 7037be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 7048bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 7059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 7069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 7079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 7089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_chk_notif_evt_id 7099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 7109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description make sure the requested player id is valid. 7119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 7129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns BTA_AV_STS_NO_RSP, if no error 7139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 7149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 7159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic tAVRC_STS bta_av_chk_notif_evt_id(tAVRC_MSG_VENDOR *p_vendor) 7169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 7179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tAVRC_STS status = BTA_AV_STS_NO_RSP; 7189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 xx; 7199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT16 u16; 7208bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org UINT8 *p = p_vendor->p_vendor_data + 2; 7218bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 7228bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org BE_STREAM_TO_UINT16 (u16, p); 7238bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org /* double check the fixed length */ 7248bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org if ((u16 != 5) || (p_vendor->vendor_len != 9)) 7258bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org { 7268bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org status = AVRC_STS_INTERNAL_ERR; 7278bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org } 7288bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org else 7298bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org { 7309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* make sure the player_id is valid */ 7319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (xx=0; xx<p_bta_av_cfg->num_evt_ids; xx++) 7329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 7339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (*p == p_bta_av_cfg->p_meta_evt_ids[xx]) 7349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 7359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break; 7369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (xx == p_bta_av_cfg->num_evt_ids) 7399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 7409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com status = AVRC_STS_BAD_PARAM; 7419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 7449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return status; 7459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 7469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 7479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 7489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 7499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_proc_meta_cmd 7509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 7519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description Process an AVRCP metadata command from the peer. 7529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 7539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns TRUE to respond immediately 7549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 7559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 7569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comtBTA_AV_EVT bta_av_proc_meta_cmd(tAVRC_RESPONSE *p_rc_rsp, tBTA_AV_RC_MSG *p_msg, UINT8 *p_ctype) 7579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 7589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_EVT evt = BTA_AV_META_MSG_EVT; 7599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 u8, pdu, *p; 7608bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org UINT16 u16; 7617be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org tAVRC_MSG_VENDOR *p_vendor = &p_msg->msg.vendor; 7628bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 7639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if (AVRC_METADATA_INCLUDED == TRUE) 7649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 7659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com pdu = *(p_vendor->p_vendor_data); 7669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rc_rsp->pdu = pdu; 7679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com *p_ctype = AVRC_RSP_REJ; 7689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* Metadata messages only use PANEL sub-unit type */ 7699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_vendor->hdr.subunit_type != AVRC_SUB_PANEL) 7709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 7719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG0("SUBUNIT must be PANEL"); 7729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* reject it */ 7739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com evt=0; 7749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_vendor->hdr.ctype = BTA_AV_RSP_NOT_IMPL; 7759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com AVRC_VendorRsp(p_msg->handle, p_msg->label, &p_msg->msg.vendor); 7769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else if (!AVRC_IsValidAvcType(pdu, p_vendor->hdr.ctype) ) 7789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 7799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG2("Invalid pdu/ctype: 0x%x, %d", pdu, p_vendor->hdr.ctype); 7809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* reject invalid message without reporting to app */ 7819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com evt = 0; 7829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rc_rsp->rsp.status = AVRC_STS_BAD_CMD; 7839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 7859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 7868bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org switch (pdu) 7877be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 7888bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org case AVRC_PDU_GET_CAPABILITIES: 7899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* process GetCapabilities command without reporting the event to app */ 7909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com evt = 0; 7919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com u8 = *(p_vendor->p_vendor_data + 4); 7929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p = p_vendor->p_vendor_data + 2; 7939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rc_rsp->get_caps.capability_id = u8; 7949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com BE_STREAM_TO_UINT16 (u16, p); 7959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((u16 != 1) || (p_vendor->vendor_len != 5)) 7969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 7979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rc_rsp->get_caps.status = AVRC_STS_INTERNAL_ERR; 7989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 8009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 8019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rc_rsp->get_caps.status = AVRC_STS_NO_ERROR; 8029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (u8 == AVRC_CAP_COMPANY_ID) 8039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 8048bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org *p_ctype = AVRC_RSP_IMPL_STBL; 8057be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org p_rc_rsp->get_caps.count = p_bta_av_cfg->num_co_ids; 8068bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org memcpy(p_rc_rsp->get_caps.param.company_id, p_bta_av_cfg->p_meta_co_ids, 8079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (p_bta_av_cfg->num_co_ids << 2)); 8089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else if (u8 == AVRC_CAP_EVENTS_SUPPORTED) 8109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 8119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com *p_ctype = AVRC_RSP_IMPL_STBL; 8129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rc_rsp->get_caps.count = p_bta_av_cfg->num_evt_ids; 8139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com memcpy(p_rc_rsp->get_caps.param.event_id, p_bta_av_cfg->p_meta_evt_ids, 8149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_bta_av_cfg->num_evt_ids); 8159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 8179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 8189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("Invalid capability ID: 0x%x", u8); 8199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* reject - unknown capability ID */ 8209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rc_rsp->get_caps.status = AVRC_STS_BAD_PARAM; 8219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break; 8249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com case AVRC_PDU_REGISTER_NOTIFICATION: 8279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* make sure the event_id is implemented */ 8289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rc_rsp->rsp.status = bta_av_chk_notif_evt_id (p_vendor); 8299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_rc_rsp->rsp.status != BTA_AV_STS_NO_RSP) 8308bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org evt = 0; 8317be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org break; 8328bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 8339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#else 836c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org APPL_TRACE_DEBUG0("AVRCP 1.3 Metadata not supporteed. Reject command."); 8379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* reject invalid message without reporting to app */ 8389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com evt = 0; 8399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rc_rsp->rsp.status = AVRC_STS_BAD_CMD; 8409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#endif 8419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return evt; 843c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org} 8449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 8479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 8489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_rc_msg 8499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 8509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description Process an AVRCP message from the peer. 8519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 8529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 8539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 8549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 8559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 8569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 8579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_EVT evt = 0; 8589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV av; 8599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com BT_HDR *p_pkt = NULL; 8608bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org tAVRC_MSG_VENDOR *p_vendor = &p_data->rc_msg.msg.vendor; 8617be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org BOOLEAN is_inquiry = ((p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_SPEC_INQ) || p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_GEN_INQ); 8628bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org#if (AVRC_METADATA_INCLUDED == TRUE) 8639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tAVRC_STS res; 8649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 ctype; 8659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tAVRC_RESPONSE rc_rsp; 8669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_rsp.rsp.status = BTA_AV_STS_NO_RSP; 8689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#endif 8699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_data->rc_msg.opcode == AVRC_OP_PASS_THRU) 8719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 8729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* if this is a pass thru command */ 873ab99eea3d9d0cc20698ebb39bf0fb80e3e66bffcager@chromium.org if ((p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_CTRL) || 8749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_SPEC_INQ) || 8759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_GEN_INQ) 8769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ) 8779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 8789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* check if operation is supported */ 8799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_data->rc_msg.msg.pass.op_id == AVRC_ID_VENDOR) 8809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 8819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_NOT_IMPL; 8829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if (AVRC_METADATA_INCLUDED == TRUE) 8839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_cb->features & BTA_AV_FEAT_METADATA) 8849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->rc_msg.msg.hdr.ctype = 8858bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org bta_av_group_navi_supported(p_data->rc_msg.msg.pass.pass_len, 8867be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org p_data->rc_msg.msg.pass.p_pass_data, is_inquiry); 8878bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org#endif 8889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 8909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 8919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->rc_msg.msg.hdr.ctype = bta_av_op_supported(p_data->rc_msg.msg.pass.op_id, is_inquiry); 8929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("ctype %d",p_data->rc_msg.msg.hdr.ctype) 8959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* send response */ 8979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_data->rc_msg.msg.hdr.ctype != BTA_AV_RSP_INTERIM) 8989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com AVRC_PassRsp(p_data->rc_msg.handle, p_data->rc_msg.label, &p_data->rc_msg.msg.pass); 8999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* set up for callback if supported */ 9019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_data->rc_msg.msg.hdr.ctype == BTA_AV_RSP_ACCEPT || p_data->rc_msg.msg.hdr.ctype == BTA_AV_RSP_INTERIM) 902c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org { 903c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org evt = BTA_AV_REMOTE_CMD_EVT; 904c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org av.remote_cmd.rc_id = p_data->rc_msg.msg.pass.op_id; 905c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org av.remote_cmd.key_state = p_data->rc_msg.msg.pass.state; 906c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org av.remote_cmd.p_data = p_data->rc_msg.msg.pass.p_pass_data; 907c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org av.remote_cmd.len = p_data->rc_msg.msg.pass.pass_len; 908c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org memcpy(&av.remote_cmd.hdr, &p_data->rc_msg.msg.hdr, sizeof (tAVRC_HDR)); 909c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org av.remote_cmd.label = p_data->rc_msg.label; 910c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org } 911c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org } 912c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org /* else if this is a pass thru response */ 913c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org else if (p_data->rc_msg.msg.hdr.ctype >= AVRC_RSP_ACCEPT) 914c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org { 915c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org /* set up for callback */ 916c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org evt = BTA_AV_REMOTE_RSP_EVT; 917c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org av.remote_rsp.rc_id = p_data->rc_msg.msg.pass.op_id; 918c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org av.remote_rsp.key_state = p_data->rc_msg.msg.pass.state; 919c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org av.remote_rsp.rsp_code = p_data->rc_msg.msg.hdr.ctype; 920c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org av.remote_rsp.label = p_data->rc_msg.label; 921c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org } 9229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* must be a bad ctype -> reject*/ 9239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 9249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 9259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_REJ; 9269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com AVRC_PassRsp(p_data->rc_msg.handle, p_data->rc_msg.label, &p_data->rc_msg.msg.pass); 9279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 9289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 9299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* else if this is a vendor specific command or response */ 9309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else if (p_data->rc_msg.opcode == AVRC_OP_VENDOR) 9319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 9329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* set up for callback */ 9339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com av.vendor_cmd.code = p_data->rc_msg.msg.hdr.ctype; 9349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com av.vendor_cmd.company_id = p_vendor->company_id; 9359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com av.vendor_cmd.label = p_data->rc_msg.label; 9369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com av.vendor_cmd.p_data = p_vendor->p_vendor_data; 9379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com av.vendor_cmd.len = p_vendor->vendor_len; 9389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* if configured to support vendor specific and it's a command */ 9409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((p_cb->features & BTA_AV_FEAT_VENDOR) && 9419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->rc_msg.msg.hdr.ctype <= AVRC_CMD_GEN_INQ) 9429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 9439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if (AVRC_METADATA_INCLUDED == TRUE) 9449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((p_cb->features & BTA_AV_FEAT_METADATA) && 9459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (p_vendor->company_id == AVRC_CO_METADATA)) 9469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 9479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com av.meta_msg.p_msg = &p_data->rc_msg.msg; 9489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com evt = bta_av_proc_meta_cmd (&rc_rsp, &p_data->rc_msg, &ctype); 9499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 9509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 951236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org#endif 9529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com evt = BTA_AV_VENDOR_CMD_EVT; 9539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 9549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* else if configured to support vendor specific and it's a response */ 9559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else if ((p_cb->features & BTA_AV_FEAT_VENDOR) && 956236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org p_data->rc_msg.msg.hdr.ctype >= AVRC_RSP_ACCEPT) 9579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 9589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if (AVRC_METADATA_INCLUDED == TRUE) 9599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((p_cb->features & BTA_AV_FEAT_METADATA) && 9609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (p_vendor->company_id == AVRC_CO_METADATA)) 961236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org { 9629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com av.meta_msg.p_msg = &p_data->rc_msg.msg; 9639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com evt = BTA_AV_META_MSG_EVT; 964236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org } 965236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org else 966236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org#endif 9679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com evt = BTA_AV_VENDOR_RSP_EVT; 9689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 9709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* else if not configured to support vendor specific and it's a command */ 9719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else if (!(p_cb->features & BTA_AV_FEAT_VENDOR) && 9729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->rc_msg.msg.hdr.ctype <= AVRC_CMD_GEN_INQ) 9739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 974236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org if(p_data->rc_msg.msg.vendor.p_vendor_data[0] == AVRC_PDU_INVALID) 9759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 9769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* reject it */ 9779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_REJ; 9789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->rc_msg.msg.vendor.p_vendor_data[4] = AVRC_STS_BAD_CMD; 9799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 9809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 981236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_NOT_IMPL; 9829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com AVRC_VendorRsp(p_data->rc_msg.handle, p_data->rc_msg.label, &p_data->rc_msg.msg.vendor); 9839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 9849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 9859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if (AVRC_METADATA_INCLUDED == TRUE) 9869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (evt == 0 && rc_rsp.rsp.status != BTA_AV_STS_NO_RSP) 9879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 9889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (!p_pkt) 9899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 9909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_rsp.rsp.opcode = p_data->rc_msg.opcode; 9919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com res = AVRC_BldResponse (0, &rc_rsp, &p_pkt); 9929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 9939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_pkt) 994236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org AVRC_MsgReq (p_data->rc_msg.handle, p_data->rc_msg.label, ctype, p_pkt); 9959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 9969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#endif 9979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* call callback */ 9999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (evt != 0) 1000236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org { 10019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com av.remote_cmd.rc_handle = p_data->rc_msg.handle; 10029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (*p_cb->p_cback)(evt, &av); 10039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 10049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 10059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1006236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org/******************************************************************************* 10079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 10089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_rc_close 10099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 10109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description close the specified AVRC handle. 10119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 10129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 10139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 10149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 10159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_rc_close (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 10169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 10179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT16 handle = p_data->hdr.layer_specific; 10189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_SCB *p_scb; 10199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RCB *p_rcb; 10209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 10219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(handle < BTA_AV_NUM_RCB) 10229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 10239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb = &p_cb->rcb[handle]; 10249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 10259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG2("bta_av_rc_close handle: %d, status=0x%x", p_rcb->handle, p_rcb->status); 10269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_rcb->handle != BTA_AV_RC_HANDLE_NONE) 10279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 10289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_rcb->shdl) 10299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 10309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb = bta_av_cb.p_scb[p_rcb->shdl - 1]; 10319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_scb) 10329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 10339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* just in case the RC timer is active 10349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(bta_av_cb.features & BTA_AV_FEAT_RCCT && 10359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb->chnl == BTA_AV_CHNL_AUDIO) */ 10369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_stop_timer(&p_scb->timer); 10379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 10389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 10399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 10409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com AVRC_Close(p_rcb->handle); 10419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 10429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 10439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 10449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 10459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 10469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 10479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_get_shdl 10489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 10499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns The index to p_scb[] 10509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 10519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 10529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic UINT8 bta_av_get_shdl(tBTA_AV_SCB *p_scb) 1053381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org{ 1054245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org int i; 10559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 shdl = 0; 10569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* find the SCB & stop the timer */ 10579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for(i=0; i<BTA_AV_NUM_STRS; i++) 10589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 10599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_scb == bta_av_cb.p_scb[i]) 10609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 10619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com shdl = i+1; 10629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break; 10639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 10649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 10659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return shdl; 10669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 10679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 10689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 10699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 10709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_stream_chg 10719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 10729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description audio streaming status changed. 10739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 10749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 10759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 1076245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org*******************************************************************************/ 1077381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.orgvoid bta_av_stream_chg(tBTA_AV_SCB *p_scb, BOOLEAN started) 10789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 10799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 started_msk; 10809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int i; 10819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 *p_streams; 10829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com BOOLEAN no_streams = FALSE; 10839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_SCB *p_scbi; 10849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 10859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com started_msk = BTA_AV_HNDL_TO_MSK(p_scb->hdi); 1086245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org APPL_TRACE_DEBUG3 ("bta_av_stream_chg started:%d started_msk:x%x chnl:x%x", started, 10879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com started_msk, p_scb->chnl); 10889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (BTA_AV_CHNL_AUDIO == p_scb->chnl) 10899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_streams = &bta_av_cb.audio_streams; 10909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 10919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_streams = &bta_av_cb.video_streams; 10929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 10939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (started) 10949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 10959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* Let L2CAP know this channel is processed with high priority */ 10969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com L2CA_SetAclPriority(p_scb->peer_addr, L2CAP_PRIORITY_HIGH); 10979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (*p_streams) |= started_msk; 10989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 10999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 11009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 11019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (*p_streams) &= ~started_msk; 11029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 11039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (!started) 11059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 11069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com i=0; 11079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (BTA_AV_CHNL_AUDIO == p_scb->chnl) 11089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 1109245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org if (bta_av_cb.video_streams == 0) 1110381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org no_streams = TRUE; 11119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 11129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 11139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 11149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com no_streams = TRUE; 11159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ( bta_av_cb.audio_streams ) 11169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 11179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (; i<BTA_AV_NUM_STRS; i++) 11189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 1119245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org p_scbi = bta_av_cb.p_scb[i]; 11209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* scb is used and started */ 11219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ( p_scbi && (bta_av_cb.audio_streams & BTA_AV_HNDL_TO_MSK(i)) 11229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com && bdcmp(p_scbi->peer_addr, p_scb->peer_addr) == 0) 11239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 11249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com no_streams = FALSE; 11259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break; 11269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 11279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 11289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 11309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 11319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG4 ("no_streams:%d i:%d, audio_streams:x%x, video_streams:x%x", no_streams, i, 11339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.audio_streams, bta_av_cb.video_streams); 11349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (no_streams) 11359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 11369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* Let L2CAP know this channel is processed with low priority */ 11379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com L2CA_SetAclPriority(p_scb->peer_addr, L2CAP_PRIORITY_NORMAL); 11389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 11399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 11409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 11419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1142245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org 1143381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org/******************************************************************************* 11449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 11459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_conn_chg 11469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 11479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description connetion status changed. 11489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Open an AVRCP acceptor channel, if new conn. 11499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 11509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 11519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 11522d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org*******************************************************************************/ 11532d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.orgvoid bta_av_conn_chg(tBTA_AV_DATA *p_data) 11542d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org{ 11552d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org tBTA_AV_CB *p_cb = &bta_av_cb; 11562d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org tBTA_AV_SCB *p_scb; 11572d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org tBTA_AV_SCB *p_scbi; 11582d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org UINT8 mask; 11592d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org UINT8 conn_msk; 11602d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org UINT8 old_msk; 11612d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org int i; 11622d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org int index = (p_data->hdr.layer_specific & BTA_AV_HNDL_MSK) - 1; 1163245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org tBTA_AV_LCB *p_lcb; 11649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_LCB *p_lcb_rc; 11659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RCB *p_rcb, *p_rcb2; 11669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com BOOLEAN chk_restore = FALSE; 11679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb = p_cb->p_scb[index]; 11699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com mask = BTA_AV_HNDL_TO_MSK(index); 11719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb = bta_av_find_lcb(p_data->conn_chg.peer_addr, BTA_AV_LCB_FIND); 11729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com conn_msk = 1 << (index + 1); 11739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_data->conn_chg.is_up) 11749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 11759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* set the conned mask for this channel */ 11769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_scb) 11772d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org { 1178e90029b96bc4097e0f14d33cc086030d7ad5007awhesse@chromium.org if(p_lcb) 11799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 11809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb->conn_msk |= conn_msk; 11812d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org for (i=0; i<BTA_AV_NUM_RCB; i++) 1182e90029b96bc4097e0f14d33cc086030d7ad5007awhesse@chromium.org { 11839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (bta_av_cb.rcb[i].lidx == p_lcb->lidx) 11849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 11859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.rcb[i].shdl = index + 1; 11869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG5("conn_chg up[%d]: %d, status=0x%x, shdl:%d, lidx:%d", i, 11879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.rcb[i].handle, bta_av_cb.rcb[i].status, 11889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.rcb[i].shdl, bta_av_cb.rcb[i].lidx); 1189245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org break; 1190381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 11919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 11929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 11939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_scb->chnl == BTA_AV_CHNL_AUDIO) 11949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 11959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com old_msk = p_cb->conn_audio; 11969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->conn_audio |= mask; 11979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 11989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 11999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 12009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com old_msk = p_cb->conn_video; 12019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->conn_video |= mask; 12029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 12049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((old_msk & mask) == 0) 12059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 12069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* increase the audio open count, if not set yet */ 12079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.audio_open_cnt++; 12089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 12109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1211245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org APPL_TRACE_DEBUG2("rc_acp_handle:%d rc_acp_idx:%d", p_cb->rc_acp_handle, p_cb->rc_acp_idx); 12129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* check if the AVRCP ACP channel is already connected */ 12139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_lcb && p_cb->rc_acp_handle != BTA_AV_RC_HANDLE_NONE && p_cb->rc_acp_idx) 12149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 12159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb_rc = &p_cb->lcb[BTA_AV_NUM_LINKS]; 12169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("rc_acp is connected && conn_chg on same addr p_lcb_rc->conn_msk:x%x", 12179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb_rc->conn_msk); 12189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* check if the RC is connected to the scb addr */ 12199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG6 ("p_lcb_rc->addr: %02x:%02x:%02x:%02x:%02x:%02x", 12209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb_rc->addr[0], p_lcb_rc->addr[1], p_lcb_rc->addr[2], p_lcb_rc->addr[3], 12219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb_rc->addr[4], p_lcb_rc->addr[5]); 12229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG6 ("conn_chg.peer_addr: %02x:%02x:%02x:%02x:%02x:%02x", 12239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->conn_chg.peer_addr[0], p_data->conn_chg.peer_addr[1], 12249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->conn_chg.peer_addr[2], 12259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->conn_chg.peer_addr[3], p_data->conn_chg.peer_addr[4], 12269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_data->conn_chg.peer_addr[5]); 12279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_lcb_rc->conn_msk && bdcmp(p_lcb_rc->addr, p_data->conn_chg.peer_addr) == 0) 12289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 12299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* AVRCP is already connected. 12309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * need to update the association betwen SCB and RCB */ 12319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb_rc->conn_msk = 0; /* indicate RC ONLY is not connected */ 12329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb_rc->lidx = 0; 12339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb->rc_handle = p_cb->rc_acp_handle; 12349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb = &p_cb->rcb[p_cb->rc_acp_idx - 1]; 12352356e6fbe66ac3aa027b61cb43a3c3619b3c3a5evegorov@chromium.org p_rcb->shdl = bta_av_get_shdl(p_scb); 12362356e6fbe66ac3aa027b61cb43a3c3619b3c3a5evegorov@chromium.org APPL_TRACE_DEBUG3("update rc_acp shdl:%d/%d srch:%d", index + 1, p_rcb->shdl, 12372356e6fbe66ac3aa027b61cb43a3c3619b3c3a5evegorov@chromium.org p_scb->rc_handle ); 12382356e6fbe66ac3aa027b61cb43a3c3619b3c3a5evegorov@chromium.org 12392356e6fbe66ac3aa027b61cb43a3c3619b3c3a5evegorov@chromium.org p_rcb2 = bta_av_get_rcb_by_shdl(p_rcb->shdl); 1240245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org if (p_rcb2) 1241381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org { 12429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* found the RCB that was created to associated with this SCB */ 12439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->rc_acp_handle = p_rcb2->handle; 12449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->rc_acp_idx = (p_rcb2 - p_cb->rcb) + 1; 12459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG2("new rc_acp_handle:%d, idx:%d", p_cb->rc_acp_handle, 12469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->rc_acp_idx); 12479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb2->lidx = (BTA_AV_NUM_LINKS + 1); 12489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG3("rc2 handle:%d lidx:%d/%d",p_rcb2->handle, p_rcb2->lidx, 12499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->lcb[p_rcb2->lidx-1].lidx); 12509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->lidx = p_lcb->lidx; 12529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG3("rc handle:%d lidx:%d/%d",p_rcb->handle, p_rcb->lidx, 12539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->lcb[p_rcb->lidx-1].lidx); 12549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 12599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 12609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((p_cb->conn_audio & mask) && bta_av_cb.audio_open_cnt) 1261ab99eea3d9d0cc20698ebb39bf0fb80e3e66bffcager@chromium.org { 12629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* this channel is still marked as open. decrease the count */ 12639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.audio_open_cnt--; 12649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 12669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* clear the conned mask for this channel */ 12679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->conn_audio &= ~mask; 12689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->conn_video &= ~mask; 12699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_scb) 12709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 12719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* the stream is closed. 12729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * clear the peer address, so it would not mess up the AVRCP for the next round of operation */ 12739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bdcpy(p_scb->peer_addr, bd_addr_null); 1274245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org if(p_scb->chnl == BTA_AV_CHNL_AUDIO) 12759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 12769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_lcb) 12779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 12789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb->conn_msk &= ~conn_msk; 12799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* audio channel is down. make sure the INT channel is down */ 12819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* just in case the RC timer is active 12829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_cb->features & BTA_AV_FEAT_RCCT) */ 12839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 12849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_stop_timer(&p_scb->timer); 12859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* one audio channel goes down. check if we need to restore high priority */ 12879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com chk_restore = TRUE; 12889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 12919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("bta_av_conn_chg shdl:%d", index + 1); 12929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (i=0; i<BTA_AV_NUM_RCB; i++) 12939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 12949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG5("conn_chg dn[%d]: %d, status=0x%x, shdl:%d, lidx:%d", i, 12959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.rcb[i].handle, bta_av_cb.rcb[i].status, 12969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.rcb[i].shdl, bta_av_cb.rcb[i].lidx); 12979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(bta_av_cb.rcb[i].shdl == index + 1) 1298245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org { 1299381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org bta_av_del_rc(&bta_av_cb.rcb[i]); 13009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break; 13019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_cb->conn_audio == 0 && p_cb->conn_video == 0) 13059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 13069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* if both channels are not connected, 13079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * close all RC channels */ 13089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_close_all_rc(p_cb); 13099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 1310245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org 13119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* if the AVRCP is no longer listening, create the listening channel */ 13129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (bta_av_cb.rc_acp_handle == BTA_AV_RC_HANDLE_NONE && bta_av_cb.features & BTA_AV_FEAT_RCTG) 13139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_rc_create(&bta_av_cb, AVCT_ACP, 0, BTA_AV_NUM_LINKS + 1); 13149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG6("bta_av_conn_chg audio:%x video:%x up:%d conn_msk:0x%x chk_restore:%d audio_open_cnt:%d", 13179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->conn_audio, p_cb->conn_video, p_data->conn_chg.is_up, conn_msk, chk_restore, p_cb->audio_open_cnt); 13189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (chk_restore) 13209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 13219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_cb->audio_open_cnt == 1) 13229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 13239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* one audio channel goes down and there's one audio channel remains open. 13249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * restore the switch role in default link policy */ 13259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_set_default_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH); 13269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* allow role switch, if this is the last connection */ 13279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_restore_switch(); 13289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_cb->audio_open_cnt) 13309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 13319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* adjust flush timeout settings to longer period */ 13329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (i=0; i<BTA_AV_NUM_STRS; i++) 13339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 13349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scbi = bta_av_cb.p_scb[i]; 13359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_scbi && p_scbi->chnl == BTA_AV_CHNL_AUDIO && p_scbi->co_started) 13369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 13379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* may need to update the flush timeout of this already started stream */ 13389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_scbi->co_started != bta_av_cb.audio_open_cnt) 13399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 13409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scbi->co_started = bta_av_cb.audio_open_cnt; 13419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com L2CA_SetFlushTimeout(p_scbi->peer_addr, p_bta_av_cfg->p_audio_flush_to[p_scbi->co_started - 1] ); 13429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 13489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1349245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org/******************************************************************************* 1350381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org** 13519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_disable 13529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 13539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description disable AV. 13549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 13559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 13569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 13579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 13587be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.orgvoid bta_av_disable(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 13597be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org{ 13607be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org BT_HDR hdr; 13619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT16 xx; 13629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->disabling = TRUE; 13649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_close_all_rc(p_cb); 1366245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org 13679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com utl_freebuf((void **) &p_cb->p_disc_db); 13689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* disable audio/video - de-register all channels, 13709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * expect BTA_AV_DEREG_COMP_EVT when deregister is complete */ 13719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for(xx=0; xx<BTA_AV_NUM_STRS; xx++) 13729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 13739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com hdr.layer_specific = xx + 1; 13749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_api_deregister((tBTA_AV_DATA *)&hdr); 13759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 13779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 13799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 13809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_api_disconnect 13819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 13829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description . 13839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 13849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 13859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 13869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 13879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_api_disconnect(tBTA_AV_DATA *p_data) 13889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 13899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com AVDT_DisconnectReq(p_data->api_discnt.bd_addr, bta_av_conn_cback); 13909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_stop_timer(&bta_av_cb.sig_tmr); 13919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 13929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 13949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 13959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_sig_chg 13969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 13979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description process AVDT signal channel up/down. 13989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 13999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 14009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 14019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 14029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_sig_chg(tBTA_AV_DATA *p_data) 14039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 14049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT16 event = p_data->str_msg.hdr.layer_specific; 14057be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org tBTA_AV_CB *p_cb = &bta_av_cb; 14069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int xx; 14079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 mask; 14089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_LCB *p_lcb = NULL; 14099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("bta_av_sig_chg event: %d", event); 14119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(event == AVDT_CONNECT_IND_EVT) 14129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 14139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb = bta_av_find_lcb(p_data->str_msg.bd_addr, BTA_AV_LCB_FIND); 14149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(!p_lcb) 14159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 14169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* if the address does not have an LCB yet, alloc one */ 14179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for(xx=0; xx<BTA_AV_NUM_LINKS; xx++) 14189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 14199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com mask = 1 << xx; 14209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("conn_lcb: 0x%x", p_cb->conn_lcb); 14217be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 14229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* look for a p_lcb with its p_scb registered */ 14239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if((!(mask & p_cb->conn_lcb)) && (p_cb->p_scb[xx] != NULL)) 14249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 14259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb = &p_cb->lcb[xx]; 14269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb->lidx = xx + 1; 14279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bdcpy(p_lcb->addr, p_data->str_msg.bd_addr); 14289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb->conn_msk = 0; /* clear the connect mask */ 14297be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org /* start listening when the signal channel is open */ 14307be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if (p_cb->features & BTA_AV_FEAT_RCTG) 14317be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 14327be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org bta_av_rc_create(p_cb, AVCT_ACP, 0, p_lcb->lidx); 14339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 14349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* this entry is not used yet. */ 14359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->conn_lcb |= mask; /* mark it as used */ 14369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("start sig timer %d", p_data->hdr.offset); 14379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_data->hdr.offset == AVDT_ACP) 14389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 14397be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org APPL_TRACE_DEBUG1("Incoming L2CAP acquired, set state as incoming", NULL); 14409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bdcpy(p_cb->p_scb[xx]->peer_addr, p_data->str_msg.bd_addr); 14419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->p_scb[xx]->use_rc = TRUE; /* allowing RC for incoming connection */ 14429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_ssm_execute(p_cb->p_scb[xx], BTA_AV_ACP_CONNECT_EVT, p_data); 14439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* The Pending Event should be sent as soon as the L2CAP signalling channel 14459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * is set up, which is NOW. Earlier this was done only after 14469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * BTA_AV_SIG_TIME_VAL milliseconds. 14479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * The following function shall send the event and start the recurring timer 14489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com */ 14499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_sig_timer(NULL); 14509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14517be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org /* Possible collision : need to avoid outgoing processing while the timer is running */ 14527be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org p_cb->p_scb[xx]->coll_mask = BTA_AV_COLL_INC_TMR; 14537be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 14547be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org p_cb->acp_sig_tmr.param = (UINT32)xx; 14557be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org p_cb->acp_sig_tmr.p_cback = (TIMER_CBACK*)&bta_av_acp_sig_timer_cback; 14567be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org bta_sys_start_timer(&p_cb->acp_sig_tmr, 0, BTA_AV_ACP_SIG_TIME_VAL); 14577be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 14587be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org break; 14597be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 14607be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 14617be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 14627be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org /* check if we found something */ 14637be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if (xx == BTA_AV_NUM_LINKS) 14647be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 14657be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org /* We do not have scb for this avdt connection. */ 14667be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org /* Silently close the connection. */ 14677be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org APPL_TRACE_ERROR0("av scb not available for avdt connection"); 14687be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org AVDT_DisconnectReq (p_data->str_msg.bd_addr, NULL); 14697be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org return; 14707be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 14717be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 14727be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 14737be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE) 14747be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org else if (event == BTA_AR_AVDT_CONN_EVT) 14757be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 14767be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org bta_sys_stop_timer(&bta_av_cb.sig_tmr); 14777be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 14787be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org#endif 14797be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org else 14807be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 14817be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org /* disconnected. */ 14827be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org p_lcb = bta_av_find_lcb(p_data->str_msg.bd_addr, BTA_AV_LCB_FREE); 14837be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if(p_lcb && p_lcb->conn_msk) 14847be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 14857be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org APPL_TRACE_DEBUG1("conn_msk: 0x%x", p_lcb->conn_msk); 14867be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org /* clean up ssm */ 14877be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org for(xx=0; xx < BTA_AV_NUM_STRS; xx++) 14887be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 14897be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org mask = 1 << (xx + 1); 14907be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if ((mask & p_lcb->conn_msk) && (p_cb->p_scb[xx]) && 14917be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org (bdcmp(p_cb->p_scb[xx]->peer_addr, p_data->str_msg.bd_addr) == 0)) 14927be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 14937be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org bta_av_ssm_execute(p_cb->p_scb[xx], BTA_AV_AVDT_DISCONNECT_EVT, NULL); 14947be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 14957be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 14967be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 14977be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 14987be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org APPL_TRACE_DEBUG1("conn_lcb: 0x%x", p_cb->conn_lcb); 14997be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org} 15007be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 15017be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org/******************************************************************************* 15027be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 15037be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** Function bta_av_sig_timer 15047be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 15057be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** Description process the signal channel timer. This timer is started 15067be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** when the AVDTP signal channel is connected. If no profile 15077be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** is connected, the timer goes off every BTA_AV_SIG_TIME_VAL 15087be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 15097be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** Returns void 15107be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 15117be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org*******************************************************************************/ 15127be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.orgvoid bta_av_sig_timer(tBTA_AV_DATA *p_data) 15137be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org{ 15147be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org tBTA_AV_CB *p_cb = &bta_av_cb; 15157be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org int xx; 15167be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org UINT8 mask; 15179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_LCB *p_lcb = NULL; 15189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_PEND pend; 15199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15207be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org APPL_TRACE_DEBUG0("bta_av_sig_timer"); 15217be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org for(xx=0; xx<BTA_AV_NUM_LINKS; xx++) 15227be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 15237be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org mask = 1 << xx; 15247be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if(mask & p_cb->conn_lcb) 15257be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 15267be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org /* this entry is used. check if it is connected */ 15277be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org p_lcb = &p_cb->lcb[xx]; 15287be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if(!p_lcb->conn_msk) 15297be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 15307be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org bta_sys_start_timer(&p_cb->sig_tmr, BTA_AV_SIG_TIMER_EVT, BTA_AV_SIG_TIME_VAL); 15317be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org bdcpy(pend.bd_addr, p_lcb->addr); 15327be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org (*p_cb->p_cback)(BTA_AV_PENDING_EVT, (tBTA_AV *) &pend); 15339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 15349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 15359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 15367be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org} 15377be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 15387be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org/******************************************************************************* 15397be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 15407be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** Function bta_av_acp_sig_timer_cback 15417be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 15427be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** Description Process the timeout when SRC is accepting connection 15437be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** and SNK did not start signalling. 15447be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 15457be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** Returns void 15467be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org** 15477be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org*******************************************************************************/ 15487be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.orgstatic void bta_av_acp_sig_timer_cback (TIMER_LIST_ENT *p_tle) 15497be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org{ 15507be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org UINT8 inx = (UINT8)p_tle->param; 15517be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org tBTA_AV_CB *p_cb = &bta_av_cb; 15527be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org tBTA_AV_SCB *p_scb = p_cb->p_scb[inx]; 15537be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org tBTA_AV_API_OPEN *p_buf; 15547be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 15557be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if (p_scb) 15567be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 15577be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org APPL_TRACE_DEBUG1("bta_av_acp_sig_timer_cback, coll_mask = 0x%02X", p_scb->coll_mask); 15587be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 1559245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org if (p_scb->coll_mask & BTA_AV_COLL_INC_TMR) 1560381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org { 15619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb->coll_mask &= ~BTA_AV_COLL_INC_TMR; 15629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (bta_av_is_scb_opening(p_scb)) 15649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 15659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_scb->p_disc_db) 15669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 15679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* We are still doing SDP. Run the timer again. */ 15689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb->coll_mask |= BTA_AV_COLL_INC_TMR; 15699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->acp_sig_tmr.param = (UINT32)inx; 15719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->acp_sig_tmr.p_cback = (TIMER_CBACK *)&bta_av_acp_sig_timer_cback; 15729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_start_timer(&p_cb->acp_sig_tmr, 0, BTA_AV_ACP_SIG_TIME_VAL); 15739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 15749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 15759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 15769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* SNK did not start signalling, resume signalling process. */ 15779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_discover_req (p_scb, NULL); 15789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 1579245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org } 15809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else if (bta_av_is_scb_incoming(p_scb)) 15819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 15829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* Stay in incoming state if SNK does not start signalling */ 15839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* API open was called right after SNK opened L2C connection. */ 15859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_scb->coll_mask & BTA_AV_COLL_API_CALLED) 15869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 15879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb->coll_mask &= ~BTA_AV_COLL_API_CALLED; 15889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* BTA_AV_API_OPEN_EVT */ 15909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL) 15919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 15929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com memcpy(p_buf, &(p_scb->open_api), sizeof(tBTA_AV_API_OPEN)); 15939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_sendmsg(p_buf); 15949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 15957be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 15969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 15979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 15989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 15999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 16009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 16019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 16029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 16039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_check_peer_features 16049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 16059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description check supported features on the peer device from the SDP record 16069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** and return the feature mask 16079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 16089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns tBTA_AV_FEAT peer device feature mask 16099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 16109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 16119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comtBTA_AV_FEAT bta_av_check_peer_features (UINT16 service_uuid) 16129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 16139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_FEAT peer_features = 0; 16149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_CB *p_cb = &bta_av_cb; 16159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tSDP_DISC_REC *p_rec = NULL; 16169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tSDP_DISC_ATTR *p_attr; 16179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT16 peer_rc_version=0; 16189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT16 categories = 0; 16199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 16209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("bta_av_check_peer_features service_uuid:x%x", service_uuid); 16219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* loop through all records we found */ 16229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com while (TRUE) 16239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 1624245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org /* get next record; if none found, we're done */ 1625381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org if ((p_rec = SDP_FindServiceInDb(p_cb->p_disc_db, service_uuid, p_rec)) == NULL) 16269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 16279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break; 16289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 16299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 16309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (( SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_CLASS_ID_LIST)) != NULL) 16319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 16329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* find peer features */ 16339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (SDP_FindServiceInDb(p_cb->p_disc_db, UUID_SERVCLASS_AV_REMOTE_CONTROL, NULL)) 16349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 16359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com peer_features |= BTA_AV_FEAT_RCCT; 1636245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org } 16379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (SDP_FindServiceInDb(p_cb->p_disc_db, UUID_SERVCLASS_AV_REM_CTRL_TARGET, NULL)) 16389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 16399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com peer_features |= BTA_AV_FEAT_RCTG; 16409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 16419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 16429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 16439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (( SDP_FindAttributeInRec(p_rec, ATTR_ID_BT_PROFILE_DESC_LIST)) != NULL) 16449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 16459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* get profile version (if failure, version parameter is not updated) */ 16469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_AV_REMOTE_CONTROL, &peer_rc_version); 16479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("peer_rc_version 0x%x", peer_rc_version); 16489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 16499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (peer_rc_version >= AVRC_REV_1_3) 16509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com peer_features |= (BTA_AV_FEAT_VENDOR | BTA_AV_FEAT_METADATA); 16519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 16529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (peer_rc_version >= AVRC_REV_1_4) 16539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 16549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com peer_features |= (BTA_AV_FEAT_ADV_CTRL); 16559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* get supported categories */ 16567be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if ((p_attr = SDP_FindAttributeInRec(p_rec, 16579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ATTR_ID_SUPPORTED_FEATURES)) != NULL) 16589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 16599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com categories = p_attr->attr_value.v.u16; 16609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (categories & AVRC_SUPF_CT_BROWSE) 16619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com peer_features |= (BTA_AV_FEAT_BROWSE); 16629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 16639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 16649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 16659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 16669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("peer_features:x%x", peer_features); 16679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return peer_features; 16689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 16692356e6fbe66ac3aa027b61cb43a3c3619b3c3a5evegorov@chromium.org 16709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 16719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 16729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_rc_disc_done 16739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 16749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description Handle AVRCP service discovery results. If matching 16759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** service found, open AVRCP connection. 16769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 16779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 16789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 16799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 16809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_rc_disc_done(tBTA_AV_DATA *p_data) 16819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 16829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_CB *p_cb = &bta_av_cb; 16839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_SCB *p_scb = NULL; 16849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_LCB *p_lcb; 16859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RC_OPEN rc_open; 1686245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org tBTA_AV_RC_FEAT rc_feat; 1687381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org UINT8 rc_handle; 16889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_FEAT peer_features; /* peer features mask */ 16899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 16909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("bta_av_rc_disc_done disc:x%x", p_cb->disc); 16919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (!p_cb->disc) 16929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 16939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return; 16949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 16959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 16969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((p_cb->disc & BTA_AV_CHNL_MSK) == BTA_AV_CHNL_MSK) 16979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 1698245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org /* this is the rc handle/index to tBTA_AV_RCB */ 16999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_handle = p_cb->disc & (~BTA_AV_CHNL_MSK); 17009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 17019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 17029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb = p_cb->p_scb[(p_cb->disc & BTA_AV_HNDL_MSK) - 1]; 17049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_scb) 17059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_handle = p_scb->rc_handle; 17069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 17079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->disc = 0; 17099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return; 17109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 17119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 17129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("rc_handle %d", rc_handle); 17147be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org /* check peer version and whether support CT and TG role */ 17159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com peer_features = bta_av_check_peer_features (UUID_SERVCLASS_AV_REMOTE_CONTROL); 17169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((p_cb->features & BTA_AV_FEAT_ADV_CTRL) && ((peer_features&BTA_AV_FEAT_ADV_CTRL) == 0)) 17179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* if we support advance control and peer does not, check their support on TG role 17199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com * some implementation uses 1.3 on CT ans 1.4 on TG */ 17209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com peer_features |= bta_av_check_peer_features (UUID_SERVCLASS_AV_REM_CTRL_TARGET); 17219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 17229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->disc = 0; 17249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com utl_freebuf((void **) &p_cb->p_disc_db); 17259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG2("peer_features 0x%x, features 0x%x", peer_features, p_cb->features); 17279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* if we have no rc connection */ 17299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (rc_handle == BTA_AV_RC_HANDLE_NONE) 17309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_scb) 17329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* if peer remote control service matches ours and USE_RC is TRUE */ 17349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((((p_cb->features & BTA_AV_FEAT_RCCT) && (peer_features & BTA_AV_FEAT_RCTG)) || 17359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ((p_cb->features & BTA_AV_FEAT_RCTG) && (peer_features & BTA_AV_FEAT_RCCT))) ) 17369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb = bta_av_find_lcb(p_scb->peer_addr, BTA_AV_LCB_FIND); 17389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_lcb) 17399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_handle = bta_av_rc_create(p_cb, AVCT_INT, (UINT8)(p_scb->hdi + 1), p_lcb->lidx); 1741245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org p_cb->rcb[rc_handle].peer_features = peer_features; 1742381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 17439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if (BT_USE_TRACES == TRUE || BT_TRACE_APPL == TRUE) 17449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 17459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_ERROR0("can not find LCB!!"); 17479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 17489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#endif 17499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 17509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else if(p_scb->use_rc) 17519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* can not find AVRC on peer device. report failure */ 1753245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org p_scb->use_rc = FALSE; 17549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bdcpy(rc_open.peer_addr, p_scb->peer_addr); 17559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_open.peer_features = 0; 17569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_open.status = BTA_AV_FAIL_SDP; 17579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (*p_cb->p_cback)(BTA_AV_RC_OPEN_EVT, (tBTA_AV *) &rc_open); 17589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 17599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 17609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 17619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 17629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->rcb[rc_handle].peer_features = peer_features; 17649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_feat.rc_handle = rc_handle; 17659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_feat.peer_features = peer_features; 17669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (*p_cb->p_cback)(BTA_AV_RC_FEAT_EVT, (tBTA_AV *) &rc_feat); 17679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 17689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 17699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17707be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org/******************************************************************************* 17719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 17729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_rc_closed 17739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 17749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description Set AVRCP state to closed. 17759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 17769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 17779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 17789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 17799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_rc_closed(tBTA_AV_DATA *p_data) 17809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 17819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_CB *p_cb = &bta_av_cb; 17829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RC_CLOSE rc_close; 17839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RC_CONN_CHG *p_msg = (tBTA_AV_RC_CONN_CHG *)p_data; 17849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_RCB *p_rcb; 17859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_SCB *p_scb; 17869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int i; 17879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com BOOLEAN conn = FALSE; 17889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_LCB *p_lcb; 17899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_close.rc_handle = BTA_AV_RC_HANDLE_NONE; 17919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("bta_av_rc_closed rc_handle:%d", p_msg->handle); 17929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for(i=0; i<BTA_AV_NUM_RCB; i++) 17939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb = &p_cb->rcb[i]; 17959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG3("bta_av_rc_closed rcb[%d] rc_handle:%d, status=0x%x", i, p_rcb->handle, p_rcb->status); 17969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_rcb->handle == p_msg->handle) 17979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 17989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_close.rc_handle = i; 17999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->status &= ~BTA_AV_RC_CONN_MASK; 1800245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org p_rcb->peer_features = 0; 1801381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org APPL_TRACE_DEBUG2(" shdl:%d, lidx:%d", p_rcb->shdl, p_rcb->lidx); 18029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_rcb->shdl) 18039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 18049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb = bta_av_cb.p_scb[p_rcb->shdl - 1]; 18059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_scb) 18069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 18079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bdcpy(rc_close.peer_addr, p_scb->peer_addr); 18089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_scb->rc_handle == p_rcb->handle) 18099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb->rc_handle = BTA_AV_RC_HANDLE_NONE; 18109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG2("shdl:%d, srch:%d", p_rcb->shdl, p_scb->rc_handle); 18119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 1812245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org p_rcb->shdl = 0; 18139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else if(p_rcb->lidx == (BTA_AV_NUM_LINKS + 1) ) 18159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 18169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* if the RCB uses the extra LCB, use the addr for event and clean it */ 18179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb = &p_cb->lcb[BTA_AV_NUM_LINKS]; 18189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bdcpy(rc_close.peer_addr, p_msg->peer_addr); 18199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG6("rc_only closed bd_addr:%02x-%02x-%02x-%02x-%02x-%02x", 18209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_msg->peer_addr[0], p_msg->peer_addr[1], 18219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_msg->peer_addr[2], p_msg->peer_addr[3], 18229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_msg->peer_addr[4], p_msg->peer_addr[5]); 18239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb->conn_msk = 0; 18249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_lcb->lidx = 0; 18259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->lidx = 0; 18279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if((p_rcb->status & BTA_AV_RC_ROLE_MASK) == BTA_AV_RC_ROLE_INT) 18299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 18309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* AVCT CCB is deallocated */ 18317be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org p_rcb->handle = BTA_AV_RC_HANDLE_NONE; 18329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_rcb->status = 0; 18339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 18359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 18369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* AVCT CCB is still there. dealloc */ 18379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_del_rc(p_rcb); 18389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* if the AVRCP is no longer listening, create the listening channel */ 18409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (bta_av_cb.rc_acp_handle == BTA_AV_RC_HANDLE_NONE && bta_av_cb.features & BTA_AV_FEAT_RCTG) 18419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_rc_create(&bta_av_cb, AVCT_ACP, 0, BTA_AV_NUM_LINKS + 1); 18429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else if((p_rcb->handle != BTA_AV_RC_HANDLE_NONE) && (p_rcb->status & BTA_AV_RC_CONN_MASK)) 18459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 18469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* at least one channel is still connected */ 18479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com conn = TRUE; 18489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(!conn) 18529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 18539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* no AVRC channels are connected, go back to INIT state */ 18549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_sm_execute(p_cb, BTA_AV_AVRC_NONE_EVT, NULL); 18559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18577be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if (rc_close.rc_handle == BTA_AV_RC_HANDLE_NONE) 18589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 18599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com rc_close.rc_handle = p_msg->handle; 18609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bdcpy(rc_close.peer_addr, p_msg->peer_addr); 18619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com (*p_cb->p_cback)(BTA_AV_RC_CLOSE_EVT, (tBTA_AV *) &rc_close); 18639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 18649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com/******************************************************************************* 1866245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org** 1867381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org** Function bta_av_rc_disc 18689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 18699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description start AVRC SDP discovery. 18709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 18719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 18729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 18739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 18749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_rc_disc(UINT8 disc) 18759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 18769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_CB *p_cb = &bta_av_cb; 18779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tAVRC_SDP_DB_PARAMS db_params; 1878245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org UINT16 attr_list[] = {ATTR_ID_SERVICE_CLASS_ID_LIST, 18799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ATTR_ID_BT_PROFILE_DESC_LIST, 18809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ATTR_ID_SUPPORTED_FEATURES}; 18819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 hdi; 18829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_SCB *p_scb; 18839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 *p_addr = NULL; 18849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 rc_handle; 18859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG2("bta_av_rc_disc 0x%x, %d", disc, bta_av_cb.disc); 18879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((bta_av_cb.disc != 0) || (disc == 0)) 18889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return; 18899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((disc & BTA_AV_CHNL_MSK) == BTA_AV_CHNL_MSK) 18919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 18929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* this is the rc handle/index to tBTA_AV_RCB */ 18937be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org rc_handle = disc & (~BTA_AV_CHNL_MSK); 18947be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if (p_cb->rcb[rc_handle].lidx) 18959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 18969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_addr = p_cb->lcb[p_cb->rcb[rc_handle].lidx-1].addr; 18979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 19009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 19019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com hdi = (disc & BTA_AV_HNDL_MSK) - 1; 19029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb = p_cb->p_scb[hdi]; 19039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_scb) 19059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 19069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("rc_handle %d", p_scb->rc_handle); 19079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_addr = p_scb->peer_addr; 19089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 19099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 19109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_addr) 19129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 19139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* allocate discovery database */ 19149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_cb->p_disc_db == NULL) 19157be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 19169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_AV_DISC_BUF_SIZE); 19179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 19189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (p_cb->p_disc_db) 19209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 19219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* set up parameters */ 1922245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org db_params.db_len = BTA_AV_DISC_BUF_SIZE; 1923381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org db_params.num_attr = 3; 19249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com db_params.p_db = p_cb->p_disc_db; 19259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com db_params.p_attrs = attr_list; 19269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* searching for UUID_SERVCLASS_AV_REMOTE_CONTROL gets both TG and CT */ 19289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (AVRC_FindService(UUID_SERVCLASS_AV_REMOTE_CONTROL, p_addr, &db_params, 19299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_avrc_sdp_cback) == AVRC_SUCCESS) 19309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 19319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->disc = disc; 19329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG1("disc %d", p_cb->disc); 19339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 19349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 19359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 19369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 19379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1938245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org/******************************************************************************* 19399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 19409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Function bta_av_dereg_comp 19419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 19429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Description deregister complete. free the stream control block. 19439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 19449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** Returns void 19459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com** 19469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com*******************************************************************************/ 19479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid bta_av_dereg_comp(tBTA_AV_DATA *p_data) 19489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com{ 19499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_CB *p_cb = &bta_av_cb; 19509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_AV_SCB *p_scb; 19519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com tBTA_UTL_COD cod; 19529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com UINT8 mask; 19539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com BT_HDR *p_buf; 19549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* find the stream control block */ 19569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_scb = bta_av_hndl_to_scb(p_data->hdr.layer_specific); 19579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_scb) 19597be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 19607be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org APPL_TRACE_DEBUG2("deregistered %d(h%d)", p_scb->chnl, p_scb->hndl); 19617be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org mask = BTA_AV_HNDL_TO_MSK(p_scb->hdi); 19629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_scb->chnl == BTA_AV_CHNL_AUDIO) 19639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 19649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->reg_audio &= ~mask; 19659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if ((p_cb->conn_audio & mask) && bta_av_cb.audio_open_cnt) 19669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 19679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* this channel is still marked as open. decrease the count */ 19689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.audio_open_cnt--; 19699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 19709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->conn_audio &= ~mask; 19719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1972c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org if (p_scb->q_tag == BTA_AV_Q_TAG_STREAM) 19739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 19749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* make sure no buffers are in q_info.a2d */ 19759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com while((p_buf = (BT_HDR*)GKI_dequeue (&p_scb->q_info.a2d)) != NULL) 19769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com GKI_freebuf(p_buf); 19779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 19789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* remove the A2DP SDP record, if no more audio stream is left */ 19809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(!p_cb->reg_audio) 19819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 19829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE) 19839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_ar_dereg_avrc (UUID_SERVCLASS_AV_REMOTE_CONTROL, BTA_ID_AV); 19849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#endif 19859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_del_sdp_rec(&p_cb->sdp_a2d_handle); 19867be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org bta_sys_remove_uuid(UUID_SERVCLASS_AUDIO_SOURCE); 19879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 19889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 19899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com else 19909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 19919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->reg_video &= ~mask; 19929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* make sure that this channel is not connected */ 19939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->conn_video &= ~mask; 19949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* remove the VDP SDP record, (only one video stream at most) */ 19959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_del_sdp_rec(&p_cb->sdp_vdp_handle); 19969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_remove_uuid(UUID_SERVCLASS_VIDEO_SOURCE); 19979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 19987be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 19999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* make sure that the timer is not active */ 20009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_sys_stop_timer(&p_scb->timer); 20019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com utl_freebuf((void **)&p_cb->p_scb[p_scb->hdi]); 20029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 20039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com APPL_TRACE_DEBUG3("audio 0x%x, video: 0x%x, disable:%d", 20059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->reg_audio, p_cb->reg_video, p_cb->disabling); 20069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* if no stream control block is active */ 20079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if((p_cb->reg_audio + p_cb->reg_video) == 0) 2008c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org { 20099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE) 20109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* deregister from AVDT */ 20117be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org bta_ar_dereg_avdt(BTA_ID_AV); 20129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* deregister from AVCT */ 20149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_ar_dereg_avrc (UUID_SERVCLASS_AV_REM_CTRL_TARGET, BTA_ID_AV); 20159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_ar_dereg_avct(BTA_ID_AV); 20169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#endif 2017c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org 20189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if(p_cb->disabling) 20199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com { 20209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com p_cb->disabling = FALSE; 20219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com bta_av_cb.features = 0; 20229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 20239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com /* Clear the Capturing service class bit */ 20259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com cod.service = BTM_COD_SERVICE_CAPTURING; 20269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com utl_set_device_class(&cod, BTA_UTL_CLR_COD_SERVICE_CLASS); 20279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 2028245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org} 2029381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org#endif /* BTA_AV_INCLUDED */ 20309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com