*
******************************************************************************/
AvdtpTransportChannel* avdt_ad_tc_tbl_by_lcid(uint16_t lcid) {
- uint8_t idx;
-
- idx = avdtp_cb.ad.lcid_tbl[lcid - L2CAP_BASE_APPL_CID];
-
- if (idx < AVDT_NUM_TC_TBL) {
+ if (avdtp_cb.ad.lcid_tbl.count(lcid) != 0) {
+ uint8_t idx = avdtp_cb.ad.lcid_tbl[lcid];
return &avdtp_cb.ad.tc_tbl[idx];
} else {
- return NULL;
+ return nullptr;
}
}
L2CA_ConnectReq2(AVDT_PSM, p_ccb->peer_addr, BTM_SEC_OUT_AUTHENTICATE);
if (lcid != 0) {
/* if connect req ok, store tcid in lcid table */
- avdtp_cb.ad.lcid_tbl[lcid - L2CAP_BASE_APPL_CID] =
- avdt_ad_tc_tbl_to_idx(p_tbl);
- AVDT_TRACE_DEBUG("avdtp_cb.ad.lcid_tbl[%d] = %d",
- (lcid - L2CAP_BASE_APPL_CID),
+ avdtp_cb.ad.lcid_tbl[lcid] = avdt_ad_tc_tbl_to_idx(p_tbl);
+ AVDT_TRACE_DEBUG("avdtp_cb.ad.lcid_tbl[%d] = %d", (lcid),
avdt_ad_tc_tbl_to_idx(p_tbl));
avdtp_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][p_tbl->tcid].lcid = lcid;
#ifndef AVDT_INT_H
#define AVDT_INT_H
+#include <unordered_map>
+
#include "avdt_api.h"
#include "avdt_defs.h"
#include "avdtc_api.h"
*/
class AvdtpAdaptationLayer {
public:
- AvdtpAdaptationLayer() : lcid_tbl{} {}
+ AvdtpAdaptationLayer() {}
void Reset() {
for (size_t i = 0; i < AVDT_NUM_LINKS; i++) {
for (size_t i = 0; i < AVDT_NUM_TC_TBL; i++) {
tc_tbl[i].Reset();
}
- memset(lcid_tbl, 0, sizeof(lcid_tbl));
+ lcid_tbl.clear();
}
/**
AvdtpRoutingEntry rt_tbl[AVDT_NUM_LINKS][AVDT_NUM_RT_TBL];
AvdtpTransportChannel tc_tbl[AVDT_NUM_TC_TBL];
- uint8_t lcid_tbl[MAX_L2CAP_CHANNELS]; // Map LCID to tc_tbl index
+
+ std::unordered_map<uint16_t, uint8_t> lcid_tbl; // Map LCID to tc_tbl index
};
/**
if (p_tbl == NULL) return;
/* store idx in LCID table, store LCID in routing table */
- avdtp_cb.ad.lcid_tbl[p_tbl->lcid - L2CAP_BASE_APPL_CID] =
- avdt_ad_tc_tbl_to_idx(p_tbl);
+ avdtp_cb.ad.lcid_tbl[p_tbl->lcid] = avdt_ad_tc_tbl_to_idx(p_tbl);
avdtp_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][p_tbl->tcid].lcid = p_tbl->lcid;
/* transition to configuration state */
/* if result ok, proceed with connection */
/* store idx in LCID table, store LCID in routing table */
- avdtp_cb.ad.lcid_tbl[lcid - L2CAP_BASE_APPL_CID] =
- avdt_ad_tc_tbl_to_idx(p_tbl);
+ avdtp_cb.ad.lcid_tbl[lcid] = avdt_ad_tc_tbl_to_idx(p_tbl);
avdtp_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][p_tbl->tcid].lcid = lcid;
/* transition to configuration state */