Merge "Add a mechanism for configuring the A2DP Source codecs"
This commit is contained in:
commit
2b4315b859
1 changed files with 128 additions and 14 deletions
|
@ -17,6 +17,10 @@
|
|||
#ifndef ANDROID_INCLUDE_BT_AV_H
|
||||
#define ANDROID_INCLUDE_BT_AV_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <hardware/bluetooth.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* Bluetooth AV connection states */
|
||||
|
@ -34,6 +38,76 @@ typedef enum {
|
|||
BTAV_AUDIO_STATE_STARTED,
|
||||
} btav_audio_state_t;
|
||||
|
||||
/*
|
||||
* Enum values for each A2DP supported codec.
|
||||
* There should be a separate entry for each A2DP codec that is supported
|
||||
* for encoding (SRC), and for decoding purpose (SINK).
|
||||
*/
|
||||
typedef enum {
|
||||
BTAV_A2DP_CODEC_INDEX_SOURCE_MIN = 0,
|
||||
BTAV_A2DP_CODEC_INDEX_SOURCE_SBC = 0,
|
||||
|
||||
/* Add an entry for each new source codec here */
|
||||
|
||||
BTAV_A2DP_CODEC_INDEX_SOURCE_MAX,
|
||||
|
||||
BTAV_A2DP_CODEC_INDEX_SINK_MIN = BTAV_A2DP_CODEC_INDEX_SOURCE_MAX,
|
||||
BTAV_A2DP_CODEC_INDEX_SINK_SBC = BTAV_A2DP_CODEC_INDEX_SINK_MIN,
|
||||
|
||||
/* Add an entry for each new sink codec here */
|
||||
|
||||
BTAV_A2DP_CODEC_INDEX_SINK_MAX,
|
||||
|
||||
BTAV_A2DP_CODEC_INDEX_MIN = BTAV_A2DP_CODEC_INDEX_SOURCE_MIN,
|
||||
BTAV_A2DP_CODEC_INDEX_MAX = BTAV_A2DP_CODEC_INDEX_SINK_MAX
|
||||
} btav_a2dp_codec_index_t;
|
||||
|
||||
typedef uint32_t btav_a2dp_codec_priority_t;
|
||||
|
||||
typedef enum {
|
||||
BTAV_A2DP_CODEC_SAMPLE_RATE_NONE = 0x0,
|
||||
BTAV_A2DP_CODEC_SAMPLE_RATE_44100 = 0x1 << 0,
|
||||
BTAV_A2DP_CODEC_SAMPLE_RATE_48000 = 0x1 << 1,
|
||||
BTAV_A2DP_CODEC_SAMPLE_RATE_88200 = 0x1 << 2,
|
||||
BTAV_A2DP_CODEC_SAMPLE_RATE_96000 = 0x1 << 3,
|
||||
BTAV_A2DP_CODEC_SAMPLE_RATE_176400 = 0x1 << 4,
|
||||
BTAV_A2DP_CODEC_SAMPLE_RATE_192000 = 0x1 << 5
|
||||
} btav_a2dp_codec_sample_rate_t;
|
||||
|
||||
typedef enum {
|
||||
BTAV_A2DP_CODEC_BITS_PER_SAMPLE_NONE = 0x0,
|
||||
BTAV_A2DP_CODEC_BITS_PER_SAMPLE_16 = 0x1 << 0,
|
||||
BTAV_A2DP_CODEC_BITS_PER_SAMPLE_24 = 0x1 << 1,
|
||||
BTAV_A2DP_CODEC_BITS_PER_SAMPLE_32 = 0x1 << 2
|
||||
} btav_a2dp_codec_bits_per_sample_t;
|
||||
|
||||
typedef enum {
|
||||
BTAV_A2DP_CODEC_CHANNEL_MODE_NONE = 0x0,
|
||||
BTAV_A2DP_CODEC_CHANNEL_MODE_MONO = 0x1 << 0,
|
||||
BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO = 0x1 << 1
|
||||
} btav_a2dp_codec_channel_mode_t;
|
||||
|
||||
/*
|
||||
* Structure for representing codec capability or configuration.
|
||||
* It is used for configuring A2DP codec preference, and for reporting back
|
||||
* current configuration or codec capability.
|
||||
* For codec capability, fields "sample_rate", "bits_per_sample" and
|
||||
* "channel_mode" can contain bit-masks with all supported features.
|
||||
*/
|
||||
typedef struct {
|
||||
btav_a2dp_codec_index_t codec_type;
|
||||
btav_a2dp_codec_priority_t codec_priority; // Codec selection priority
|
||||
// relative to other codecs: larger value
|
||||
// means higher priority. If 0, reset to
|
||||
// default.
|
||||
btav_a2dp_codec_sample_rate_t sample_rate;
|
||||
btav_a2dp_codec_bits_per_sample_t bits_per_sample;
|
||||
btav_a2dp_codec_channel_mode_t channel_mode;
|
||||
int64_t codec_specific_1; // Codec-specific value 1
|
||||
int64_t codec_specific_2; // Codec-specific value 2
|
||||
int64_t codec_specific_3; // Codec-specific value 3
|
||||
int64_t codec_specific_4; // Codec-specific value 4
|
||||
} btav_a2dp_codec_config_t;
|
||||
|
||||
/** Callback for connection state change.
|
||||
* state will have one of the values from btav_connection_state_t
|
||||
|
@ -48,23 +122,38 @@ 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
|
||||
* Used only for the A2DP Source interface.
|
||||
*/
|
||||
typedef void (* btav_audio_source_config_callback)(
|
||||
btav_a2dp_codec_config_t codec_config,
|
||||
std::vector<btav_a2dp_codec_config_t> codec_capabilities);
|
||||
|
||||
/** Callback for audio configuration change.
|
||||
* Used only for the A2DP Sink interface.
|
||||
* 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);
|
||||
typedef void (* btav_audio_sink_config_callback)(bt_bdaddr_t *bd_addr,
|
||||
uint32_t sample_rate,
|
||||
uint8_t channel_count);
|
||||
|
||||
/** BT-AV callback structure. */
|
||||
/** BT-AV A2DP Source callback structure. */
|
||||
typedef struct {
|
||||
/** set to sizeof(btav_callbacks_t) */
|
||||
/** set to sizeof(btav_source_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;
|
||||
btav_audio_source_config_callback audio_config_cb;
|
||||
} btav_source_callbacks_t;
|
||||
|
||||
/** BT-AV A2DP Source callback structure. */
|
||||
typedef struct {
|
||||
/** set to sizeof(btav_sink_callbacks_t) */
|
||||
size_t size;
|
||||
btav_connection_state_callback connection_state_cb;
|
||||
btav_audio_state_callback audio_state_cb;
|
||||
btav_audio_sink_config_callback audio_config_cb;
|
||||
} btav_sink_callbacks_t;
|
||||
|
||||
/**
|
||||
* NOTE:
|
||||
|
@ -76,17 +165,42 @@ typedef struct {
|
|||
* android_audio_hw library and the Bluetooth stack.
|
||||
*
|
||||
*/
|
||||
/** Represents the standard BT-AV interface.
|
||||
* Used for both the A2DP source and sink interfaces.
|
||||
|
||||
/** Represents the standard BT-AV A2DP Source interface.
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
/** set to sizeof(btav_interface_t) */
|
||||
/** set to sizeof(btav_source_interface_t) */
|
||||
size_t size;
|
||||
/**
|
||||
* Register the BtAv callbacks
|
||||
*/
|
||||
bt_status_t (*init)( btav_callbacks_t* callbacks );
|
||||
bt_status_t (*init)( btav_source_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 );
|
||||
|
||||
/** configure the codecs settings preferences */
|
||||
bt_status_t (*config_codec)(std::vector<btav_a2dp_codec_config_t> codec_preferences);
|
||||
|
||||
/** Closes the interface. */
|
||||
void (*cleanup)( void );
|
||||
|
||||
} btav_source_interface_t;
|
||||
|
||||
/** Represents the standard BT-AV A2DP Sink interface.
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
/** set to sizeof(btav_sink_interface_t) */
|
||||
size_t size;
|
||||
/**
|
||||
* Register the BtAv callbacks
|
||||
*/
|
||||
bt_status_t (*init)( btav_sink_callbacks_t* callbacks );
|
||||
|
||||
/** connect to headset */
|
||||
bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
|
||||
|
@ -102,7 +216,7 @@ typedef struct {
|
|||
|
||||
/** Sets the audio track gain. */
|
||||
void (*set_audio_track_gain)( float gain );
|
||||
} btav_interface_t;
|
||||
} btav_sink_interface_t;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue