Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
|
Advanced Audio Distribution Profile header. More...
#include <stdint.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/l2cap.h>
#include <zephyr/bluetooth/classic/avdtp.h>
Go to the source code of this file.
Data Structures | |
struct | bt_a2dp_codec_ie |
codec information elements for the endpoint More... | |
struct | bt_a2dp_codec_cfg |
The endpoint configuration. More... | |
struct | bt_a2dp_ep |
Stream End Point. More... | |
struct | bt_a2dp_ep_info |
struct | bt_a2dp_discover_param |
struct | bt_a2dp_cb |
The connecting callback. More... | |
struct | bt_a2dp_stream |
A2DP Stream. More... | |
struct | bt_a2dp_stream_ops |
The stream endpoint related operations. More... | |
Macros | |
#define | BT_A2DP_STREAM_BUF_RESERVE (12u + BT_L2CAP_BUF_SIZE(0)) |
#define | BT_A2DP_SBC_IE_LENGTH (4u) |
SBC IE length. | |
#define | BT_A2DP_MPEG_1_2_IE_LENGTH (4u) |
MPEG1,2 IE length. | |
#define | BT_A2DP_MPEG_2_4_IE_LENGTH (6u) |
MPEG2,4 IE length. | |
#define | A2DP_MAX_IE_LENGTH (8U) |
The max IE (Codec Info Element) length. | |
#define | BT_A2DP_EP_INIT(_role, _codec, _capability) |
define the audio endpoint | |
#define | BT_A2DP_SINK_EP_INIT(_codec, _capability) |
define the audio sink endpoint | |
#define | BT_A2DP_SOURCE_EP_INIT(_codec, _capability) |
define the audio source endpoint | |
#define | BT_A2DP_SBC_SINK_EP(_name, _freq, _ch_mode, _blk_len, _subband, _alloc_mthd, _min_bitpool, _max_bitpool) |
define the SBC sink endpoint that can be used as bt_a2dp_register_endpoint's parameter. | |
#define | BT_A2DP_SBC_SOURCE_EP(_name, _freq, _ch_mode, _blk_len, _subband, _alloc_mthd, _min_bitpool, _max_bitpool) |
define the SBC source endpoint that can be used as bt_a2dp_register_endpoint's parameter. | |
#define | BT_A2DP_SBC_SINK_EP_DEFAULT(_name) |
define the default SBC sink endpoint that can be used as bt_a2dp_register_endpoint's parameter. | |
#define | BT_A2DP_SBC_SOURCE_EP_DEFAULT(_name) |
define the default SBC source endpoint that can be used as bt_a2dp_register_endpoint's parameter. | |
#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) |
define the SBC default configuration. | |
#define | BT_A2DP_SBC_EP_CFG_DEFAULT(_name, _freq_cfg) |
define the SBC default configuration. | |
Typedefs | |
typedef 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. | |
Functions | |
struct bt_a2dp * | bt_a2dp_connect (struct bt_conn *conn) |
A2DP Connect. | |
int | bt_a2dp_disconnect (struct bt_a2dp *a2dp) |
disconnect l2cap a2dp | |
int | bt_a2dp_register_ep (struct bt_a2dp_ep *ep, uint8_t media_type, uint8_t role) |
Endpoint Registration. | |
int | bt_a2dp_register_cb (struct bt_a2dp_cb *cb) |
register callback. | |
int | bt_a2dp_discover (struct bt_a2dp *a2dp, struct bt_a2dp_discover_param *param) |
Discover remote endpoints. | |
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_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. | |
int | bt_a2dp_stream_establish (struct bt_a2dp_stream *stream) |
establish a2dp streamer. | |
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_suspend (struct bt_a2dp_stream *stream) |
suspend a2dp streamer. | |
int | bt_a2dp_stream_reconfig (struct bt_a2dp_stream *stream, struct bt_a2dp_codec_cfg *config) |
re-configure a2dp streamer | |
uint32_t | bt_a2dp_get_mtu (struct bt_a2dp_stream *stream) |
get the stream l2cap mtu | |
Advanced Audio Distribution Profile header.
#define A2DP_MAX_IE_LENGTH (8U) |
The max IE (Codec Info Element) length.
#define BT_A2DP_EP_INIT | ( | _role, | |
_codec, | |||
_capability ) |
define the audio endpoint
_role | BT_AVDTP_SOURCE or BT_AVDTP_SINK. |
_codec | value of enum bt_a2dp_codec_id. |
_capability | the codec capability. |
#define BT_A2DP_MPEG_1_2_IE_LENGTH (4u) |
MPEG1,2 IE length.
#define BT_A2DP_MPEG_2_4_IE_LENGTH (6u) |
MPEG2,4 IE length.
#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 ) |
define the SBC default configuration.
_name | unique structure name postfix. |
_freq_cfg | sbc codec frequency. for example: A2DP_SBC_SAMP_FREQ_44100 |
_ch_mode_cfg | sbc codec channel mode. for example: A2DP_SBC_CH_MODE_JOINT |
_blk_len_cfg | sbc codec block length. for example: A2DP_SBC_BLK_LEN_16 |
_subband_cfg | sbc codec subband. for example: A2DP_SBC_SUBBAND_8 |
_alloc_mthd_cfg | sbc codec allocate method. for example: A2DP_SBC_ALLOC_MTHD_LOUDNESS |
_min_bitpool_cfg | sbc codec min bit pool. for example: 18 |
_max_bitpool_cfg | sbc codec max bit pool. for example: 35 |
#define BT_A2DP_SBC_EP_CFG_DEFAULT | ( | _name, | |
_freq_cfg ) |
define the SBC default configuration.
_name | unique structure name postfix. |
_freq_cfg | the frequency to configure the remote same codec type endpoint. |
#define BT_A2DP_SBC_IE_LENGTH (4u) |
SBC IE length.
#define BT_A2DP_SBC_SINK_EP | ( | _name, | |
_freq, | |||
_ch_mode, | |||
_blk_len, | |||
_subband, | |||
_alloc_mthd, | |||
_min_bitpool, | |||
_max_bitpool ) |
define the SBC sink endpoint that can be used as bt_a2dp_register_endpoint's parameter.
SBC is mandatory as a2dp specification, BT_A2DP_SBC_SINK_EP_DEFAULT is more convenient for user to register SBC endpoint.
_name | unique structure name postfix. |
_freq | sbc codec frequency. for example: A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000 |
_ch_mode | sbc codec channel mode. for example: A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO |
_blk_len | sbc codec block length. for example: A2DP_SBC_BLK_LEN_16 |
_subband | sbc codec subband. for example: A2DP_SBC_SUBBAND_8 |
_alloc_mthd | sbc codec allocate method. for example: A2DP_SBC_ALLOC_MTHD_LOUDNESS |
_min_bitpool | sbc codec min bit pool. for example: 18 |
_max_bitpool | sbc codec max bit pool. for example: 35 @ |
#define BT_A2DP_SBC_SINK_EP_DEFAULT | ( | _name | ) |
define the default SBC sink endpoint that can be used as bt_a2dp_register_endpoint's parameter.
SBC is mandatory as a2dp specification, BT_A2DP_SBC_SINK_EP_DEFAULT is more convenient for user to register SBC endpoint.
_name | the endpoint variable name. |
#define BT_A2DP_SBC_SOURCE_EP | ( | _name, | |
_freq, | |||
_ch_mode, | |||
_blk_len, | |||
_subband, | |||
_alloc_mthd, | |||
_min_bitpool, | |||
_max_bitpool ) |
define the SBC source endpoint that can be used as bt_a2dp_register_endpoint's parameter.
SBC is mandatory as a2dp specification, BT_A2DP_SBC_SOURCE_EP_DEFAULT is more convenient for user to register SBC endpoint.
_name | the endpoint variable name. |
_freq | sbc codec frequency. for example: A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000 |
_ch_mode | sbc codec channel mode. for example: A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO |
_blk_len | sbc codec block length. for example: A2DP_SBC_BLK_LEN_16 |
_subband | sbc codec subband. for example: A2DP_SBC_SUBBAND_8 |
_alloc_mthd | sbc codec allocate method. for example: A2DP_SBC_ALLOC_MTHD_LOUDNESS |
_min_bitpool | sbc codec min bit pool. for example: 18 |
_max_bitpool | sbc codec max bit pool. for example: 35 |
#define BT_A2DP_SBC_SOURCE_EP_DEFAULT | ( | _name | ) |
define the default SBC source endpoint that can be used as bt_a2dp_register_endpoint's parameter.
SBC is mandatory as a2dp specification, BT_A2DP_SBC_SOURCE_EP_DEFAULT is more convenient for user to register SBC endpoint.
_name | the endpoint variable name. |
#define BT_A2DP_SINK_EP_INIT | ( | _codec, | |
_capability ) |
define the audio sink endpoint
_codec | value of enum bt_a2dp_codec_id. |
_capability | the codec capability. |
#define BT_A2DP_SOURCE_EP_INIT | ( | _codec, | |
_capability ) |
define the audio source endpoint
_codec | value of enum bt_a2dp_codec_id. |
_capability | the codec capability. |
#define BT_A2DP_STREAM_BUF_RESERVE (12u + BT_L2CAP_BUF_SIZE(0)) |
typedef 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.
A function of this type is given by the user to the bt_a2dp_discover_param object. It'll be called on each valid stream endpoint discovery completion. When no more endpoint then NULL is passed to the user. Otherwise user can get valid endpoint information from parameter info, user can set parameter ep to get the endpoint after the callback is return. The returned function value allows the user to control retrieving follow-up endpoints if any. If the user doesn't want to read more endpoints since current found endpoints fulfill its requirements then should return BT_A2DP_DISCOVER_EP_STOP. Otherwise returned value means more subcall iterations are allowable.
a2dp | a2dp connection object identifying a2dp connection to queried remote. |
info | Object pointing to the information of the callbacked endpoint. |
ep | If the user want to use this found endpoint, user can set value to it to get the endpoint that can be used further in other A2DP APIs. It is NULL if info is NULL (no more endpoint is found). |
anonymous enum |
enum bt_a2dp_codec_type |
enum bt_a2dp_err_code |
A2DP error code.
struct bt_a2dp * bt_a2dp_connect | ( | struct bt_conn * | conn | ) |
A2DP Connect.
This function is to be called after the conn parameter is obtained by performing a GAP procedure. The API is to be used to establish A2DP connection between devices. This function only establish AVDTP L2CAP Signaling connection. After connection success, the callback that is registered by bt_a2dp_register_connect_callback is called.
conn | Pointer to bt_conn structure. |
int bt_a2dp_disconnect | ( | struct bt_a2dp * | a2dp | ) |
disconnect l2cap a2dp
This function close AVDTP L2CAP Signaling connection. It closes the AVDTP L2CAP Media connection too if it is established.
a2dp | The a2dp instance. |
int bt_a2dp_discover | ( | struct bt_a2dp * | a2dp, |
struct bt_a2dp_discover_param * | param ) |
Discover remote endpoints.
a2dp | The a2dp instance. |
param | the discover used param. |
uint32_t bt_a2dp_get_mtu | ( | struct bt_a2dp_stream * | stream | ) |
get the stream l2cap mtu
stream | The stream object. |
int bt_a2dp_register_cb | ( | struct bt_a2dp_cb * | cb | ) |
register callback.
The cb is called when bt_a2dp_connect is called or it is operated by remote device.
cb | The callback function. |
int bt_a2dp_register_ep | ( | struct bt_a2dp_ep * | ep, |
uint8_t | media_type, | ||
uint8_t | role ) |
Endpoint Registration.
ep | Pointer to bt_a2dp_ep structure. |
media_type | Media type that the Endpoint is. |
role | Role of Endpoint. |
void bt_a2dp_stream_cb_register | ( | struct bt_a2dp_stream * | stream, |
struct bt_a2dp_stream_ops * | ops ) |
Register Audio callbacks for a stream.
Register Audio callbacks for a stream.
stream | Stream object. |
ops | Stream operations structure. |
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_discover can be used to find remote's endpoints. This function to configure the selected endpoint that is found by bt_a2dp_discover. This function sends AVDTP_SET_CONFIGURATION.
a2dp | The a2dp instance. |
stream | Stream object. |
local_ep | The configured endpoint that is registered. |
remote_ep | The remote endpoint. |
config | The config to configure the endpoint. |
int bt_a2dp_stream_establish | ( | struct bt_a2dp_stream * | stream | ) |
establish a2dp streamer.
This function sends the AVDTP_OPEN command and create the l2cap channel.
stream | The stream object. |
int bt_a2dp_stream_reconfig | ( | struct bt_a2dp_stream * | stream, |
struct bt_a2dp_codec_cfg * | config ) |
re-configure a2dp streamer
This function sends the AVDTP_RECONFIGURE command.
stream | The stream object. |
config | The config to configure the stream. |
int bt_a2dp_stream_release | ( | struct bt_a2dp_stream * | stream | ) |
release a2dp streamer.
This function sends the AVDTP_CLOSE command and release the l2cap channel.
stream | The stream object. |
int bt_a2dp_stream_start | ( | struct bt_a2dp_stream * | stream | ) |
start a2dp streamer.
This function sends the AVDTP_START command.
stream | The stream object. |
int bt_a2dp_stream_suspend | ( | struct bt_a2dp_stream * | stream | ) |
suspend a2dp streamer.
This function sends the AVDTP_SUSPEND command.
stream | The stream object. |