11#ifndef ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_
12#define ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_
33#define BT_A2DP_SBC_IE_LENGTH (4U)
35#define BT_A2DP_MPEG_1_2_IE_LENGTH (4U)
37#define BT_A2DP_MPEG_2_4_IE_LENGTH (6U)
39#define BT_A2DP_MAX_IE_LENGTH (8U)
47#define BT_A2DP_EP_INIT(_role, _codec, _capability, _delay_report) \
49 .codec_type = _codec, \
50 .sep = {.sep_info = {.media_type = BT_AVDTP_AUDIO, .tsep = _role}}, \
51 .codec_cap = _capability, .stream = NULL, \
52 .delay_report = _delay_report, \
60#define BT_A2DP_SINK_EP_INIT(_codec, _capability, _delay_report) \
61 BT_A2DP_EP_INIT(BT_AVDTP_SINK, _codec, _capability, _delay_report)
68#define BT_A2DP_SOURCE_EP_INIT(_codec, _capability, _delay_report) \
69 BT_A2DP_EP_INIT(BT_AVDTP_SOURCE, _codec, _capability, _delay_report)
92#define BT_A2DP_SBC_SINK_EP(_name, _freq, _ch_mode, _blk_len, _subband, _alloc_mthd, _min_bitpool, \
93 _max_bitpool, _delay_report) \
94 static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = { \
95 .len = BT_A2DP_SBC_IE_LENGTH, \
96 .codec_ie = {_freq | _ch_mode, _blk_len | _subband | _alloc_mthd, _min_bitpool, \
98 static struct bt_a2dp_ep _name = \
99 BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC, (&bt_a2dp_ep_cap_ie##_name), _delay_report)
121#define BT_A2DP_SBC_SOURCE_EP(_name, _freq, _ch_mode, _blk_len, _subband, _alloc_mthd, \
122 _min_bitpool, _max_bitpool, _delay_report) \
123 static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = { \
124 .len = BT_A2DP_SBC_IE_LENGTH, \
125 .codec_ie = {_freq | _ch_mode, _blk_len | _subband | _alloc_mthd, _min_bitpool, \
127 static struct bt_a2dp_ep _name = \
128 BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC, &bt_a2dp_ep_cap_ie##_name, _delay_report)
137#define BT_A2DP_SBC_SINK_EP_DEFAULT(_name) \
138 static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = { \
139 .len = BT_A2DP_SBC_IE_LENGTH, \
140 .codec_ie = {A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000 | \
141 A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STEREO | \
142 A2DP_SBC_CH_MODE_JOINT, \
143 A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | \
144 A2DP_SBC_ALLOC_MTHD_LOUDNESS, \
146 static struct bt_a2dp_ep _name = \
147 BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC, &bt_a2dp_ep_cap_ie##_name, true)
157#define BT_A2DP_SBC_SOURCE_EP_DEFAULT(_name) \
158 static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = { \
159 .len = BT_A2DP_SBC_IE_LENGTH, \
160 .codec_ie = {A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000 | \
161 A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STEREO | \
162 A2DP_SBC_CH_MODE_JOINT, \
163 A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | \
164 A2DP_SBC_ALLOC_MTHD_LOUDNESS, \
167 static struct bt_a2dp_ep _name = \
168 BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC, &bt_a2dp_ep_cap_ie##_name, false)
186#define BT_A2DP_SBC_EP_CFG(_name, _freq_cfg, _ch_mode_cfg, _blk_len_cfg, _subband_cfg, \
187 _alloc_mthd_cfg, _min_bitpool_cfg, _max_bitpool_cfg) \
188 static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = { \
189 .len = BT_A2DP_SBC_IE_LENGTH, \
190 .codec_ie = {_freq_cfg | _ch_mode_cfg, \
191 _blk_len_cfg | _subband_cfg | _alloc_mthd_cfg, _min_bitpool_cfg, \
194 struct bt_a2dp_codec_cfg _name = { \
195 .codec_config = &bt_a2dp_codec_ie##_name, \
203#define BT_A2DP_SBC_EP_CFG_DEFAULT(_name, _freq_cfg) \
204 static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = { \
205 .len = BT_A2DP_SBC_IE_LENGTH, \
206 .codec_ie = {_freq_cfg | A2DP_SBC_CH_MODE_JOINT, \
207 A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | \
208 A2DP_SBC_ALLOC_MTHD_LOUDNESS, \
211 struct bt_a2dp_codec_cfg _name = { \
212 .codec_config = &bt_a2dp_codec_ie##_name, \
620#ifdef CONFIG_BT_A2DP_SOURCE
636#ifdef CONFIG_BT_A2DP_SINK
780#if defined(CONFIG_BT_A2DP_SINK)
790#if defined(CONFIG_BT_A2DP_SOURCE)
Audio/Video Distribution Transport Protocol header.
Bluetooth subsystem core APIs.
struct bt_conn * bt_a2dp_get_conn(struct bt_a2dp *a2dp)
Obtain the ACL connection corresponding to A2DP.
struct net_buf * bt_a2dp_stream_create_pdu(struct net_buf_pool *pool, k_timeout_t timeout)
Allocate a net_buf for bt_a2dp_stream_send.
int bt_a2dp_stream_release(struct bt_a2dp_stream *stream)
release a2dp streamer.
int bt_a2dp_stream_start(struct bt_a2dp_stream *stream)
start a2dp streamer.
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)
configure endpoint.
bt_a2dp_err_code
A2DP error code.
Definition a2dp.h:218
int bt_a2dp_register_cb(struct bt_a2dp_cb *cb)
register callback.
int bt_a2dp_stream_get_config(struct bt_a2dp_stream *stream)
get config of the stream
int bt_a2dp_stream_reconfig(struct bt_a2dp_stream *stream, struct bt_a2dp_codec_cfg *config)
re-configure a2dp streamer
int bt_a2dp_stream_abort(struct bt_a2dp_stream *stream)
abort a2dp streamer.
#define BT_A2DP_MAX_IE_LENGTH
The max IE (Codec Info Element) length.
Definition a2dp.h:39
int bt_a2dp_discover(struct bt_a2dp *a2dp, struct bt_a2dp_discover_param *param)
Discover remote endpoints.
int bt_a2dp_stream_delay_report(struct bt_a2dp_stream *stream, uint16_t delay)
send delay report
int bt_a2dp_register_ep(struct bt_a2dp_ep *ep, uint8_t media_type, uint8_t sep_type)
Endpoint Registration.
void bt_a2dp_stream_cb_register(struct bt_a2dp_stream *stream, struct bt_a2dp_stream_ops *ops)
Register Audio callbacks for a stream.
int bt_a2dp_disconnect(struct bt_a2dp *a2dp)
disconnect l2cap a2dp
struct bt_a2dp * bt_a2dp_connect(struct bt_conn *conn)
A2DP Connect.
uint8_t(* bt_a2dp_discover_ep_cb)(struct bt_a2dp *a2dp, struct bt_a2dp_ep_info *info, struct bt_a2dp_ep **ep)
Called when a stream endpoint is discovered.
Definition a2dp.h:397
int bt_a2dp_stream_send(struct bt_a2dp_stream *stream, struct net_buf *buf, uint16_t seq_num, uint32_t ts)
send a2dp media data
int bt_a2dp_stream_suspend(struct bt_a2dp_stream *stream)
suspend a2dp streamer.
int bt_a2dp_stream_establish(struct bt_a2dp_stream *stream)
establish a2dp streamer.
uint32_t bt_a2dp_get_mtu(struct bt_a2dp_stream *stream)
get the stream l2cap mtu
bt_a2dp_codec_type
Codec Type.
Definition a2dp.h:302
@ BT_A2DP_INVALID_CP_FORMAT
The format of Content Protection Service Capability/Content Protection Scheme Dependent Data is not c...
Definition a2dp.h:286
@ BT_A2DP_INVALID_CODEC_TYPE
Media Codec Type is not valid.
Definition a2dp.h:220
@ BT_A2DP_INVALID_CHANNELS
Either 1) Channels is not valid or 2) None or multiple values have been selected for Channels.
Definition a2dp.h:270
@ BT_A2DP_NOT_SUPPORTED_DRC
DRC is not supported.
Definition a2dp.h:298
@ BT_A2DP_NOT_SUPPORTED_VERSION
Version is not supported.
Definition a2dp.h:276
@ BT_A2DP_NOT_SUPPORTED_SUBBANDS
Number of Subbands is not supported.
Definition a2dp.h:234
@ BT_A2DP_NOT_SUPPORTED_CHANNELS
Channels is not supported.
Definition a2dp.h:272
@ BT_A2DP_INVALID_OBJECT_TYPE
Either 1) Object type is not valid or 2) None or multiple values have been selected for Object Type.
Definition a2dp.h:264
@ BT_A2DP_NOT_SUPPORTED_CODEC_PARAMETER
The codec parameter is not supported.
Definition a2dp.h:294
@ BT_A2DP_INVALID_VERSION
Version is not valid.
Definition a2dp.h:274
@ BT_A2DP_NOT_SUPPORTED_LAYER
Layer is not supported.
Definition a2dp.h:250
@ BT_A2DP_NOT_SUPPORTED_SAMPLING_FREQUENCY
Sampling Frequency is not supported.
Definition a2dp.h:226
@ BT_A2DP_NOT_SUPPORTED_CRC
CRC is not supported.
Definition a2dp.h:252
@ BT_A2DP_INVALID_CHANNEL_MODE
Channel Mode is not valid or multiple values have been selected.
Definition a2dp.h:228
@ BT_A2DP_INVALID_SAMPLING_FREQUENCY
Sampling Frequency is not valid or multiple values have been selected.
Definition a2dp.h:224
@ BT_A2DP_INVALID_MAXIMUM_BITPOOL_VALUE
Maximum Bitpool Value is not valid.
Definition a2dp.h:244
@ BT_A2DP_NOT_SUPPORTED_OBJECT_TYPE
Object Type is not supported.
Definition a2dp.h:266
@ BT_A2DP_NOT_SUPPORTED_ALLOCATION_METHOD
Allocation Method is not supported.
Definition a2dp.h:238
@ BT_A2DP_INVALID_SUBBANDS
None or multiple values have been selected for Number of Subbands.
Definition a2dp.h:232
@ BT_A2DP_NOT_SUPPORTED_CHANNEL_MODE
Channel Mode is not supported.
Definition a2dp.h:230
@ BT_A2DP_NOT_SUPPORTED_VBR
VBR is not supported.
Definition a2dp.h:256
@ BT_A2DP_NOT_SUPPORTED_MPF
MPF-2 is not supported.
Definition a2dp.h:254
@ BT_A2DP_INVALID_CODEC_PARAMETER
The codec parameter is invalid.
Definition a2dp.h:290
@ BT_A2DP_NOT_SUPPORTED_MAXIMUM_BITPOOL_VALUE
Maximum Bitpool Value is not supported.
Definition a2dp.h:246
@ BT_A2DP_INVALID_CP_TYPE
The requested CP Type is not supported.
Definition a2dp.h:282
@ BT_A2DP_NOT_SUPPORTED_CODEC_TYPE
Media Codec Type is not supported.
Definition a2dp.h:222
@ BT_A2DP_NOT_SUPPORTED_MINIMUM_BITPOOL_VALUE
Minimum Bitpool Value is not supported.
Definition a2dp.h:242
@ BT_A2DP_INVALID_MINIMUM_BITPOOL_VALUE
Minimum Bitpool Value is not valid.
Definition a2dp.h:240
@ BT_A2DP_INVALID_BIT_RATE
None or multiple values have been selected for Bit Rate.
Definition a2dp.h:258
@ BT_A2DP_INVALID_BLOCK_LENGTH
None or multiple values have been selected for Block Length.
Definition a2dp.h:280
@ BT_A2DP_INVALID_ALLOCATION_METHOD
None or multiple values have been selected for Allocation Method.
Definition a2dp.h:236
@ BT_A2DP_INVALID_LAYER
None or multiple values have been selected for Layer.
Definition a2dp.h:248
@ BT_A2DP_NOT_SUPPORTED_BIT_RATE
Bit Rate is not supported.
Definition a2dp.h:260
@ BT_A2DP_INVALID_DRC
Combination of Object Type and DRC is invalid.
Definition a2dp.h:296
@ BT_A2DP_NOT_SUPPORTED_MAXIMUM_SUL
Maximum SUL is not acceptable for the Decoder in the SNK.
Definition a2dp.h:278
@ BT_A2DP_DISCOVER_EP_STOP
Definition a2dp.h:368
@ BT_A2DP_DISCOVER_EP_CONTINUE
Definition a2dp.h:369
@ BT_A2DP_MPEG1
Codec MPEG-1.
Definition a2dp.h:306
@ BT_A2DP_ATRAC
Codec ATRAC.
Definition a2dp.h:312
@ BT_A2DP_SBC
Codec SBC.
Definition a2dp.h:304
@ BT_A2DP_VENDOR
Codec Non-A2DP.
Definition a2dp.h:314
@ BT_A2DP_MPEGD
Codec MPEG-D.
Definition a2dp.h:310
@ BT_A2DP_MPEG2
Codec MPEG-2.
Definition a2dp.h:308
Bluetooth L2CAP handling.
ssize_t recv(int sock, void *buf, size_t max_len, int flags)
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
The connecting callback.
Definition a2dp.h:423
int(* start_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code)
Stream start request callback.
Definition a2dp.h:542
int(* get_config_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code)
Stream get config callback.
Definition a2dp.h:608
void(* config_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_config() and bt_a2dp_stream_reconfig().
Definition a2dp.h:483
void(* start_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_start().
Definition a2dp.h:551
void(* suspend_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_suspend().
Definition a2dp.h:573
int(* suspend_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code)
Stream suspend request callback.
Definition a2dp.h:564
void(* disconnected)(struct bt_a2dp *a2dp)
A a2dp connection has been disconnected.
Definition a2dp.h:442
int(* abort_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code)
Stream abort request callback.
Definition a2dp.h:586
int(* release_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code)
Stream release request callback.
Definition a2dp.h:519
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)
Endpoint config request callback.
Definition a2dp.h:458
void(* connected)(struct bt_a2dp *a2dp, int err)
A a2dp connection has been established.
Definition a2dp.h:434
void(* release_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_release().
Definition a2dp.h:529
int(* reconfig_req)(struct bt_a2dp_stream *stream, struct bt_a2dp_codec_cfg *codec_cfg, uint8_t *rsp_err_code)
Endpoint config request callback.
Definition a2dp.h:473
int(* establish_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code)
Stream establishment request callback.
Definition a2dp.h:496
void(* get_config_rsp)(struct bt_a2dp_stream *stream, struct bt_a2dp_codec_cfg *codec_cfg, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_get_config().
Definition a2dp.h:618
void(* abort_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_abort().
Definition a2dp.h:595
void(* establish_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_establish().
Definition a2dp.h:506
The endpoint configuration.
Definition a2dp.h:332
struct bt_a2dp_codec_ie * codec_config
The media codec configuration content.
Definition a2dp.h:336
bool delay_report
the delay reporting configured state
Definition a2dp.h:334
codec information elements for the endpoint
Definition a2dp.h:324
uint8_t len
Length of codec_cap.
Definition a2dp.h:326
uint8_t codec_ie[(8U)]
codec information element
Definition a2dp.h:328
struct bt_a2dp_ep_info info
The discovered endpoint info that is callbacked by cb.
Definition a2dp.h:404
uint16_t avdtp_version
The AVDTP version of the peer's A2DP sdp service.
Definition a2dp.h:417
uint8_t sep_count
The max count of seps (stream endpoint) that can be got in this call route.
Definition a2dp.h:419
bt_a2dp_discover_ep_cb cb
discover callback
Definition a2dp.h:402
struct bt_avdtp_sep_info * seps_info
The max count of remote endpoints that can be got, it save endpoint info internally.
Definition a2dp.h:408
bool delay_report
Whether the endpoint has delay reporting service.
Definition a2dp.h:357
struct bt_avdtp_sep_info * sep_info
Stream End Point Information.
Definition a2dp.h:361
struct bt_a2dp_codec_ie codec_cap
Codec capabilities, if SBC, use function of a2dp_codec_sbc.h to parse it.
Definition a2dp.h:359
uint8_t codec_type
Code Type bt_a2dp_codec_type.
Definition a2dp.h:355
Stream End Point.
Definition a2dp.h:340
struct bt_avdtp_sep sep
AVDTP Stream End Point Identifier.
Definition a2dp.h:348
struct bt_a2dp_stream * stream
Definition a2dp.h:350
uint8_t codec_type
Code Type bt_a2dp_codec_type.
Definition a2dp.h:342
bool delay_report
Whether the endpoint has delay reporting service.
Definition a2dp.h:344
struct bt_a2dp_codec_ie * codec_cap
Capabilities.
Definition a2dp.h:346
The stream endpoint related operations.
Definition a2dp.h:734
void(* configured)(struct bt_a2dp_stream *stream)
Stream configured callback.
Definition a2dp.h:742
void(* started)(struct bt_a2dp_stream *stream)
Stream start callback.
Definition a2dp.h:771
void(* established)(struct bt_a2dp_stream *stream)
Stream establishment callback.
Definition a2dp.h:750
void(* released)(struct bt_a2dp_stream *stream)
Stream release callback.
Definition a2dp.h:763
void(* suspended)(struct bt_a2dp_stream *stream)
Stream suspend callback.
Definition a2dp.h:779
A2DP Stream.
Definition a2dp.h:716
uint8_t remote_ep_id
remote endpoint's Stream End Point ID
Definition a2dp.h:722
struct bt_a2dp_ep * remote_ep
remote endpoint
Definition a2dp.h:720
struct bt_a2dp_ep * local_ep
local endpoint
Definition a2dp.h:718
struct bt_a2dp_stream_ops * ops
Audio stream operations.
Definition a2dp.h:726
struct bt_a2dp * a2dp
the a2dp connection
Definition a2dp.h:728
bool delay_report
whether the delay report is configured on the stream
Definition a2dp.h:724
struct bt_a2dp_codec_ie codec_config
the stream current configuration
Definition a2dp.h:730
AVDTP stream endpoint information.
Definition avdtp.h:92
AVDTP Stream End Point.
Definition avdtp.h:136
Kernel timeout type.
Definition clock.h:65
Network buffer pool representation.
Definition net_buf.h:1079
Network buffer representation.
Definition net_buf.h:1006