mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
component/bt: modify the a2dp APIs
This commit is contained in:
parent
50227f12fd
commit
5b120186f1
@ -10,7 +10,8 @@
|
||||
#include "btif_stack_manager.h"
|
||||
#include "esp_gap_bt_api.h"
|
||||
#include "bta_api.h"
|
||||
#include "bt_av.h"
|
||||
// #include "bt_av.h"
|
||||
#include "esp_a2dp_api.h"
|
||||
|
||||
/* utl_set_device_class() */
|
||||
#include "utl.h"
|
||||
@ -27,7 +28,7 @@ typedef union {
|
||||
uint32_t dummy;
|
||||
} tBT_APP_EVT_DATA;
|
||||
|
||||
extern const btav_interface_t *btif_av_get_sink_interface(void);
|
||||
// extern const btav_interface_t *btif_av_get_sink_interface(void);
|
||||
static void bt_stack_evt(tBT_APP_EVT event, tBT_APP_EVT_DATA *p_data);
|
||||
static void bt_stack_state_changed(bt_state_t state);
|
||||
|
||||
@ -39,27 +40,26 @@ static bt_callbacks_t bt_callbacks = {
|
||||
|
||||
osi_alarm_t *app_alarm = NULL;
|
||||
|
||||
static void btav_conn_state_cb(btav_connection_state_t state,
|
||||
bt_bdaddr_t *bd_addr)
|
||||
static void btav_conn_state_cb(esp_a2dp_connection_state_t state,
|
||||
esp_bd_addr_t *bd_addr)
|
||||
{
|
||||
LOG_ERROR("===btav_conn_state_cb %d ===\n", state);
|
||||
LOG_ERROR("===esp_a2dp_conn_state_cb %d ===\n", state);
|
||||
(void) bd_addr;
|
||||
}
|
||||
|
||||
static void btav_audio_state_cb(btav_audio_state_t state, bt_bdaddr_t *bd_addr)
|
||||
static void btav_audio_state_cb(esp_a2dp_audio_state_t state, esp_bd_addr_t *bd_addr)
|
||||
{
|
||||
LOG_ERROR("===btav_audio_state_cb %d ===\n", state);
|
||||
LOG_ERROR("===esp_a2dp_audio_state_cb %d ===\n", state);
|
||||
(void) bd_addr;
|
||||
}
|
||||
|
||||
static void btav_audio_cfg_cb(bt_bdaddr_t *bd_addr, uint32_t sample_rate, uint8_t channel_count)
|
||||
static void btav_audio_cfg_cb(esp_bd_addr_t *bd_addr, uint32_t sample_rate, uint8_t channel_count)
|
||||
{
|
||||
LOG_ERROR("===btav_audio_cfg_cb %d %d===\n", sample_rate, channel_count);
|
||||
LOG_ERROR("===esp_a2dp_audio_cfg_cb %d %d===\n", sample_rate, channel_count);
|
||||
(void) bd_addr;
|
||||
}
|
||||
|
||||
static btav_callbacks_t btav_cbs = {
|
||||
sizeof (btav_callbacks_t),
|
||||
static esp_a2dp_callbacks_t btav_cbs = {
|
||||
btav_conn_state_cb,
|
||||
btav_audio_state_cb,
|
||||
btav_audio_cfg_cb
|
||||
@ -92,7 +92,8 @@ static void bt_app_stack_evt(UINT16 event, char *p_param)
|
||||
btav_set_device_class();
|
||||
BTA_DmSetDeviceName(dev_name);
|
||||
esp_bt_gap_set_scan_mode(BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
|
||||
btif_av_get_sink_interface()->init(&btav_cbs);
|
||||
esp_a2dp_sink_init(&btav_cbs);
|
||||
// btif_av_get_sink_interface()->init(&btav_cbs);
|
||||
|
||||
// app_alarm = osi_alarm_new("app_alarm", bt_sdp_add_record_to, NULL, 1000, false);
|
||||
app_alarm = osi_alarm_new("app_alarm", btav_open_to, NULL, 1000, false);
|
||||
|
@ -32,7 +32,8 @@
|
||||
// #include <hardware/bluetooth.h>
|
||||
#include "bt_defs.h"
|
||||
// #include <system/audio.h>
|
||||
#include "bt_av.h"
|
||||
// #include "bt_av.h"
|
||||
#include "esp_a2dp_api.h"
|
||||
#include "allocator.h"
|
||||
|
||||
#define LOG_TAG "bt_btif_av"
|
||||
@ -98,17 +99,17 @@ typedef struct {
|
||||
/*****************************************************************************
|
||||
** Static variables
|
||||
******************************************************************************/
|
||||
static btav_callbacks_t *bt_av_src_callbacks = NULL;
|
||||
static btav_callbacks_t *bt_av_sink_callbacks = NULL;
|
||||
static esp_a2dp_callbacks_t *bt_av_sink_callbacks = NULL;
|
||||
|
||||
static btif_av_cb_t btif_av_cb = {0};
|
||||
// static TIMER_LIST_ENT tle_av_open_on_rc;
|
||||
|
||||
/* both interface and media task needs to be ready to alloc incoming request */
|
||||
#define CHECK_BTAV_INIT() if (((bt_av_src_callbacks == NULL) &&(bt_av_sink_callbacks == NULL)) \
|
||||
#define CHECK_BTAV_INIT() if ((bt_av_sink_callbacks == NULL) \
|
||||
|| (btif_av_cb.sm_handle == NULL))\
|
||||
{\
|
||||
BTIF_TRACE_WARNING("%s: BTAV not initialized\n", __FUNCTION__);\
|
||||
return BT_STATUS_NOT_READY;\
|
||||
return ESP_ERR_INVALID_STATE;\
|
||||
}\
|
||||
else\
|
||||
{\
|
||||
@ -206,22 +207,29 @@ const char *dump_av_sm_event_name(btif_av_sm_event_t event)
|
||||
/*****************************************************************************
|
||||
** Static functions
|
||||
******************************************************************************/
|
||||
|
||||
static void btif_report_connection_state(btav_connection_state_t state, bt_bdaddr_t *bd_addr)
|
||||
static void btif_report_connection_state(esp_a2dp_connection_state_t state, bt_bdaddr_t *bd_addr)
|
||||
{
|
||||
if (bt_av_sink_callbacks != NULL) {
|
||||
HAL_CBACK(bt_av_sink_callbacks, connection_state_cb, state, bd_addr);
|
||||
} else if (bt_av_src_callbacks != NULL) {
|
||||
HAL_CBACK(bt_av_src_callbacks, connection_state_cb, state, bd_addr);
|
||||
esp_bd_addr_t remote_bda;
|
||||
if (bd_addr) {
|
||||
memcpy(&remote_bda, bd_addr, sizeof(esp_bd_addr_t));
|
||||
} else {
|
||||
memset(&remote_bda, 0, sizeof(esp_bd_addr_t));
|
||||
}
|
||||
HAL_CBACK(bt_av_sink_callbacks, connection_state_cb, state, &remote_bda);
|
||||
}
|
||||
}
|
||||
|
||||
static void btif_report_audio_state(btav_audio_state_t state, bt_bdaddr_t *bd_addr)
|
||||
static void btif_report_audio_state(esp_a2dp_audio_state_t state, bt_bdaddr_t *bd_addr)
|
||||
{
|
||||
if (bt_av_sink_callbacks != NULL) {
|
||||
HAL_CBACK(bt_av_sink_callbacks, audio_state_cb, state, bd_addr);
|
||||
} else if (bt_av_src_callbacks != NULL) {
|
||||
HAL_CBACK(bt_av_src_callbacks, audio_state_cb, state, bd_addr);
|
||||
esp_bd_addr_t remote_bda;
|
||||
if (bd_addr) {
|
||||
memcpy(&remote_bda, bd_addr, sizeof(esp_bd_addr_t));
|
||||
} else {
|
||||
memset(&remote_bda, 0, sizeof(esp_bd_addr_t));
|
||||
}
|
||||
HAL_CBACK(bt_av_sink_callbacks, audio_state_cb, state, &remote_bda);
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,7 +320,7 @@ static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data
|
||||
switch (event) {
|
||||
case BTIF_SM_ENTER_EVT:
|
||||
/* inform the application that we are entering connecting state */
|
||||
btif_report_connection_state(BTAV_CONNECTION_STATE_CONNECTING, &(btif_av_cb.peer_bda));
|
||||
btif_report_connection_state(ESP_A2DP_CONNECTION_STATE_CONNECTING, &(btif_av_cb.peer_bda));
|
||||
break;
|
||||
|
||||
case BTIF_SM_EXIT_EVT:
|
||||
@ -320,19 +328,19 @@ static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data
|
||||
|
||||
case BTA_AV_REJECT_EVT:
|
||||
BTIF_TRACE_DEBUG(" Received BTA_AV_REJECT_EVT \n");
|
||||
btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
|
||||
btif_report_connection_state(ESP_A2DP_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
|
||||
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_IDLE);
|
||||
break;
|
||||
|
||||
case BTA_AV_OPEN_EVT: {
|
||||
tBTA_AV *p_bta_data = (tBTA_AV *)p_data;
|
||||
btav_connection_state_t state;
|
||||
esp_a2dp_connection_state_t state;
|
||||
btif_sm_state_t av_state;
|
||||
BTIF_TRACE_DEBUG("status:%d, edr 0x%x\n", p_bta_data->open.status,
|
||||
p_bta_data->open.edr);
|
||||
|
||||
if (p_bta_data->open.status == BTA_AV_SUCCESS) {
|
||||
state = BTAV_CONNECTION_STATE_CONNECTED;
|
||||
state = ESP_A2DP_CONNECTION_STATE_CONNECTED;
|
||||
av_state = BTIF_AV_STATE_OPENED;
|
||||
btif_av_cb.edr = p_bta_data->open.edr;
|
||||
|
||||
@ -341,7 +349,7 @@ static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data
|
||||
} else {
|
||||
BTIF_TRACE_WARNING("BTA_AV_OPEN_EVT::FAILED status: %d\n",
|
||||
p_bta_data->open.status );
|
||||
state = BTAV_CONNECTION_STATE_DISCONNECTED;
|
||||
state = ESP_A2DP_CONNECTION_STATE_DISCONNECTED;
|
||||
av_state = BTIF_AV_STATE_IDLE;
|
||||
}
|
||||
|
||||
@ -372,7 +380,9 @@ static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data
|
||||
BTIF_TRACE_WARNING("BTIF_AV_SINK_CONFIG_REQ_EVT %d %d\n", req.sample_rate,
|
||||
req.channel_count);
|
||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SRC && bt_av_sink_callbacks != NULL) {
|
||||
HAL_CBACK(bt_av_sink_callbacks, audio_config_cb, &(btif_av_cb.peer_bda),
|
||||
esp_bd_addr_t remote_bda;
|
||||
memcpy(&remote_bda, &btif_av_cb.peer_bda, sizeof(esp_bd_addr_t));
|
||||
HAL_CBACK(bt_av_sink_callbacks, audio_config_cb, &remote_bda,
|
||||
req.sample_rate, req.channel_count);
|
||||
}
|
||||
} break;
|
||||
@ -386,7 +396,7 @@ static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data
|
||||
break;
|
||||
} else {
|
||||
BTIF_TRACE_DEBUG("%s: Moved from idle by Incoming Connection request\n", __func__);
|
||||
btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTED, (bt_bdaddr_t *)p_data);
|
||||
btif_report_connection_state(ESP_A2DP_CONNECTION_STATE_DISCONNECTED, (bt_bdaddr_t *)p_data);
|
||||
btif_queue_advance();
|
||||
break;
|
||||
}
|
||||
@ -466,7 +476,7 @@ static BOOLEAN btif_av_state_closing_handler(btif_sm_event_t event, void *p_data
|
||||
case BTA_AV_CLOSE_EVT:
|
||||
|
||||
/* inform the application that we are disconnecting */
|
||||
btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
|
||||
btif_report_connection_state(ESP_A2DP_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
|
||||
|
||||
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_IDLE);
|
||||
break;
|
||||
@ -584,7 +594,7 @@ static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data)
|
||||
BTA_AvClose(btif_av_cb.bta_handle);
|
||||
|
||||
/* inform the application that we are disconnecting */
|
||||
btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTING, &(btif_av_cb.peer_bda));
|
||||
btif_report_connection_state(ESP_A2DP_CONNECTION_STATE_DISCONNECTING, &(btif_av_cb.peer_bda));
|
||||
break;
|
||||
|
||||
case BTA_AV_CLOSE_EVT:
|
||||
@ -592,7 +602,7 @@ static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data)
|
||||
btif_a2dp_on_stopped(NULL);
|
||||
|
||||
/* inform the application that we are disconnected */
|
||||
btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
|
||||
btif_report_connection_state(ESP_A2DP_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
|
||||
|
||||
/* change state to idle, send acknowledgement if start is pending */
|
||||
if (btif_av_cb.flags & BTIF_AV_FLAG_PENDING_START) {
|
||||
@ -619,7 +629,7 @@ static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data)
|
||||
BTIF_TRACE_DEBUG("%s: Ignore BTIF_AV_CONNECT_REQ_EVT for same device\n", __func__);
|
||||
} else {
|
||||
BTIF_TRACE_DEBUG("%s: Moved to opened by Other Incoming Conn req\n", __func__);
|
||||
btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTED,
|
||||
btif_report_connection_state(ESP_A2DP_CONNECTION_STATE_DISCONNECTED,
|
||||
(bt_bdaddr_t *)p_data);
|
||||
}
|
||||
btif_queue_advance();
|
||||
@ -659,7 +669,7 @@ static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data
|
||||
/* we are again in started state, clear any remote suspend flags */
|
||||
btif_av_cb.flags &= ~BTIF_AV_FLAG_REMOTE_SUSPEND;
|
||||
|
||||
btif_report_audio_state(BTAV_AUDIO_STATE_STARTED, &(btif_av_cb.peer_bda));
|
||||
btif_report_audio_state(ESP_A2DP_AUDIO_STATE_STARTED, &(btif_av_cb.peer_bda));
|
||||
|
||||
/* increase the a2dp consumer task priority temporarily when start
|
||||
** audio playing, to avoid overflow the audio packet queue. */
|
||||
@ -713,7 +723,7 @@ static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data
|
||||
BTA_AvClose(btif_av_cb.bta_handle);
|
||||
|
||||
/* inform the application that we are disconnecting */
|
||||
btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTING, &(btif_av_cb.peer_bda));
|
||||
btif_report_connection_state(ESP_A2DP_CONNECTION_STATE_DISCONNECTING, &(btif_av_cb.peer_bda));
|
||||
|
||||
/* wait in closing state until fully closed */
|
||||
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_CLOSING);
|
||||
@ -749,9 +759,9 @@ static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data
|
||||
btif_av_cb.flags |= BTIF_AV_FLAG_REMOTE_SUSPEND;
|
||||
}
|
||||
|
||||
btif_report_audio_state(BTAV_AUDIO_STATE_REMOTE_SUSPEND, &(btif_av_cb.peer_bda));
|
||||
btif_report_audio_state(ESP_A2DP_AUDIO_STATE_REMOTE_SUSPEND, &(btif_av_cb.peer_bda));
|
||||
} else {
|
||||
btif_report_audio_state(BTAV_AUDIO_STATE_STOPPED, &(btif_av_cb.peer_bda));
|
||||
btif_report_audio_state(ESP_A2DP_AUDIO_STATE_STOPPED, &(btif_av_cb.peer_bda));
|
||||
}
|
||||
|
||||
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_OPENED);
|
||||
@ -765,7 +775,7 @@ static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data
|
||||
btif_av_cb.flags |= BTIF_AV_FLAG_PENDING_STOP;
|
||||
btif_a2dp_on_stopped(&p_av->suspend);
|
||||
|
||||
btif_report_audio_state(BTAV_AUDIO_STATE_STOPPED, &(btif_av_cb.peer_bda));
|
||||
btif_report_audio_state(ESP_A2DP_AUDIO_STATE_STOPPED, &(btif_av_cb.peer_bda));
|
||||
|
||||
/* if stop was successful, change state to open */
|
||||
if (p_av->suspend.status == BTA_AV_SUCCESS) {
|
||||
@ -782,7 +792,7 @@ static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data
|
||||
btif_a2dp_on_stopped(NULL);
|
||||
|
||||
/* inform the application that we are disconnected */
|
||||
btif_report_connection_state(BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
|
||||
btif_report_connection_state(ESP_A2DP_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
|
||||
|
||||
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_IDLE);
|
||||
break;
|
||||
@ -975,8 +985,8 @@ static bt_status_t init_src(btav_callbacks_t *callbacks)
|
||||
** Returns bt_status_t
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
static bt_status_t init_sink(btav_callbacks_t *callbacks)
|
||||
esp_err_t esp_a2dp_sink_init(esp_a2dp_callbacks_t *callbacks)
|
||||
// static bt_status_t init_sink(btav_callbacks_t *callbacks)
|
||||
{
|
||||
BTIF_TRACE_EVENT("%s()\n", __func__);
|
||||
|
||||
@ -985,7 +995,7 @@ static bt_status_t init_sink(btav_callbacks_t *callbacks)
|
||||
bt_av_sink_callbacks = callbacks;
|
||||
}
|
||||
|
||||
return status;
|
||||
return (status == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -1020,12 +1030,18 @@ static bt_status_t src_connect_sink(bt_bdaddr_t *bd_addr)
|
||||
}
|
||||
#endif
|
||||
|
||||
static bt_status_t sink_connect_src(bt_bdaddr_t *bd_addr)
|
||||
esp_err_t esp_a2dp_sink_connect(esp_bd_addr_t *remote_bda)
|
||||
// static bt_status_t sink_connect_src(bt_bdaddr_t *bd_addr)
|
||||
{
|
||||
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
||||
CHECK_BTAV_INIT();
|
||||
|
||||
return btif_queue_connect(UUID_SERVCLASS_AUDIO_SINK, bd_addr, connect_int);
|
||||
bt_status_t stat;
|
||||
bt_bdaddr_t bd_addr;
|
||||
memcpy(&bd_addr, remote_bda, sizeof(bt_bdaddr_t));
|
||||
|
||||
stat = btif_queue_connect(UUID_SERVCLASS_AUDIO_SINK, &bd_addr, connect_int);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -1048,6 +1064,18 @@ static bt_status_t disconnect(bt_bdaddr_t *bd_addr)
|
||||
(char *)bd_addr, sizeof(bt_bdaddr_t), NULL);
|
||||
}
|
||||
|
||||
esp_err_t esp_a2dp_sink_disconnect(esp_bd_addr_t *remote_bda)
|
||||
{
|
||||
bt_status_t stat;
|
||||
bt_bdaddr_t bd_addr;
|
||||
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
||||
CHECK_BTAV_INIT();
|
||||
memcpy(&bd_addr, remote_bda, sizeof(bt_bdaddr_t));
|
||||
/* Switch to BTIF context */
|
||||
stat = btif_transfer_context(btif_av_handle_event, BTIF_AV_DISCONNECT_REQ_EVT,
|
||||
(char *)(&bd_addr), sizeof(bt_bdaddr_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function cleanup
|
||||
@ -1087,15 +1115,13 @@ static void cleanup_src(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void cleanup_sink(void)
|
||||
void esp_a2dp_sink_deinit(void)
|
||||
{
|
||||
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
||||
|
||||
if (bt_av_sink_callbacks) {
|
||||
bt_av_sink_callbacks = NULL;
|
||||
if (bt_av_src_callbacks == NULL) {
|
||||
cleanup();
|
||||
}
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1109,6 +1135,7 @@ static const btav_interface_t bt_av_src_interface = {
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
static const btav_interface_t bt_av_sink_interface = {
|
||||
sizeof(btav_interface_t),
|
||||
init_sink,
|
||||
@ -1116,7 +1143,7 @@ static const btav_interface_t bt_av_sink_interface = {
|
||||
disconnect,
|
||||
cleanup_sink,
|
||||
};
|
||||
|
||||
*/
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btif_av_get_sm_handle
|
||||
@ -1270,20 +1297,6 @@ const btav_interface_t *btif_av_get_src_interface(void)
|
||||
}
|
||||
|
||||
#endif
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btif_av_get_sink_interface
|
||||
**
|
||||
** Description Get the AV callback interface for A2DP sink profile
|
||||
**
|
||||
** Returns btav_interface_t
|
||||
**
|
||||
*******************************************************************************/
|
||||
const btav_interface_t *btif_av_get_sink_interface(void)
|
||||
{
|
||||
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
||||
return &bt_av_sink_interface;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_INCLUDE_BT_AV_H
|
||||
#define ANDROID_INCLUDE_BT_AV_H
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* Bluetooth AV connection states */
|
||||
typedef enum {
|
||||
BTAV_CONNECTION_STATE_DISCONNECTED = 0,
|
||||
BTAV_CONNECTION_STATE_CONNECTING,
|
||||
BTAV_CONNECTION_STATE_CONNECTED,
|
||||
BTAV_CONNECTION_STATE_DISCONNECTING
|
||||
} btav_connection_state_t;
|
||||
|
||||
/* Bluetooth AV datapath states */
|
||||
typedef enum {
|
||||
BTAV_AUDIO_STATE_REMOTE_SUSPEND = 0,
|
||||
BTAV_AUDIO_STATE_STOPPED,
|
||||
BTAV_AUDIO_STATE_STARTED,
|
||||
} btav_audio_state_t;
|
||||
|
||||
|
||||
/** Callback for connection state change.
|
||||
* state will have one of the values from btav_connection_state_t
|
||||
*/
|
||||
typedef void (* btav_connection_state_callback)(btav_connection_state_t state,
|
||||
bt_bdaddr_t *bd_addr);
|
||||
|
||||
/** Callback for audiopath state change.
|
||||
* state will have one of the values from btav_audio_state_t
|
||||
*/
|
||||
typedef void (* btav_audio_state_callback)(btav_audio_state_t state,
|
||||
bt_bdaddr_t *bd_addr);
|
||||
|
||||
/** Callback for audio configuration change.
|
||||
* Used only for the A2DP sink interface.
|
||||
* state will have one of the values from btav_audio_state_t
|
||||
* sample_rate: sample rate in Hz
|
||||
* channel_count: number of channels (1 for mono, 2 for stereo)
|
||||
*/
|
||||
typedef void (* btav_audio_config_callback)(bt_bdaddr_t *bd_addr,
|
||||
uint32_t sample_rate,
|
||||
uint8_t channel_count);
|
||||
|
||||
/** BT-AV callback structure. */
|
||||
typedef struct {
|
||||
/** set to sizeof(btav_callbacks_t) */
|
||||
size_t size;
|
||||
btav_connection_state_callback connection_state_cb;
|
||||
btav_audio_state_callback audio_state_cb;
|
||||
btav_audio_config_callback audio_config_cb;
|
||||
} btav_callbacks_t;
|
||||
|
||||
/**
|
||||
* NOTE:
|
||||
*
|
||||
* 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands
|
||||
* shall be handled internally via uinput
|
||||
*
|
||||
* 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger
|
||||
* android_audio_hw library and the Bluetooth stack.
|
||||
*
|
||||
*/
|
||||
/** Represents the standard BT-AV interface.
|
||||
* Used for both the A2DP source and sink interfaces.
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
/** set to sizeof(btav_interface_t) */
|
||||
size_t size;
|
||||
/**
|
||||
* Register the BtAv callbacks
|
||||
*/
|
||||
bt_status_t (*init)( btav_callbacks_t *callbacks );
|
||||
|
||||
/** connect to headset */
|
||||
bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
|
||||
|
||||
/** dis-connect from headset */
|
||||
bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
|
||||
|
||||
/** Closes the interface. */
|
||||
void (*cleanup)( void );
|
||||
} btav_interface_t;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ANDROID_INCLUDE_BT_AV_H */
|
@ -1,295 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_INCLUDE_BT_RC_H
|
||||
#define ANDROID_INCLUDE_BT_RC_H
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* Macros */
|
||||
#define BTRC_MAX_ATTR_STR_LEN 255
|
||||
#define BTRC_UID_SIZE 8
|
||||
#define BTRC_MAX_APP_SETTINGS 8
|
||||
#define BTRC_MAX_FOLDER_DEPTH 4
|
||||
#define BTRC_MAX_APP_ATTR_SIZE 16
|
||||
#define BTRC_MAX_ELEM_ATTR_SIZE 7
|
||||
|
||||
typedef uint8_t btrc_uid_t[BTRC_UID_SIZE];
|
||||
|
||||
typedef enum {
|
||||
BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */
|
||||
BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */
|
||||
BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */
|
||||
BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */
|
||||
} btrc_remote_features_t;
|
||||
|
||||
typedef enum {
|
||||
BTRC_PLAYSTATE_STOPPED = 0x00, /* Stopped */
|
||||
BTRC_PLAYSTATE_PLAYING = 0x01, /* Playing */
|
||||
BTRC_PLAYSTATE_PAUSED = 0x02, /* Paused */
|
||||
BTRC_PLAYSTATE_FWD_SEEK = 0x03, /* Fwd Seek*/
|
||||
BTRC_PLAYSTATE_REV_SEEK = 0x04, /* Rev Seek*/
|
||||
BTRC_PLAYSTATE_ERROR = 0xFF, /* Error */
|
||||
} btrc_play_status_t;
|
||||
|
||||
typedef enum {
|
||||
BTRC_EVT_PLAY_STATUS_CHANGED = 0x01,
|
||||
BTRC_EVT_TRACK_CHANGE = 0x02,
|
||||
BTRC_EVT_TRACK_REACHED_END = 0x03,
|
||||
BTRC_EVT_TRACK_REACHED_START = 0x04,
|
||||
BTRC_EVT_PLAY_POS_CHANGED = 0x05,
|
||||
BTRC_EVT_APP_SETTINGS_CHANGED = 0x08,
|
||||
} btrc_event_id_t;
|
||||
|
||||
typedef enum {
|
||||
BTRC_NOTIFICATION_TYPE_INTERIM = 0,
|
||||
BTRC_NOTIFICATION_TYPE_CHANGED = 1,
|
||||
} btrc_notification_type_t;
|
||||
|
||||
typedef enum {
|
||||
BTRC_PLAYER_ATTR_EQUALIZER = 0x01,
|
||||
BTRC_PLAYER_ATTR_REPEAT = 0x02,
|
||||
BTRC_PLAYER_ATTR_SHUFFLE = 0x03,
|
||||
BTRC_PLAYER_ATTR_SCAN = 0x04,
|
||||
} btrc_player_attr_t;
|
||||
|
||||
typedef enum {
|
||||
BTRC_MEDIA_ATTR_TITLE = 0x01,
|
||||
BTRC_MEDIA_ATTR_ARTIST = 0x02,
|
||||
BTRC_MEDIA_ATTR_ALBUM = 0x03,
|
||||
BTRC_MEDIA_ATTR_TRACK_NUM = 0x04,
|
||||
BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05,
|
||||
BTRC_MEDIA_ATTR_GENRE = 0x06,
|
||||
BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07,
|
||||
} btrc_media_attr_t;
|
||||
|
||||
typedef enum {
|
||||
BTRC_PLAYER_VAL_OFF_REPEAT = 0x01,
|
||||
BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02,
|
||||
BTRC_PLAYER_VAL_ALL_REPEAT = 0x03,
|
||||
BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04
|
||||
} btrc_player_repeat_val_t;
|
||||
|
||||
typedef enum {
|
||||
BTRC_PLAYER_VAL_OFF_SHUFFLE = 0x01,
|
||||
BTRC_PLAYER_VAL_ALL_SHUFFLE = 0x02,
|
||||
BTRC_PLAYER_VAL_GROUP_SHUFFLE = 0x03
|
||||
} btrc_player_shuffle_val_t;
|
||||
|
||||
typedef enum {
|
||||
BTRC_STS_BAD_CMD = 0x00, /* Invalid command */
|
||||
BTRC_STS_BAD_PARAM = 0x01, /* Invalid parameter */
|
||||
BTRC_STS_NOT_FOUND = 0x02, /* Specified parameter is wrong or not found */
|
||||
BTRC_STS_INTERNAL_ERR = 0x03, /* Internal Error */
|
||||
BTRC_STS_NO_ERROR = 0x04 /* Operation Success */
|
||||
} btrc_status_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t num_attr;
|
||||
uint8_t attr_ids[BTRC_MAX_APP_SETTINGS];
|
||||
uint8_t attr_values[BTRC_MAX_APP_SETTINGS];
|
||||
} btrc_player_settings_t;
|
||||
|
||||
typedef union {
|
||||
btrc_play_status_t play_status;
|
||||
btrc_uid_t track; /* queue position in NowPlaying */
|
||||
uint32_t song_pos;
|
||||
btrc_player_settings_t player_setting;
|
||||
} btrc_register_notification_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t id; /* can be attr_id or value_id */
|
||||
uint8_t text[BTRC_MAX_ATTR_STR_LEN];
|
||||
} btrc_player_setting_text_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t attr_id;
|
||||
uint8_t text[BTRC_MAX_ATTR_STR_LEN];
|
||||
} btrc_element_attr_val_t;
|
||||
|
||||
/** Callback for the controller's supported feautres */
|
||||
typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr,
|
||||
btrc_remote_features_t features);
|
||||
|
||||
/** Callback for play status request */
|
||||
typedef void (* btrc_get_play_status_callback)();
|
||||
|
||||
/** Callback for list player application attributes (Shuffle, Repeat,...) */
|
||||
typedef void (* btrc_list_player_app_attr_callback)();
|
||||
|
||||
/** Callback for list player application attributes (Shuffle, Repeat,...) */
|
||||
typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id);
|
||||
|
||||
/** Callback for getting the current player application settings value
|
||||
** num_attr: specifies the number of attribute ids contained in p_attrs
|
||||
*/
|
||||
typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
|
||||
|
||||
/** Callback for getting the player application settings attributes' text
|
||||
** num_attr: specifies the number of attribute ids contained in p_attrs
|
||||
*/
|
||||
typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
|
||||
|
||||
/** Callback for getting the player application settings values' text
|
||||
** num_attr: specifies the number of value ids contained in p_vals
|
||||
*/
|
||||
typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, uint8_t num_val, uint8_t *p_vals);
|
||||
|
||||
/** Callback for setting the player application settings values */
|
||||
typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals);
|
||||
|
||||
/** Callback to fetch the get element attributes of the current song
|
||||
** num_attr: specifies the number of attributes requested in p_attrs
|
||||
*/
|
||||
typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs);
|
||||
|
||||
/** Callback for register notification (Play state change/track change/...)
|
||||
** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED
|
||||
*/
|
||||
typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param);
|
||||
|
||||
/* AVRCP 1.4 Enhancements */
|
||||
/** Callback for volume change on CT
|
||||
** volume: Current volume setting on the CT (0-127)
|
||||
*/
|
||||
typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype);
|
||||
|
||||
/** Callback for passthrough commands */
|
||||
typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state);
|
||||
|
||||
/** BT-RC Target callback structure. */
|
||||
typedef struct {
|
||||
/** set to sizeof(BtRcCallbacks) */
|
||||
size_t size;
|
||||
btrc_remote_features_callback remote_features_cb;
|
||||
btrc_get_play_status_callback get_play_status_cb;
|
||||
btrc_list_player_app_attr_callback list_player_app_attr_cb;
|
||||
btrc_list_player_app_values_callback list_player_app_values_cb;
|
||||
btrc_get_player_app_value_callback get_player_app_value_cb;
|
||||
btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb;
|
||||
btrc_get_player_app_values_text_callback get_player_app_values_text_cb;
|
||||
btrc_set_player_app_value_callback set_player_app_value_cb;
|
||||
btrc_get_element_attr_callback get_element_attr_cb;
|
||||
btrc_register_notification_callback register_notification_cb;
|
||||
btrc_volume_change_callback volume_change_cb;
|
||||
btrc_passthrough_cmd_callback passthrough_cmd_cb;
|
||||
} btrc_callbacks_t;
|
||||
|
||||
/** Represents the standard BT-RC AVRCP Target interface. */
|
||||
typedef struct {
|
||||
|
||||
/** set to sizeof(BtRcInterface) */
|
||||
size_t size;
|
||||
/**
|
||||
* Register the BtRc callbacks
|
||||
*/
|
||||
bt_status_t (*init)( btrc_callbacks_t *callbacks );
|
||||
|
||||
/** Respose to GetPlayStatus request. Contains the current
|
||||
** 1. Play status
|
||||
** 2. Song duration/length
|
||||
** 3. Song position
|
||||
*/
|
||||
bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, uint32_t song_pos);
|
||||
|
||||
/** Lists the support player application attributes (Shuffle/Repeat/...)
|
||||
** num_attr: Specifies the number of attributes contained in the pointer p_attrs
|
||||
*/
|
||||
bt_status_t (*list_player_app_attr_rsp)( int num_attr, btrc_player_attr_t *p_attrs);
|
||||
|
||||
/** Lists the support player application attributes (Shuffle Off/On/Group)
|
||||
** num_val: Specifies the number of values contained in the pointer p_vals
|
||||
*/
|
||||
bt_status_t (*list_player_app_value_rsp)( int num_val, uint8_t *p_vals);
|
||||
|
||||
/** Returns the current application attribute values for each of the specified attr_id */
|
||||
bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals);
|
||||
|
||||
/** Returns the application attributes text ("Shuffle"/"Repeat"/...)
|
||||
** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
|
||||
*/
|
||||
bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs);
|
||||
|
||||
/** Returns the application attributes text ("Shuffle"/"Repeat"/...)
|
||||
** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals
|
||||
*/
|
||||
bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals);
|
||||
|
||||
/** Returns the current songs' element attributes text ("Title"/"Album"/"Artist")
|
||||
** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
|
||||
*/
|
||||
bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs);
|
||||
|
||||
/** Response to set player attribute request ("Shuffle"/"Repeat")
|
||||
** rsp_status: Status of setting the player attributes for the current media player
|
||||
*/
|
||||
bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status);
|
||||
|
||||
/* Response to the register notification request (Play state change/track change/...).
|
||||
** event_id: Refers to the event_id this notification change corresponds too
|
||||
** type: Response type - interim/changed
|
||||
** p_params: Based on the event_id, this parameter should be populated
|
||||
*/
|
||||
bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id,
|
||||
btrc_notification_type_t type,
|
||||
btrc_register_notification_t *p_param);
|
||||
|
||||
/* AVRCP 1.4 enhancements */
|
||||
|
||||
/**Send current volume setting to remote side. Support limited to SetAbsoluteVolume
|
||||
** This can be enhanced to support Relative Volume (AVRCP 1.0).
|
||||
** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level
|
||||
** volume: Should be in the range 0-127. bit7 is reseved and cannot be set
|
||||
*/
|
||||
bt_status_t (*set_volume)(uint8_t volume);
|
||||
|
||||
/** Closes the interface. */
|
||||
void (*cleanup)( void );
|
||||
} btrc_interface_t;
|
||||
|
||||
|
||||
typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state);
|
||||
|
||||
typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr);
|
||||
|
||||
/** BT-RC Controller callback structure. */
|
||||
typedef struct {
|
||||
/** set to sizeof(BtRcCallbacks) */
|
||||
size_t size;
|
||||
btrc_passthrough_rsp_callback passthrough_rsp_cb;
|
||||
btrc_connection_state_callback connection_state_cb;
|
||||
} btrc_ctrl_callbacks_t;
|
||||
|
||||
/** Represents the standard BT-RC AVRCP Controller interface. */
|
||||
typedef struct {
|
||||
|
||||
/** set to sizeof(BtRcInterface) */
|
||||
size_t size;
|
||||
/**
|
||||
* Register the BtRc callbacks
|
||||
*/
|
||||
bt_status_t (*init)( btrc_ctrl_callbacks_t *callbacks );
|
||||
|
||||
/** send pass through command to target */
|
||||
bt_status_t (*send_pass_through_cmd) ( bt_bdaddr_t *bd_addr, uint8_t key_code, uint8_t key_state );
|
||||
|
||||
/** Closes the interface. */
|
||||
void (*cleanup)( void );
|
||||
} btrc_ctrl_interface_t;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ANDROID_INCLUDE_BT_RC_H */
|
@ -0,0 +1,116 @@
|
||||
#ifndef __ESP_A2DP_API_H__
|
||||
#define __ESP_A2DP_API_H__
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
/* Codec types */
|
||||
#define ESP_A2DP_CODEC_SBC (0)
|
||||
#define ESP_A2DP_CODEC_M12 (0x01)
|
||||
#define ESP_A2DP_CODEC_M24 (0x02)
|
||||
#define ESP_A2DP_CODEC_ATRAC (0x04)
|
||||
#define ESP_A2DP_CODEC_NON_A2DP (0xff)
|
||||
typedef uint8_t esp_a2dp_codec_type_t;
|
||||
|
||||
/* codec specific information element */
|
||||
typedef struct {
|
||||
uint8_t oct[4];
|
||||
} esp_sbc_cie_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t oct[4];
|
||||
} esp_mpeg12_audio_cie_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t oct[6];
|
||||
} esp_mpeg24_aac_cie_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t oct[7];
|
||||
} esp_atrac_cie_t;
|
||||
|
||||
typedef struct {
|
||||
esp_a2dp_codec_type_t type; /* A2DP codec type*/
|
||||
union {
|
||||
esp_sbc_cie_t sbc;
|
||||
esp_mpeg12_audio_cie_t mpeg12;
|
||||
esp_mpeg24_aac_cie_t mpeg24;
|
||||
esp_atrac_cie_t atrac;
|
||||
} cie;
|
||||
} esp_a2dp_codec_cfg_t;
|
||||
|
||||
/* Bluetooth A2DP connection states */
|
||||
typedef enum {
|
||||
ESP_A2DP_CONNECTION_STATE_DISCONNECTED = 0,
|
||||
ESP_A2DP_CONNECTION_STATE_CONNECTING,
|
||||
ESP_A2DP_CONNECTION_STATE_CONNECTED,
|
||||
ESP_A2DP_CONNECTION_STATE_DISCONNECTING
|
||||
} esp_a2dp_connection_state_t;
|
||||
|
||||
/* Bluetooth A2DP datapath states */
|
||||
typedef enum {
|
||||
ESP_A2DP_AUDIO_STATE_REMOTE_SUSPEND = 0,
|
||||
ESP_A2DP_AUDIO_STATE_STOPPED,
|
||||
ESP_A2DP_AUDIO_STATE_STARTED,
|
||||
} esp_a2dp_audio_state_t;
|
||||
|
||||
/** Callback for connection state change.
|
||||
* state will have one of the values from btav_connection_state_t
|
||||
*/
|
||||
typedef void (* esp_a2dp_connection_state_cb_t)(esp_a2dp_connection_state_t state,
|
||||
esp_bd_addr_t *remote_bda);
|
||||
|
||||
/** Callback for audiopath state change.
|
||||
* state will have one of the values from btav_audio_state_t
|
||||
*/
|
||||
typedef void (* esp_a2dp_audio_state_cb_t)(esp_a2dp_audio_state_t state,
|
||||
esp_bd_addr_t *remote_bda);
|
||||
|
||||
/** Callback for audio configuration change.
|
||||
* Used only for the A2DP sink interface.
|
||||
* state will have one of the values from btav_audio_state_t
|
||||
* sample_rate: sample rate in Hz
|
||||
* channel_count: number of channels (1 for mono, 2 for stereo)
|
||||
*/
|
||||
/*
|
||||
typedef void (* esp_a2dp_audio_config_cb_t)(esp_bd_addr_t *remote_bda,
|
||||
esp_a2dp_codec_cfg_t *cfg);
|
||||
*/
|
||||
typedef void (* esp_a2dp_audio_config_cb_t)(esp_bd_addr_t *remote_bda,
|
||||
uint32_t sample_rate, uint8_t channel_count); // TODO: to be modified
|
||||
|
||||
/** BT-a2dp callback structure. */
|
||||
typedef struct {
|
||||
esp_a2dp_connection_state_cb_t connection_state_cb;
|
||||
esp_a2dp_audio_state_cb_t audio_state_cb;
|
||||
esp_a2dp_audio_config_cb_t audio_config_cb;
|
||||
} esp_a2dp_callbacks_t;
|
||||
|
||||
|
||||
/**
|
||||
* NOTE:
|
||||
* A2DP data path is handled via below function sets, between the Audio HAL
|
||||
* and the Bluetooth stack.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int (* open)(void);
|
||||
void (* close)(void);
|
||||
int (* ioctl)(int cmd, void *param); // not used for now
|
||||
uint32_t (* write)(uint8_t *buf, uint32_t len);
|
||||
} esp_a2dp_sink_audio_hal_t;
|
||||
|
||||
#define ESP_A2DP_AUDIO_HAL_IOC_WRITE_FLUSH (1) // ioctl command, which is not used for now
|
||||
|
||||
|
||||
/** Represents the A2DP sink interface.
|
||||
*/
|
||||
esp_err_t esp_a2dp_sink_init(esp_a2dp_callbacks_t *callbacks);
|
||||
|
||||
esp_err_t esp_a2dp_sink_connect(esp_bd_addr_t *remote_bda);
|
||||
|
||||
esp_err_t esp_a2dp_sink_disconnect(esp_bd_addr_t *remote_bda);
|
||||
|
||||
void esp_a2dp_sink_deinit(void);
|
||||
|
||||
#endif /* __ESP_A2DP_API_H__ */
|
@ -87,13 +87,6 @@ BOOLEAN UIPC_Open(tUIPC_CH_ID ch_id, tUIPC_RCV_CBACK *p_cback)
|
||||
LOG_ERROR("UIPC_Open\n");
|
||||
|
||||
//if (ch_id == UIPC_CH_ID_AV_AUDIO) {
|
||||
int volumn;
|
||||
// TODO: review the stream param config parameter here
|
||||
EspAudioPlayerStreamCfg(StreamSampleRate_44k, StreamChannel_Two, StreamBitLen_16BIT);
|
||||
EspAudio_SetupStream("stream.pcm", InputSrcType_Stream);
|
||||
EspAudio_GetVolume(&volumn);
|
||||
LOG_ERROR("UIPC_Open: Vol: %d\n", volumn);
|
||||
EspAudio_SetVolume(99);
|
||||
// }
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user