11#ifndef ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_
12#define ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_
24#define BT_A2DP_STREAM_BUF_RESERVE (12u + BT_L2CAP_BUF_SIZE(0))
27#define BT_A2DP_SBC_IE_LENGTH (4u)
29#define BT_A2DP_MPEG_1_2_IE_LENGTH (4u)
31#define BT_A2DP_MPEG_2_4_IE_LENGTH (6u)
33#define A2DP_MAX_IE_LENGTH (8U)
40#define BT_A2DP_EP_INIT(_role, _codec, _capability)\
42 .codec_type = _codec,\
43 .sep = {.sep_info = {.media_type = BT_AVDTP_AUDIO, .tsep = _role}},\
44 .codec_cap = _capability,\
52#define BT_A2DP_SINK_EP_INIT(_codec, _capability)\
53BT_A2DP_EP_INIT(BT_AVDTP_SINK, _codec, _capability)
59#define BT_A2DP_SOURCE_EP_INIT(_codec, _capability)\
60BT_A2DP_EP_INIT(BT_AVDTP_SOURCE, _codec, _capability)
83#define BT_A2DP_SBC_SINK_EP(_name, _freq, _ch_mode, _blk_len, _subband,\
84_alloc_mthd, _min_bitpool, _max_bitpool)\
85static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
86{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq | _ch_mode,\
87_blk_len | _subband | _alloc_mthd, _min_bitpool, _max_bitpool}};\
88static struct bt_a2dp_ep _name = BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC,\
89(&bt_a2dp_ep_cap_ie##_name))
111#define BT_A2DP_SBC_SOURCE_EP(_name, _freq, _ch_mode, _blk_len, _subband,\
112_alloc_mthd, _min_bitpool, _max_bitpool)\
113static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
114{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq | _ch_mode,\
115_blk_len | _subband | _alloc_mthd, _min_bitpool, _max_bitpool}};\
116static struct bt_a2dp_ep _name = BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC,\
117&bt_a2dp_ep_cap_ie##_name)
127#define BT_A2DP_SBC_SINK_EP_DEFAULT(_name)\
128static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
129{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {A2DP_SBC_SAMP_FREQ_44100 |\
130A2DP_SBC_SAMP_FREQ_48000 | A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO |\
131A2DP_SBC_CH_MODE_JOINT, A2DP_SBC_BLK_LEN_16 |\
132A2DP_SBC_SUBBAND_8 | A2DP_SBC_ALLOC_MTHD_LOUDNESS, 18U, 35U}};\
133static struct bt_a2dp_ep _name = BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC,\
134&bt_a2dp_ep_cap_ie##_name)
144#define BT_A2DP_SBC_SOURCE_EP_DEFAULT(_name)\
145static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
146{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {A2DP_SBC_SAMP_FREQ_44100 | \
147A2DP_SBC_SAMP_FREQ_48000 | A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO | \
148A2DP_SBC_CH_MODE_JOINT, A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | A2DP_SBC_ALLOC_MTHD_LOUDNESS,\
150static struct bt_a2dp_ep _name = BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC,\
151&bt_a2dp_ep_cap_ie##_name)
169#define BT_A2DP_SBC_EP_CFG(_name, _freq_cfg, _ch_mode_cfg, _blk_len_cfg, _subband_cfg,\
170_alloc_mthd_cfg, _min_bitpool_cfg, _max_bitpool_cfg)\
171static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = {\
172.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq_cfg | _ch_mode_cfg,\
173_blk_len_cfg | _subband_cfg | _alloc_mthd_cfg, _min_bitpool_cfg, _max_bitpool_cfg},};\
174struct bt_a2dp_codec_cfg _name = {.codec_config = &bt_a2dp_codec_ie##_name,}
181#define BT_A2DP_SBC_EP_CFG_DEFAULT(_name, _freq_cfg)\
182static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = {\
183.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq_cfg | A2DP_SBC_CH_MODE_JOINT,\
184A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | A2DP_SBC_ALLOC_MTHD_LOUDNESS, 18U, 35U},};\
185struct bt_a2dp_codec_cfg _name = {.codec_config = &bt_a2dp_codec_ie##_name,}
661#if defined(CONFIG_BT_A2DP_SINK)
671#if defined(CONFIG_BT_A2DP_SOURCE)
776#if defined(CONFIG_BT_A2DP_SOURCE)
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:190
@ BT_A2DP_INVALID_CP_FORMAT
The format of Content Protection Service Capability/Content Protection Scheme Dependent Data is not c...
Definition a2dp.h:258
@ BT_A2DP_INVALID_CODEC_TYPE
Media Codec Type is not valid.
Definition a2dp.h:192
@ BT_A2DP_INVALID_CHANNELS
Either 1) Channels is not valid or 2) None or multiple values have been selected for Channels.
Definition a2dp.h:242
@ BT_A2DP_NOT_SUPPORTED_DRC
DRC is not supported.
Definition a2dp.h:270
@ BT_A2DP_NOT_SUPPORTED_VERSION
Version is not supported.
Definition a2dp.h:248
@ BT_A2DP_NOT_SUPPORTED_SUBBANDS
Number of Subbands is not supported.
Definition a2dp.h:206
@ BT_A2DP_NOT_SUPPORTED_CHANNELS
Channels is not supported.
Definition a2dp.h:244
@ 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:236
@ BT_A2DP_NOT_SUPPORTED_CODEC_PARAMETER
The codec parameter is not supported.
Definition a2dp.h:266
@ BT_A2DP_INVALID_VERSION
Version is not valid.
Definition a2dp.h:246
@ BT_A2DP_NOT_SUPPORTED_LAYER
Layer is not supported.
Definition a2dp.h:222
@ BT_A2DP_NOT_SUPPORTED_SAMPLING_FREQUENCY
Sampling Frequency is not supported.
Definition a2dp.h:198
@ BT_A2DP_NOT_SUPPORTED_CRC
CRC is not supported.
Definition a2dp.h:224
@ BT_A2DP_INVALID_CHANNEL_MODE
Channel Mode is not valid or multiple values have been selected.
Definition a2dp.h:200
@ BT_A2DP_INVALID_SAMPLING_FREQUENCY
Sampling Frequency is not valid or multiple values have been selected.
Definition a2dp.h:196
@ BT_A2DP_INVALID_MAXIMUM_BITPOOL_VALUE
Maximum Bitpool Value is not valid.
Definition a2dp.h:216
@ BT_A2DP_NOT_SUPPORTED_OBJECT_TYPE
Object Type is not supported.
Definition a2dp.h:238
@ BT_A2DP_NOT_SUPPORTED_ALLOCATION_METHOD
Allocation Method is not supported.
Definition a2dp.h:210
@ BT_A2DP_INVALID_SUBBANDS
None or multiple values have been selected for Number of Subbands.
Definition a2dp.h:204
@ BT_A2DP_NOT_SUPPORTED_CHANNEL_MODE
Channel Mode is not supported.
Definition a2dp.h:202
@ BT_A2DP_NOT_SUPPORTED_VBR
VBR is not supported.
Definition a2dp.h:228
@ BT_A2DP_NOT_SUPPORTED_MPF
MPF-2 is not supported.
Definition a2dp.h:226
@ BT_A2DP_INVALID_CODEC_PARAMETER
The codec parameter is invalid.
Definition a2dp.h:262
@ BT_A2DP_NOT_SUPPORTED_MAXIMUM_BITPOOL_VALUE
Maximum Bitpool Value is not supported.
Definition a2dp.h:218
@ BT_A2DP_INVALID_CP_TYPE
The requested CP Type is not supported.
Definition a2dp.h:254
@ BT_A2DP_NOT_SUPPORTED_CODEC_TYPE
Media Codec Type is not supported.
Definition a2dp.h:194
@ BT_A2DP_NOT_SUPPORTED_MINIMUM_BITPOOL_VALUE
Minimum Bitpool Value is not supported.
Definition a2dp.h:214
@ BT_A2DP_INVALID_MINIMUM_BITPOOL_VALUE
Minimum Bitpool Value is not valid.
Definition a2dp.h:212
@ BT_A2DP_INVALID_BIT_RATE
None or multiple values have been selected for Bit Rate.
Definition a2dp.h:230
@ BT_A2DP_INVALID_BLOCK_LENGTH
None or multiple values have been selected for Block Length.
Definition a2dp.h:252
@ BT_A2DP_INVALID_ALLOCATION_METHOD
None or multiple values have been selected for Allocation Method.
Definition a2dp.h:208
@ BT_A2DP_INVALID_LAYER
None or multiple values have been selected for Layer.
Definition a2dp.h:220
@ BT_A2DP_NOT_SUPPORTED_BIT_RATE
Bit Rate is not supported.
Definition a2dp.h:232
@ BT_A2DP_INVALID_DRC
Combination of Object Type and DRC is invalid.
Definition a2dp.h:268
@ BT_A2DP_NOT_SUPPORTED_MAXIMUM_SUL
Maximum SUL is not acceptable for the Decoder in the SNK.
Definition a2dp.h:250
int bt_a2dp_register_cb(struct bt_a2dp_cb *cb)
register callback.
int bt_a2dp_stream_reconfig(struct bt_a2dp_stream *stream, struct bt_a2dp_codec_cfg *config)
re-configure a2dp streamer
int bt_a2dp_discover(struct bt_a2dp *a2dp, struct bt_a2dp_discover_param *param)
Discover remote endpoints.
@ BT_A2DP_DISCOVER_EP_STOP
Definition a2dp.h:332
@ BT_A2DP_DISCOVER_EP_CONTINUE
Definition a2dp.h:333
#define A2DP_MAX_IE_LENGTH
The max IE (Codec Info Element) length.
Definition a2dp.h:33
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.
int bt_a2dp_register_ep(struct bt_a2dp_ep *ep, uint8_t media_type, uint8_t role)
Endpoint Registration.
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:361
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:274
@ BT_A2DP_MPEG1
Codec MPEG-1.
Definition a2dp.h:278
@ BT_A2DP_ATRAC
Codec ATRAC.
Definition a2dp.h:282
@ BT_A2DP_SBC
Codec SBC.
Definition a2dp.h:276
@ BT_A2DP_VENDOR
Codec Non-A2DP.
Definition a2dp.h:284
@ BT_A2DP_MPEG2
Codec MPEG-2.
Definition a2dp.h:280
Audio/Video Distribution Transport Protocol header.
Bluetooth subsystem core APIs.
static ssize_t recv(int sock, void *buf, size_t max_len, int flags)
POSIX wrapper for zsock_recv.
Definition socket.h:873
Bluetooth L2CAP handling.
__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:378
int(* start_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code)
stream start request callback
Definition a2dp.h:483
void(* config_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_config()
Definition a2dp.h:424
int(* reconfig_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code)
Endpoint config request callback.
Definition a2dp.h:527
void(* start_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_start()
Definition a2dp.h:492
void(* suspend_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_suspend()
Definition a2dp.h:514
int(* suspend_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code)
Endpoint suspend request callback.
Definition a2dp.h:505
void(* disconnected)(struct bt_a2dp *a2dp)
A a2dp connection has been disconnected.
Definition a2dp.h:397
void(* reconfig_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_reconfig()
Definition a2dp.h:536
int(* release_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code)
stream release request callback
Definition a2dp.h:460
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:413
void(* connected)(struct bt_a2dp *a2dp, int err)
A a2dp connection has been established.
Definition a2dp.h:389
void(* release_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_release()
Definition a2dp.h:470
int(* establish_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code)
stream establishment request callback
Definition a2dp.h:437
void(* establish_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code)
Callback function for bt_a2dp_stream_establish()
Definition a2dp.h:447
The endpoint configuration.
Definition a2dp.h:302
struct bt_a2dp_codec_ie * codec_config
The media codec configuration content.
Definition a2dp.h:304
codec information elements for the endpoint
Definition a2dp.h:294
uint8_t len
Length of codec_cap.
Definition a2dp.h:296
uint8_t codec_ie[(8U)]
codec information element
Definition a2dp.h:298
struct bt_a2dp_ep_info info
The discovered endpoint info that is callbacked by cb.
Definition a2dp.h:368
uint8_t sep_count
The max count of seps (stream endpoint) that can be got in this call route.
Definition a2dp.h:374
bt_a2dp_discover_ep_cb cb
discover callback
Definition a2dp.h:366
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:372
struct bt_avdtp_sep_info sep_info
Stream End Point Information.
Definition a2dp.h:325
struct bt_a2dp_codec_ie codec_cap
Codec capabilities, if SBC, use function of a2dp_codec_sbc.h to parse it.
Definition a2dp.h:323
uint8_t codec_type
Code Type bt_a2dp_codec_type.
Definition a2dp.h:321
Stream End Point.
Definition a2dp.h:308
struct bt_avdtp_sep sep
AVDTP Stream End Point Identifier.
Definition a2dp.h:314
struct bt_a2dp_stream * stream
Definition a2dp.h:316
uint8_t codec_type
Code Type bt_a2dp_codec_type.
Definition a2dp.h:310
struct bt_a2dp_codec_ie * codec_cap
Capabilities.
Definition a2dp.h:312
The stream endpoint related operations.
Definition a2dp.h:612
void(* configured)(struct bt_a2dp_stream *stream)
Stream configured callback.
Definition a2dp.h:620
void(* started)(struct bt_a2dp_stream *stream)
Stream start callback.
Definition a2dp.h:644
void(* established)(struct bt_a2dp_stream *stream)
Stream establishment callback.
Definition a2dp.h:628
void(* reconfigured)(struct bt_a2dp_stream *stream)
Stream reconfigured callback.
Definition a2dp.h:660
void(* released)(struct bt_a2dp_stream *stream)
Stream release callback.
Definition a2dp.h:636
void(* suspended)(struct bt_a2dp_stream *stream)
Stream suspend callback.
Definition a2dp.h:652
A2DP Stream.
Definition a2dp.h:596
uint8_t remote_ep_id
remote endpoint's Stream End Point ID
Definition a2dp.h:602
struct bt_a2dp_ep * remote_ep
remote endpoint
Definition a2dp.h:600
struct bt_a2dp_ep * local_ep
local endpoint
Definition a2dp.h:598
struct bt_a2dp_stream_ops * ops
Audio stream operations.
Definition a2dp.h:604
struct bt_a2dp * a2dp
the a2dp connection
Definition a2dp.h:606
struct bt_a2dp_codec_ie codec_config
the stream current configuration
Definition a2dp.h:608
AVDTP stream endpoint information.
Definition avdtp.h:88
AVDTP Stream End Point.
Definition avdtp.h:124
Network buffer representation.
Definition net_buf.h:1006