Bluetooth: Audio: Rename bt_codec to bt_audio_codec_{cap, conf, data}
Rename the bt_codec struct to bt_audio_codec_conf or to the new struct bt_audio_codec_cap. Rename the bt_codec_data to bt_audio_codec_data. The purpose of this is to split the codec specific configuration and codec capabilities into seperate structs, as they do not reflect the same values, or used for the same purpose. This commit depends on the preset macros workings on either type of struct (for now), but will be modified in future updates. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
33b116407b
commit
69f7fd9cb2
58 changed files with 1861 additions and 1668 deletions
|
@ -45,8 +45,8 @@ static struct bt_bap_stream *streams_p[ARRAY_SIZE(streams)];
|
|||
static struct bt_conn *broadcast_assistant_conn;
|
||||
static struct bt_le_ext_adv *ext_adv;
|
||||
|
||||
static struct bt_codec codec = BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED);
|
||||
static struct bt_audio_codec_cap codec_cap = BT_AUDIO_CODEC_LC3_CONFIG_16_2(
|
||||
BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED);
|
||||
|
||||
/* Create a mask for the maximum BIS we can sync to using the number of streams
|
||||
* we have. We add an additional 1 since the bis indexes start from 1 and not
|
||||
|
@ -416,7 +416,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
|
|||
};
|
||||
|
||||
static struct bt_pacs_cap cap = {
|
||||
.codec = &codec,
|
||||
.codec_cap = &codec_cap,
|
||||
};
|
||||
|
||||
static int init(void)
|
||||
|
|
|
@ -102,7 +102,7 @@ static int setup_broadcast_source(struct bt_bap_broadcast_source **source)
|
|||
for (size_t i = 0U; i < ARRAY_SIZE(subgroup_param); i++) {
|
||||
subgroup_param[i].params_count = streams_per_subgroup;
|
||||
subgroup_param[i].params = stream_params + i * streams_per_subgroup;
|
||||
subgroup_param[i].codec = &preset_16_2_1.codec;
|
||||
subgroup_param[i].codec_cfg = &preset_16_2_1.codec_cfg;
|
||||
}
|
||||
|
||||
for (size_t j = 0U; j < ARRAY_SIZE(stream_params); j++) {
|
||||
|
|
|
@ -21,11 +21,10 @@ NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_ASCS_ASE_SRC_COUNT,
|
|||
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU),
|
||||
CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL);
|
||||
|
||||
static struct bt_codec lc3_codec =
|
||||
BT_CODEC_LC3(BT_CODEC_LC3_FREQ_16KHZ | BT_CODEC_LC3_FREQ_24KHZ,
|
||||
BT_CODEC_LC3_DURATION_10,
|
||||
BT_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 60u, 1u,
|
||||
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
|
||||
static struct bt_audio_codec_cap lc3_codec_cap = BT_AUDIO_CODEC_LC3(
|
||||
BT_AUDIO_CODEC_LC3_FREQ_16KHZ | BT_AUDIO_CODEC_LC3_FREQ_24KHZ,
|
||||
BT_AUDIO_CODEC_LC3_DURATION_10, BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 60u, 1u,
|
||||
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
|
||||
|
||||
static struct bt_conn *default_conn;
|
||||
static struct k_work_delayable audio_send_work;
|
||||
|
@ -36,8 +35,8 @@ static struct audio_source {
|
|||
} source_streams[CONFIG_BT_ASCS_ASE_SRC_COUNT];
|
||||
static size_t configured_source_stream_count;
|
||||
|
||||
static const struct bt_codec_qos_pref qos_pref = BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02,
|
||||
10, 20000, 40000, 20000, 40000);
|
||||
static const struct bt_audio_codec_qos_pref qos_pref =
|
||||
BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 20000, 40000, 20000, 40000);
|
||||
|
||||
static uint16_t get_and_incr_seq_num(const struct bt_bap_stream *stream)
|
||||
{
|
||||
|
@ -59,50 +58,47 @@ static void print_hex(const uint8_t *ptr, size_t len)
|
|||
}
|
||||
}
|
||||
|
||||
static void print_codec(const struct bt_codec *codec)
|
||||
static void print_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg)
|
||||
{
|
||||
printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n",
|
||||
codec->id, codec->cid, codec->vid, codec->data_count);
|
||||
printk("codec_cfg 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cfg->id, codec_cfg->cid,
|
||||
codec_cfg->vid, codec_cfg->data_count);
|
||||
|
||||
for (size_t i = 0; i < codec->data_count; i++) {
|
||||
printk("data #%zu: type 0x%02x len %u\n",
|
||||
i, codec->data[i].data.type,
|
||||
codec->data[i].data.data_len);
|
||||
print_hex(codec->data[i].data.data,
|
||||
codec->data[i].data.data_len -
|
||||
sizeof(codec->data[i].data.type));
|
||||
for (size_t i = 0; i < codec_cfg->data_count; i++) {
|
||||
printk("data #%zu: type 0x%02x len %u\n", i, codec_cfg->data[i].data.type,
|
||||
codec_cfg->data[i].data.data_len);
|
||||
print_hex(codec_cfg->data[i].data.data,
|
||||
codec_cfg->data[i].data.data_len - sizeof(codec_cfg->data[i].data.type));
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
if (codec->id == BT_CODEC_LC3_ID) {
|
||||
if (codec_cfg->id == BT_AUDIO_CODEC_LC3_ID) {
|
||||
/* LC3 uses the generic LTV format - other codecs might do as well */
|
||||
|
||||
enum bt_audio_location chan_allocation;
|
||||
|
||||
printk(" Frequency: %d Hz\n", bt_codec_cfg_get_freq(codec));
|
||||
printk(" Frame Duration: %d us\n", bt_codec_cfg_get_frame_duration_us(codec));
|
||||
if (bt_codec_cfg_get_chan_allocation_val(codec, &chan_allocation) == 0) {
|
||||
printk(" Frequency: %d Hz\n", bt_audio_codec_cfg_get_freq(codec_cfg));
|
||||
printk(" Frame Duration: %d us\n",
|
||||
bt_audio_codec_cfg_get_frame_duration_us(codec_cfg));
|
||||
if (bt_audio_codec_cfg_get_chan_allocation_val(codec_cfg, &chan_allocation) == 0) {
|
||||
printk(" Channel allocation: 0x%x\n", chan_allocation);
|
||||
}
|
||||
|
||||
printk(" Octets per frame: %d (negative means value not pressent)\n",
|
||||
bt_codec_cfg_get_octets_per_frame(codec));
|
||||
bt_audio_codec_cfg_get_octets_per_frame(codec_cfg));
|
||||
printk(" Frames per SDU: %d\n",
|
||||
bt_codec_cfg_get_frame_blocks_per_sdu(codec, true));
|
||||
bt_audio_codec_cfg_get_frame_blocks_per_sdu(codec_cfg, true));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < codec->meta_count; i++) {
|
||||
printk("meta #%zu: type 0x%02x len %u\n",
|
||||
i, codec->meta[i].data.type,
|
||||
codec->meta[i].data.data_len);
|
||||
print_hex(codec->meta[i].data.data,
|
||||
codec->meta[i].data.data_len -
|
||||
sizeof(codec->meta[i].data.type));
|
||||
for (size_t i = 0; i < codec_cfg->meta_count; i++) {
|
||||
printk("meta #%zu: type 0x%02x len %u\n", i, codec_cfg->meta[i].data.type,
|
||||
codec_cfg->meta[i].data.data_len);
|
||||
print_hex(codec_cfg->meta[i].data.data,
|
||||
codec_cfg->meta[i].data.data_len - sizeof(codec_cfg->meta[i].data.type));
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void print_qos(const struct bt_codec_qos *qos)
|
||||
static void print_qos(const struct bt_audio_codec_qos *qos)
|
||||
{
|
||||
printk("QoS: interval %u framing 0x%02x phy 0x%02x sdu %u "
|
||||
"rtn %u latency %u pd %u\n",
|
||||
|
@ -188,12 +184,12 @@ static struct bt_bap_stream *stream_alloc(void)
|
|||
}
|
||||
|
||||
static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir,
|
||||
const struct bt_codec *codec, struct bt_bap_stream **stream,
|
||||
struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp)
|
||||
const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream,
|
||||
struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("ASE Codec Config: conn %p ep %p dir %u\n", conn, ep, dir);
|
||||
|
||||
print_codec(codec);
|
||||
print_codec_cfg(codec_cfg);
|
||||
|
||||
*stream = stream_alloc();
|
||||
if (*stream == NULL) {
|
||||
|
@ -214,12 +210,12 @@ static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_
|
|||
}
|
||||
|
||||
static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir,
|
||||
const struct bt_codec *codec, struct bt_codec_qos_pref *const pref,
|
||||
struct bt_bap_ascs_rsp *rsp)
|
||||
const struct bt_audio_codec_cfg *codec_cfg,
|
||||
struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("ASE Codec Reconfig: stream %p\n", stream);
|
||||
|
||||
print_codec(codec);
|
||||
print_codec_cfg(codec_cfg);
|
||||
|
||||
*rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED, BT_BAP_ASCS_REASON_NONE);
|
||||
|
||||
|
@ -227,7 +223,7 @@ static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos,
|
||||
static int lc3_qos(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos,
|
||||
struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("QoS: stream %p qos %p\n", stream, qos);
|
||||
|
@ -237,7 +233,7 @@ static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lc3_enable(struct bt_bap_stream *stream, const struct bt_codec_data *meta,
|
||||
static int lc3_enable(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta,
|
||||
size_t meta_count, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("Enable: stream %p meta_count %u\n", stream, meta_count);
|
||||
|
@ -307,13 +303,13 @@ static bool valid_metadata_type(uint8_t type, uint8_t len)
|
|||
}
|
||||
}
|
||||
|
||||
static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_codec_data *meta,
|
||||
static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta,
|
||||
size_t meta_count, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("Metadata: stream %p meta_count %u\n", stream, meta_count);
|
||||
|
||||
for (size_t i = 0; i < meta_count; i++) {
|
||||
const struct bt_codec_data *data = &meta[i];
|
||||
const struct bt_audio_codec_data *data = &meta[i];
|
||||
|
||||
if (!valid_metadata_type(data->data.type, data->data.data_len)) {
|
||||
printk("Invalid metadata type %u or length %u\n",
|
||||
|
@ -417,11 +413,11 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
|
|||
};
|
||||
|
||||
static struct bt_pacs_cap cap_sink = {
|
||||
.codec = &lc3_codec,
|
||||
.codec_cap = &lc3_codec_cap,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_source = {
|
||||
.codec = &lc3_codec,
|
||||
.codec_cap = &lc3_codec_cap,
|
||||
};
|
||||
|
||||
int bap_unicast_sr_init(void)
|
||||
|
|
|
@ -33,7 +33,7 @@ static K_SEM_DEFINE(sem_discover_source, 0, 1);
|
|||
static K_SEM_DEFINE(sem_audio_start, 0, 1);
|
||||
|
||||
static void unicast_stream_configured(struct bt_bap_stream *stream,
|
||||
const struct bt_codec_qos_pref *pref)
|
||||
const struct bt_audio_codec_qos_pref *pref)
|
||||
{
|
||||
printk("Configured stream %p\n", stream);
|
||||
|
||||
|
@ -180,36 +180,32 @@ static void print_hex(const uint8_t *ptr, size_t len)
|
|||
}
|
||||
}
|
||||
|
||||
static void print_codec_capabilities(const struct bt_codec *codec)
|
||||
static void print_codec_capabilities(const struct bt_audio_codec_cap *codec_cap)
|
||||
{
|
||||
printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n",
|
||||
codec->id, codec->cid, codec->vid, codec->data_count);
|
||||
printk("codec_cap 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cap->id, codec_cap->cid,
|
||||
codec_cap->vid, codec_cap->data_count);
|
||||
|
||||
for (size_t i = 0; i < codec->data_count; i++) {
|
||||
printk("data #%zu: type 0x%02x len %u\n",
|
||||
i, codec->data[i].data.type,
|
||||
codec->data[i].data.data_len);
|
||||
print_hex(codec->data[i].data.data,
|
||||
codec->data[i].data.data_len -
|
||||
sizeof(codec->data[i].data.type));
|
||||
for (size_t i = 0; i < codec_cap->data_count; i++) {
|
||||
printk("data #%zu: type 0x%02x len %u\n", i, codec_cap->data[i].data.type,
|
||||
codec_cap->data[i].data.data_len);
|
||||
print_hex(codec_cap->data[i].data.data,
|
||||
codec_cap->data[i].data.data_len - sizeof(codec_cap->data[i].data.type));
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < codec->meta_count; i++) {
|
||||
printk("meta #%zu: type 0x%02x len %u\n",
|
||||
i, codec->meta[i].data.type,
|
||||
codec->meta[i].data.data_len);
|
||||
print_hex(codec->meta[i].data.data,
|
||||
codec->meta[i].data.data_len -
|
||||
sizeof(codec->meta[i].data.type));
|
||||
for (size_t i = 0; i < codec_cap->meta_count; i++) {
|
||||
printk("meta #%zu: type 0x%02x len %u\n", i, codec_cap->meta[i].data.type,
|
||||
codec_cap->meta[i].data.data_len);
|
||||
print_hex(codec_cap->meta[i].data.data,
|
||||
codec_cap->meta[i].data.data_len - sizeof(codec_cap->meta[i].data.type));
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void print_remote_codec(const struct bt_codec *codec_capabilities, enum bt_audio_dir dir)
|
||||
static void print_remote_codec(const struct bt_audio_codec_cap *codec_cap, enum bt_audio_dir dir)
|
||||
{
|
||||
printk("codec_capabilities %p dir 0x%02x\n", codec_capabilities, dir);
|
||||
print_codec_capabilities(codec_capabilities);
|
||||
printk("codec_cap %p dir 0x%02x\n", codec_cap, dir);
|
||||
print_codec_capabilities(codec_cap);
|
||||
}
|
||||
|
||||
static void add_remote_sink(struct bt_bap_ep *ep)
|
||||
|
@ -250,9 +246,10 @@ static void discover_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir)
|
|||
}
|
||||
}
|
||||
|
||||
static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, const struct bt_codec *codec)
|
||||
static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir,
|
||||
const struct bt_audio_codec_cap *codec_cap)
|
||||
{
|
||||
print_remote_codec(codec, dir);
|
||||
print_remote_codec(codec_cap, dir);
|
||||
}
|
||||
|
||||
static void endpoint_cb(struct bt_conn *conn, enum bt_audio_dir dir, struct bt_bap_ep *ep)
|
||||
|
@ -347,7 +344,7 @@ static int unicast_audio_start(struct bt_conn *conn, struct bt_bap_unicast_group
|
|||
stream_param.member.member = conn;
|
||||
stream_param.stream = &unicast_streams[0];
|
||||
stream_param.ep = unicast_sink_eps[0];
|
||||
stream_param.codec = &unicast_preset_48_2_1.codec;
|
||||
stream_param.codec_cfg = &unicast_preset_48_2_1.codec_cfg;
|
||||
stream_param.qos = &unicast_preset_48_2_1.qos;
|
||||
|
||||
err = bt_cap_initiator_unicast_audio_start(¶m, unicast_group);
|
||||
|
|
|
@ -23,53 +23,12 @@
|
|||
#define AVAILABLE_SINK_CONTEXT CONFIG_BT_PACS_SNK_CONTEXT
|
||||
#define AVAILABLE_SOURCE_CONTEXT CONFIG_BT_PACS_SRC_CONTEXT
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_src_16_1_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_16_1_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SRC_CONTEXT);
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_snk_16_1_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_16_1_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SNK_CONTEXT);
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_src_32_1_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_32_1_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SRC_CONTEXT);
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_snk_32_1_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_32_1_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SNK_CONTEXT);
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_src_32_2_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_32_2_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SRC_CONTEXT);
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_snk_32_2_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_32_2_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SNK_CONTEXT);
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_snk_48_1_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_48_1_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SNK_CONTEXT);
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_snk_48_2_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_48_2_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SNK_CONTEXT);
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_snk_48_3_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_48_3_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SNK_CONTEXT);
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_snk_48_4_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_48_4_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SNK_CONTEXT);
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_snk_48_5_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_48_5_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SNK_CONTEXT);
|
||||
|
||||
static struct bt_bap_lc3_preset codec_cfg_snk_48_6_1 =
|
||||
BT_BAP_LC3_UNICAST_PRESET_48_6_1(BT_AUDIO_LOCATION_FRONT_LEFT,
|
||||
CONFIG_BT_PACS_SNK_CONTEXT);
|
||||
static struct bt_audio_codec_cap lc3_codec_cap =
|
||||
BT_AUDIO_CODEC_LC3(BT_AUDIO_CODEC_LC3_FREQ_16KHZ | BT_AUDIO_CODEC_LC3_FREQ_32KHZ |
|
||||
BT_AUDIO_CODEC_LC3_FREQ_48KHZ,
|
||||
BT_AUDIO_CODEC_LC3_DURATION_7_5 | BT_AUDIO_CODEC_LC3_DURATION_10,
|
||||
BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(2), 30, 155u, 1u,
|
||||
(CONFIG_BT_PACS_SNK_CONTEXT | CONFIG_BT_PACS_SRC_CONTEXT));
|
||||
|
||||
static struct bt_conn *default_conn;
|
||||
static struct bt_bap_stream streams[CONFIG_BT_ASCS_ASE_SNK_COUNT + CONFIG_BT_ASCS_ASE_SRC_COUNT];
|
||||
|
@ -79,8 +38,8 @@ static struct audio_source {
|
|||
} source_streams[CONFIG_BT_ASCS_ASE_SRC_COUNT];
|
||||
static size_t configured_source_stream_count;
|
||||
|
||||
static const struct bt_codec_qos_pref qos_pref = BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02,
|
||||
10, 20000, 40000, 20000, 40000);
|
||||
static const struct bt_audio_codec_qos_pref qos_pref =
|
||||
BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 20000, 40000, 20000, 40000);
|
||||
|
||||
static void print_hex(const uint8_t *ptr, size_t len)
|
||||
{
|
||||
|
@ -89,50 +48,47 @@ static void print_hex(const uint8_t *ptr, size_t len)
|
|||
}
|
||||
}
|
||||
|
||||
static void print_codec(const struct bt_codec *codec)
|
||||
static void print_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg)
|
||||
{
|
||||
printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n",
|
||||
codec->id, codec->cid, codec->vid, codec->data_count);
|
||||
printk("codec_cfg 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cfg->id, codec_cfg->cid,
|
||||
codec_cfg->vid, codec_cfg->data_count);
|
||||
|
||||
for (size_t i = 0; i < codec->data_count; i++) {
|
||||
printk("data #%zu: type 0x%02x len %u\n",
|
||||
i, codec->data[i].data.type,
|
||||
codec->data[i].data.data_len);
|
||||
print_hex(codec->data[i].data.data,
|
||||
codec->data[i].data.data_len -
|
||||
sizeof(codec->data[i].data.type));
|
||||
for (size_t i = 0; i < codec_cfg->data_count; i++) {
|
||||
printk("data #%zu: type 0x%02x len %u\n", i, codec_cfg->data[i].data.type,
|
||||
codec_cfg->data[i].data.data_len);
|
||||
print_hex(codec_cfg->data[i].data.data,
|
||||
codec_cfg->data[i].data.data_len - sizeof(codec_cfg->data[i].data.type));
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
if (codec->id == BT_CODEC_LC3_ID) {
|
||||
if (codec_cfg->id == BT_AUDIO_CODEC_LC3_ID) {
|
||||
/* LC3 uses the generic LTV format - other codecs might do as well */
|
||||
|
||||
uint32_t chan_allocation;
|
||||
|
||||
printk(" Frequency: %d Hz\n", bt_codec_cfg_get_freq(codec));
|
||||
printk(" Frame Duration: %d us\n", bt_codec_cfg_get_frame_duration_us(codec));
|
||||
if (bt_codec_cfg_get_chan_allocation_val(codec, &chan_allocation) == 0) {
|
||||
printk(" Frequency: %d Hz\n", bt_audio_codec_cfg_get_freq(codec_cfg));
|
||||
printk(" Frame Duration: %d us\n",
|
||||
bt_audio_codec_cfg_get_frame_duration_us(codec_cfg));
|
||||
if (bt_audio_codec_cfg_get_chan_allocation_val(codec_cfg, &chan_allocation) == 0) {
|
||||
printk(" Channel allocation: 0x%x\n", chan_allocation);
|
||||
}
|
||||
|
||||
printk(" Octets per frame: %d (negative means value not pressent)\n",
|
||||
bt_codec_cfg_get_octets_per_frame(codec));
|
||||
bt_audio_codec_cfg_get_octets_per_frame(codec_cfg));
|
||||
printk(" Frames per SDU: %d\n",
|
||||
bt_codec_cfg_get_frame_blocks_per_sdu(codec, true));
|
||||
bt_audio_codec_cfg_get_frame_blocks_per_sdu(codec_cfg, true));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < codec->meta_count; i++) {
|
||||
printk("meta #%zu: type 0x%02x len %u\n",
|
||||
i, codec->meta[i].data.type,
|
||||
codec->meta[i].data.data_len);
|
||||
print_hex(codec->meta[i].data.data,
|
||||
codec->meta[i].data.data_len -
|
||||
sizeof(codec->meta[i].data.type));
|
||||
for (size_t i = 0; i < codec_cfg->meta_count; i++) {
|
||||
printk("meta #%zu: type 0x%02x len %u\n", i, codec_cfg->meta[i].data.type,
|
||||
codec_cfg->meta[i].data.data_len);
|
||||
print_hex(codec_cfg->meta[i].data.data,
|
||||
codec_cfg->meta[i].data.data_len - sizeof(codec_cfg->meta[i].data.type));
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void print_qos(const struct bt_codec_qos *qos)
|
||||
static void print_qos(const struct bt_audio_codec_qos *qos)
|
||||
{
|
||||
printk("QoS: interval %u framing 0x%02x phy 0x%02x sdu %u "
|
||||
"rtn %u latency %u pd %u\n",
|
||||
|
@ -154,13 +110,13 @@ static struct bt_bap_stream *stream_alloc(void)
|
|||
}
|
||||
|
||||
static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir,
|
||||
const struct bt_codec *codec, struct bt_bap_stream **stream,
|
||||
struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp)
|
||||
const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream,
|
||||
struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
|
||||
printk("ASE Codec Config: conn %p ep %p dir %u\n", conn, ep, dir);
|
||||
|
||||
print_codec(codec);
|
||||
print_codec_cfg(codec_cfg);
|
||||
|
||||
*stream = stream_alloc();
|
||||
if (*stream == NULL) {
|
||||
|
@ -182,17 +138,17 @@ static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_
|
|||
}
|
||||
|
||||
static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir,
|
||||
const struct bt_codec *codec, struct bt_codec_qos_pref *const pref,
|
||||
struct bt_bap_ascs_rsp *rsp)
|
||||
const struct bt_audio_codec_cfg *codec_cfg,
|
||||
struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("ASE Codec Reconfig: stream %p\n", stream);
|
||||
print_codec(codec);
|
||||
print_codec_cfg(codec_cfg);
|
||||
*pref = qos_pref;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos,
|
||||
static int lc3_qos(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos,
|
||||
struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("QoS: stream %p qos %p\n", stream, qos);
|
||||
|
@ -202,7 +158,7 @@ static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lc3_enable(struct bt_bap_stream *stream, const struct bt_codec_data *meta,
|
||||
static int lc3_enable(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta,
|
||||
size_t meta_count, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("Enable: stream %p meta_count %u\n", stream, meta_count);
|
||||
|
@ -256,14 +212,14 @@ static bool valid_metadata_type(uint8_t type, uint8_t len)
|
|||
}
|
||||
}
|
||||
|
||||
static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_codec_data *meta,
|
||||
static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta,
|
||||
size_t meta_count, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("Metadata: stream %p meta_count %u\n", stream, meta_count);
|
||||
bool stream_context_present = false;
|
||||
|
||||
for (size_t i = 0; i < meta_count; i++) {
|
||||
const struct bt_codec_data *data = &meta[i];
|
||||
const struct bt_audio_codec_data *data = &meta[i];
|
||||
|
||||
if (!valid_metadata_type(data->data.type, data->data.data_len)) {
|
||||
printk("Invalid metadata type %u or length %u\n",
|
||||
|
@ -388,52 +344,8 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
|
|||
.disconnected = disconnected,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_sink_16_1_1 = {
|
||||
.codec = &codec_cfg_snk_16_1_1.codec,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_source_16_1_1 = {
|
||||
.codec = &codec_cfg_src_16_1_1.codec,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_sink_32_1_1 = {
|
||||
.codec = &codec_cfg_snk_32_1_1.codec,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_source_32_1_1 = {
|
||||
.codec = &codec_cfg_src_32_1_1.codec,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_sink_32_2_1 = {
|
||||
.codec = &codec_cfg_snk_32_2_1.codec,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_source_32_2_1 = {
|
||||
.codec = &codec_cfg_src_32_2_1.codec,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_sink_48_1_1 = {
|
||||
.codec = &codec_cfg_snk_48_1_1.codec,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_sink_48_2_1 = {
|
||||
.codec = &codec_cfg_snk_48_2_1.codec,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_sink_48_3_1 = {
|
||||
.codec = &codec_cfg_snk_48_3_1.codec,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_sink_48_4_1 = {
|
||||
.codec = &codec_cfg_snk_48_4_1.codec,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_sink_48_5_1 = {
|
||||
.codec = &codec_cfg_snk_48_5_1.codec,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_sink_48_6_1 = {
|
||||
.codec = &codec_cfg_snk_48_6_1.codec,
|
||||
static struct bt_pacs_cap cap = {
|
||||
.codec_cap = &lc3_codec_cap,
|
||||
};
|
||||
|
||||
int bap_unicast_sr_init(void)
|
||||
|
@ -442,17 +354,7 @@ int bap_unicast_sr_init(void)
|
|||
|
||||
if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) {
|
||||
/* Register CT required capabilities */
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_16_1_1);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_32_1_1);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_32_2_1);
|
||||
|
||||
/* Register UMR required capabilities */
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_1_1);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_2_1);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_3_1);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_4_1);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_5_1);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_6_1);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap);
|
||||
|
||||
if (IS_ENABLED(CONFIG_TMAP_PERIPHERAL_LEFT)) {
|
||||
bt_pacs_set_location(BT_AUDIO_DIR_SINK, BT_AUDIO_LOCATION_FRONT_LEFT);
|
||||
|
@ -468,9 +370,7 @@ int bap_unicast_sr_init(void)
|
|||
|
||||
if (IS_ENABLED(CONFIG_BT_ASCS_ASE_SRC)) {
|
||||
/* Register CT required capabilities */
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source_16_1_1);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source_32_1_1);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source_32_2_1);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap);
|
||||
|
||||
if (IS_ENABLED(CONFIG_TMAP_PERIPHERAL_LEFT)) {
|
||||
bt_pacs_set_location(BT_AUDIO_DIR_SOURCE, BT_AUDIO_LOCATION_FRONT_LEFT);
|
||||
|
|
|
@ -223,13 +223,14 @@ static void lc3_audio_timer_timeout(struct k_work *work)
|
|||
|
||||
static void init_lc3(void)
|
||||
{
|
||||
const struct bt_audio_codec_cfg *codec_cfg = &codec_configuration.codec_cfg;
|
||||
unsigned int num_samples;
|
||||
|
||||
freq_hz = bt_codec_cfg_get_freq(&codec_configuration.codec);
|
||||
frame_duration_us = bt_codec_cfg_get_frame_duration_us(&codec_configuration.codec);
|
||||
octets_per_frame = bt_codec_cfg_get_octets_per_frame(&codec_configuration.codec);
|
||||
frames_per_sdu = bt_codec_cfg_get_frame_blocks_per_sdu(&codec_configuration.codec, true);
|
||||
octets_per_frame = bt_codec_cfg_get_octets_per_frame(&codec_configuration.codec);
|
||||
freq_hz = bt_audio_codec_cfg_get_freq(codec_cfg);
|
||||
frame_duration_us = bt_audio_codec_cfg_get_frame_duration_us(codec_cfg);
|
||||
octets_per_frame = bt_audio_codec_cfg_get_octets_per_frame(codec_cfg);
|
||||
frames_per_sdu = bt_audio_codec_cfg_get_frame_blocks_per_sdu(codec_cfg, true);
|
||||
octets_per_frame = bt_audio_codec_cfg_get_octets_per_frame(codec_cfg);
|
||||
|
||||
if (freq_hz < 0) {
|
||||
printk("Error: Codec frequency not set, cannot start codec.");
|
||||
|
@ -352,28 +353,24 @@ static void print_hex(const uint8_t *ptr, size_t len)
|
|||
}
|
||||
}
|
||||
|
||||
static void print_codec_capabilities(const struct bt_codec *codec)
|
||||
static void print_codec_cap(const struct bt_audio_codec_cap *codec_cap)
|
||||
{
|
||||
printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n",
|
||||
codec->id, codec->cid, codec->vid, codec->data_count);
|
||||
printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cap->id, codec_cap->cid,
|
||||
codec_cap->vid, codec_cap->data_count);
|
||||
|
||||
for (size_t i = 0; i < codec->data_count; i++) {
|
||||
printk("data #%zu: type 0x%02x len %u\n",
|
||||
i, codec->data[i].data.type,
|
||||
codec->data[i].data.data_len);
|
||||
print_hex(codec->data[i].data.data,
|
||||
codec->data[i].data.data_len -
|
||||
sizeof(codec->data[i].data.type));
|
||||
for (size_t i = 0; i < codec_cap->data_count; i++) {
|
||||
printk("data #%zu: type 0x%02x len %u\n", i, codec_cap->data[i].data.type,
|
||||
codec_cap->data[i].data.data_len);
|
||||
print_hex(codec_cap->data[i].data.data,
|
||||
codec_cap->data[i].data.data_len - sizeof(codec_cap->data[i].data.type));
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < codec->meta_count; i++) {
|
||||
printk("meta #%zu: type 0x%02x len %u\n",
|
||||
i, codec->meta[i].data.type,
|
||||
codec->meta[i].data.data_len);
|
||||
print_hex(codec->meta[i].data.data,
|
||||
codec->meta[i].data.data_len -
|
||||
sizeof(codec->meta[i].data.type));
|
||||
for (size_t i = 0; i < codec_cap->meta_count; i++) {
|
||||
printk("meta #%zu: type 0x%02x len %u\n", i, codec_cap->meta[i].data.type,
|
||||
codec_cap->meta[i].data.data_len);
|
||||
print_hex(codec_cap->meta[i].data.data,
|
||||
codec_cap->meta[i].data.data_len - sizeof(codec_cap->meta[i].data.type));
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +482,7 @@ static void start_scan(void)
|
|||
}
|
||||
|
||||
static void stream_configured(struct bt_bap_stream *stream,
|
||||
const struct bt_codec_qos_pref *pref)
|
||||
const struct bt_audio_codec_qos_pref *pref)
|
||||
{
|
||||
printk("Audio Stream %p configured\n", stream);
|
||||
|
||||
|
@ -591,11 +588,12 @@ static void add_remote_sink(struct bt_bap_ep *ep)
|
|||
printk("Could not add sink ep\n");
|
||||
}
|
||||
|
||||
static void print_remote_codec(const struct bt_codec *codec_capabilities, enum bt_audio_dir dir)
|
||||
static void print_remote_codec_cap(const struct bt_audio_codec_cap *codec_cap,
|
||||
enum bt_audio_dir dir)
|
||||
{
|
||||
printk("codec_capabilities %p dir 0x%02x\n", codec_capabilities, dir);
|
||||
printk("codec_cap %p dir 0x%02x\n", codec_cap, dir);
|
||||
|
||||
print_codec_capabilities(codec_capabilities);
|
||||
print_codec_cap(codec_cap);
|
||||
}
|
||||
|
||||
static void discover_sinks_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir)
|
||||
|
@ -712,9 +710,10 @@ static void available_contexts_cb(struct bt_conn *conn,
|
|||
printk("snk ctx %u src ctx %u\n", snk_ctx, src_ctx);
|
||||
}
|
||||
|
||||
static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, const struct bt_codec *codec)
|
||||
static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir,
|
||||
const struct bt_audio_codec_cap *codec_cap)
|
||||
{
|
||||
print_remote_codec(codec, dir);
|
||||
print_remote_codec_cap(codec_cap, dir);
|
||||
}
|
||||
|
||||
static void endpoint_cb(struct bt_conn *conn, enum bt_audio_dir dir, struct bt_bap_ep *ep)
|
||||
|
@ -837,8 +836,7 @@ static int configure_stream(struct bt_bap_stream *stream, struct bt_bap_ep *ep)
|
|||
{
|
||||
int err;
|
||||
|
||||
err = bt_bap_stream_config(default_conn, stream, ep,
|
||||
&codec_configuration.codec);
|
||||
err = bt_bap_stream_config(default_conn, stream, ep, &codec_configuration.codec_cfg);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
@ -982,9 +980,8 @@ static int enable_streams(void)
|
|||
for (size_t i = 0U; i < configured_stream_count; i++) {
|
||||
int err;
|
||||
|
||||
err = bt_bap_stream_enable(&streams[i],
|
||||
codec_configuration.codec.meta,
|
||||
codec_configuration.codec.meta_count);
|
||||
err = bt_bap_stream_enable(&streams[i], codec_configuration.codec_cfg.meta,
|
||||
codec_configuration.codec_cfg.meta_count);
|
||||
if (err != 0) {
|
||||
printk("Unable to enable stream: %d\n", err);
|
||||
return err;
|
||||
|
|
|
@ -33,10 +33,10 @@ NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_ASCS_ASE_SRC_COUNT,
|
|||
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU),
|
||||
CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL);
|
||||
|
||||
static struct bt_codec lc3_codec =
|
||||
BT_CODEC_LC3(BT_CODEC_LC3_FREQ_ANY, BT_CODEC_LC3_DURATION_10,
|
||||
BT_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u,
|
||||
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
|
||||
static struct bt_audio_codec_cap lc3_codec_cap =
|
||||
BT_AUDIO_CODEC_LC3(BT_AUDIO_CODEC_LC3_FREQ_ANY, BT_AUDIO_CODEC_LC3_DURATION_10,
|
||||
BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u,
|
||||
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
|
||||
|
||||
static struct bt_conn *default_conn;
|
||||
static struct k_work_delayable audio_send_work;
|
||||
|
@ -49,8 +49,8 @@ static struct audio_source {
|
|||
} source_streams[CONFIG_BT_ASCS_ASE_SRC_COUNT];
|
||||
static size_t configured_source_stream_count;
|
||||
|
||||
static const struct bt_codec_qos_pref qos_pref = BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02,
|
||||
10, 40000, 40000, 40000, 40000);
|
||||
static const struct bt_audio_codec_qos_pref qos_pref =
|
||||
BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 40000, 40000, 40000, 40000);
|
||||
|
||||
static K_SEM_DEFINE(sem_disconnected, 0, 1);
|
||||
|
||||
|
@ -118,50 +118,47 @@ void print_hex(const uint8_t *ptr, size_t len)
|
|||
}
|
||||
}
|
||||
|
||||
static void print_codec(const struct bt_codec *codec)
|
||||
static void print_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg)
|
||||
{
|
||||
printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n",
|
||||
codec->id, codec->cid, codec->vid, codec->data_count);
|
||||
printk("codec_cfg 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cfg->id, codec_cfg->cid,
|
||||
codec_cfg->vid, codec_cfg->data_count);
|
||||
|
||||
for (size_t i = 0; i < codec->data_count; i++) {
|
||||
printk("data #%zu: type 0x%02x len %u\n",
|
||||
i, codec->data[i].data.type,
|
||||
codec->data[i].data.data_len);
|
||||
print_hex(codec->data[i].data.data,
|
||||
codec->data[i].data.data_len -
|
||||
sizeof(codec->data[i].data.type));
|
||||
for (size_t i = 0; i < codec_cfg->data_count; i++) {
|
||||
printk("data #%zu: type 0x%02x len %u\n", i, codec_cfg->data[i].data.type,
|
||||
codec_cfg->data[i].data.data_len);
|
||||
print_hex(codec_cfg->data[i].data.data,
|
||||
codec_cfg->data[i].data.data_len - sizeof(codec_cfg->data[i].data.type));
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
if (codec->id == BT_CODEC_LC3_ID) {
|
||||
if (codec_cfg->id == BT_AUDIO_CODEC_LC3_ID) {
|
||||
/* LC3 uses the generic LTV format - other codecs might do as well */
|
||||
|
||||
enum bt_audio_location chan_allocation;
|
||||
|
||||
printk(" Frequency: %d Hz\n", bt_codec_cfg_get_freq(codec));
|
||||
printk(" Frame Duration: %d us\n", bt_codec_cfg_get_frame_duration_us(codec));
|
||||
if (bt_codec_cfg_get_chan_allocation_val(codec, &chan_allocation) == 0) {
|
||||
printk(" Frequency: %d Hz\n", bt_audio_codec_cfg_get_freq(codec_cfg));
|
||||
printk(" Frame Duration: %d us\n",
|
||||
bt_audio_codec_cfg_get_frame_duration_us(codec_cfg));
|
||||
if (bt_audio_codec_cfg_get_chan_allocation_val(codec_cfg, &chan_allocation) == 0) {
|
||||
printk(" Channel allocation: 0x%x\n", chan_allocation);
|
||||
}
|
||||
|
||||
printk(" Octets per frame: %d (negative means value not pressent)\n",
|
||||
bt_codec_cfg_get_octets_per_frame(codec));
|
||||
bt_audio_codec_cfg_get_octets_per_frame(codec_cfg));
|
||||
printk(" Frames per SDU: %d\n",
|
||||
bt_codec_cfg_get_frame_blocks_per_sdu(codec, true));
|
||||
bt_audio_codec_cfg_get_frame_blocks_per_sdu(codec_cfg, true));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < codec->meta_count; i++) {
|
||||
printk("meta #%zu: type 0x%02x len %u\n",
|
||||
i, codec->meta[i].data.type,
|
||||
codec->meta[i].data.data_len);
|
||||
print_hex(codec->meta[i].data.data,
|
||||
codec->meta[i].data.data_len -
|
||||
sizeof(codec->meta[i].data.type));
|
||||
for (size_t i = 0; i < codec_cfg->meta_count; i++) {
|
||||
printk("meta #%zu: type 0x%02x len %u\n", i, codec_cfg->meta[i].data.type,
|
||||
codec_cfg->meta[i].data.data_len);
|
||||
print_hex(codec_cfg->meta[i].data.data,
|
||||
codec_cfg->meta[i].data.data_len - sizeof(codec_cfg->meta[i].data.type));
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void print_qos(const struct bt_codec_qos *qos)
|
||||
static void print_qos(const struct bt_audio_codec_qos *qos)
|
||||
{
|
||||
printk("QoS: interval %u framing 0x%02x phy 0x%02x sdu %u "
|
||||
"rtn %u latency %u pd %u\n",
|
||||
|
@ -277,12 +274,12 @@ static struct bt_bap_stream *stream_alloc(enum bt_audio_dir dir)
|
|||
}
|
||||
|
||||
static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir,
|
||||
const struct bt_codec *codec, struct bt_bap_stream **stream,
|
||||
struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp)
|
||||
const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream,
|
||||
struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("ASE Codec Config: conn %p ep %p dir %u\n", conn, ep, dir);
|
||||
|
||||
print_codec(codec);
|
||||
print_codec_cfg(codec_cfg);
|
||||
|
||||
*stream = stream_alloc(dir);
|
||||
if (*stream == NULL) {
|
||||
|
@ -309,12 +306,12 @@ static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_
|
|||
}
|
||||
|
||||
static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir,
|
||||
const struct bt_codec *codec, struct bt_codec_qos_pref *const pref,
|
||||
struct bt_bap_ascs_rsp *rsp)
|
||||
const struct bt_audio_codec_cfg *codec_cfg,
|
||||
struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("ASE Codec Reconfig: stream %p\n", stream);
|
||||
|
||||
print_codec(codec);
|
||||
print_codec_cfg(codec_cfg);
|
||||
|
||||
#if defined(CONFIG_LIBLC3)
|
||||
/* Nothing to free as static memory is used */
|
||||
|
@ -327,7 +324,7 @@ static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos,
|
||||
static int lc3_qos(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos,
|
||||
struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("QoS: stream %p qos %p\n", stream, qos);
|
||||
|
@ -344,15 +341,16 @@ static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lc3_enable(struct bt_bap_stream *stream, const struct bt_codec_data *meta,
|
||||
static int lc3_enable(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta,
|
||||
size_t meta_count, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("Enable: stream %p meta_count %u\n", stream, meta_count);
|
||||
|
||||
#if defined(CONFIG_LIBLC3)
|
||||
{
|
||||
const int freq = bt_codec_cfg_get_freq(stream->codec);
|
||||
const int frame_duration_us = bt_codec_cfg_get_frame_duration_us(stream->codec);
|
||||
const int freq = bt_audio_codec_cfg_get_freq(stream->codec_cfg);
|
||||
const int frame_duration_us =
|
||||
bt_audio_codec_cfg_get_frame_duration_us(stream->codec_cfg);
|
||||
|
||||
if (freq < 0) {
|
||||
printk("Error: Codec frequency not set, cannot start codec.");
|
||||
|
@ -368,7 +366,8 @@ static int lc3_enable(struct bt_bap_stream *stream, const struct bt_codec_data *
|
|||
return -1;
|
||||
}
|
||||
|
||||
frames_per_sdu = bt_codec_cfg_get_frame_blocks_per_sdu(stream->codec, true);
|
||||
frames_per_sdu =
|
||||
bt_audio_codec_cfg_get_frame_blocks_per_sdu(stream->codec_cfg, true);
|
||||
|
||||
lc3_decoder = lc3_setup_decoder(frame_duration_us,
|
||||
freq,
|
||||
|
@ -448,13 +447,13 @@ static bool valid_metadata_type(uint8_t type, uint8_t len)
|
|||
}
|
||||
}
|
||||
|
||||
static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_codec_data *meta,
|
||||
static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta,
|
||||
size_t meta_count, struct bt_bap_ascs_rsp *rsp)
|
||||
{
|
||||
printk("Metadata: stream %p meta_count %u\n", stream, meta_count);
|
||||
|
||||
for (size_t i = 0; i < meta_count; i++) {
|
||||
const struct bt_codec_data *data = &meta[i];
|
||||
const struct bt_audio_codec_data *data = &meta[i];
|
||||
|
||||
if (!valid_metadata_type(data->data.type, data->data.data_len)) {
|
||||
printk("Invalid metadata type %u or length %u\n",
|
||||
|
@ -640,11 +639,11 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
|
|||
};
|
||||
|
||||
static struct bt_pacs_cap cap_sink = {
|
||||
.codec = &lc3_codec,
|
||||
.codec_cap = &lc3_codec_cap,
|
||||
};
|
||||
|
||||
static struct bt_pacs_cap cap_source = {
|
||||
.codec = &lc3_codec,
|
||||
.codec_cap = &lc3_codec_cap,
|
||||
};
|
||||
|
||||
static int set_location(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue