Bluetooth: AVDTP:Add Accept Incoming connection cb
Added Accept Incoming connection callbacks for the A2DP layer Change-Id: I8aee32a97916ed9fc9c4050151e7395e288c404c Signed-off-by: Arun Jagadish <arun.jagadish@intel.com>
This commit is contained in:
parent
c2a2841212
commit
231050a966
2 changed files with 25 additions and 50 deletions
|
@ -47,8 +47,6 @@ NET_BUF_POOL_DEFINE(avdtp_sig_pool, CONFIG_BLUETOOTH_AVDTP_CONN,
|
|||
BT_BUF_USER_DATA_MIN, NULL);
|
||||
*/
|
||||
|
||||
static struct bt_avdtp bt_avdtp_pool[CONFIG_BLUETOOTH_AVDTP_CONN];
|
||||
|
||||
static struct bt_avdtp_event_cb *event_cb;
|
||||
|
||||
static struct bt_avdtp_seid_lsep *lseps;
|
||||
|
@ -81,7 +79,6 @@ void bt_avdtp_l2cap_connected(struct bt_l2cap_chan *chan)
|
|||
|
||||
session = AVDTP_CHAN(chan);
|
||||
BT_DBG("chan %p session %p", chan, session);
|
||||
|
||||
/* Init the timer */
|
||||
k_delayed_work_init(&session->req.timeout_work, avdtp_timeout);
|
||||
|
||||
|
@ -89,12 +86,11 @@ void bt_avdtp_l2cap_connected(struct bt_l2cap_chan *chan)
|
|||
|
||||
void bt_avdtp_l2cap_disconnected(struct bt_l2cap_chan *chan)
|
||||
{
|
||||
if (!chan) {
|
||||
BT_ERR("Invalid AVDTP chan");
|
||||
return;
|
||||
}
|
||||
struct bt_avdtp *session = AVDTP_CHAN(chan);
|
||||
|
||||
BT_DBG("chan %p session %p", chan, AVDTP_CHAN(chan));
|
||||
BT_DBG("chan %p session %p", chan, session);
|
||||
session->br_chan.chan.conn = NULL;
|
||||
/* Clear the Pending req if set*/
|
||||
}
|
||||
|
||||
void bt_avdtp_l2cap_encrypt_changed(struct bt_l2cap_chan *chan, uint8_t status)
|
||||
|
@ -141,7 +137,8 @@ int bt_avdtp_disconnect(struct bt_avdtp *session)
|
|||
|
||||
int bt_avdtp_l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
|
||||
{
|
||||
int i;
|
||||
struct bt_avdtp *session = NULL;
|
||||
int result;
|
||||
static struct bt_l2cap_chan_ops ops = {
|
||||
.connected = bt_avdtp_l2cap_connected,
|
||||
.disconnected = bt_avdtp_l2cap_disconnected,
|
||||
|
@ -149,23 +146,17 @@ int bt_avdtp_l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
|
|||
};
|
||||
|
||||
BT_DBG("conn %p", conn);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_avdtp_pool); i++) {
|
||||
struct bt_avdtp *avdtp = &bt_avdtp_pool[i];
|
||||
|
||||
if (avdtp->br_chan.chan.conn) {
|
||||
continue;
|
||||
/* Get the AVDTP session from upper layer */
|
||||
result = event_cb->accept(conn, &session);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
avdtp->br_chan.chan.ops = &ops;
|
||||
avdtp->br_chan.rx.mtu = BT_AVDTP_MAX_MTU;
|
||||
*chan = &avdtp->br_chan.chan;
|
||||
session->br_chan.chan.ops = &ops;
|
||||
session->br_chan.rx.mtu = BT_AVDTP_MAX_MTU;
|
||||
*chan = &session->br_chan.chan;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Application will register its callback */
|
||||
int bt_avdtp_register(struct bt_avdtp_event_cb *cb)
|
||||
{
|
||||
|
|
|
@ -55,16 +55,12 @@
|
|||
#define BT_AVDTP_GET_ALL_CAPABILITIES 0x0c
|
||||
#define BT_AVDTP_DELAYREPORT 0x0d
|
||||
|
||||
/* @brief AVDTP STATE */
|
||||
#define BT_AVDTP_STATE_IDLE 0x01
|
||||
#define BT_AVDTP_STATE_CONFIGURED 0x02
|
||||
#define BT_AVDTP_STATE_OPEN 0x03
|
||||
#define BT_AVDTP_STATE_STREAMING 0x04
|
||||
#define BT_AVDTP_STATE_CLOSING 0x05
|
||||
#define BT_AVDTP_STATE_ABORT 0x06
|
||||
#define BT_AVDTP_STATE_SIG_CONNECTED 0x07
|
||||
#define BT_AVDTP_STATE_SIG_DISCONNECTED 0x08
|
||||
#define BT_AVDTP_STATE_INVALID 0x00
|
||||
/* @brief AVDTP STREAM STATE */
|
||||
#define BT_AVDTP_STREAM_STATE_IDLE 0x01
|
||||
#define BT_AVDTP_STREAM_STATE_CONFIGURED 0x02
|
||||
#define BT_AVDTP_STREAM_STATE_OPEN 0x03
|
||||
#define BT_AVDTP_STREAM_STATE_STREAMING 0x04
|
||||
#define BT_AVDTP_STREAM_STATE_CLOSING 0x05
|
||||
|
||||
/* @brief AVDTP Media TYPE */
|
||||
#define BT_AVDTP_SERVICE_CAT_MEDIA_TRANSPORT 0x01
|
||||
|
@ -115,18 +111,6 @@ struct bt_avdtp_single_sig_hdr {
|
|||
|
||||
#define BT_AVDTP_SIG_HDR_LEN sizeof(struct bt_avdtp_single_sig_hdr)
|
||||
|
||||
struct bt_avdtp_cfm_cb {
|
||||
/*
|
||||
* Discovery_cfm;
|
||||
* get_capabilities_cfm;
|
||||
* set_configuration_cfm;
|
||||
* open_cfm;
|
||||
* start_cfm;
|
||||
* suspend_cfm;
|
||||
* close_cfm;
|
||||
*/
|
||||
};
|
||||
|
||||
struct bt_avdtp_ind_cb {
|
||||
/*
|
||||
* discovery_ind;
|
||||
|
@ -139,11 +123,6 @@ struct bt_avdtp_ind_cb {
|
|||
*/
|
||||
};
|
||||
|
||||
struct bt_avdtp_event_cb {
|
||||
struct bt_avdtp_ind_cb *ind;
|
||||
struct bt_avdtp_cfm_cb *cfm;
|
||||
};
|
||||
|
||||
struct bt_pending_req {
|
||||
uint8_t signal_id;
|
||||
uint8_t transaction_id;
|
||||
|
@ -157,6 +136,11 @@ struct bt_avdtp {
|
|||
struct bt_pending_req req;
|
||||
};
|
||||
|
||||
struct bt_avdtp_event_cb {
|
||||
struct bt_avdtp_ind_cb *ind;
|
||||
int (*accept)(struct bt_conn *conn, struct bt_avdtp **session);
|
||||
};
|
||||
|
||||
/* Initialize AVDTP layer*/
|
||||
int bt_avdtp_init(void);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue