Bluetooth: A2DP: clang-format the codes
run clang-format Signed-off-by: Mark Wang <yichang.wang@nxp.com>
This commit is contained in:
parent
4137c11ee3
commit
b8399c31a2
5 changed files with 286 additions and 334 deletions
|
|
@ -30,34 +30,33 @@ extern "C" {
|
|||
/** MPEG2,4 IE length */
|
||||
#define BT_A2DP_MPEG_2_4_IE_LENGTH (6u)
|
||||
/** The max IE (Codec Info Element) length */
|
||||
#define A2DP_MAX_IE_LENGTH (8U)
|
||||
#define A2DP_MAX_IE_LENGTH (8U)
|
||||
|
||||
/** @brief define the audio endpoint
|
||||
* @param _role BT_AVDTP_SOURCE or BT_AVDTP_SINK.
|
||||
* @param _codec value of enum bt_a2dp_codec_id.
|
||||
* @param _capability the codec capability.
|
||||
*/
|
||||
#define BT_A2DP_EP_INIT(_role, _codec, _capability)\
|
||||
{\
|
||||
.codec_type = _codec,\
|
||||
.sep = {.sep_info = {.media_type = BT_AVDTP_AUDIO, .tsep = _role}},\
|
||||
.codec_cap = _capability,\
|
||||
.stream = NULL,\
|
||||
}
|
||||
#define BT_A2DP_EP_INIT(_role, _codec, _capability) \
|
||||
{ \
|
||||
.codec_type = _codec, \
|
||||
.sep = {.sep_info = {.media_type = BT_AVDTP_AUDIO, .tsep = _role}}, \
|
||||
.codec_cap = _capability, .stream = NULL, \
|
||||
}
|
||||
|
||||
/** @brief define the audio sink endpoint
|
||||
* @param _codec value of enum bt_a2dp_codec_id.
|
||||
* @param _capability the codec capability.
|
||||
*/
|
||||
#define BT_A2DP_SINK_EP_INIT(_codec, _capability)\
|
||||
BT_A2DP_EP_INIT(BT_AVDTP_SINK, _codec, _capability)
|
||||
#define BT_A2DP_SINK_EP_INIT(_codec, _capability) \
|
||||
BT_A2DP_EP_INIT(BT_AVDTP_SINK, _codec, _capability)
|
||||
|
||||
/** @brief define the audio source endpoint
|
||||
* @param _codec value of enum bt_a2dp_codec_id.
|
||||
* @param _capability the codec capability.
|
||||
*/
|
||||
#define BT_A2DP_SOURCE_EP_INIT(_codec, _capability)\
|
||||
BT_A2DP_EP_INIT(BT_AVDTP_SOURCE, _codec, _capability)
|
||||
#define BT_A2DP_SOURCE_EP_INIT(_codec, _capability) \
|
||||
BT_A2DP_EP_INIT(BT_AVDTP_SOURCE, _codec, _capability)
|
||||
|
||||
/** @brief define the SBC sink endpoint that can be used as
|
||||
* bt_a2dp_register_endpoint's parameter.
|
||||
|
|
@ -80,13 +79,14 @@ BT_A2DP_EP_INIT(BT_AVDTP_SOURCE, _codec, _capability)
|
|||
* @param _max_bitpool sbc codec max bit pool. for example: 35
|
||||
* @
|
||||
*/
|
||||
#define BT_A2DP_SBC_SINK_EP(_name, _freq, _ch_mode, _blk_len, _subband,\
|
||||
_alloc_mthd, _min_bitpool, _max_bitpool)\
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
|
||||
{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq | _ch_mode,\
|
||||
_blk_len | _subband | _alloc_mthd, _min_bitpool, _max_bitpool}};\
|
||||
static struct bt_a2dp_ep _name = BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC,\
|
||||
(&bt_a2dp_ep_cap_ie##_name))
|
||||
#define BT_A2DP_SBC_SINK_EP(_name, _freq, _ch_mode, _blk_len, _subband, _alloc_mthd, _min_bitpool, \
|
||||
_max_bitpool) \
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = { \
|
||||
.len = BT_A2DP_SBC_IE_LENGTH, \
|
||||
.codec_ie = {_freq | _ch_mode, _blk_len | _subband | _alloc_mthd, _min_bitpool, \
|
||||
_max_bitpool}}; \
|
||||
static struct bt_a2dp_ep _name = \
|
||||
BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC, (&bt_a2dp_ep_cap_ie##_name))
|
||||
|
||||
/** @brief define the SBC source endpoint that can be used as bt_a2dp_register_endpoint's
|
||||
* parameter.
|
||||
|
|
@ -108,13 +108,14 @@ static struct bt_a2dp_ep _name = BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC,\
|
|||
* @param _min_bitpool sbc codec min bit pool. for example: 18
|
||||
* @param _max_bitpool sbc codec max bit pool. for example: 35
|
||||
*/
|
||||
#define BT_A2DP_SBC_SOURCE_EP(_name, _freq, _ch_mode, _blk_len, _subband,\
|
||||
_alloc_mthd, _min_bitpool, _max_bitpool)\
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
|
||||
{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq | _ch_mode,\
|
||||
_blk_len | _subband | _alloc_mthd, _min_bitpool, _max_bitpool}};\
|
||||
static struct bt_a2dp_ep _name = BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC,\
|
||||
&bt_a2dp_ep_cap_ie##_name)
|
||||
#define BT_A2DP_SBC_SOURCE_EP(_name, _freq, _ch_mode, _blk_len, _subband, _alloc_mthd, \
|
||||
_min_bitpool, _max_bitpool) \
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = { \
|
||||
.len = BT_A2DP_SBC_IE_LENGTH, \
|
||||
.codec_ie = {_freq | _ch_mode, _blk_len | _subband | _alloc_mthd, _min_bitpool, \
|
||||
_max_bitpool}}; \
|
||||
static struct bt_a2dp_ep _name = \
|
||||
BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC, &bt_a2dp_ep_cap_ie##_name)
|
||||
|
||||
/** @brief define the default SBC sink endpoint that can be used as
|
||||
* bt_a2dp_register_endpoint's parameter.
|
||||
|
|
@ -124,14 +125,17 @@ static struct bt_a2dp_ep _name = BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC,\
|
|||
*
|
||||
* @param _name the endpoint variable name.
|
||||
*/
|
||||
#define BT_A2DP_SBC_SINK_EP_DEFAULT(_name)\
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
|
||||
{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {A2DP_SBC_SAMP_FREQ_44100 |\
|
||||
A2DP_SBC_SAMP_FREQ_48000 | A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO |\
|
||||
A2DP_SBC_CH_MODE_JOINT, A2DP_SBC_BLK_LEN_16 |\
|
||||
A2DP_SBC_SUBBAND_8 | A2DP_SBC_ALLOC_MTHD_LOUDNESS, 18U, 35U}};\
|
||||
static struct bt_a2dp_ep _name = BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC,\
|
||||
&bt_a2dp_ep_cap_ie##_name)
|
||||
#define BT_A2DP_SBC_SINK_EP_DEFAULT(_name) \
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = { \
|
||||
.len = BT_A2DP_SBC_IE_LENGTH, \
|
||||
.codec_ie = {A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000 | \
|
||||
A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO | \
|
||||
A2DP_SBC_CH_MODE_JOINT, \
|
||||
A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | \
|
||||
A2DP_SBC_ALLOC_MTHD_LOUDNESS, \
|
||||
18U, 35U}}; \
|
||||
static struct bt_a2dp_ep _name = \
|
||||
BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC, &bt_a2dp_ep_cap_ie##_name)
|
||||
|
||||
/** @brief define the default SBC source endpoint that can be used as bt_a2dp_register_endpoint's
|
||||
* parameter.
|
||||
|
|
@ -141,14 +145,18 @@ static struct bt_a2dp_ep _name = BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC,\
|
|||
*
|
||||
* @param _name the endpoint variable name.
|
||||
*/
|
||||
#define BT_A2DP_SBC_SOURCE_EP_DEFAULT(_name)\
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
|
||||
{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {A2DP_SBC_SAMP_FREQ_44100 | \
|
||||
A2DP_SBC_SAMP_FREQ_48000 | A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO | \
|
||||
A2DP_SBC_CH_MODE_JOINT, A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | A2DP_SBC_ALLOC_MTHD_LOUDNESS,\
|
||||
18U, 35U},};\
|
||||
static struct bt_a2dp_ep _name = BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC,\
|
||||
&bt_a2dp_ep_cap_ie##_name)
|
||||
#define BT_A2DP_SBC_SOURCE_EP_DEFAULT(_name) \
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = { \
|
||||
.len = BT_A2DP_SBC_IE_LENGTH, \
|
||||
.codec_ie = {A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000 | \
|
||||
A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO | \
|
||||
A2DP_SBC_CH_MODE_JOINT, \
|
||||
A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | \
|
||||
A2DP_SBC_ALLOC_MTHD_LOUDNESS, \
|
||||
18U, 35U}, \
|
||||
}; \
|
||||
static struct bt_a2dp_ep _name = \
|
||||
BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC, &bt_a2dp_ep_cap_ie##_name)
|
||||
|
||||
/** @brief define the SBC default configuration.
|
||||
*
|
||||
|
|
@ -166,23 +174,34 @@ static struct bt_a2dp_ep _name = BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC,\
|
|||
* @param _min_bitpool_cfg sbc codec min bit pool. for example: 18
|
||||
* @param _max_bitpool_cfg sbc codec max bit pool. for example: 35
|
||||
*/
|
||||
#define BT_A2DP_SBC_EP_CFG(_name, _freq_cfg, _ch_mode_cfg, _blk_len_cfg, _subband_cfg,\
|
||||
_alloc_mthd_cfg, _min_bitpool_cfg, _max_bitpool_cfg)\
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = {\
|
||||
.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq_cfg | _ch_mode_cfg,\
|
||||
_blk_len_cfg | _subband_cfg | _alloc_mthd_cfg, _min_bitpool_cfg, _max_bitpool_cfg},};\
|
||||
struct bt_a2dp_codec_cfg _name = {.codec_config = &bt_a2dp_codec_ie##_name,}
|
||||
#define BT_A2DP_SBC_EP_CFG(_name, _freq_cfg, _ch_mode_cfg, _blk_len_cfg, _subband_cfg, \
|
||||
_alloc_mthd_cfg, _min_bitpool_cfg, _max_bitpool_cfg) \
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = { \
|
||||
.len = BT_A2DP_SBC_IE_LENGTH, \
|
||||
.codec_ie = {_freq_cfg | _ch_mode_cfg, \
|
||||
_blk_len_cfg | _subband_cfg | _alloc_mthd_cfg, _min_bitpool_cfg, \
|
||||
_max_bitpool_cfg}, \
|
||||
}; \
|
||||
struct bt_a2dp_codec_cfg _name = { \
|
||||
.codec_config = &bt_a2dp_codec_ie##_name, \
|
||||
}
|
||||
|
||||
/** @brief define the SBC default configuration.
|
||||
*
|
||||
* @param _name unique structure name postfix.
|
||||
* @param _freq_cfg the frequency to configure the remote same codec type endpoint.
|
||||
*/
|
||||
#define BT_A2DP_SBC_EP_CFG_DEFAULT(_name, _freq_cfg)\
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = {\
|
||||
.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq_cfg | A2DP_SBC_CH_MODE_JOINT,\
|
||||
A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | A2DP_SBC_ALLOC_MTHD_LOUDNESS, 18U, 35U},};\
|
||||
struct bt_a2dp_codec_cfg _name = {.codec_config = &bt_a2dp_codec_ie##_name,}
|
||||
#define BT_A2DP_SBC_EP_CFG_DEFAULT(_name, _freq_cfg) \
|
||||
static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = { \
|
||||
.len = BT_A2DP_SBC_IE_LENGTH, \
|
||||
.codec_ie = {_freq_cfg | A2DP_SBC_CH_MODE_JOINT, \
|
||||
A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | \
|
||||
A2DP_SBC_ALLOC_MTHD_LOUDNESS, \
|
||||
18U, 35U}, \
|
||||
}; \
|
||||
struct bt_a2dp_codec_cfg _name = { \
|
||||
.codec_config = &bt_a2dp_codec_ie##_name, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A2DP error code
|
||||
|
|
@ -358,8 +377,8 @@ enum {
|
|||
* for next endpoint. By returning BT_A2DP_DISCOVER_EP_STOP user allows this
|
||||
* discovery continuation.
|
||||
*/
|
||||
typedef uint8_t (*bt_a2dp_discover_ep_cb)(struct bt_a2dp *a2dp,
|
||||
struct bt_a2dp_ep_info *info, struct bt_a2dp_ep **ep);
|
||||
typedef uint8_t (*bt_a2dp_discover_ep_cb)(struct bt_a2dp *a2dp, struct bt_a2dp_ep_info *info,
|
||||
struct bt_a2dp_ep **ep);
|
||||
|
||||
struct bt_a2dp_discover_param {
|
||||
/** discover callback */
|
||||
|
|
@ -411,8 +430,8 @@ struct bt_a2dp_cb {
|
|||
* @return 0 in case of success or negative value in case of error.
|
||||
*/
|
||||
int (*config_req)(struct bt_a2dp *a2dp, struct bt_a2dp_ep *ep,
|
||||
struct bt_a2dp_codec_cfg *codec_cfg, struct bt_a2dp_stream **stream,
|
||||
uint8_t *rsp_err_code);
|
||||
struct bt_a2dp_codec_cfg *codec_cfg, struct bt_a2dp_stream **stream,
|
||||
uint8_t *rsp_err_code);
|
||||
/** @brief Callback function for bt_a2dp_stream_config()
|
||||
*
|
||||
* Called when the codec configure operation is completed.
|
||||
|
|
@ -665,8 +684,8 @@ struct bt_a2dp_stream_ops {
|
|||
* @param seq_num the sequence number
|
||||
* @param ts the time stamp
|
||||
*/
|
||||
void (*recv)(struct bt_a2dp_stream *stream,
|
||||
struct net_buf *buf, uint16_t seq_num, uint32_t ts);
|
||||
void (*recv)(struct bt_a2dp_stream *stream, struct net_buf *buf, uint16_t seq_num,
|
||||
uint32_t ts);
|
||||
#endif
|
||||
#if defined(CONFIG_BT_A2DP_SOURCE)
|
||||
/**
|
||||
|
|
@ -711,8 +730,8 @@ void bt_a2dp_stream_cb_register(struct bt_a2dp_stream *stream, struct bt_a2dp_st
|
|||
* @return 0 in case of success and error code in case of error.
|
||||
*/
|
||||
int bt_a2dp_stream_config(struct bt_a2dp *a2dp, struct bt_a2dp_stream *stream,
|
||||
struct bt_a2dp_ep *local_ep, struct bt_a2dp_ep *remote_ep,
|
||||
struct bt_a2dp_codec_cfg *config);
|
||||
struct bt_a2dp_ep *local_ep, struct bt_a2dp_ep *remote_ep,
|
||||
struct bt_a2dp_codec_cfg *config);
|
||||
|
||||
/** @brief establish a2dp streamer.
|
||||
*
|
||||
|
|
@ -785,8 +804,8 @@ uint32_t bt_a2dp_get_mtu(struct bt_a2dp_stream *stream);
|
|||
*
|
||||
* @return 0 in case of success and error code in case of error.
|
||||
*/
|
||||
int bt_a2dp_stream_send(struct bt_a2dp_stream *stream, struct net_buf *buf,
|
||||
uint16_t seq_num, uint32_t ts);
|
||||
int bt_a2dp_stream_send(struct bt_a2dp_stream *stream, struct net_buf *buf, uint16_t seq_num,
|
||||
uint32_t ts);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -87,11 +87,11 @@ enum bt_avdtp_media_type {
|
|||
*/
|
||||
struct bt_avdtp_sep_info {
|
||||
/** End Point usage status */
|
||||
uint8_t inuse:1;
|
||||
uint8_t inuse: 1;
|
||||
/** Stream End Point ID that is the identifier of the stream endpoint */
|
||||
uint8_t id:6;
|
||||
uint8_t id: 6;
|
||||
/** Reserved */
|
||||
uint8_t reserved:1;
|
||||
uint8_t reserved: 1;
|
||||
/** Stream End-point Type that indicates if the stream end-point is SNK or SRC */
|
||||
enum bt_avdtp_sep_type tsep;
|
||||
/** Media-type of the End Point
|
||||
|
|
@ -127,8 +127,7 @@ struct bt_avdtp_sep {
|
|||
/** Media Transport Channel*/
|
||||
struct bt_l2cap_br_chan chan;
|
||||
/** the endpoint media data */
|
||||
void (*media_data_cb)(struct bt_avdtp_sep *sep,
|
||||
struct net_buf *buf);
|
||||
void (*media_data_cb)(struct bt_avdtp_sep *sep, struct net_buf *buf);
|
||||
/** avdtp session */
|
||||
struct bt_avdtp *session;
|
||||
/** SEP state */
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@
|
|||
|
||||
#define A2DP_AVDTP(_avdtp) CONTAINER_OF(_avdtp, struct bt_a2dp, session)
|
||||
#define DISCOVER_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_discover_params, req)
|
||||
#define DISCOVER_PARAM(_discover_param) CONTAINER_OF(_discover_param, struct bt_a2dp,\
|
||||
discover_param)
|
||||
#define DISCOVER_PARAM(_discover_param) \
|
||||
CONTAINER_OF(_discover_param, struct bt_a2dp, discover_param)
|
||||
#define GET_CAP_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_get_capabilities_params, req)
|
||||
#define GET_CAP_PARAM(_get_cap_param) CONTAINER_OF(_get_cap_param, struct bt_a2dp,\
|
||||
get_capabilities_param)
|
||||
#define GET_CAP_PARAM(_get_cap_param) \
|
||||
CONTAINER_OF(_get_cap_param, struct bt_a2dp, get_capabilities_param)
|
||||
#define SET_CONF_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_set_configuration_params, req)
|
||||
#define SET_CONF_PARAM(_set_conf_param) CONTAINER_OF(_set_conf_param, struct bt_a2dp,\
|
||||
set_config_param)
|
||||
#define OPEN_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_open_params, req)
|
||||
#define OPEN_PARAM(_open_param) CONTAINER_OF(_open_param, struct bt_a2dp, open_param)
|
||||
#define START_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_start_params, req)
|
||||
#define SET_CONF_PARAM(_set_conf_param) \
|
||||
CONTAINER_OF(_set_conf_param, struct bt_a2dp, set_config_param)
|
||||
#define OPEN_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_open_params, req)
|
||||
#define OPEN_PARAM(_open_param) CONTAINER_OF(_open_param, struct bt_a2dp, open_param)
|
||||
#define START_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_start_params, req)
|
||||
#define START_PARAM(_start_param) CONTAINER_OF(_start_param, struct bt_a2dp, start_param)
|
||||
|
||||
#include "host/hci_core.h"
|
||||
|
|
@ -75,7 +75,7 @@ struct bt_a2dp {
|
|||
static struct bt_a2dp_cb *a2dp_cb;
|
||||
K_MUTEX_DEFINE(a2dp_mutex);
|
||||
|
||||
#define A2DP_LOCK() k_mutex_lock(&a2dp_mutex, K_FOREVER)
|
||||
#define A2DP_LOCK() k_mutex_lock(&a2dp_mutex, K_FOREVER)
|
||||
#define A2DP_UNLOCK() k_mutex_unlock(&a2dp_mutex)
|
||||
|
||||
/* Connections */
|
||||
|
|
@ -106,8 +106,7 @@ static struct bt_a2dp *get_new_connection(struct bt_conn *conn)
|
|||
return &connection[i];
|
||||
}
|
||||
|
||||
if (!connection[i].session.br_chan.chan.conn &&
|
||||
free == A2DP_NO_SPACE) {
|
||||
if (!connection[i].session.br_chan.chan.conn && free == A2DP_NO_SPACE) {
|
||||
free = i;
|
||||
break;
|
||||
}
|
||||
|
|
@ -160,7 +159,7 @@ static int a2dp_discovery_ind(struct bt_avdtp *session, uint8_t *errcode)
|
|||
}
|
||||
|
||||
static int a2dp_get_capabilities_ind(struct bt_avdtp *session, struct bt_avdtp_sep *sep,
|
||||
struct net_buf *rsp_buf, uint8_t *errcode)
|
||||
struct net_buf *rsp_buf, uint8_t *errcode)
|
||||
{
|
||||
struct bt_a2dp_ep *ep;
|
||||
|
||||
|
|
@ -182,8 +181,8 @@ static int a2dp_get_capabilities_ind(struct bt_avdtp *session, struct bt_avdtp_s
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int a2dp_set_config_ind(struct bt_avdtp *session, struct bt_avdtp_sep *sep,
|
||||
uint8_t int_seid, struct net_buf *buf, uint8_t *errcode)
|
||||
static int a2dp_set_config_ind(struct bt_avdtp *session, struct bt_avdtp_sep *sep, uint8_t int_seid,
|
||||
struct net_buf *buf, uint8_t *errcode)
|
||||
{
|
||||
struct bt_a2dp *a2dp = A2DP_AVDTP(session);
|
||||
struct bt_a2dp_ep *ep;
|
||||
|
|
@ -202,9 +201,8 @@ static int a2dp_set_config_ind(struct bt_avdtp *session, struct bt_avdtp_sep *se
|
|||
|
||||
/* parse the configuration */
|
||||
codec_info_element_len = 4U;
|
||||
err = bt_avdtp_parse_capability_codec(buf,
|
||||
&codec_type, &codec_info_element,
|
||||
&codec_info_element_len);
|
||||
err = bt_avdtp_parse_capability_codec(buf, &codec_type, &codec_info_element,
|
||||
&codec_info_element_len);
|
||||
if (err) {
|
||||
*errcode = BT_AVDTP_BAD_ACP_SEID;
|
||||
return -1;
|
||||
|
|
@ -222,10 +220,10 @@ static int a2dp_set_config_ind(struct bt_avdtp *session, struct bt_avdtp_sep *se
|
|||
sbc_set = (struct bt_a2dp_codec_sbc_params *)codec_info_element;
|
||||
sbc = (struct bt_a2dp_codec_sbc_params *)&ep->codec_cap->codec_ie[0];
|
||||
if (((BT_A2DP_SBC_SAMP_FREQ(sbc_set) & BT_A2DP_SBC_SAMP_FREQ(sbc)) == 0) ||
|
||||
((BT_A2DP_SBC_CHAN_MODE(sbc_set) & BT_A2DP_SBC_CHAN_MODE(sbc)) == 0) ||
|
||||
((BT_A2DP_SBC_BLK_LEN(sbc_set) & BT_A2DP_SBC_BLK_LEN(sbc)) == 0) ||
|
||||
((BT_A2DP_SBC_SUB_BAND(sbc_set) & BT_A2DP_SBC_SUB_BAND(sbc)) == 0) ||
|
||||
((BT_A2DP_SBC_ALLOC_MTHD(sbc_set) & BT_A2DP_SBC_ALLOC_MTHD(sbc)) == 0)) {
|
||||
((BT_A2DP_SBC_CHAN_MODE(sbc_set) & BT_A2DP_SBC_CHAN_MODE(sbc)) == 0) ||
|
||||
((BT_A2DP_SBC_BLK_LEN(sbc_set) & BT_A2DP_SBC_BLK_LEN(sbc)) == 0) ||
|
||||
((BT_A2DP_SBC_SUB_BAND(sbc_set) & BT_A2DP_SBC_SUB_BAND(sbc)) == 0) ||
|
||||
((BT_A2DP_SBC_ALLOC_MTHD(sbc_set) & BT_A2DP_SBC_ALLOC_MTHD(sbc)) == 0)) {
|
||||
*errcode = BT_AVDTP_BAD_ACP_SEID;
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -239,8 +237,8 @@ static int a2dp_set_config_ind(struct bt_avdtp *session, struct bt_avdtp_sep *se
|
|||
cfg.codec_config = &codec_config;
|
||||
cfg.codec_config->len = codec_info_element_len;
|
||||
memcpy(&cfg.codec_config->codec_ie[0], codec_info_element,
|
||||
(codec_info_element_len > A2DP_MAX_IE_LENGTH ?
|
||||
A2DP_MAX_IE_LENGTH : codec_info_element_len));
|
||||
(codec_info_element_len > A2DP_MAX_IE_LENGTH ? A2DP_MAX_IE_LENGTH
|
||||
: codec_info_element_len));
|
||||
err = a2dp_cb->config_req(a2dp, ep, &cfg, &stream, &rsp_err_code);
|
||||
if (err) {
|
||||
*errcode = rsp_err_code;
|
||||
|
|
@ -263,9 +261,7 @@ static int a2dp_set_config_ind(struct bt_avdtp *session, struct bt_avdtp_sep *se
|
|||
}
|
||||
|
||||
#if defined(CONFIG_BT_A2DP_SINK)
|
||||
static void bt_a2dp_media_data_callback(
|
||||
struct bt_avdtp_sep *sep,
|
||||
struct net_buf *buf)
|
||||
static void bt_a2dp_media_data_callback(struct bt_avdtp_sep *sep, struct net_buf *buf)
|
||||
{
|
||||
struct bt_avdtp_media_hdr *media_hdr;
|
||||
struct bt_a2dp_ep *ep;
|
||||
|
|
@ -279,9 +275,8 @@ static void bt_a2dp_media_data_callback(
|
|||
|
||||
media_hdr = net_buf_pull_mem(buf, sizeof(*media_hdr));
|
||||
|
||||
stream->ops->recv(stream, buf,
|
||||
sys_get_be16((uint8_t *)&media_hdr->sequence_number),
|
||||
sys_get_be32((uint8_t *)&media_hdr->time_stamp));
|
||||
stream->ops->recv(stream, buf, sys_get_be16((uint8_t *)&media_hdr->sequence_number),
|
||||
sys_get_be32((uint8_t *)&media_hdr->time_stamp));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -484,16 +479,15 @@ static int bt_a2dp_get_capabilities_cb(struct bt_avdtp_req *req)
|
|||
|
||||
LOG_DBG("GET CAPABILITIES result:%d", a2dp->get_capabilities_param.status);
|
||||
if (a2dp->get_capabilities_param.status) {
|
||||
if ((a2dp->discover_cb_param != NULL) &&
|
||||
(a2dp->discover_cb_param->cb != NULL)) {
|
||||
if ((a2dp->discover_cb_param != NULL) && (a2dp->discover_cb_param->cb != NULL)) {
|
||||
a2dp->discover_cb_param->cb(a2dp, NULL, NULL);
|
||||
a2dp->discover_cb_param = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = bt_avdtp_parse_capability_codec(a2dp->get_capabilities_param.buf,
|
||||
&codec_type, &codec_info_element, &codec_info_element_len);
|
||||
err = bt_avdtp_parse_capability_codec(a2dp->get_capabilities_param.buf, &codec_type,
|
||||
&codec_info_element, &codec_info_element_len);
|
||||
if (err) {
|
||||
LOG_DBG("codec capability parsing fail");
|
||||
return 0;
|
||||
|
|
@ -509,8 +503,7 @@ static int bt_a2dp_get_capabilities_cb(struct bt_avdtp_req *req)
|
|||
|
||||
info->codec_type = codec_type;
|
||||
info->sep_info = a2dp->discover_cb_param->seps_info[a2dp->get_cap_index];
|
||||
memcpy(&info->codec_cap.codec_ie,
|
||||
codec_info_element, codec_info_element_len);
|
||||
memcpy(&info->codec_cap.codec_ie, codec_info_element, codec_info_element_len);
|
||||
info->codec_cap.len = codec_info_element_len;
|
||||
user_ret = a2dp->discover_cb_param->cb(a2dp, info, &ep);
|
||||
if (ep != NULL) {
|
||||
|
|
@ -547,16 +540,15 @@ static int bt_a2dp_get_sep_caps(struct bt_a2dp *a2dp)
|
|||
a2dp->get_cap_index++;
|
||||
}
|
||||
|
||||
for (; a2dp->get_cap_index < a2dp->peer_seps_count;
|
||||
a2dp->get_cap_index++) {
|
||||
for (; a2dp->get_cap_index < a2dp->peer_seps_count; a2dp->get_cap_index++) {
|
||||
if (a2dp->discover_cb_param->seps_info[a2dp->get_cap_index].media_type ==
|
||||
BT_AVDTP_AUDIO) {
|
||||
BT_AVDTP_AUDIO) {
|
||||
a2dp->get_capabilities_param.req.func = bt_a2dp_get_capabilities_cb;
|
||||
a2dp->get_capabilities_param.buf = NULL;
|
||||
a2dp->get_capabilities_param.stream_endpoint_id =
|
||||
a2dp->discover_cb_param->seps_info[a2dp->get_cap_index].id;
|
||||
err = bt_avdtp_get_capabilities(&a2dp->session,
|
||||
&a2dp->get_capabilities_param);
|
||||
&a2dp->get_capabilities_param);
|
||||
if (err) {
|
||||
LOG_DBG("AVDTP get codec_cap failed");
|
||||
a2dp->discover_cb_param->cb(a2dp, NULL, NULL);
|
||||
|
|
@ -595,11 +587,8 @@ static int bt_a2dp_discover_cb(struct bt_avdtp_req *req)
|
|||
break;
|
||||
}
|
||||
a2dp->peer_seps_count++;
|
||||
LOG_DBG("id:%d, inuse:%d, media_type:%d, tsep:%d, ",
|
||||
sep_info->id,
|
||||
sep_info->inuse,
|
||||
sep_info->media_type,
|
||||
sep_info->tsep);
|
||||
LOG_DBG("id:%d, inuse:%d, media_type:%d, tsep:%d, ", sep_info->id,
|
||||
sep_info->inuse, sep_info->media_type, sep_info->tsep);
|
||||
} while (a2dp->peer_seps_count < a2dp->discover_cb_param->sep_count);
|
||||
|
||||
/* trigger the getting capability */
|
||||
|
|
@ -684,11 +673,11 @@ void bt_a2dp_stream_cb_register(struct bt_a2dp_stream *stream, struct bt_a2dp_st
|
|||
}
|
||||
|
||||
int bt_a2dp_stream_config(struct bt_a2dp *a2dp, struct bt_a2dp_stream *stream,
|
||||
struct bt_a2dp_ep *local_ep, struct bt_a2dp_ep *remote_ep,
|
||||
struct bt_a2dp_codec_cfg *config)
|
||||
struct bt_a2dp_ep *local_ep, struct bt_a2dp_ep *remote_ep,
|
||||
struct bt_a2dp_codec_cfg *config)
|
||||
{
|
||||
if ((a2dp == NULL) || (stream == NULL) || (local_ep == NULL) ||
|
||||
(remote_ep == NULL) || (config == NULL)) {
|
||||
if ((a2dp == NULL) || (stream == NULL) || (local_ep == NULL) || (remote_ep == NULL) ||
|
||||
(config == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -724,8 +713,9 @@ int bt_a2dp_stream_establish(struct bt_a2dp_stream *stream)
|
|||
|
||||
a2dp = stream->a2dp;
|
||||
a2dp->open_param.req.func = bt_a2dp_open_cb;
|
||||
a2dp->open_param.acp_stream_ep_id = stream->remote_ep != NULL ?
|
||||
stream->remote_ep->sep.sep_info.id : stream->remote_ep_id;
|
||||
a2dp->open_param.acp_stream_ep_id = stream->remote_ep != NULL
|
||||
? stream->remote_ep->sep.sep_info.id
|
||||
: stream->remote_ep_id;
|
||||
a2dp->open_param.sep = &stream->local_ep->sep;
|
||||
return bt_avdtp_open(&a2dp->session, &a2dp->open_param);
|
||||
}
|
||||
|
|
@ -746,8 +736,9 @@ int bt_a2dp_stream_start(struct bt_a2dp_stream *stream)
|
|||
|
||||
a2dp = stream->a2dp;
|
||||
a2dp->start_param.req.func = bt_a2dp_start_cb;
|
||||
a2dp->start_param.acp_stream_ep_id = stream->remote_ep != NULL ?
|
||||
stream->remote_ep->sep.sep_info.id : stream->remote_ep_id;
|
||||
a2dp->start_param.acp_stream_ep_id = stream->remote_ep != NULL
|
||||
? stream->remote_ep->sep.sep_info.id
|
||||
: stream->remote_ep_id;
|
||||
a2dp->start_param.sep = &stream->local_ep->sep;
|
||||
return bt_avdtp_start(&a2dp->session, &a2dp->start_param);
|
||||
}
|
||||
|
|
@ -774,8 +765,8 @@ uint32_t bt_a2dp_get_mtu(struct bt_a2dp_stream *stream)
|
|||
}
|
||||
|
||||
#if defined(CONFIG_BT_A2DP_SOURCE)
|
||||
int bt_a2dp_stream_send(struct bt_a2dp_stream *stream, struct net_buf *buf,
|
||||
uint16_t seq_num, uint32_t ts)
|
||||
int bt_a2dp_stream_send(struct bt_a2dp_stream *stream, struct net_buf *buf, uint16_t seq_num,
|
||||
uint32_t ts)
|
||||
{
|
||||
struct bt_avdtp_media_hdr *media_hdr;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,31 +30,32 @@ LOG_MODULE_REGISTER(bt_avdtp);
|
|||
#define AVDTP_MSG_POISTION 0x00
|
||||
#define AVDTP_PKT_POSITION 0x02
|
||||
#define AVDTP_TID_POSITION 0x04
|
||||
#define AVDTP_SIGID_MASK 0x3f
|
||||
#define AVDTP_SIGID_MASK 0x3f
|
||||
|
||||
#define AVDTP_GET_TR_ID(hdr) ((hdr & 0xf0) >> AVDTP_TID_POSITION)
|
||||
#define AVDTP_GET_TR_ID(hdr) ((hdr & 0xf0) >> AVDTP_TID_POSITION)
|
||||
#define AVDTP_GET_MSG_TYPE(hdr) (hdr & 0x03)
|
||||
#define AVDTP_GET_PKT_TYPE(hdr) ((hdr & 0x0c) >> AVDTP_PKT_POSITION)
|
||||
#define AVDTP_GET_SIG_ID(s) (s & AVDTP_SIGID_MASK)
|
||||
#define AVDTP_GET_SIG_ID(s) (s & AVDTP_SIGID_MASK)
|
||||
|
||||
static struct bt_avdtp_event_cb *event_cb;
|
||||
static sys_slist_t seps;
|
||||
|
||||
#define AVDTP_CHAN(_ch) CONTAINER_OF(_ch, struct bt_avdtp, br_chan.chan)
|
||||
|
||||
#define AVDTP_KWORK(_work) CONTAINER_OF(CONTAINER_OF(_work, struct k_work_delayable, work),\
|
||||
struct bt_avdtp, timeout_work)
|
||||
#define AVDTP_KWORK(_work) \
|
||||
CONTAINER_OF(CONTAINER_OF(_work, struct k_work_delayable, work), struct bt_avdtp, \
|
||||
timeout_work)
|
||||
|
||||
#define DISCOVER_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_discover_params, req)
|
||||
#define GET_CAP_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_get_capabilities_params, req)
|
||||
#define GET_CAP_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_get_capabilities_params, req)
|
||||
#define SET_CONF_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_set_configuration_params, req)
|
||||
#define OPEN_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_open_params, req)
|
||||
#define START_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_start_params, req)
|
||||
#define OPEN_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_open_params, req)
|
||||
#define START_REQ(_req) CONTAINER_OF(_req, struct bt_avdtp_start_params, req)
|
||||
|
||||
#define AVDTP_TIMEOUT K_SECONDS(6)
|
||||
|
||||
K_MUTEX_DEFINE(avdtp_mutex);
|
||||
#define AVDTP_LOCK() k_mutex_lock(&avdtp_mutex, K_FOREVER)
|
||||
#define AVDTP_LOCK() k_mutex_lock(&avdtp_mutex, K_FOREVER)
|
||||
#define AVDTP_UNLOCK() k_mutex_unlock(&avdtp_mutex)
|
||||
|
||||
enum sep_state {
|
||||
|
|
@ -72,8 +73,7 @@ enum sep_state {
|
|||
void bt_avdtp_media_l2cap_connected(struct bt_l2cap_chan *chan)
|
||||
{
|
||||
struct bt_avdtp *session;
|
||||
struct bt_avdtp_sep *sep =
|
||||
CONTAINER_OF(chan, struct bt_avdtp_sep, chan.chan);
|
||||
struct bt_avdtp_sep *sep = CONTAINER_OF(chan, struct bt_avdtp_sep, chan.chan);
|
||||
|
||||
if (!chan) {
|
||||
LOG_ERR("Invalid AVDTP chan");
|
||||
|
|
@ -102,8 +102,7 @@ void bt_avdtp_media_l2cap_connected(struct bt_l2cap_chan *chan)
|
|||
|
||||
void bt_avdtp_media_l2cap_disconnected(struct bt_l2cap_chan *chan)
|
||||
{
|
||||
struct bt_avdtp_sep *sep =
|
||||
CONTAINER_OF(chan, struct bt_avdtp_sep, chan.chan);
|
||||
struct bt_avdtp_sep *sep = CONTAINER_OF(chan, struct bt_avdtp_sep, chan.chan);
|
||||
|
||||
LOG_DBG("chan %p", chan);
|
||||
chan->conn = NULL;
|
||||
|
|
@ -115,8 +114,7 @@ void bt_avdtp_media_l2cap_disconnected(struct bt_l2cap_chan *chan)
|
|||
int bt_avdtp_media_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
||||
{
|
||||
/* media data is received */
|
||||
struct bt_avdtp_sep *sep =
|
||||
CONTAINER_OF(chan, struct bt_avdtp_sep, chan.chan);
|
||||
struct bt_avdtp_sep *sep = CONTAINER_OF(chan, struct bt_avdtp_sep, chan.chan);
|
||||
|
||||
if (sep->media_data_cb != NULL) {
|
||||
sep->media_data_cb(sep, buf);
|
||||
|
|
@ -126,11 +124,10 @@ int bt_avdtp_media_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
|||
|
||||
static int avdtp_media_connect(struct bt_avdtp *session, struct bt_avdtp_sep *sep)
|
||||
{
|
||||
static const struct bt_l2cap_chan_ops ops = {
|
||||
.connected = bt_avdtp_media_l2cap_connected,
|
||||
.disconnected = bt_avdtp_media_l2cap_disconnected,
|
||||
.recv = bt_avdtp_media_l2cap_recv
|
||||
};
|
||||
static const struct bt_l2cap_chan_ops ops = {.connected = bt_avdtp_media_l2cap_connected,
|
||||
.disconnected =
|
||||
bt_avdtp_media_l2cap_disconnected,
|
||||
.recv = bt_avdtp_media_l2cap_recv};
|
||||
|
||||
if (!session) {
|
||||
return -EINVAL;
|
||||
|
|
@ -142,13 +139,11 @@ static int avdtp_media_connect(struct bt_avdtp *session, struct bt_avdtp_sep *se
|
|||
sep->chan.required_sec_level = BT_SECURITY_L2;
|
||||
|
||||
return bt_l2cap_chan_connect(session->br_chan.chan.conn, &sep->chan.chan,
|
||||
BT_L2CAP_PSM_AVDTP);
|
||||
BT_L2CAP_PSM_AVDTP);
|
||||
}
|
||||
|
||||
static struct net_buf *avdtp_create_reply_pdu(uint8_t msg_type,
|
||||
uint8_t pkt_type,
|
||||
uint8_t sig_id,
|
||||
uint8_t tid)
|
||||
static struct net_buf *avdtp_create_reply_pdu(uint8_t msg_type, uint8_t pkt_type, uint8_t sig_id,
|
||||
uint8_t tid)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
struct bt_avdtp_single_sig_hdr *hdr;
|
||||
|
|
@ -163,17 +158,15 @@ static struct net_buf *avdtp_create_reply_pdu(uint8_t msg_type,
|
|||
|
||||
hdr = net_buf_add(buf, sizeof(*hdr));
|
||||
|
||||
hdr->hdr = (msg_type | pkt_type << AVDTP_PKT_POSITION |
|
||||
tid << AVDTP_TID_POSITION);
|
||||
hdr->hdr = (msg_type | pkt_type << AVDTP_PKT_POSITION | tid << AVDTP_TID_POSITION);
|
||||
hdr->signal_id = sig_id & AVDTP_SIGID_MASK;
|
||||
|
||||
LOG_DBG("hdr = 0x%02X, Signal_ID = 0x%02X", hdr->hdr, hdr->signal_id);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void avdtp_discover_handler(struct bt_avdtp *session,
|
||||
struct net_buf *buf, uint8_t msg_type,
|
||||
uint8_t tid)
|
||||
static void avdtp_discover_handler(struct bt_avdtp *session, struct net_buf *buf, uint8_t msg_type,
|
||||
uint8_t tid)
|
||||
{
|
||||
if (msg_type == BT_AVDTP_CMD) {
|
||||
int err;
|
||||
|
|
@ -187,10 +180,9 @@ static void avdtp_discover_handler(struct bt_avdtp *session,
|
|||
err = session->ops->discovery_ind(session, &error_code);
|
||||
}
|
||||
|
||||
rsp_buf = avdtp_create_reply_pdu(err ?
|
||||
BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_DISCOVER, tid);
|
||||
rsp_buf =
|
||||
avdtp_create_reply_pdu(err ? BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE, BT_AVDTP_DISCOVER, tid);
|
||||
if (!rsp_buf) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -262,8 +254,8 @@ static struct bt_avdtp_sep *avdtp_get_sep(uint8_t stream_endpoint_id)
|
|||
return sep;
|
||||
}
|
||||
|
||||
static void avdtp_get_capabilities_handler(struct bt_avdtp *session,
|
||||
struct net_buf *buf, uint8_t msg_type, uint8_t tid)
|
||||
static void avdtp_get_capabilities_handler(struct bt_avdtp *session, struct net_buf *buf,
|
||||
uint8_t msg_type, uint8_t tid)
|
||||
{
|
||||
if (msg_type == BT_AVDTP_CMD) {
|
||||
int err = 0;
|
||||
|
|
@ -280,24 +272,23 @@ static void avdtp_get_capabilities_handler(struct bt_avdtp *session,
|
|||
if ((sep == NULL) || (session->ops->get_capabilities_ind == NULL)) {
|
||||
err = -ENOTSUP;
|
||||
} else {
|
||||
rsp_buf = avdtp_create_reply_pdu(BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_GET_CAPABILITIES,
|
||||
tid);
|
||||
rsp_buf =
|
||||
avdtp_create_reply_pdu(BT_AVDTP_ACCEPT, BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_GET_CAPABILITIES, tid);
|
||||
if (!rsp_buf) {
|
||||
return;
|
||||
}
|
||||
err = session->ops->get_capabilities_ind(session,
|
||||
sep, rsp_buf, &error_code);
|
||||
err = session->ops->get_capabilities_ind(session, sep, rsp_buf,
|
||||
&error_code);
|
||||
if (err) {
|
||||
net_buf_unref(rsp_buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (err) {
|
||||
rsp_buf = avdtp_create_reply_pdu(BT_AVDTP_REJECT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_GET_CAPABILITIES, tid);
|
||||
rsp_buf =
|
||||
avdtp_create_reply_pdu(BT_AVDTP_REJECT, BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_GET_CAPABILITIES, tid);
|
||||
if (!rsp_buf) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -348,8 +339,8 @@ static void avdtp_get_capabilities_handler(struct bt_avdtp *session,
|
|||
}
|
||||
}
|
||||
|
||||
static void avdtp_process_configuration(struct bt_avdtp *session,
|
||||
struct net_buf *buf, uint8_t msg_type, uint8_t tid)
|
||||
static void avdtp_process_configuration(struct bt_avdtp *session, struct net_buf *buf,
|
||||
uint8_t msg_type, uint8_t tid)
|
||||
{
|
||||
if (msg_type == BT_AVDTP_CMD) {
|
||||
int err = 0;
|
||||
|
|
@ -379,15 +370,14 @@ static void avdtp_process_configuration(struct bt_avdtp *session,
|
|||
|
||||
/* INT Stream Endpoint ID */
|
||||
int_seid = net_buf_pull_u8(buf);
|
||||
err = session->ops->set_configuration_ind(session,
|
||||
sep, int_seid, buf, &error_code);
|
||||
err = session->ops->set_configuration_ind(session, sep, int_seid,
|
||||
buf, &error_code);
|
||||
}
|
||||
}
|
||||
|
||||
rsp_buf = avdtp_create_reply_pdu(err ?
|
||||
BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_SET_CONFIGURATION, tid);
|
||||
rsp_buf = avdtp_create_reply_pdu(err ? BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_SET_CONFIGURATION, tid);
|
||||
if (!rsp_buf) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -444,22 +434,21 @@ static void avdtp_process_configuration(struct bt_avdtp *session,
|
|||
}
|
||||
}
|
||||
|
||||
static void avdtp_set_configuration_handler(struct bt_avdtp *session,
|
||||
struct net_buf *buf, uint8_t msg_type, uint8_t tid)
|
||||
static void avdtp_set_configuration_handler(struct bt_avdtp *session, struct net_buf *buf,
|
||||
uint8_t msg_type, uint8_t tid)
|
||||
{
|
||||
avdtp_process_configuration(session, buf, msg_type, tid);
|
||||
}
|
||||
|
||||
static void avdtp_get_configuration_handler(struct bt_avdtp *session,
|
||||
struct net_buf *buf, uint8_t msg_type, uint8_t tid)
|
||||
static void avdtp_get_configuration_handler(struct bt_avdtp *session, struct net_buf *buf,
|
||||
uint8_t msg_type, uint8_t tid)
|
||||
{
|
||||
/* todo: is not supported now, reply reject */
|
||||
struct net_buf *rsp_buf;
|
||||
int err;
|
||||
|
||||
rsp_buf = avdtp_create_reply_pdu(BT_AVDTP_REJECT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_GET_CONFIGURATION, tid);
|
||||
rsp_buf = avdtp_create_reply_pdu(BT_AVDTP_REJECT, BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_GET_CONFIGURATION, tid);
|
||||
if (!rsp_buf) {
|
||||
LOG_ERR("Error: No Buff available");
|
||||
return;
|
||||
|
|
@ -473,14 +462,14 @@ static void avdtp_get_configuration_handler(struct bt_avdtp *session,
|
|||
}
|
||||
}
|
||||
|
||||
static void avdtp_re_configure_handler(struct bt_avdtp *session,
|
||||
struct net_buf *buf, uint8_t msg_type, uint8_t tid)
|
||||
static void avdtp_re_configure_handler(struct bt_avdtp *session, struct net_buf *buf,
|
||||
uint8_t msg_type, uint8_t tid)
|
||||
{
|
||||
avdtp_process_configuration(session, buf, msg_type, tid);
|
||||
}
|
||||
|
||||
static void avdtp_open_handler(struct bt_avdtp *session,
|
||||
struct net_buf *buf, uint8_t msg_type, uint8_t tid)
|
||||
static void avdtp_open_handler(struct bt_avdtp *session, struct net_buf *buf, uint8_t msg_type,
|
||||
uint8_t tid)
|
||||
{
|
||||
if (msg_type == BT_AVDTP_CMD) {
|
||||
int err = 0;
|
||||
|
|
@ -505,10 +494,8 @@ static void avdtp_open_handler(struct bt_avdtp *session,
|
|||
}
|
||||
}
|
||||
|
||||
rsp_buf = avdtp_create_reply_pdu(err ?
|
||||
BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_OPEN, tid);
|
||||
rsp_buf = avdtp_create_reply_pdu(err ? BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE, BT_AVDTP_OPEN, tid);
|
||||
if (!rsp_buf) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -566,8 +553,8 @@ static void avdtp_open_handler(struct bt_avdtp *session,
|
|||
}
|
||||
}
|
||||
|
||||
static void avdtp_start_handler(struct bt_avdtp *session,
|
||||
struct net_buf *buf, uint8_t msg_type, uint8_t tid)
|
||||
static void avdtp_start_handler(struct bt_avdtp *session, struct net_buf *buf, uint8_t msg_type,
|
||||
uint8_t tid)
|
||||
{
|
||||
if (msg_type == BT_AVDTP_CMD) {
|
||||
int err = 0;
|
||||
|
|
@ -592,10 +579,8 @@ static void avdtp_start_handler(struct bt_avdtp *session,
|
|||
}
|
||||
}
|
||||
|
||||
rsp_buf = avdtp_create_reply_pdu(err ?
|
||||
BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_START, tid);
|
||||
rsp_buf = avdtp_create_reply_pdu(err ? BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE, BT_AVDTP_START, tid);
|
||||
if (!rsp_buf) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -652,8 +637,8 @@ static void avdtp_start_handler(struct bt_avdtp *session,
|
|||
}
|
||||
}
|
||||
|
||||
static void avdtp_close_handler(struct bt_avdtp *session,
|
||||
struct net_buf *buf, uint8_t msg_type, uint8_t tid)
|
||||
static void avdtp_close_handler(struct bt_avdtp *session, struct net_buf *buf, uint8_t msg_type,
|
||||
uint8_t tid)
|
||||
{
|
||||
if (msg_type == BT_AVDTP_CMD) {
|
||||
int err = 0;
|
||||
|
|
@ -678,10 +663,8 @@ static void avdtp_close_handler(struct bt_avdtp *session,
|
|||
}
|
||||
}
|
||||
|
||||
rsp_buf = avdtp_create_reply_pdu(err ?
|
||||
BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_CLOSE, tid);
|
||||
rsp_buf = avdtp_create_reply_pdu(err ? BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE, BT_AVDTP_CLOSE, tid);
|
||||
if (!rsp_buf) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -706,8 +689,8 @@ static void avdtp_close_handler(struct bt_avdtp *session,
|
|||
}
|
||||
}
|
||||
|
||||
static void avdtp_suspend_handler(struct bt_avdtp *session,
|
||||
struct net_buf *buf, uint8_t msg_type, uint8_t tid)
|
||||
static void avdtp_suspend_handler(struct bt_avdtp *session, struct net_buf *buf, uint8_t msg_type,
|
||||
uint8_t tid)
|
||||
{
|
||||
if (msg_type == BT_AVDTP_CMD) {
|
||||
int err = 0;
|
||||
|
|
@ -732,10 +715,9 @@ static void avdtp_suspend_handler(struct bt_avdtp *session,
|
|||
}
|
||||
}
|
||||
|
||||
rsp_buf = avdtp_create_reply_pdu(err ?
|
||||
BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_SUSPEND, tid);
|
||||
rsp_buf =
|
||||
avdtp_create_reply_pdu(err ? BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE, BT_AVDTP_SUSPEND, tid);
|
||||
if (!rsp_buf) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -759,8 +741,8 @@ static void avdtp_suspend_handler(struct bt_avdtp *session,
|
|||
}
|
||||
}
|
||||
|
||||
static void avdtp_abort_handler(struct bt_avdtp *session,
|
||||
struct net_buf *buf, uint8_t msg_type, uint8_t tid)
|
||||
static void avdtp_abort_handler(struct bt_avdtp *session, struct net_buf *buf, uint8_t msg_type,
|
||||
uint8_t tid)
|
||||
{
|
||||
if (msg_type == BT_AVDTP_CMD) {
|
||||
int err = 0;
|
||||
|
|
@ -780,10 +762,8 @@ static void avdtp_abort_handler(struct bt_avdtp *session,
|
|||
err = session->ops->abort_ind(session, sep, &error_code);
|
||||
}
|
||||
|
||||
rsp_buf = avdtp_create_reply_pdu(err ?
|
||||
BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_ABORT, tid);
|
||||
rsp_buf = avdtp_create_reply_pdu(err ? BT_AVDTP_REJECT : BT_AVDTP_ACCEPT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE, BT_AVDTP_ABORT, tid);
|
||||
if (!rsp_buf) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -846,8 +826,7 @@ static void avdtp_timeout(struct k_work *work)
|
|||
}
|
||||
}
|
||||
|
||||
static int avdtp_send(struct bt_avdtp *session,
|
||||
struct net_buf *buf, struct bt_avdtp_req *req)
|
||||
static int avdtp_send(struct bt_avdtp *session, struct net_buf *buf, struct bt_avdtp_req *req)
|
||||
{
|
||||
int result;
|
||||
struct bt_avdtp_single_sig_hdr *hdr;
|
||||
|
|
@ -883,9 +862,7 @@ static int avdtp_send(struct bt_avdtp *session,
|
|||
return result;
|
||||
}
|
||||
|
||||
static struct net_buf *avdtp_create_pdu(uint8_t msg_type,
|
||||
uint8_t pkt_type,
|
||||
uint8_t sig_id)
|
||||
static struct net_buf *avdtp_create_pdu(uint8_t msg_type, uint8_t pkt_type, uint8_t sig_id)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
static uint8_t tid;
|
||||
|
|
@ -897,8 +874,7 @@ static struct net_buf *avdtp_create_pdu(uint8_t msg_type,
|
|||
|
||||
hdr = net_buf_add(buf, sizeof(*hdr));
|
||||
|
||||
hdr->hdr = (msg_type | pkt_type << AVDTP_PKT_POSITION |
|
||||
tid++ << AVDTP_TID_POSITION);
|
||||
hdr->hdr = (msg_type | pkt_type << AVDTP_PKT_POSITION | tid++ << AVDTP_TID_POSITION);
|
||||
tid %= 16; /* Loop for 16*/
|
||||
hdr->signal_id = sig_id & AVDTP_SIGID_MASK;
|
||||
|
||||
|
|
@ -943,8 +919,7 @@ void bt_avdtp_l2cap_encrypt_changed(struct bt_l2cap_chan *chan, uint8_t status)
|
|||
|
||||
static const struct {
|
||||
uint8_t sig_id;
|
||||
void (*func)(struct bt_avdtp *session, struct net_buf *buf,
|
||||
uint8_t msg_type, uint8_t tid);
|
||||
void (*func)(struct bt_avdtp *session, struct net_buf *buf, uint8_t msg_type, uint8_t tid);
|
||||
} handler[] = {
|
||||
{BT_AVDTP_DISCOVER, avdtp_discover_handler},
|
||||
{BT_AVDTP_GET_CAPABILITIES, avdtp_get_capabilities_handler},
|
||||
|
|
@ -975,8 +950,8 @@ int bt_avdtp_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
|||
sigid = AVDTP_GET_SIG_ID(hdr->signal_id);
|
||||
tid = AVDTP_GET_TR_ID(hdr->hdr);
|
||||
|
||||
LOG_DBG("pack_type[0x%02x] msg_type[0x%02x] sig_id[0x%02x] tid[0x%02x]",
|
||||
pack_type, msgtype, sigid, tid);
|
||||
LOG_DBG("pack_type[0x%02x] msg_type[0x%02x] sig_id[0x%02x] tid[0x%02x]", pack_type, msgtype,
|
||||
sigid, tid);
|
||||
|
||||
/* TODO: only support single packet now */
|
||||
if (pack_type != BT_AVDTP_PACKET_TYPE_SINGLE) {
|
||||
|
|
@ -991,8 +966,7 @@ int bt_avdtp_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
|||
|
||||
sigid = net_buf_pull_u8(buf);
|
||||
rsp_buf = avdtp_create_reply_pdu(BT_AVDTP_REJECT,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
sigid, tid);
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE, sigid, tid);
|
||||
if (!rsp_buf) {
|
||||
LOG_ERR("Error: No Buff available");
|
||||
return 0;
|
||||
|
|
@ -1013,11 +987,10 @@ int bt_avdtp_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (session->req->sig != sigid ||
|
||||
session->req->tid != tid) {
|
||||
if (session->req->sig != sigid || session->req->tid != tid) {
|
||||
LOG_DBG("Peer mismatch resp, expected sig[0x%02x]"
|
||||
"tid[0x%02x]", session->req->sig,
|
||||
session->req->tid);
|
||||
"tid[0x%02x]",
|
||||
session->req->sig, session->req->tid);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1040,24 +1013,22 @@ int bt_avdtp_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
|||
/*A2DP Layer interface */
|
||||
int bt_avdtp_connect(struct bt_conn *conn, struct bt_avdtp *session)
|
||||
{
|
||||
static const struct bt_l2cap_chan_ops ops = {
|
||||
.connected = bt_avdtp_l2cap_connected,
|
||||
.disconnected = bt_avdtp_l2cap_disconnected,
|
||||
.encrypt_change = bt_avdtp_l2cap_encrypt_changed,
|
||||
.recv = bt_avdtp_l2cap_recv
|
||||
};
|
||||
static const struct bt_l2cap_chan_ops ops = {.connected = bt_avdtp_l2cap_connected,
|
||||
.disconnected = bt_avdtp_l2cap_disconnected,
|
||||
.encrypt_change =
|
||||
bt_avdtp_l2cap_encrypt_changed,
|
||||
.recv = bt_avdtp_l2cap_recv};
|
||||
|
||||
if (!session) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
session->signalling_l2cap_connected = 1;
|
||||
session->br_chan.rx.mtu = BT_L2CAP_RX_MTU;
|
||||
session->br_chan.rx.mtu = BT_L2CAP_RX_MTU;
|
||||
session->br_chan.chan.ops = &ops;
|
||||
session->br_chan.required_sec_level = BT_SECURITY_L2;
|
||||
|
||||
return bt_l2cap_chan_connect(conn, &session->br_chan.chan,
|
||||
BT_L2CAP_PSM_AVDTP);
|
||||
return bt_l2cap_chan_connect(conn, &session->br_chan.chan, BT_L2CAP_PSM_AVDTP);
|
||||
}
|
||||
|
||||
int bt_avdtp_disconnect(struct bt_avdtp *session)
|
||||
|
|
@ -1073,7 +1044,7 @@ int bt_avdtp_disconnect(struct bt_avdtp *session)
|
|||
}
|
||||
|
||||
int bt_avdtp_l2cap_accept(struct bt_conn *conn, struct bt_l2cap_server *server,
|
||||
struct bt_l2cap_chan **chan)
|
||||
struct bt_l2cap_chan **chan)
|
||||
{
|
||||
struct bt_avdtp *session = NULL;
|
||||
int result;
|
||||
|
|
@ -1101,13 +1072,11 @@ int bt_avdtp_l2cap_accept(struct bt_conn *conn, struct bt_l2cap_server *server,
|
|||
static const struct bt_l2cap_chan_ops ops = {
|
||||
.connected = bt_avdtp_media_l2cap_connected,
|
||||
.disconnected = bt_avdtp_media_l2cap_disconnected,
|
||||
.recv = bt_avdtp_media_l2cap_recv
|
||||
};
|
||||
.recv = bt_avdtp_media_l2cap_recv};
|
||||
session->current_sep->session = session;
|
||||
session->current_sep->chan.chan.ops = &ops;
|
||||
session->current_sep->chan.rx.mtu = BT_L2CAP_RX_MTU;
|
||||
session->current_sep->chan.required_sec_level =
|
||||
BT_SECURITY_L2;
|
||||
session->current_sep->chan.required_sec_level = BT_SECURITY_L2;
|
||||
*chan = &session->current_sep->chan.chan;
|
||||
session->current_sep = NULL;
|
||||
}
|
||||
|
|
@ -1130,8 +1099,7 @@ int bt_avdtp_register(struct bt_avdtp_event_cb *cb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_avdtp_register_sep(uint8_t media_type, uint8_t role,
|
||||
struct bt_avdtp_sep *sep)
|
||||
int bt_avdtp_register_sep(uint8_t media_type, uint8_t role, struct bt_avdtp_sep *sep)
|
||||
{
|
||||
LOG_DBG("");
|
||||
|
||||
|
|
@ -1178,8 +1146,7 @@ int bt_avdtp_init(void)
|
|||
}
|
||||
|
||||
/* AVDTP Discover Request */
|
||||
int bt_avdtp_discover(struct bt_avdtp *session,
|
||||
struct bt_avdtp_discover_params *param)
|
||||
int bt_avdtp_discover(struct bt_avdtp *session, struct bt_avdtp_discover_params *param)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
|
|
@ -1189,9 +1156,7 @@ int bt_avdtp_discover(struct bt_avdtp *session,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf = avdtp_create_pdu(BT_AVDTP_CMD,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_DISCOVER);
|
||||
buf = avdtp_create_pdu(BT_AVDTP_CMD, BT_AVDTP_PACKET_TYPE_SINGLE, BT_AVDTP_DISCOVER);
|
||||
if (!buf) {
|
||||
LOG_ERR("Error: No Buff available");
|
||||
return -ENOMEM;
|
||||
|
|
@ -1220,7 +1185,7 @@ int bt_avdtp_parse_sep(struct net_buf *buf, struct bt_avdtp_sep_info *sep_info)
|
|||
|
||||
/* AVDTP Get Capabilities Request */
|
||||
int bt_avdtp_get_capabilities(struct bt_avdtp *session,
|
||||
struct bt_avdtp_get_capabilities_params *param)
|
||||
struct bt_avdtp_get_capabilities_params *param)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
|
|
@ -1230,9 +1195,8 @@ int bt_avdtp_get_capabilities(struct bt_avdtp *session,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf = avdtp_create_pdu(BT_AVDTP_CMD,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_GET_CAPABILITIES);
|
||||
buf = avdtp_create_pdu(BT_AVDTP_CMD, BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_GET_CAPABILITIES);
|
||||
if (!buf) {
|
||||
LOG_ERR("Error: No Buff available");
|
||||
return -ENOMEM;
|
||||
|
|
@ -1244,9 +1208,8 @@ int bt_avdtp_get_capabilities(struct bt_avdtp *session,
|
|||
return avdtp_send(session, buf, ¶m->req);
|
||||
}
|
||||
|
||||
int bt_avdtp_parse_capability_codec(struct net_buf *buf,
|
||||
uint8_t *codec_type, uint8_t **codec_info_element,
|
||||
uint16_t *codec_info_element_len)
|
||||
int bt_avdtp_parse_capability_codec(struct net_buf *buf, uint8_t *codec_type,
|
||||
uint8_t **codec_info_element, uint16_t *codec_info_element_len)
|
||||
{
|
||||
uint8_t data;
|
||||
uint8_t length;
|
||||
|
|
@ -1310,9 +1273,8 @@ int bt_avdtp_parse_capability_codec(struct net_buf *buf,
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
static int avdtp_process_configure_command(struct bt_avdtp *session,
|
||||
uint8_t cmd,
|
||||
struct bt_avdtp_set_configuration_params *param)
|
||||
static int avdtp_process_configure_command(struct bt_avdtp *session, uint8_t cmd,
|
||||
struct bt_avdtp_set_configuration_params *param)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
|
|
@ -1322,9 +1284,7 @@ static int avdtp_process_configure_command(struct bt_avdtp *session,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf = avdtp_create_pdu(BT_AVDTP_CMD,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
cmd);
|
||||
buf = avdtp_create_pdu(BT_AVDTP_CMD, BT_AVDTP_PACKET_TYPE_SINGLE, cmd);
|
||||
if (!buf) {
|
||||
LOG_ERR("Error: No Buff available");
|
||||
return -ENOMEM;
|
||||
|
|
@ -1354,7 +1314,7 @@ static int avdtp_process_configure_command(struct bt_avdtp *session,
|
|||
}
|
||||
|
||||
int bt_avdtp_set_configuration(struct bt_avdtp *session,
|
||||
struct bt_avdtp_set_configuration_params *param)
|
||||
struct bt_avdtp_set_configuration_params *param)
|
||||
{
|
||||
if (!param || !session || !param->sep) {
|
||||
LOG_DBG("Error: parameters not valid");
|
||||
|
|
@ -1368,8 +1328,7 @@ int bt_avdtp_set_configuration(struct bt_avdtp *session,
|
|||
return avdtp_process_configure_command(session, BT_AVDTP_SET_CONFIGURATION, param);
|
||||
}
|
||||
|
||||
int bt_avdtp_reconfigure(struct bt_avdtp *session,
|
||||
struct bt_avdtp_set_configuration_params *param)
|
||||
int bt_avdtp_reconfigure(struct bt_avdtp *session, struct bt_avdtp_set_configuration_params *param)
|
||||
{
|
||||
if (!param || !session || !param->sep) {
|
||||
LOG_DBG("Error: parameters not valid");
|
||||
|
|
@ -1383,8 +1342,7 @@ int bt_avdtp_reconfigure(struct bt_avdtp *session,
|
|||
return avdtp_process_configure_command(session, BT_AVDTP_RECONFIGURE, param);
|
||||
}
|
||||
|
||||
int bt_avdtp_open(struct bt_avdtp *session,
|
||||
struct bt_avdtp_open_params *param)
|
||||
int bt_avdtp_open(struct bt_avdtp *session, struct bt_avdtp_open_params *param)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
|
|
@ -1398,9 +1356,7 @@ int bt_avdtp_open(struct bt_avdtp *session,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf = avdtp_create_pdu(BT_AVDTP_CMD,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_OPEN);
|
||||
buf = avdtp_create_pdu(BT_AVDTP_CMD, BT_AVDTP_PACKET_TYPE_SINGLE, BT_AVDTP_OPEN);
|
||||
if (!buf) {
|
||||
LOG_ERR("Error: No Buff available");
|
||||
return -ENOMEM;
|
||||
|
|
@ -1413,8 +1369,7 @@ int bt_avdtp_open(struct bt_avdtp *session,
|
|||
return avdtp_send(session, buf, ¶m->req);
|
||||
}
|
||||
|
||||
int bt_avdtp_start(struct bt_avdtp *session,
|
||||
struct bt_avdtp_start_params *param)
|
||||
int bt_avdtp_start(struct bt_avdtp *session, struct bt_avdtp_start_params *param)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
|
|
@ -1428,9 +1383,7 @@ int bt_avdtp_start(struct bt_avdtp *session,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf = avdtp_create_pdu(BT_AVDTP_CMD,
|
||||
BT_AVDTP_PACKET_TYPE_SINGLE,
|
||||
BT_AVDTP_START);
|
||||
buf = avdtp_create_pdu(BT_AVDTP_CMD, BT_AVDTP_PACKET_TYPE_SINGLE, BT_AVDTP_START);
|
||||
if (!buf) {
|
||||
LOG_ERR("Error: No Buff available");
|
||||
return -ENOMEM;
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@
|
|||
#define BT_AVDTP_DELAYREPORT 0x0d
|
||||
|
||||
/* @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
|
||||
#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
|
||||
|
|
@ -93,19 +93,19 @@ struct bt_avdtp_sep_info;
|
|||
/** @brief AVDTP SEID Information AVDTP_SPEC V13 Table 8.8 */
|
||||
struct bt_avdtp_sep_data {
|
||||
#ifdef CONFIG_LITTLE_ENDIAN
|
||||
uint8_t rfa0:1;
|
||||
uint8_t inuse:1;
|
||||
uint8_t id:6;
|
||||
uint8_t rfa1:3;
|
||||
uint8_t tsep:1;
|
||||
uint8_t media_type:4;
|
||||
uint8_t rfa0: 1;
|
||||
uint8_t inuse: 1;
|
||||
uint8_t id: 6;
|
||||
uint8_t rfa1: 3;
|
||||
uint8_t tsep: 1;
|
||||
uint8_t media_type: 4;
|
||||
#else
|
||||
uint8_t id:6;
|
||||
uint8_t inuse:1;
|
||||
uint8_t rfa0:1;
|
||||
uint8_t media_type:4;
|
||||
uint8_t tsep:1;
|
||||
uint8_t rfa1:3;
|
||||
uint8_t id: 6;
|
||||
uint8_t inuse: 1;
|
||||
uint8_t rfa0: 1;
|
||||
uint8_t media_type: 4;
|
||||
uint8_t tsep: 1;
|
||||
uint8_t rfa1: 3;
|
||||
#endif
|
||||
} __packed;
|
||||
|
||||
|
|
@ -124,19 +124,19 @@ struct bt_avdtp_single_sig_hdr {
|
|||
|
||||
struct bt_avdtp_media_hdr {
|
||||
#ifdef CONFIG_LITTLE_ENDIAN
|
||||
uint8_t CSRC_count:4;
|
||||
uint8_t header_extension:1;
|
||||
uint8_t padding:1;
|
||||
uint8_t RTP_version:2;
|
||||
uint8_t playload_type:7;
|
||||
uint8_t marker:1;
|
||||
uint8_t CSRC_count: 4;
|
||||
uint8_t header_extension: 1;
|
||||
uint8_t padding: 1;
|
||||
uint8_t RTP_version: 2;
|
||||
uint8_t playload_type: 7;
|
||||
uint8_t marker: 1;
|
||||
#else
|
||||
uint8_t RTP_version:2;
|
||||
uint8_t padding:1;
|
||||
uint8_t header_extension:1;
|
||||
uint8_t CSRC_count:4;
|
||||
uint8_t marker:1;
|
||||
uint8_t playload_type:7;
|
||||
uint8_t RTP_version: 2;
|
||||
uint8_t padding: 1;
|
||||
uint8_t header_extension: 1;
|
||||
uint8_t CSRC_count: 4;
|
||||
uint8_t marker: 1;
|
||||
uint8_t playload_type: 7;
|
||||
#endif
|
||||
uint16_t sequence_number;
|
||||
uint32_t time_stamp;
|
||||
|
|
@ -191,26 +191,21 @@ struct bt_avdtp_ops_cb {
|
|||
|
||||
int (*discovery_ind)(struct bt_avdtp *session, uint8_t *errcode);
|
||||
|
||||
int (*get_capabilities_ind)(struct bt_avdtp *session,
|
||||
struct bt_avdtp_sep *sep, struct net_buf *rsp_buf, uint8_t *errcode);
|
||||
int (*get_capabilities_ind)(struct bt_avdtp *session, struct bt_avdtp_sep *sep,
|
||||
struct net_buf *rsp_buf, uint8_t *errcode);
|
||||
|
||||
int (*set_configuration_ind)(struct bt_avdtp *session, struct bt_avdtp_sep *sep,
|
||||
uint8_t int_seid, struct net_buf *buf, uint8_t *errcode);
|
||||
uint8_t int_seid, struct net_buf *buf, uint8_t *errcode);
|
||||
|
||||
int (*open_ind)(struct bt_avdtp *session,
|
||||
struct bt_avdtp_sep *sep, uint8_t *errcode);
|
||||
int (*open_ind)(struct bt_avdtp *session, struct bt_avdtp_sep *sep, uint8_t *errcode);
|
||||
|
||||
int (*close_ind)(struct bt_avdtp *session,
|
||||
struct bt_avdtp_sep *sep, uint8_t *errcode);
|
||||
int (*close_ind)(struct bt_avdtp *session, struct bt_avdtp_sep *sep, uint8_t *errcode);
|
||||
|
||||
int (*start_ind)(struct bt_avdtp *session,
|
||||
struct bt_avdtp_sep *sep, uint8_t *errcode);
|
||||
int (*start_ind)(struct bt_avdtp *session, struct bt_avdtp_sep *sep, uint8_t *errcode);
|
||||
|
||||
int (*suspend_ind)(struct bt_avdtp *session,
|
||||
struct bt_avdtp_sep *sep, uint8_t *errcode);
|
||||
int (*suspend_ind)(struct bt_avdtp *session, struct bt_avdtp_sep *sep, uint8_t *errcode);
|
||||
|
||||
int (*abort_ind)(struct bt_avdtp *session,
|
||||
struct bt_avdtp_sep *sep, uint8_t *errcode);
|
||||
int (*abort_ind)(struct bt_avdtp *session, struct bt_avdtp_sep *sep, uint8_t *errcode);
|
||||
};
|
||||
|
||||
/** @brief Global AVDTP session structure. */
|
||||
|
|
@ -240,39 +235,34 @@ int bt_avdtp_connect(struct bt_conn *conn, struct bt_avdtp *session);
|
|||
int bt_avdtp_disconnect(struct bt_avdtp *session);
|
||||
|
||||
/* AVDTP SEP register function */
|
||||
int bt_avdtp_register_sep(uint8_t media_type, uint8_t role,
|
||||
struct bt_avdtp_sep *sep);
|
||||
int bt_avdtp_register_sep(uint8_t media_type, uint8_t sep_type, struct bt_avdtp_sep *sep);
|
||||
|
||||
/* AVDTP Discover Request */
|
||||
int bt_avdtp_discover(struct bt_avdtp *session,
|
||||
struct bt_avdtp_discover_params *param);
|
||||
int bt_avdtp_discover(struct bt_avdtp *session, struct bt_avdtp_discover_params *param);
|
||||
|
||||
/* Parse the sep of discovered result */
|
||||
int bt_avdtp_parse_sep(struct net_buf *buf, struct bt_avdtp_sep_info *sep_info);
|
||||
|
||||
/* AVDTP Get Capabilities */
|
||||
int bt_avdtp_get_capabilities(struct bt_avdtp *session,
|
||||
struct bt_avdtp_get_capabilities_params *param);
|
||||
struct bt_avdtp_get_capabilities_params *param);
|
||||
|
||||
/* Parse the codec type of capabilities */
|
||||
int bt_avdtp_parse_capability_codec(struct net_buf *buf, uint8_t *codec_type,
|
||||
uint8_t **codec_info_element, uint16_t *codec_info_element_len);
|
||||
uint8_t **codec_info_element, uint16_t *codec_info_element_len);
|
||||
|
||||
/* AVDTP Set Configuration */
|
||||
int bt_avdtp_set_configuration(struct bt_avdtp *session,
|
||||
struct bt_avdtp_set_configuration_params *param);
|
||||
struct bt_avdtp_set_configuration_params *param);
|
||||
|
||||
/* AVDTP reconfigure */
|
||||
int bt_avdtp_reconfigure(struct bt_avdtp *session,
|
||||
struct bt_avdtp_set_configuration_params *param);
|
||||
int bt_avdtp_reconfigure(struct bt_avdtp *session, struct bt_avdtp_set_configuration_params *param);
|
||||
|
||||
/* AVDTP OPEN */
|
||||
int bt_avdtp_open(struct bt_avdtp *session,
|
||||
struct bt_avdtp_open_params *param);
|
||||
int bt_avdtp_open(struct bt_avdtp *session, struct bt_avdtp_ctrl_params *param);
|
||||
|
||||
/* AVDTP START */
|
||||
int bt_avdtp_start(struct bt_avdtp *session,
|
||||
struct bt_avdtp_start_params *param);
|
||||
int bt_avdtp_start(struct bt_avdtp *session, struct bt_avdtp_ctrl_params *param);
|
||||
|
||||
/* AVDTP send data */
|
||||
int bt_avdtp_send_media_data(struct bt_avdtp_sep *sep, struct net_buf *buf);
|
||||
|
|
|
|||
Loading…
Reference in a new issue