mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(bt/bluedroid): Add API to set encoder parameters for A2DP source
- Add API to set encoder parameters for A2DP source - Add the use of the API for setting encoding parameters in the a2dp_source example
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -349,6 +349,35 @@ esp_err_t esp_a2d_source_init(void)
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_source_set_pref_mcc(esp_a2d_conn_hdl_t conn_hdl, const esp_a2d_mcc_t *pref_mcc)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_on_deinit || g_a2dp_source_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (conn_hdl == 0 || pref_mcc == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SRC_API_SET_PREF_MCC_EVT;
|
||||
|
||||
btc_av_args_t arg;
|
||||
memset(&arg, 0, sizeof(btc_av_args_t));
|
||||
arg.set_pref_mcc.conn_hdl = conn_hdl;
|
||||
memcpy(&arg.set_pref_mcc.pref_mcc, pref_mcc, sizeof(esp_a2d_mcc_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_source_register_stream_endpoint(uint8_t seid, const esp_a2d_mcc_t *mcc)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -243,6 +243,7 @@ typedef enum {
|
||||
ESP_A2D_SNK_GET_DELAY_VALUE_EVT, /*!< indicate a2dp sink get delay report value complete, only used for A2DP SINK */
|
||||
ESP_A2D_REPORT_SNK_DELAY_VALUE_EVT, /*!< report delay value, only used for A2DP SRC */
|
||||
ESP_A2D_REPORT_SNK_CODEC_CAPS_EVT, /*!< report sink codec capabilities, only used for A2DP SRC */
|
||||
ESP_A2D_SRC_SET_PREF_MCC_EVT, /*!< indicate a2dp source set preferred media codec configuration status, only used for A2DP SRC */
|
||||
} esp_a2d_cb_event_t;
|
||||
|
||||
/**
|
||||
@@ -349,6 +350,16 @@ typedef union {
|
||||
esp_a2d_mcc_t mcc; /*!< A2DP sink media codec capability information */
|
||||
} a2d_report_snk_codec_caps_stat; /*!< A2DP source received sink codec capabilities */
|
||||
|
||||
/**
|
||||
* @brief ESP_A2D_SRC_SET_PREF_MCC_EVT
|
||||
*/
|
||||
struct a2d_set_pref_mcc_param {
|
||||
esp_bt_status_t set_status; /*!< set status.
|
||||
@note Possible values: ESP_BT_STATUS_SUCCESS, ESP_BT_STATUS_FAIL,
|
||||
ESP_BT_STATUS_NOT_READY, ESP_BT_STATUS_BUSY, ESP_BT_STATUS_UNSUPPORTED. */
|
||||
esp_a2d_conn_hdl_t conn_hdl; /*!< connection handle */
|
||||
} a2d_set_pref_mcc_stat; /*!< A2DP source set preferred media codec configuration */
|
||||
|
||||
} esp_a2d_cb_param_t;
|
||||
|
||||
/**
|
||||
@@ -570,6 +581,23 @@ esp_err_t esp_a2d_get_profile_status(esp_a2d_profile_status_t *profile_status);
|
||||
*/
|
||||
esp_err_t esp_a2d_source_init(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Set the preferred A2DP source media codec configuration after establishing A2DP connection
|
||||
* and before starting A2DP stream.
|
||||
*
|
||||
* @param[in] conn_hdl : connection handle
|
||||
* @param[in] pref_mcc : preferred media codec configuration
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_ERR_INVALID_ARG: invalid parameter
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_source_set_pref_mcc(esp_a2d_conn_hdl_t conn_hdl, const esp_a2d_mcc_t *pref_mcc);
|
||||
|
||||
/**
|
||||
* @brief Register a a2dp source Stream Endpoint (SEP) with specific codec capability, shall register
|
||||
* SEP after a2dp source initializing and before a2dp connection establishing. Register the same
|
||||
|
||||
Reference in New Issue
Block a user