2016-12-01 06:57:44 +00:00
|
|
|
#ifndef __ESP_A2DP_API_H__
|
|
|
|
#define __ESP_A2DP_API_H__
|
|
|
|
|
|
|
|
#include "esp_err.h"
|
|
|
|
#include "esp_bt_defs.h"
|
|
|
|
|
2016-12-01 11:48:51 +00:00
|
|
|
/* Media codec types */
|
|
|
|
#define ESP_A2D_MCT_SBC (0)
|
|
|
|
#define ESP_A2D_MCT_M12 (0x01)
|
|
|
|
#define ESP_A2D_MCT_M24 (0x02)
|
|
|
|
#define ESP_A2D_MCT_ATRAC (0x04)
|
|
|
|
#define ESP_A2D_MCT_NON_A2DP (0xff)
|
|
|
|
typedef uint8_t esp_a2d_mct_t;
|
2016-12-01 06:57:44 +00:00
|
|
|
|
|
|
|
/* codec specific information element */
|
2016-12-01 11:48:51 +00:00
|
|
|
#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)
|
|
|
|
|
2016-12-01 06:57:44 +00:00
|
|
|
typedef struct {
|
2016-12-01 11:48:51 +00:00
|
|
|
uint8_t oct[ESP_A2D_CIE_LEN_SBC];
|
|
|
|
} esp_a2d_cie_sbc_t;
|
2016-12-01 06:57:44 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2016-12-01 11:48:51 +00:00
|
|
|
uint8_t oct[ESP_A2D_CIE_LEN_M12];
|
|
|
|
} esp_a2d_cie_m12_t;
|
2016-12-01 06:57:44 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2016-12-01 11:48:51 +00:00
|
|
|
uint8_t oct[ESP_A2D_CIE_LEN_M24];
|
|
|
|
} esp_a2d_cie_m24_t;
|
2016-12-01 06:57:44 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2016-12-01 11:48:51 +00:00
|
|
|
uint8_t oct[ESP_A2D_CIE_LEN_ATRAC];
|
|
|
|
} esp_a2d_cie_atrac_t;
|
2016-12-01 06:57:44 +00:00
|
|
|
|
2016-12-01 11:48:51 +00:00
|
|
|
/* media codec capabilities */
|
2016-12-01 06:57:44 +00:00
|
|
|
typedef struct {
|
2016-12-01 11:48:51 +00:00
|
|
|
esp_a2d_mct_t type; /* A2DP media codec type*/
|
2016-12-01 06:57:44 +00:00
|
|
|
union {
|
2016-12-01 11:48:51 +00:00
|
|
|
esp_a2d_cie_sbc_t sbc;
|
|
|
|
esp_a2d_cie_m12_t m12;
|
|
|
|
esp_a2d_cie_m24_t m24;
|
|
|
|
esp_a2d_cie_atrac_t atrac;
|
2016-12-01 06:57:44 +00:00
|
|
|
} cie;
|
2016-12-01 11:48:51 +00:00
|
|
|
} esp_a2d_mcc_t;
|
2016-12-01 06:57:44 +00:00
|
|
|
|
|
|
|
/* Bluetooth A2DP connection states */
|
|
|
|
typedef enum {
|
2016-12-01 11:48:51 +00:00
|
|
|
ESP_A2D_CONNECTION_STATE_DISCONNECTED = 0,
|
|
|
|
ESP_A2D_CONNECTION_STATE_CONNECTING,
|
|
|
|
ESP_A2D_CONNECTION_STATE_CONNECTED,
|
|
|
|
ESP_A2D_CONNECTION_STATE_DISCONNECTING
|
|
|
|
} esp_a2d_connection_state_t;
|
2016-12-01 06:57:44 +00:00
|
|
|
|
|
|
|
/* Bluetooth A2DP datapath states */
|
|
|
|
typedef enum {
|
2016-12-01 11:48:51 +00:00
|
|
|
ESP_A2D_AUDIO_STATE_REMOTE_SUSPEND = 0,
|
|
|
|
ESP_A2D_AUDIO_STATE_STOPPED,
|
|
|
|
ESP_A2D_AUDIO_STATE_STARTED,
|
|
|
|
} esp_a2d_audio_state_t;
|
2016-12-01 06:57:44 +00:00
|
|
|
|
|
|
|
/** Callback for connection state change.
|
|
|
|
* state will have one of the values from btav_connection_state_t
|
|
|
|
*/
|
2016-12-01 11:48:51 +00:00
|
|
|
typedef void (* esp_a2d_connection_state_cb_t)(esp_a2d_connection_state_t state,
|
2016-12-01 06:57:44 +00:00
|
|
|
esp_bd_addr_t *remote_bda);
|
|
|
|
|
|
|
|
/** Callback for audiopath state change.
|
|
|
|
* state will have one of the values from btav_audio_state_t
|
|
|
|
*/
|
2016-12-01 11:48:51 +00:00
|
|
|
typedef void (* esp_a2d_audio_state_cb_t)(esp_a2d_audio_state_t state,
|
2016-12-01 06:57:44 +00:00
|
|
|
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
|
|
|
|
*/
|
2016-12-01 11:48:51 +00:00
|
|
|
typedef void (* esp_a2d_audio_config_cb_t)(esp_bd_addr_t *remote_bda,
|
|
|
|
esp_a2d_mcc_t *mcc);
|
2016-12-01 06:57:44 +00:00
|
|
|
|
|
|
|
/** BT-a2dp callback structure. */
|
|
|
|
typedef struct {
|
2016-12-01 11:48:51 +00:00
|
|
|
esp_a2d_connection_state_cb_t connection_state_cb;
|
|
|
|
esp_a2d_audio_state_cb_t audio_state_cb;
|
|
|
|
esp_a2d_audio_config_cb_t audio_config_cb;
|
|
|
|
} esp_a2d_callbacks_t;
|
2016-12-01 06:57:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
2016-12-01 11:48:51 +00:00
|
|
|
} esp_a2d_sink_audio_hal_t;
|
2016-12-01 06:57:44 +00:00
|
|
|
|
2016-12-01 11:48:51 +00:00
|
|
|
#define ESP_A2D_AUDIO_HAL_IOC_WRITE_FLUSH (1) // ioctl command, which is not used for now
|
2016-12-01 06:57:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** Represents the A2DP sink interface.
|
|
|
|
*/
|
2016-12-01 11:48:51 +00:00
|
|
|
esp_err_t esp_a2d_sink_init(esp_a2d_callbacks_t *callbacks);
|
2016-12-01 06:57:44 +00:00
|
|
|
|
2016-12-01 11:48:51 +00:00
|
|
|
esp_err_t esp_a2d_sink_connect(esp_bd_addr_t *remote_bda);
|
2016-12-01 06:57:44 +00:00
|
|
|
|
2016-12-01 11:48:51 +00:00
|
|
|
esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t *remote_bda);
|
2016-12-01 06:57:44 +00:00
|
|
|
|
2016-12-01 11:48:51 +00:00
|
|
|
void esp_a2d_sink_deinit(void);
|
2016-12-01 06:57:44 +00:00
|
|
|
|
|
|
|
#endif /* __ESP_A2DP_API_H__ */
|