Commit 310e2877 authored by Igor Kovalenko's avatar Igor Kovalenko Committed by PulseAudio Marge Bot
Browse files

bluetooth: split BT codec from A2DP SEP configuration api

Common API for all bluetooth codecs is now pa_bt_codec.
API to negotiate and configure A2DP SEP over Bluez is now pa_a2dp_endpoint_conf.

Part-of: <!507>
parent c7c9ca22
......@@ -22,6 +22,8 @@
#include <pulsecore/core.h>
#include "bt-codec-api.h"
#define MAX_A2DP_CAPS_SIZE 254
#define DEFAULT_OUTPUT_RATE_REFRESH_INTERVAL_MS 500
......@@ -36,13 +38,7 @@ typedef struct pa_a2dp_codec_id {
uint16_t vendor_codec_id;
} pa_a2dp_codec_id;
typedef struct pa_a2dp_codec {
/* Unique name of the codec, lowercase and without whitespaces, used for
* constructing identifier, D-Bus paths, ... */
const char *name;
/* Human readable codec description */
const char *description;
typedef struct pa_a2dp_endpoint_conf {
/* A2DP codec id */
pa_a2dp_codec_id id;
......@@ -67,44 +63,8 @@ typedef struct pa_a2dp_codec {
/* Fill preferred codec configuration, returns size of filled buffer or 0 on failure */
uint8_t (*fill_preferred_configuration)(const pa_sample_spec *default_sample_spec, const uint8_t *capabilities_buffer, uint8_t capabilities_size, uint8_t config_buffer[MAX_A2DP_CAPS_SIZE]);
/* Initialize codec, returns codec info data and set sample_spec,
* for_encoding is true when codec_info is used for encoding,
* for_backchannel is true when codec_info is used for backchannel */
void *(*init)(bool for_encoding, bool for_backchannel, const uint8_t *config_buffer, uint8_t config_size, pa_sample_spec *sample_spec, pa_core *core);
/* Deinitialize and release codec info data in codec_info */
void (*deinit)(void *codec_info);
/* Reset internal state of codec info data in codec_info, returns
* a negative value on failure */
int (*reset)(void *codec_info);
/* Get read block size for codec, it is minimal size of buffer
* needed to decode read_link_mtu bytes of encoded data */
size_t (*get_read_block_size)(void *codec_info, size_t read_link_mtu);
/* Get write block size for codec, it is maximal size of buffer
* which can produce at most write_link_mtu bytes of encoded data */
size_t (*get_write_block_size)(void *codec_info, size_t write_link_mtu);
/* Get encoded block size for codec to hold one encoded frame.
* Note HFP mSBC codec encoded block may not fit into one MTU and is sent out in chunks. */
size_t (*get_encoded_block_size)(void *codec_info, size_t input_size);
/* Reduce encoder bitrate for codec, returns new write block size or zero
* if not changed, called when socket is not accepting encoded data fast
* enough */
size_t (*reduce_encoder_bitrate)(void *codec_info, size_t write_link_mtu);
/* Increase encoder bitrate for codec, returns new write block size or zero
* if not changed, called periodically when socket is keeping up with
* encoded data */
size_t (*increase_encoder_bitrate)(void *codec_info, size_t write_link_mtu);
/* Encode input_buffer of input_size to output_buffer of output_size,
* returns size of filled ouput_buffer and set processed to size of
* processed input_buffer */
size_t (*encode_buffer)(void *codec_info, uint32_t timestamp, const uint8_t *input_buffer, size_t input_size, uint8_t *output_buffer, size_t output_size, size_t *processed);
/* Decode input_buffer of input_size to output_buffer of output_size,
* returns size of filled ouput_buffer and set processed to size of
* processed input_buffer */
size_t (*decode_buffer)(void *codec_info, const uint8_t *input_buffer, size_t input_size, uint8_t *output_buffer, size_t output_size, size_t *processed);
} pa_a2dp_codec;
/* Bluetooth codec */
pa_bt_codec bt_codec;
} pa_a2dp_endpoint_conf;
#endif
......@@ -554,9 +554,7 @@ static size_t decode_buffer_hd(void *codec_info, const uint8_t *input_buffer, si
return written;
}
const pa_a2dp_codec pa_a2dp_codec_aptx = {
.name = "aptx",
.description = "aptX",
const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_aptx = {
.id = { A2DP_CODEC_VENDOR, APTX_VENDOR_ID, APTX_CODEC_ID },
.support_backchannel = false,
.can_be_supported = can_be_supported,
......@@ -565,20 +563,22 @@ const pa_a2dp_codec pa_a2dp_codec_aptx = {
.fill_capabilities = fill_capabilities,
.is_configuration_valid = is_configuration_valid,
.fill_preferred_configuration = fill_preferred_configuration,
.init = init,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.encode_buffer = encode_buffer,
.decode_buffer = decode_buffer,
.bt_codec = {
.name = "aptx",
.description = "aptX",
.init = init,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.encode_buffer = encode_buffer,
.decode_buffer = decode_buffer,
},
};
const pa_a2dp_codec pa_a2dp_codec_aptx_hd = {
.name = "aptx_hd",
.description = "aptX HD",
const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_aptx_hd = {
.id = { A2DP_CODEC_VENDOR, APTX_HD_VENDOR_ID, APTX_HD_CODEC_ID },
.support_backchannel = false,
.can_be_supported = can_be_supported,
......@@ -587,13 +587,17 @@ const pa_a2dp_codec pa_a2dp_codec_aptx_hd = {
.fill_capabilities = fill_capabilities_hd,
.is_configuration_valid = is_configuration_valid_hd,
.fill_preferred_configuration = fill_preferred_configuration_hd,
.init = init_hd,
.deinit = deinit,
.reset = reset_hd,
.get_read_block_size = get_block_size_hd,
.get_write_block_size = get_block_size_hd,
.get_encoded_block_size = get_encoded_block_size_hd,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.encode_buffer = encode_buffer_hd,
.decode_buffer = decode_buffer_hd,
.bt_codec = {
.name = "aptx_hd",
.description = "aptX HD",
.init = init_hd,
.deinit = deinit,
.reset = reset_hd,
.get_read_block_size = get_block_size_hd,
.get_write_block_size = get_block_size_hd,
.get_encoded_block_size = get_encoded_block_size_hd,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.encode_buffer = encode_buffer_hd,
.decode_buffer = decode_buffer_hd,
},
};
......@@ -424,9 +424,7 @@ static size_t encode_buffer(void *codec_info, uint32_t timestamp, const uint8_t
return written;
}
const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_hq = {
.name = "ldac_hq",
.description = "LDAC (High Quality)",
const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_ldac_eqmid_hq = {
.id = { A2DP_CODEC_VENDOR, LDAC_VENDOR_ID, LDAC_CODEC_ID },
.support_backchannel = false,
.can_be_supported = can_be_supported,
......@@ -435,19 +433,21 @@ const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_hq = {
.fill_capabilities = fill_capabilities,
.is_configuration_valid = is_configuration_valid,
.fill_preferred_configuration = fill_preferred_configuration,
.init = init_hq,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.encode_buffer = encode_buffer,
.bt_codec = {
.name = "ldac_hq",
.description = "LDAC (High Quality)",
.init = init_hq,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.encode_buffer = encode_buffer,
},
};
const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_sq = {
.name = "ldac_sq",
.description = "LDAC (Standard Quality)",
const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_ldac_eqmid_sq = {
.id = { A2DP_CODEC_VENDOR, LDAC_VENDOR_ID, LDAC_CODEC_ID },
.support_backchannel = false,
.can_be_supported = can_be_supported,
......@@ -456,19 +456,21 @@ const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_sq = {
.fill_capabilities = fill_capabilities,
.is_configuration_valid = is_configuration_valid,
.fill_preferred_configuration = fill_preferred_configuration,
.init = init_sq,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.encode_buffer = encode_buffer,
.bt_codec = {
.name = "ldac_sq",
.description = "LDAC (Standard Quality)",
.init = init_sq,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.encode_buffer = encode_buffer,
},
};
const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_mq = {
.name = "ldac_mq",
.description = "LDAC (Mobile Quality)",
const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_ldac_eqmid_mq = {
.id = { A2DP_CODEC_VENDOR, LDAC_VENDOR_ID, LDAC_CODEC_ID },
.support_backchannel = false,
.can_be_supported = can_be_supported,
......@@ -477,12 +479,16 @@ const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_mq = {
.fill_capabilities = fill_capabilities,
.is_configuration_valid = is_configuration_valid,
.fill_preferred_configuration = fill_preferred_configuration,
.init = init_mq,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.encode_buffer = encode_buffer,
.bt_codec = {
.name = "ldac_mq",
.description = "LDAC (Mobile Quality)",
.init = init_mq,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.encode_buffer = encode_buffer,
},
};
......@@ -896,9 +896,7 @@ static size_t decode_buffer(void *codec_info, const uint8_t *input_buffer, size_
return d - output_buffer;
}
const pa_a2dp_codec pa_a2dp_codec_sbc = {
.name = "sbc",
.description = "SBC",
const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc = {
.id = { A2DP_CODEC_SBC, 0, 0 },
.support_backchannel = false,
.can_be_supported = can_be_supported,
......@@ -907,16 +905,20 @@ const pa_a2dp_codec pa_a2dp_codec_sbc = {
.fill_capabilities = fill_capabilities,
.is_configuration_valid = is_configuration_valid,
.fill_preferred_configuration = fill_preferred_configuration,
.init = init,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.increase_encoder_bitrate = increase_encoder_bitrate,
.encode_buffer = encode_buffer,
.decode_buffer = decode_buffer,
.bt_codec = {
.name = "sbc",
.description = "SBC",
.init = init,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.increase_encoder_bitrate = increase_encoder_bitrate,
.encode_buffer = encode_buffer,
.decode_buffer = decode_buffer,
},
};
/* There are multiple definitions of SBC XQ, but in all cases this is
......@@ -932,9 +934,7 @@ const pa_a2dp_codec pa_a2dp_codec_sbc = {
* we can gain from increased bitrate.
*/
const pa_a2dp_codec pa_a2dp_codec_sbc_xq_453 = {
.name = "sbc_xq_453",
.description = "SBC XQ 453kbps",
const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc_xq_453 = {
.id = { A2DP_CODEC_SBC, 0, 0 },
.support_backchannel = false,
.can_be_supported = can_be_supported,
......@@ -943,21 +943,23 @@ const pa_a2dp_codec pa_a2dp_codec_sbc_xq_453 = {
.fill_capabilities = fill_capabilities_xq,
.is_configuration_valid = is_configuration_valid,
.fill_preferred_configuration = fill_preferred_configuration_xq_453kbps,
.init = init,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.increase_encoder_bitrate = increase_encoder_bitrate,
.encode_buffer = encode_buffer,
.decode_buffer = decode_buffer,
.bt_codec = {
.name = "sbc_xq_453",
.description = "SBC XQ 453kbps",
.init = init,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.increase_encoder_bitrate = increase_encoder_bitrate,
.encode_buffer = encode_buffer,
.decode_buffer = decode_buffer,
},
};
const pa_a2dp_codec pa_a2dp_codec_sbc_xq_512 = {
.name = "sbc_xq_512",
.description = "SBC XQ 512kbps",
const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc_xq_512 = {
.id = { A2DP_CODEC_SBC, 0, 0 },
.support_backchannel = false,
.can_be_supported = can_be_supported,
......@@ -966,21 +968,23 @@ const pa_a2dp_codec pa_a2dp_codec_sbc_xq_512 = {
.fill_capabilities = fill_capabilities_xq,
.is_configuration_valid = is_configuration_valid,
.fill_preferred_configuration = fill_preferred_configuration_xq_512kbps,
.init = init,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.increase_encoder_bitrate = increase_encoder_bitrate,
.encode_buffer = encode_buffer,
.decode_buffer = decode_buffer,
.bt_codec = {
.name = "sbc_xq_512",
.description = "SBC XQ 512kbps",
.init = init,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.increase_encoder_bitrate = increase_encoder_bitrate,
.encode_buffer = encode_buffer,
.decode_buffer = decode_buffer,
},
};
const pa_a2dp_codec pa_a2dp_codec_sbc_xq_552 = {
.name = "sbc_xq_552",
.description = "SBC XQ 552kbps",
const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc_xq_552 = {
.id = { A2DP_CODEC_SBC, 0, 0 },
.support_backchannel = false,
.can_be_supported = can_be_supported,
......@@ -989,14 +993,18 @@ const pa_a2dp_codec pa_a2dp_codec_sbc_xq_552 = {
.fill_capabilities = fill_capabilities_xq,
.is_configuration_valid = is_configuration_valid,
.fill_preferred_configuration = fill_preferred_configuration_xq_552kbps,
.init = init,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.increase_encoder_bitrate = increase_encoder_bitrate,
.encode_buffer = encode_buffer,
.decode_buffer = decode_buffer,
.bt_codec = {
.name = "sbc_xq_552",
.description = "SBC XQ 552kbps",
.init = init,
.deinit = deinit,
.reset = reset,
.get_read_block_size = get_block_size,
.get_write_block_size = get_block_size,
.get_encoded_block_size = get_encoded_block_size,
.reduce_encoder_bitrate = reduce_encoder_bitrate,
.increase_encoder_bitrate = increase_encoder_bitrate,
.encode_buffer = encode_buffer,
.decode_buffer = decode_buffer,
},
};
......@@ -29,67 +29,67 @@
#include "a2dp-codec-util.h"
extern const pa_a2dp_codec pa_bt_codec_msbc;
extern const pa_a2dp_codec pa_bt_codec_cvsd;
extern const pa_bt_codec pa_bt_codec_msbc;
extern const pa_bt_codec pa_bt_codec_cvsd;
/* List of HSP/HFP codecs.
*/
static const pa_a2dp_codec *pa_hf_codecs[] = {
static const pa_bt_codec *pa_hf_codecs[] = {
&pa_bt_codec_cvsd,
&pa_bt_codec_msbc,
};
extern const pa_a2dp_codec pa_a2dp_codec_sbc;
extern const pa_a2dp_codec pa_a2dp_codec_sbc_xq_453;
extern const pa_a2dp_codec pa_a2dp_codec_sbc_xq_512;
extern const pa_a2dp_codec pa_a2dp_codec_sbc_xq_552;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc_xq_453;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc_xq_512;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc_xq_552;
#ifdef HAVE_GSTAPTX
extern const pa_a2dp_codec pa_a2dp_codec_aptx;
extern const pa_a2dp_codec pa_a2dp_codec_aptx_hd;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_aptx;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_aptx_hd;
#endif
#ifdef HAVE_GSTLDAC
extern const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_hq;
extern const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_sq;
extern const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_mq;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_ldac_eqmid_hq;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_ldac_eqmid_sq;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_ldac_eqmid_mq;
#endif
/* This is list of supported codecs. Their order is important.
* Codec with lower index has higher priority. */
static const pa_a2dp_codec *pa_a2dp_codecs[] = {
static const pa_a2dp_endpoint_conf *pa_a2dp_endpoint_configurations[] = {
#ifdef HAVE_GSTLDAC
&pa_a2dp_codec_ldac_eqmid_hq,
&pa_a2dp_codec_ldac_eqmid_sq,
&pa_a2dp_codec_ldac_eqmid_mq,
&pa_a2dp_endpoint_conf_ldac_eqmid_hq,
&pa_a2dp_endpoint_conf_ldac_eqmid_sq,
&pa_a2dp_endpoint_conf_ldac_eqmid_mq,
#endif
#ifdef HAVE_GSTAPTX
&pa_a2dp_codec_aptx_hd,
&pa_a2dp_codec_aptx,
&pa_a2dp_endpoint_conf_aptx_hd,
&pa_a2dp_endpoint_conf_aptx,
#endif
&pa_a2dp_codec_sbc,
&pa_a2dp_codec_sbc_xq_453,
&pa_a2dp_codec_sbc_xq_512,
&pa_a2dp_codec_sbc_xq_552,
&pa_a2dp_endpoint_conf_sbc,
&pa_a2dp_endpoint_conf_sbc_xq_453,
&pa_a2dp_endpoint_conf_sbc_xq_512,
&pa_a2dp_endpoint_conf_sbc_xq_552,
};
unsigned int pa_bluetooth_a2dp_codec_count(void) {
return PA_ELEMENTSOF(pa_a2dp_codecs);
unsigned int pa_bluetooth_a2dp_endpoint_conf_count(void) {
return PA_ELEMENTSOF(pa_a2dp_endpoint_configurations);
}
const pa_a2dp_codec *pa_bluetooth_a2dp_codec_iter(unsigned int i) {
pa_assert(i < pa_bluetooth_a2dp_codec_count());
return pa_a2dp_codecs[i];
const pa_a2dp_endpoint_conf *pa_bluetooth_a2dp_endpoint_conf_iter(unsigned int i) {
pa_assert(i < pa_bluetooth_a2dp_endpoint_conf_count());
return pa_a2dp_endpoint_configurations[i];
}
unsigned int pa_bluetooth_hf_codec_count(void) {
return PA_ELEMENTSOF(pa_hf_codecs);
}
const pa_a2dp_codec *pa_bluetooth_hf_codec_iter(unsigned int i) {
const pa_bt_codec *pa_bluetooth_hf_codec_iter(unsigned int i) {
pa_assert(i < pa_bluetooth_hf_codec_count());
return pa_hf_codecs[i];
}
const pa_a2dp_codec *pa_bluetooth_get_hf_codec(const char *name) {
const pa_bt_codec *pa_bluetooth_get_hf_codec(const char *name) {
unsigned int i;
for (i = 0; i < PA_ELEMENTSOF(pa_hf_codecs); ++i) {
......@@ -100,13 +100,13 @@ const pa_a2dp_codec *pa_bluetooth_get_hf_codec(const char *name) {
return NULL;
}
const pa_a2dp_codec *pa_bluetooth_get_a2dp_codec(const char *name) {
const pa_a2dp_endpoint_conf *pa_bluetooth_get_a2dp_endpoint_conf(const char *name) {
unsigned int i;
unsigned int count = pa_bluetooth_a2dp_codec_count();
unsigned int count = pa_bluetooth_a2dp_endpoint_conf_count();
for (i = 0; i < count; i++) {
if (pa_streq(pa_a2dp_codecs[i]->name, name))
return pa_a2dp_codecs[i];
if (pa_streq(pa_a2dp_endpoint_configurations[i]->bt_codec.name, name))
return pa_a2dp_endpoint_configurations[i];
}
return NULL;
......@@ -127,13 +127,13 @@ void pa_bluetooth_a2dp_codec_gst_init(void) {
bool pa_bluetooth_a2dp_codec_is_available(const pa_a2dp_codec_id *id, bool is_a2dp_sink) {
unsigned int i;
unsigned int count = pa_bluetooth_a2dp_codec_count();
const pa_a2dp_codec *a2dp_codec;
unsigned int count = pa_bluetooth_a2dp_endpoint_conf_count();
const pa_a2dp_endpoint_conf *conf;
for (i = 0; i < count; i++) {
a2dp_codec = pa_bluetooth_a2dp_codec_iter(i);
if (memcmp(id, &a2dp_codec->id, sizeof(pa_a2dp_codec_id)) == 0
&& a2dp_codec->can_be_supported(is_a2dp_sink))
conf = pa_bluetooth_a2dp_endpoint_conf_iter(i);
if (memcmp(id, &conf->id, sizeof(pa_a2dp_codec_id)) == 0
&& conf->can_be_supported(is_a2dp_sink))
return true;
}
......
......@@ -23,13 +23,13 @@
#include "a2dp-codec-api.h"
/* Get number of supported A2DP codecs */
unsigned int pa_bluetooth_a2dp_codec_count(void);
unsigned int pa_bluetooth_a2dp_endpoint_conf_count(void);
/* Get i-th codec. Codec with higher number has higher priority */
const pa_a2dp_codec *pa_bluetooth_a2dp_codec_iter(unsigned int i);
const pa_a2dp_endpoint_conf *pa_bluetooth_a2dp_endpoint_conf_iter(unsigned int i);
/* Get codec by name */
const pa_a2dp_codec *pa_bluetooth_get_a2dp_codec(const char *name);
const pa_a2dp_endpoint_conf *pa_bluetooth_get_a2dp_endpoint_conf(const char *name);
/* Check if the given codec can be supported in A2DP_SINK or A2DP_SOURCE */
bool pa_bluetooth_a2dp_codec_is_available(const pa_a2dp_codec_id *id, bool is_a2dp_sink);
......@@ -41,9 +41,9 @@ void pa_bluetooth_a2dp_codec_gst_init(void);
unsigned int pa_bluetooth_hf_codec_count(void);
/* Get i-th codec. Codec with higher number has higher priority */
const pa_a2dp_codec *pa_bluetooth_hf_codec_iter(unsigned int i);
const pa_bt_codec *pa_bluetooth_hf_codec_iter(unsigned int i);
/* Get HSP/HFP codec by name */
const pa_a2dp_codec *pa_bluetooth_get_hf_codec(const char *name);
const pa_bt_codec *pa_bluetooth_get_hf_codec(const char *name);
#endif
......@@ -184,7 +184,7 @@ pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const
return t;
}
void pa_bluetooth_transport_reconfigure(pa_bluetooth_transport *t, const pa_a2dp_codec *bt_codec,
void pa_bluetooth_transport_reconfigure(pa_bluetooth_transport *t, const pa_bt_codec *bt_codec,
pa_bluetooth_transport_write_cb write_cb, pa_bluetooth_transport_setsockopt_cb setsockopt_cb) {
pa_assert(t);
......@@ -365,7 +365,7 @@ static void pa_bluetooth_device_switch_codec_reply(DBusPendingCall *pending, voi
}
bool pa_bluetooth_device_switch_codec(pa_bluetooth_device *device, pa_bluetooth_profile_t profile,
pa_hashmap *capabilities_hashmap, const pa_a2dp_codec *a2dp_codec,
pa_hashmap *capabilities_hashmap, const pa_a2dp_endpoint_conf *endpoint_conf,
void (*codec_switch_cb)(bool, pa_bluetooth_profile_t profile, void *), void *userdata) {
DBusMessageIter iter, dict;
DBusMessage *m;
......@@ -380,7 +380,7 @@ bool pa_bluetooth_device_switch_codec(pa_bluetooth_device *device, pa_bluetooth_
pa_assert(device);
pa_assert(capabilities_hashmap);
pa_assert(a2dp_codec);
pa_assert(endpoint_conf);
if (device->codec_switching_in_progress) {
pa_log_error("Codec switching operation already in progress");
......@@ -391,19 +391,19 @@ bool pa_bluetooth_device_switch_codec(pa_bluetooth_device *device, pa_bluetooth_
all_endpoints = NULL;
all_endpoints = pa_hashmap_get(is_a2dp_sink ? device->a2dp_sink_endpoints : device->a2dp_source_endpoints,
&a2dp_codec->id);
&endpoint_conf->id);
pa_assert(all_endpoints);
pa_assert_se(endpoint = a2dp_codec->choose_remote_endpoint(capabilities_hashmap, &device->discovery->core->default_sample_spec, is_a2dp_sink));
pa_assert_se(endpoint = endpoint_conf->choose_remote_endpoint(capabilities_hashmap, &device->discovery->core->default_sample_spec, is_a2dp_sink));
pa_assert_se(capabilities = pa_hashmap_get(all_endpoints, endpoint));
config_size = a2dp_codec->fill_preferred_configuration(&device->discovery->core->default_sample_spec,