Bluetooth: audio: pacs: Replace capabilities API with pacs
This changes the API to use proper naming convention, as the code has been moved out of capabilities. Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit is contained in:
parent
e635d3aab6
commit
2627063ab2
13 changed files with 135 additions and 135 deletions
|
@ -7,8 +7,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAPABILITIES_H_
|
||||
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAPABILITIES_H_
|
||||
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_
|
||||
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_
|
||||
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief Audio Capability structure. */
|
||||
struct bt_audio_capability {
|
||||
/** @brief Published Audio Capability structure. */
|
||||
struct bt_pacs_cap {
|
||||
/** Capability codec reference */
|
||||
struct bt_codec *codec;
|
||||
|
||||
|
@ -25,19 +25,19 @@ struct bt_audio_capability {
|
|||
sys_snode_t _node;
|
||||
};
|
||||
|
||||
/** @typedef bt_audio_foreach_capability_func_t
|
||||
* @brief Capability iterator callback.
|
||||
/** @typedef bt_pacs_cap_foreach_func_t
|
||||
* @brief Published Audio Capability iterator callback.
|
||||
*
|
||||
* @param capability Capability found.
|
||||
* @param cap Capability found.
|
||||
* @param user_data Data given.
|
||||
*
|
||||
* @return true to continue to the next capability
|
||||
* @return false to stop the iteration
|
||||
*/
|
||||
typedef bool (*bt_audio_foreach_capability_func_t)(const struct bt_audio_capability *capability,
|
||||
typedef bool (*bt_pacs_cap_foreach_func_t)(const struct bt_pacs_cap *cap,
|
||||
void *user_data);
|
||||
|
||||
/** @brief Capability iterator.
|
||||
/** @brief Published Audio Capability iterator.
|
||||
*
|
||||
* Iterate capabilities with endpoint direction specified.
|
||||
*
|
||||
|
@ -45,10 +45,11 @@ typedef bool (*bt_audio_foreach_capability_func_t)(const struct bt_audio_capabil
|
|||
* @param func Callback function.
|
||||
* @param user_data Data to pass to the callback.
|
||||
*/
|
||||
void bt_audio_foreach_capability(enum bt_audio_dir dir, bt_audio_foreach_capability_func_t func,
|
||||
void bt_pacs_cap_foreach(enum bt_audio_dir dir,
|
||||
bt_pacs_cap_foreach_func_t func,
|
||||
void *user_data);
|
||||
|
||||
/** @brief Register Audio Capability.
|
||||
/** @brief Register Published Audio Capability.
|
||||
*
|
||||
* Register Audio Local Capability.
|
||||
*
|
||||
|
@ -57,9 +58,9 @@ void bt_audio_foreach_capability(enum bt_audio_dir dir, bt_audio_foreach_capabil
|
|||
*
|
||||
* @return 0 in case of success or negative value in case of error.
|
||||
*/
|
||||
int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capability *cap);
|
||||
int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap);
|
||||
|
||||
/** @brief Unregister Audio Capability.
|
||||
/** @brief Unregister Published Audio Capability.
|
||||
*
|
||||
* Unregister Audio Local Capability.
|
||||
*
|
||||
|
@ -68,7 +69,7 @@ int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capabili
|
|||
*
|
||||
* @return 0 in case of success or negative value in case of error.
|
||||
*/
|
||||
int bt_audio_capability_unregister(enum bt_audio_dir dir, struct bt_audio_capability *cap);
|
||||
int bt_pacs_cap_unregister(enum bt_audio_dir dir, struct bt_pacs_cap *cap);
|
||||
|
||||
/** @brief Set the location for an endpoint type
|
||||
*
|
||||
|
@ -76,7 +77,7 @@ int bt_audio_capability_unregister(enum bt_audio_dir dir, struct bt_audio_capabi
|
|||
* @param location The location to be set.
|
||||
*
|
||||
*/
|
||||
int bt_audio_capability_set_location(enum bt_audio_dir dir,
|
||||
int bt_pacs_set_location(enum bt_audio_dir dir,
|
||||
enum bt_audio_location location);
|
||||
|
||||
/** @brief Set the available contexts for an endpoint type
|
||||
|
@ -84,7 +85,7 @@ int bt_audio_capability_set_location(enum bt_audio_dir dir,
|
|||
* @param dir Direction of the endpoints to change available contexts for.
|
||||
* @param contexts The contexts to be set.
|
||||
*/
|
||||
int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir,
|
||||
int bt_pacs_set_available_contexts(enum bt_audio_dir dir,
|
||||
enum bt_audio_context contexts);
|
||||
|
||||
/** @brief Get the available contexts for an endpoint type
|
||||
|
@ -93,10 +94,10 @@ int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir,
|
|||
*
|
||||
* @return Bitmask of available contexts.
|
||||
*/
|
||||
enum bt_audio_context bt_audio_capability_get_available_contexts(enum bt_audio_dir dir);
|
||||
enum bt_audio_context bt_pacs_get_available_contexts(enum bt_audio_dir dir);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAPABILITIES_H_ */
|
||||
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_ */
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
|
||||
#define SEM_TIMEOUT K_SECONDS(10)
|
||||
|
||||
|
@ -148,7 +148,7 @@ static struct bt_audio_broadcast_sink_cb broadcast_sink_cbs = {
|
|||
.pa_sync_lost = pa_sync_lost_cb
|
||||
};
|
||||
|
||||
static struct bt_audio_capability capabilities = {
|
||||
static struct bt_pacs_cap cap = {
|
||||
.codec = &codec,
|
||||
};
|
||||
|
||||
|
@ -164,7 +164,7 @@ static int init(void)
|
|||
|
||||
printk("Bluetooth initialized\n");
|
||||
|
||||
err = bt_audio_capability_register(BT_AUDIO_DIR_SINK, &capabilities);
|
||||
err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap);
|
||||
if (err) {
|
||||
printk("Capability register failed (err %d)\n", err);
|
||||
return err;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/conn.h>
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
|
||||
NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_ASCS_ASE_SRC_COUNT,
|
||||
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU),
|
||||
|
@ -411,11 +411,11 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
|
|||
.disconnected = disconnected,
|
||||
};
|
||||
|
||||
static struct bt_audio_capability caps_sink = {
|
||||
static struct bt_pacs_cap cap_sink = {
|
||||
.codec = &lc3_codec,
|
||||
};
|
||||
|
||||
static struct bt_audio_capability caps_source = {
|
||||
static struct bt_pacs_cap cap_source = {
|
||||
.codec = &lc3_codec,
|
||||
};
|
||||
|
||||
|
@ -423,10 +423,10 @@ int bap_unicast_sr_init(void)
|
|||
{
|
||||
bt_audio_unicast_server_register_cb(&unicast_server_cb);
|
||||
|
||||
bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps_sink);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_ASCS_ASE_SRC)) {
|
||||
bt_audio_capability_register(BT_AUDIO_DIR_SOURCE, &caps_source);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(streams); i++) {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/conn.h>
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
#include <zephyr/bluetooth/audio/csis.h>
|
||||
#include <zephyr/bluetooth/services/ias.h>
|
||||
|
||||
|
@ -213,21 +213,21 @@ void main(void)
|
|||
* Front Left and the Front Right bits to a value of 0b1
|
||||
* in the Sink Audio Locations characteristic value.
|
||||
*/
|
||||
bt_audio_capability_set_location(BT_AUDIO_DIR_SINK,
|
||||
bt_pacs_set_location(BT_AUDIO_DIR_SINK,
|
||||
(BT_AUDIO_LOCATION_FRONT_LEFT |
|
||||
BT_AUDIO_LOCATION_FRONT_RIGHT));
|
||||
} else {
|
||||
bt_audio_capability_set_location(BT_AUDIO_DIR_SINK,
|
||||
bt_pacs_set_location(BT_AUDIO_DIR_SINK,
|
||||
BT_AUDIO_LOCATION_FRONT_LEFT);
|
||||
}
|
||||
|
||||
bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK,
|
||||
bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK,
|
||||
AVAILABLE_SINK_CONTEXT);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_ASCS_ASE_SRC)) {
|
||||
bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE,
|
||||
bt_pacs_set_location(BT_AUDIO_DIR_SOURCE,
|
||||
BT_AUDIO_LOCATION_FRONT_LEFT);
|
||||
bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE,
|
||||
bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE,
|
||||
AVAILABLE_SOURCE_CONTEXT);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/conn.h>
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
#include <zephyr/sys/byteorder.h>
|
||||
|
||||
#define AVAILABLE_SINK_CONTEXT (BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED | \
|
||||
|
@ -563,11 +563,11 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
|
|||
.disconnected = disconnected,
|
||||
};
|
||||
|
||||
static struct bt_audio_capability caps_sink = {
|
||||
static struct bt_pacs_cap cap_sink = {
|
||||
.codec = &lc3_codec,
|
||||
};
|
||||
|
||||
static struct bt_audio_capability caps_source = {
|
||||
static struct bt_pacs_cap cap_source = {
|
||||
.codec = &lc3_codec,
|
||||
};
|
||||
|
||||
|
@ -576,7 +576,7 @@ static int set_location(void)
|
|||
int err;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) {
|
||||
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SINK,
|
||||
err = bt_pacs_set_location(BT_AUDIO_DIR_SINK,
|
||||
BT_AUDIO_LOCATION_FRONT_CENTER);
|
||||
if (err != 0) {
|
||||
printk("Failed to set sink location (err %d)\n", err);
|
||||
|
@ -585,7 +585,7 @@ static int set_location(void)
|
|||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) {
|
||||
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE,
|
||||
err = bt_pacs_set_location(BT_AUDIO_DIR_SOURCE,
|
||||
(BT_AUDIO_LOCATION_FRONT_LEFT |
|
||||
BT_AUDIO_LOCATION_FRONT_RIGHT));
|
||||
if (err != 0) {
|
||||
|
@ -604,7 +604,7 @@ static int set_available_contexts(void)
|
|||
int err;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_PAC_SNK)) {
|
||||
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK,
|
||||
err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK,
|
||||
AVAILABLE_SINK_CONTEXT);
|
||||
if (err != 0) {
|
||||
printk("Failed to set sink available contexts (err %d)\n", err);
|
||||
|
@ -613,7 +613,7 @@ static int set_available_contexts(void)
|
|||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_PAC_SRC)) {
|
||||
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE,
|
||||
err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE,
|
||||
AVAILABLE_SOURCE_CONTEXT);
|
||||
if (err != 0) {
|
||||
printk("Failed to set source available contexts (err %d)\n", err);
|
||||
|
@ -640,8 +640,8 @@ void main(void)
|
|||
|
||||
bt_audio_unicast_server_register_cb(&unicast_server_cb);
|
||||
|
||||
bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps_sink);
|
||||
bt_audio_capability_register(BT_AUDIO_DIR_SOURCE, &caps_source);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source);
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(streams); i++) {
|
||||
bt_audio_stream_cb_register(&streams[i], &stream_ops);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <zephyr/bluetooth/gatt.h>
|
||||
#include "zephyr/bluetooth/iso.h"
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_ASCS)
|
||||
#define LOG_MODULE_NAME bt_ascs
|
||||
|
@ -1187,12 +1187,12 @@ struct codec_lookup_id_data {
|
|||
struct bt_codec *codec;
|
||||
};
|
||||
|
||||
static bool codec_lookup_id(const struct bt_audio_capability *capability, void *user_data)
|
||||
static bool codec_lookup_id(const struct bt_pacs_cap *cap, void *user_data)
|
||||
{
|
||||
struct codec_lookup_id_data *data = user_data;
|
||||
|
||||
if (capability->codec->id == data->id) {
|
||||
data->codec = capability->codec;
|
||||
if (cap->codec->id == data->id) {
|
||||
data->codec = cap->codec;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1216,7 +1216,7 @@ static int ascs_ep_set_codec(struct bt_audio_ep *ep, uint8_t id, uint16_t cid,
|
|||
BT_DBG("ep %p dir %u codec id 0x%02x cid 0x%04x vid 0x%04x len %u",
|
||||
ep, ep->dir, id, cid, vid, len);
|
||||
|
||||
bt_audio_foreach_capability(ep->dir, codec_lookup_id, &lookup_data);
|
||||
bt_pacs_cap_foreach(ep->dir, codec_lookup_id, &lookup_data);
|
||||
|
||||
if (lookup_data.codec == NULL) {
|
||||
return -ENOENT;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/gatt.h>
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
#include <zephyr/bluetooth/audio/has.h>
|
||||
#include <zephyr/sys/check.h>
|
||||
|
||||
|
@ -1151,14 +1151,14 @@ static int has_init(const struct device *dev)
|
|||
* Front Left and the Front Right bits to a value of 0b1
|
||||
* in the Sink Audio Locations characteristic value.
|
||||
*/
|
||||
bt_audio_capability_set_location(BT_AUDIO_DIR_SINK,
|
||||
bt_pacs_set_location(BT_AUDIO_DIR_SINK,
|
||||
(BT_AUDIO_LOCATION_FRONT_LEFT |
|
||||
BT_AUDIO_LOCATION_FRONT_RIGHT));
|
||||
} else if (IS_ENABLED(CONFIG_BT_HAS_HEARING_AID_LEFT)) {
|
||||
bt_audio_capability_set_location(BT_AUDIO_DIR_SINK,
|
||||
bt_pacs_set_location(BT_AUDIO_DIR_SINK,
|
||||
BT_AUDIO_LOCATION_FRONT_LEFT);
|
||||
} else {
|
||||
bt_audio_capability_set_location(BT_AUDIO_DIR_SINK,
|
||||
bt_pacs_set_location(BT_AUDIO_DIR_SINK,
|
||||
BT_AUDIO_LOCATION_FRONT_RIGHT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <zephyr/bluetooth/conn.h>
|
||||
#include <zephyr/bluetooth/gatt.h>
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
#include "../host/conn_internal.h"
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_PACS)
|
||||
|
@ -101,10 +101,10 @@ struct pac_records_build_data {
|
|||
struct net_buf_simple *buf;
|
||||
};
|
||||
|
||||
static bool build_pac_records(const struct bt_audio_capability *capability, void *user_data)
|
||||
static bool build_pac_records(const struct bt_pacs_cap *cap, void *user_data)
|
||||
{
|
||||
struct pac_records_build_data *data = user_data;
|
||||
struct bt_codec *codec = capability->codec;
|
||||
struct bt_codec *codec = cap->codec;
|
||||
struct net_buf_simple *buf = data->buf;
|
||||
struct net_buf_simple_state state;
|
||||
struct bt_pac_ltv_data *cc, *meta;
|
||||
|
@ -153,17 +153,17 @@ static bool build_pac_records(const struct bt_audio_capability *capability, void
|
|||
return true;
|
||||
|
||||
fail:
|
||||
__ASSERT(true, "No space for %p", capability);
|
||||
__ASSERT(true, "No space for %p", cap);
|
||||
|
||||
net_buf_simple_restore(buf, &state);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void foreach_capability(sys_slist_t *list, bt_audio_foreach_capability_func_t func,
|
||||
static void foreach_cap(sys_slist_t *list, bt_pacs_cap_foreach_func_t func,
|
||||
void *user_data)
|
||||
{
|
||||
struct bt_audio_capability *cap;
|
||||
struct bt_pacs_cap *cap;
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(list, cap, _node) {
|
||||
if (!func(cap, user_data)) {
|
||||
|
@ -184,7 +184,7 @@ static void get_pac_records(struct bt_conn *conn, sys_slist_t *list,
|
|||
data.rsp->num_pac = 0;
|
||||
data.buf = buf;
|
||||
|
||||
foreach_capability(list, build_pac_records, &data);
|
||||
foreach_cap(list, build_pac_records, &data);
|
||||
}
|
||||
|
||||
static void available_context_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
|
||||
|
@ -192,7 +192,6 @@ static void available_context_cfg_changed(const struct bt_gatt_attr *attr, uint1
|
|||
BT_DBG("attr %p value 0x%04x", attr, value);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t available_contexts_read(struct bt_conn *conn,
|
||||
const struct bt_gatt_attr *attr, void *buf,
|
||||
uint16_t len, uint16_t offset)
|
||||
|
@ -558,10 +557,10 @@ static void pac_notify_src_loc(struct k_work *work)
|
|||
#if defined(CONFIG_BT_PAC_SNK)
|
||||
static void pac_notify_snk(struct k_work *work)
|
||||
{
|
||||
struct pacs *caps = CONTAINER_OF(work, struct pacs, work);
|
||||
struct pacs *pac = CONTAINER_OF(work, struct pacs, work);
|
||||
int err;
|
||||
|
||||
get_pac_records(NULL, &caps->list, &read_buf);
|
||||
get_pac_records(NULL, &pac->list, &read_buf);
|
||||
|
||||
err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SNK, pacs_svc.attrs,
|
||||
read_buf.data, read_buf.len);
|
||||
|
@ -574,10 +573,10 @@ static void pac_notify_snk(struct k_work *work)
|
|||
#if defined(CONFIG_BT_PAC_SRC)
|
||||
static void pac_notify_src(struct k_work *work)
|
||||
{
|
||||
struct pacs *caps = CONTAINER_OF(work, struct pacs, work);
|
||||
struct pacs *pac = CONTAINER_OF(work, struct pacs, work);
|
||||
int err = 0;
|
||||
|
||||
get_pac_records(NULL, &caps->list, &read_buf);
|
||||
get_pac_records(NULL, &pac->list, &read_buf);
|
||||
|
||||
err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SRC, pacs_svc.attrs,
|
||||
read_buf.data, read_buf.len);
|
||||
|
@ -636,35 +635,34 @@ static struct pacs *pacs_get(enum bt_audio_dir dir)
|
|||
}
|
||||
}
|
||||
|
||||
void bt_audio_foreach_capability(enum bt_audio_dir dir, bt_audio_foreach_capability_func_t func,
|
||||
void *user_data)
|
||||
void bt_pacs_cap_foreach(enum bt_audio_dir dir, bt_pacs_cap_foreach_func_t func, void *user_data)
|
||||
{
|
||||
struct pacs *caps;
|
||||
struct pacs *pac;
|
||||
|
||||
CHECKIF(func == NULL) {
|
||||
BT_ERR("func is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
caps = pacs_get(dir);
|
||||
if (!caps) {
|
||||
pac = pacs_get(dir);
|
||||
if (!pac) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach_capability(&caps->list, func, user_data);
|
||||
foreach_cap(&pac->list, func, user_data);
|
||||
}
|
||||
|
||||
/* Register Audio Capability */
|
||||
int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capability *cap)
|
||||
int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap)
|
||||
{
|
||||
struct pacs *caps;
|
||||
struct pacs *pac;
|
||||
|
||||
if (!cap || !cap->codec) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
caps = pacs_get(dir);
|
||||
if (!caps) {
|
||||
pac = pacs_get(dir);
|
||||
if (!pac) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -672,39 +670,39 @@ int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capabili
|
|||
"codec vid 0x%04x", cap, dir, cap->codec->id,
|
||||
cap->codec->cid, cap->codec->vid);
|
||||
|
||||
sys_slist_append(&caps->list, &cap->_node);
|
||||
sys_slist_append(&pac->list, &cap->_node);
|
||||
|
||||
pacs_changed(caps);
|
||||
pacs_changed(pac);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unregister Audio Capability */
|
||||
int bt_audio_capability_unregister(enum bt_audio_dir dir, struct bt_audio_capability *cap)
|
||||
int bt_pacs_cap_unregister(enum bt_audio_dir dir, struct bt_pacs_cap *cap)
|
||||
{
|
||||
struct pacs *caps;
|
||||
struct pacs *pac;
|
||||
|
||||
if (!cap) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
caps = pacs_get(dir);
|
||||
if (!caps) {
|
||||
pac = pacs_get(dir);
|
||||
if (!pac) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
BT_DBG("cap %p dir 0x%02x", cap, dir);
|
||||
|
||||
if (!sys_slist_find_and_remove(&caps->list, &cap->_node)) {
|
||||
if (!sys_slist_find_and_remove(&pac->list, &cap->_node)) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
pacs_changed(caps);
|
||||
pacs_changed(pac);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_audio_capability_set_location(enum bt_audio_dir dir, enum bt_audio_location location)
|
||||
int bt_pacs_set_location(enum bt_audio_dir dir, enum bt_audio_location location)
|
||||
{
|
||||
switch (dir) {
|
||||
case BT_AUDIO_DIR_SINK:
|
||||
|
@ -716,8 +714,7 @@ int bt_audio_capability_set_location(enum bt_audio_dir dir, enum bt_audio_locati
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir,
|
||||
enum bt_audio_context contexts)
|
||||
int bt_pacs_set_available_contexts(enum bt_audio_dir dir, enum bt_audio_context contexts)
|
||||
{
|
||||
switch (dir) {
|
||||
case BT_AUDIO_DIR_SINK:
|
||||
|
@ -729,7 +726,7 @@ int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
enum bt_audio_context bt_audio_capability_get_available_contexts(enum bt_audio_dir dir)
|
||||
enum bt_audio_context bt_pacs_get_available_contexts(enum bt_audio_dir dir)
|
||||
{
|
||||
switch (dir) {
|
||||
case BT_AUDIO_DIR_SINK:
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <zephyr/bluetooth/gatt.h>
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
|
||||
#include "bt.h"
|
||||
|
||||
|
@ -684,11 +684,11 @@ static const struct bt_audio_unicast_server_cb unicast_server_cb = {
|
|||
.release = lc3_release,
|
||||
};
|
||||
|
||||
static struct bt_audio_capability caps_sink = {
|
||||
static struct bt_pacs_cap cap_sink = {
|
||||
.codec = &lc3_codec,
|
||||
};
|
||||
|
||||
static struct bt_audio_capability caps_source = {
|
||||
static struct bt_pacs_cap cap_source = {
|
||||
.codec = &lc3_codec,
|
||||
};
|
||||
|
||||
|
@ -1697,7 +1697,7 @@ static int cmd_set_loc(const struct shell *sh, size_t argc, char *argv[])
|
|||
}
|
||||
|
||||
loc = shell_strtoul(argv[2], 16, &err);
|
||||
err = bt_audio_capability_set_location(dir, loc);
|
||||
err = bt_pacs_set_location(dir, loc);
|
||||
if (err) {
|
||||
shell_error(ctx_shell, "Set available contexts err %d", err);
|
||||
return -ENOEXEC;
|
||||
|
@ -1727,7 +1727,7 @@ static int cmd_context(const struct shell *sh, size_t argc, char *argv[])
|
|||
return err;
|
||||
}
|
||||
|
||||
err = bt_audio_capability_set_available_contexts(dir, ctx);
|
||||
err = bt_pacs_set_available_contexts(dir, ctx);
|
||||
if (err) {
|
||||
shell_error(ctx_shell, "Set available contexts err %d", err);
|
||||
return err;
|
||||
|
@ -1753,26 +1753,28 @@ static int cmd_init(const struct shell *sh, size_t argc, char *argv[])
|
|||
|
||||
if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_SERVER) ||
|
||||
IS_ENABLED(CONFIG_BT_AUDIO_BROADCAST_SINK)) {
|
||||
bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps_sink);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_SERVER)) {
|
||||
bt_audio_capability_register(BT_AUDIO_DIR_SOURCE, &caps_source);
|
||||
bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) {
|
||||
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, LOCATION);
|
||||
err = bt_pacs_set_location(BT_AUDIO_DIR_SINK, LOCATION);
|
||||
__ASSERT(err == 0, "Failed to set sink location");
|
||||
|
||||
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK, CONTEXT);
|
||||
err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK,
|
||||
CONTEXT);
|
||||
__ASSERT(err == 0, "Failed to set sink available contexts");
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) {
|
||||
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE, LOCATION);
|
||||
err = bt_pacs_set_location(BT_AUDIO_DIR_SOURCE, LOCATION);
|
||||
__ASSERT(err == 0, "Failed to set source location");
|
||||
|
||||
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE, CONTEXT);
|
||||
err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE,
|
||||
CONTEXT);
|
||||
__ASSERT(err == 0, "Failed to set source available contexts");
|
||||
}
|
||||
|
||||
|
@ -1971,10 +1973,10 @@ ssize_t audio_ad_data_add(struct bt_data *data_array, const size_t data_array_si
|
|||
};
|
||||
enum bt_audio_context snk_context, src_context;
|
||||
|
||||
snk_context = bt_audio_capability_get_available_contexts(BT_AUDIO_DIR_SINK);
|
||||
snk_context = bt_pacs_get_available_contexts(BT_AUDIO_DIR_SINK);
|
||||
sys_put_le16(snk_context, &ad_bap_announcement[3]);
|
||||
|
||||
src_context = bt_audio_capability_get_available_contexts(BT_AUDIO_DIR_SOURCE);
|
||||
src_context = bt_pacs_get_available_contexts(BT_AUDIO_DIR_SOURCE);
|
||||
sys_put_le16(snk_context, &ad_bap_announcement[5]);
|
||||
|
||||
/* Metadata length */
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <zephyr/bluetooth/sdp.h>
|
||||
#include <zephyr/bluetooth/iso.h>
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
#include <zephyr/bluetooth/audio/csis.h>
|
||||
|
||||
#include <zephyr/shell/shell.h>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
#include "common.h"
|
||||
|
||||
extern enum bst_result_t bst_result;
|
||||
|
@ -130,7 +130,7 @@ static struct bt_audio_broadcast_sink_cb broadcast_sink_cbs = {
|
|||
.pa_sync_lost = pa_sync_lost_cb
|
||||
};
|
||||
|
||||
static struct bt_audio_capability capabilities = {
|
||||
static struct bt_pacs_cap cap = {
|
||||
.codec = &preset_16_2_1.codec,
|
||||
};
|
||||
|
||||
|
@ -171,7 +171,7 @@ static int init(void)
|
|||
|
||||
printk("Bluetooth initialized\n");
|
||||
|
||||
err = bt_audio_capability_register(BT_AUDIO_DIR_SINK, &capabilities);
|
||||
err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap);
|
||||
if (err) {
|
||||
FAIL("Capability register failed (err %d)\n", err);
|
||||
return err;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
#include "common.h"
|
||||
#include "unicast_common.h"
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/audio/audio.h>
|
||||
#include <zephyr/bluetooth/audio/capabilities.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
#include "common.h"
|
||||
#include "unicast_common.h"
|
||||
|
||||
|
@ -232,7 +232,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
|
|||
|
||||
static void init(void)
|
||||
{
|
||||
static struct bt_audio_capability caps = {
|
||||
static struct bt_pacs_cap cap = {
|
||||
.codec = &lc3_codec,
|
||||
};
|
||||
int err;
|
||||
|
@ -247,7 +247,7 @@ static void init(void)
|
|||
|
||||
bt_audio_unicast_server_register_cb(&unicast_server_cb);
|
||||
|
||||
err = bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps);
|
||||
err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap);
|
||||
if (err != 0) {
|
||||
FAIL("Failed to register capabilities: %d", err);
|
||||
return;
|
||||
|
@ -271,7 +271,7 @@ static void set_location(void)
|
|||
int err;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) {
|
||||
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SINK,
|
||||
err = bt_pacs_set_location(BT_AUDIO_DIR_SINK,
|
||||
BT_AUDIO_LOCATION_FRONT_CENTER);
|
||||
if (err != 0) {
|
||||
FAIL("Failed to set sink location (err %d)\n", err);
|
||||
|
@ -280,7 +280,7 @@ static void set_location(void)
|
|||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) {
|
||||
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE,
|
||||
err = bt_pacs_set_location(BT_AUDIO_DIR_SOURCE,
|
||||
(BT_AUDIO_LOCATION_FRONT_LEFT |
|
||||
BT_AUDIO_LOCATION_FRONT_RIGHT));
|
||||
if (err != 0) {
|
||||
|
@ -296,7 +296,7 @@ static void set_available_contexts(void)
|
|||
{
|
||||
int err;
|
||||
|
||||
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK,
|
||||
err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK,
|
||||
BT_AUDIO_CONTEXT_TYPE_MEDIA |
|
||||
BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL);
|
||||
if (IS_ENABLED(CONFIG_BT_PAC_SNK) && err != 0) {
|
||||
|
@ -304,7 +304,7 @@ static void set_available_contexts(void)
|
|||
return;
|
||||
}
|
||||
|
||||
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE,
|
||||
err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE,
|
||||
BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS);
|
||||
if (IS_ENABLED(CONFIG_BT_PAC_SRC) && err != 0) {
|
||||
FAIL("Failed to set source available contexts (err %d)\n", err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue