docs(bt): update Classic Bluetooth api reference of A2DP

This commit is contained in:
yangfeng
2025-12-01 17:29:51 +08:00
parent e1445c682b
commit 2e1a089a6a
8 changed files with 35 additions and 38 deletions
@@ -19,56 +19,44 @@ extern "C" {
typedef uint16_t esp_a2d_conn_hdl_t; /*!< Connection handle, associate with specific device that connected */
/**
* @brief Media codec types supported by A2DP.
*/
/* Media codec types supported by A2DP. */
#define ESP_A2D_MCT_SBC (0) /*!< SBC */
#define ESP_A2D_MCT_M12 (0x01) /*!< MPEG-1, 2 Audio */
#define ESP_A2D_MCT_M24 (0x02) /*!< MPEG-2, 4 AAC */
#define ESP_A2D_MCT_ATRAC (0x04) /*!< ATRAC family */
#define ESP_A2D_MCT_NON_A2DP (0xff) /*!< NON-A2DP */
typedef uint8_t esp_a2d_mct_t;
typedef uint8_t esp_a2d_mct_t; /*!< Media codec type of A2DP */
/**
* @brief Protocol service capabilities. This value is a mask.
*/
/* Protocol service capabilities. This value is a mask. */
#define ESP_A2D_PSC_DELAY_RPT (1<<0) /*!< Delay Report */
typedef uint16_t esp_a2d_psc_t;
typedef uint16_t esp_a2d_psc_t; /*!< Protocol service capabilities type */
/**
* @brief A2DP SBC sampling frequency bit mask in CIE
*/
/* A2DP SBC sampling frequency bit mask in CIE */
#define ESP_A2D_SBC_CIE_SF_16K (0x8) /*!< SBC sampling frequency 16kHz */
#define ESP_A2D_SBC_CIE_SF_32K (0x4) /*!< SBC sampling frequency 32kHz */
#define ESP_A2D_SBC_CIE_SF_44K (0x2) /*!< SBC sampling frequency 44.1kHz */
#define ESP_A2D_SBC_CIE_SF_48K (0x1) /*!< SBC sampling frequency 48kHz */
/**
* @brief A2DP SBC channel mode bit mask in CIE
*/
/* A2DP SBC channel mode bit mask in CIE */
#define ESP_A2D_SBC_CIE_CH_MODE_MONO (0x8) /*!< SBC channel mode Mono */
#define ESP_A2D_SBC_CIE_CH_MODE_DUAL_CHANNEL (0x4) /*!< SBC channel mode Dual Channel */
#define ESP_A2D_SBC_CIE_CH_MODE_STEREO (0x2) /*!< SBC channel mode Stereo */
#define ESP_A2D_SBC_CIE_CH_MODE_JOINT_STEREO (0x1) /*!< SBC channel mode Stereo */
#define ESP_A2D_SBC_CIE_CH_MODE_JOINT_STEREO (0x1) /*!< SBC channel mode Joint Stereo */
/**
* @brief A2DP SBC block length bit mask in CIE
*/
/* A2DP SBC block length bit mask in CIE */
#define ESP_A2D_SBC_CIE_BLOCK_LEN_4 (0x8) /*!< SBC block length 4 */
#define ESP_A2D_SBC_CIE_BLOCK_LEN_8 (0x4) /*!< SBC block length 8 */
#define ESP_A2D_SBC_CIE_BLOCK_LEN_12 (0x2) /*!< SBC block length 12 */
#define ESP_A2D_SBC_CIE_BLOCK_LEN_16 (0x1) /*!< SBC block length 16 */
/**
* @brief A2DP SBC number of subbands bit mask in CIE
*/
/* A2DP SBC number of subbands bit mask in CIE */
#define ESP_A2D_SBC_CIE_NUM_SUBBANDS_4 (0x2) /*!< SBC number of subbands 4 */
#define ESP_A2D_SBC_CIE_NUM_SUBBANDS_8 (0x1) /*!< SBC number of subbands 8 */
/**
* @brief A2DP SBC allocation method bit mask in CIE
*/
#define ESP_A2D_SBC_CIE_ALLOC_MTHD_SRN (0x2) /*!< SBC allocation method SNR */
/* A2DP SBC allocation method bit mask in CIE */
#define ESP_A2D_SBC_CIE_ALLOC_MTHD_SNR (0x2) /*!< SBC allocation method SNR */
/*!< @deprecated Renamed to ESP_A2D_SBC_CIE_ALLOC_MTHD_SNR */
#define ESP_A2D_SBC_CIE_ALLOC_MTHD_SRN _Pragma("GCC warning \"'ESP_A2D_SBC_CIE_ALLOC_MTHD_SRN' macro is deprecated, use 'ESP_A2D_SBC_CIE_ALLOC_MTHD_SNR'\"") ESP_A2D_SBC_CIE_ALLOC_MTHD_SNR
#define ESP_A2D_SBC_CIE_ALLOC_MTHD_LOUDNESS (0x1) /*!< SBC allocation method Loudness */
/**
@@ -136,10 +124,10 @@ typedef struct {
*/
typedef struct {
esp_a2d_mct_t type; /*!< A2DP media codec type */
#define ESP_A2D_CIE_LEN_SBC (4)
#define ESP_A2D_CIE_LEN_M12 (4)
#define ESP_A2D_CIE_LEN_M24 (6)
#define ESP_A2D_CIE_LEN_ATRAC (7)
#define ESP_A2D_CIE_LEN_SBC (4) /*!< SBC cie length */
#define ESP_A2D_CIE_LEN_M12 (4) /*!< MPEG-1,2 cie length */
#define ESP_A2D_CIE_LEN_M24 (6) /*!< MPEG-2,4 AAC cie length */
#define ESP_A2D_CIE_LEN_ATRAC (7) /*!< ATRAC family cie length */
union {
esp_a2d_cie_sbc_t sbc_info; /*!< SBC codec capabilities */
esp_a2d_cie_m12_t m12_info; /*!< MPEG-1,2 audio codec capabilities */
@@ -198,7 +186,7 @@ typedef enum {
*/
typedef enum {
ESP_A2D_DEINIT_SUCCESS = 0, /*!< A2DP profile deinit successful event */
ESP_A2D_INIT_SUCCESS /*!< A2DP profile deinit successful event */
ESP_A2D_INIT_SUCCESS /*!< A2DP profile init successful event */
} esp_a2d_init_state_t;
/**
@@ -237,7 +225,7 @@ typedef enum {
ESP_A2D_AUDIO_CFG_EVT, /*!< audio codec is configured */
ESP_A2D_MEDIA_CTRL_ACK_EVT, /*!< acknowledge event in response to media control commands */
ESP_A2D_PROF_STATE_EVT, /*!< indicate a2dp init&deinit complete */
ESP_A2D_SEP_REG_STATE_EVT, /*!< indicate a2dp steam endpoint register status */
ESP_A2D_SEP_REG_STATE_EVT, /*!< indicate a2dp stream endpoint register status */
ESP_A2D_SNK_PSC_CFG_EVT, /*!< protocol service capabilities configuredonly used for A2DP SINK */
ESP_A2D_SNK_SET_DELAY_VALUE_EVT, /*!< indicate a2dp sink set delay report value complete, only used for A2DP SINK */
ESP_A2D_SNK_GET_DELAY_VALUE_EVT, /*!< indicate a2dp sink get delay report value complete, only used for A2DP SINK */
@@ -345,9 +333,9 @@ typedef union {
/**
* @brief A2DP profile callback function type
*
* @param event : Event type
* @param[in] event : Event type
*
* @param param : Pointer to callback parameter
* @param[in] param : Pointer to callback parameter
*/
typedef void (* esp_a2d_cb_t)(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param);
@@ -594,7 +582,7 @@ esp_err_t esp_a2d_source_register_stream_endpoint(uint8_t seid, const esp_a2d_mc
esp_err_t esp_a2d_source_deinit(void);
/**
* @brief Send a audio buff with encoded audio data to sink, the audio data len shall not bigger than
* @brief Send an audio buffer with encoded audio data to sink. The audio data length shall not be bigger than
* audio connection mtu (retrieved from ESP_A2D_CONNECTION_STATE_EVT). if the return value is
* ESP_OK, then the audio buff is consumed, otherwise, audio buff can be reused by user.
*
@@ -1,6 +1,11 @@
Bluetooth® A2DP API
===================
Overview
--------
A2DP (Advanced Audio Distribution Profile) enables high-quality audio streaming from one device to another over Bluetooth. It is primarily used for streaming audio from source devices such as smartphones, computers, and media players to sink devices such as Bluetooth speakers, headphones, and car audio systems. Users can use the A2DP APIs to transmit or receive audio streams.
Application Examples
--------------------
@@ -42,3 +42,5 @@ Bluedroid
- Field ``ESP_A2D_MEDIA_CTRL_STOP`` is removed in structure ``esp_a2d_media_ctrl_t``, and is replaced by ``ESP_A2D_MEDIA_CTRL_SUSPEND``.
- Field ``sbc, m12, m24 and atrac`` is removed and replaced by ``sbc_info, m12_info, m24_info and atrc_info`` in structure ``esp_a2d_mcc_t``.
- Macro ``ESP_A2D_SBC_CIE_ALLOC_MTHD_SRN`` is renamed to ``ESP_A2D_SBC_CIE_ALLOC_MTHD_SNR``. The old macro is kept for backward compatibility, but it is deprecated and will emit a compile-time warning.
@@ -42,3 +42,5 @@ Bluedroid
- 结构体 ``esp_a2d_media_ctrl_t`` 中的字段 ``ESP_A2D_MEDIA_CTRL_STOP`` 被移除,该字段被 ``ESP_A2D_MEDIA_CTRL_SUSPEND`` 替代。
- 结构体 ``esp_a2d_mcc_t`` 中的字段 ``sbc, m12, m24, atrac`` 被移除并由字段 ``bc_info, m12_info, m24_info , atrc_info`` 替代。
- 宏 ``ESP_A2D_SBC_CIE_ALLOC_MTHD_SRN`` 更名为 ``ESP_A2D_SBC_CIE_ALLOC_MTHD_SNR``。旧宏为兼容保留,但已废弃,使用时会产生编译期告警。
@@ -139,7 +139,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
ESP_A2D_SBC_CIE_BLOCK_LEN_12 |
ESP_A2D_SBC_CIE_BLOCK_LEN_16;
mcc.cie.sbc_info.num_subbands = ESP_A2D_SBC_CIE_NUM_SUBBANDS_4 | ESP_A2D_SBC_CIE_NUM_SUBBANDS_8;
mcc.cie.sbc_info.alloc_mthd = ESP_A2D_SBC_CIE_ALLOC_MTHD_SRN | ESP_A2D_SBC_CIE_ALLOC_MTHD_LOUDNESS;
mcc.cie.sbc_info.alloc_mthd = ESP_A2D_SBC_CIE_ALLOC_MTHD_SNR | ESP_A2D_SBC_CIE_ALLOC_MTHD_LOUDNESS;
mcc.cie.sbc_info.max_bitpool = 250;
mcc.cie.sbc_info.min_bitpool = 2;
/* register stream end point, only support SBC currently */
@@ -212,7 +212,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
ESP_A2D_SBC_CIE_BLOCK_LEN_12 |
ESP_A2D_SBC_CIE_BLOCK_LEN_16;
mcc.cie.sbc_info.num_subbands = ESP_A2D_SBC_CIE_NUM_SUBBANDS_4 | ESP_A2D_SBC_CIE_NUM_SUBBANDS_8;
mcc.cie.sbc_info.alloc_mthd = ESP_A2D_SBC_CIE_ALLOC_MTHD_SRN | ESP_A2D_SBC_CIE_ALLOC_MTHD_LOUDNESS;
mcc.cie.sbc_info.alloc_mthd = ESP_A2D_SBC_CIE_ALLOC_MTHD_SNR | ESP_A2D_SBC_CIE_ALLOC_MTHD_LOUDNESS;
mcc.cie.sbc_info.max_bitpool = 250;
mcc.cie.sbc_info.min_bitpool = 2;
/* register stream end point, only support SBC currently */
@@ -94,7 +94,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
ESP_A2D_SBC_CIE_BLOCK_LEN_12 |
ESP_A2D_SBC_CIE_BLOCK_LEN_16;
mcc.cie.sbc_info.num_subbands = ESP_A2D_SBC_CIE_NUM_SUBBANDS_4 | ESP_A2D_SBC_CIE_NUM_SUBBANDS_8;
mcc.cie.sbc_info.alloc_mthd = ESP_A2D_SBC_CIE_ALLOC_MTHD_SRN | ESP_A2D_SBC_CIE_ALLOC_MTHD_LOUDNESS;
mcc.cie.sbc_info.alloc_mthd = ESP_A2D_SBC_CIE_ALLOC_MTHD_SNR | ESP_A2D_SBC_CIE_ALLOC_MTHD_LOUDNESS;
mcc.cie.sbc_info.max_bitpool = 250;
mcc.cie.sbc_info.min_bitpool = 2;
/* register stream end point, only support SBC currently */
@@ -256,7 +256,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
ESP_A2D_SBC_CIE_BLOCK_LEN_12 |
ESP_A2D_SBC_CIE_BLOCK_LEN_16;
mcc.cie.sbc_info.num_subbands = ESP_A2D_SBC_CIE_NUM_SUBBANDS_4 | ESP_A2D_SBC_CIE_NUM_SUBBANDS_8;
mcc.cie.sbc_info.alloc_mthd = ESP_A2D_SBC_CIE_ALLOC_MTHD_SRN | ESP_A2D_SBC_CIE_ALLOC_MTHD_LOUDNESS;
mcc.cie.sbc_info.alloc_mthd = ESP_A2D_SBC_CIE_ALLOC_MTHD_SNR | ESP_A2D_SBC_CIE_ALLOC_MTHD_LOUDNESS;
mcc.cie.sbc_info.max_bitpool = 250;
mcc.cie.sbc_info.min_bitpool = 2;
/* register stream end point, only support SBC currently */