nRF Connect SDK API 3.3.99
Loading...
Searching...
No Matches
server_store.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
16#ifndef _SERVER_STORE_H_
17#define _SERVER_STORE_H_
18
19#include <zephyr/bluetooth/conn.h>
20#include <zephyr/bluetooth/audio/audio.h>
21#include <zephyr/bluetooth/audio/csip.h>
22#include <zephyr/bluetooth/audio/cap.h>
23#include <zephyr/bluetooth/audio/bap.h>
24#include <zephyr/bluetooth/audio/bap_lc3_preset.h>
25#include <zephyr/bluetooth/addr.h>
26
29 uint32_t locations;
30 struct bt_bap_lc3_preset lc3_preset[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT];
31 struct bt_audio_codec_cap codec_caps[CONFIG_CODEC_CAP_COUNT_MAX];
33 struct bt_bap_ep *eps[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT];
34 size_t num_eps;
35 enum bt_audio_context supported_ctx;
36 enum bt_audio_context available_ctx;
37 struct bt_cap_stream cap_streams[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT];
38};
39
42 uint32_t locations;
43 struct bt_bap_lc3_preset lc3_preset[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT];
44 struct bt_audio_codec_cap codec_caps[CONFIG_CODEC_CAP_COUNT_MAX];
46 struct bt_bap_ep *eps[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT];
47 size_t num_eps;
48 enum bt_audio_context supported_ctx;
49 enum bt_audio_context available_ctx;
50 struct bt_cap_stream cap_streams[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT];
51};
52
53/* This struct holds the parameters for a given unicast server/headset device */
55 char *name;
56 bt_addr_le_t addr;
57 struct bt_conn *conn;
58 const struct bt_csip_set_coordinator_set_member *member;
61};
62
64 enum bt_audio_codec_cap_freq freq;
65 enum bt_audio_codec_cap_frame_dur dur;
66 enum bt_audio_codec_cap_chan_count chan_count;
67 struct bt_audio_codec_octets_per_codec_frame oct_per_codec_frame;
68};
69
79typedef bool (*srv_store_foreach_func_t)(struct server_store *server, void *user_data);
80
94
107bool srv_store_preset_validated(struct bt_audio_codec_cfg const *const new,
108 struct bt_audio_codec_cfg const *const existing,
109 uint8_t pref_sample_rate_value);
110
133int srv_store_pres_dly_find(struct bt_bap_stream *stream, uint32_t *computed_pres_dly_us,
134 uint32_t *existing_pres_dly_us,
135 struct bt_bap_qos_cfg_pref const *server_qos_pref,
136 bool *group_reconfig_needed,
137 struct bt_cap_unicast_group *unicast_group);
138
152int srv_store_location_set(struct bt_conn const *const conn, enum bt_audio_dir dir,
153 enum bt_audio_location loc);
154
172int srv_store_valid_codec_cap_check(struct bt_conn const *const conn, enum bt_audio_dir dir,
173 uint32_t *valid_codec_caps,
174 struct client_supp_configs const **const client_supp_cfgs,
175 uint8_t num_client_supp_cfgs);
176
188int srv_store_from_stream_get(struct bt_bap_stream const *const stream,
189 struct server_store **server);
190
201int srv_store_all_ep_state_count(enum bt_bap_ep_state state, enum bt_audio_dir dir);
202
216int srv_store_avail_context_set(struct bt_conn *conn, enum bt_audio_context snk_ctx,
217 enum bt_audio_context src_ctx);
218
233int srv_store_codec_cap_set(struct bt_conn const *const conn, enum bt_audio_dir dir,
234 struct bt_audio_codec_cap const *const codec);
235
247int srv_store_from_addr_get(bt_addr_le_t const *const addr, struct server_store **server);
248
257bool srv_store_server_exists(bt_addr_le_t const *const addr);
258
271int srv_store_from_conn_get(struct bt_conn const *const conn, struct server_store **server);
272
286
302int srv_store_add_by_conn(struct bt_conn *conn);
303
321int srv_store_add_by_addr(const bt_addr_le_t *addr);
322
340int srv_store_conn_update(struct bt_conn *conn, bt_addr_le_t const *const addr);
341
356int srv_store_clear_by_conn(struct bt_conn const *const conn);
357
378int srv_store_remove_by_conn(struct bt_conn const *const conn);
379
390int srv_store_remove_by_addr(bt_addr_le_t const *const addr);
391
405int srv_store_remove_all(bool force);
406
422int _srv_store_lock(k_timeout_t timeout, const char *file, int line);
423
424#ifdef CONFIG_DEBUG
425#define srv_store_lock(timeout) _srv_store_lock(timeout, __func__, __LINE__)
426#else
427#define srv_store_lock(timeout) _srv_store_lock(timeout, NULL, 0)
428#endif
429
434
442
448#endif /* _SERVER_STORE_H_ */
int srv_store_num_get(void)
Get the number of stored servers.
int srv_store_all_ep_state_count(enum bt_bap_ep_state state, enum bt_audio_dir dir)
Get the number of endpoints in a given state across all stored servers.
bool srv_store_preset_validated(struct bt_audio_codec_cfg const *const new, struct bt_audio_codec_cfg const *const existing, uint8_t pref_sample_rate_value)
Validate the codec configuration preset.
int srv_store_remove_by_conn(struct bt_conn const *const conn)
Remove a server by conn pointer.
void srv_store_unlock(void)
Give the server store semaphore to unlock server store.
int srv_store_init(void)
Initialize the server store and clear all contents.
int srv_store_from_stream_get(struct bt_bap_stream const *const stream, struct server_store **server)
Get a server based on stream pointer.
int srv_store_location_set(struct bt_conn const *const conn, enum bt_audio_dir dir, enum bt_audio_location loc)
Set the valid locations of a unicast server.
int srv_store_conn_update(struct bt_conn *conn, bt_addr_le_t const *const addr)
Update the conn pointer of an existing server, based on address.
int srv_store_remove_by_addr(bt_addr_le_t const *const addr)
Remove a single stored server based on address.
int srv_store_valid_codec_cap_check(struct bt_conn const *const conn, enum bt_audio_dir dir, uint32_t *valid_codec_caps, struct client_supp_configs const **const client_supp_cfgs, uint8_t num_client_supp_cfgs)
Check which codec capabilities are valid.
int srv_store_add_by_conn(struct bt_conn *conn)
Add a server to the storage based on conn.
int srv_store_remove_all(bool force)
Remove all servers.
int srv_store_avail_context_set(struct bt_conn *conn, enum bt_audio_context snk_ctx, enum bt_audio_context src_ctx)
Store the available audio context for a server based on conn.
int srv_store_add_by_addr(const bt_addr_le_t *addr)
Add a server to the storage based on address.
bool(* srv_store_foreach_func_t)(struct server_store *server, void *user_data)
Function for bt_bap_unicast_group_foreach_server().
Definition server_store.h:79
bool srv_store_server_exists(bt_addr_le_t const *const addr)
Check if there is a server with the given address in the server store.
int srv_store_foreach_server(srv_store_foreach_func_t func, void *user_data)
Iterate through all stored servers and call the given function for each.
int srv_store_pres_dly_find(struct bt_bap_stream *stream, uint32_t *computed_pres_dly_us, uint32_t *existing_pres_dly_us, struct bt_bap_qos_cfg_pref const *server_qos_pref, bool *group_reconfig_needed, struct bt_cap_unicast_group *unicast_group)
Search for a common presentation delay across all server Audio Stream Endpoints (ASEs) in a given uni...
int srv_store_from_conn_get(struct bt_conn const *const conn, struct server_store **server)
Get a server from the conn pointer.
int srv_store_codec_cap_set(struct bt_conn const *const conn, enum bt_audio_dir dir, struct bt_audio_codec_cap const *const codec)
Store the codec capabilities for a given server based on conn.
int srv_store_clear_by_conn(struct bt_conn const *const conn)
Clear the contents of a server based on conn pointer.
int srv_store_from_addr_get(bt_addr_le_t const *const addr, struct server_store **server)
Get a server from the address.
enum bt_audio_codec_cap_frame_dur dur
Definition server_store.h:65
enum bt_audio_codec_cap_freq freq
Definition server_store.h:64
struct bt_audio_codec_octets_per_codec_frame oct_per_codec_frame
Definition server_store.h:67
enum bt_audio_codec_cap_chan_count chan_count
Definition server_store.h:66
Definition server_store.h:63
const struct bt_csip_set_coordinator_set_member * member
Definition server_store.h:58
struct bt_conn * conn
Definition server_store.h:57
struct unicast_server_snk_vars snk
Definition server_store.h:59
struct unicast_server_src_vars src
Definition server_store.h:60
bt_addr_le_t addr
Definition server_store.h:56
char * name
Definition server_store.h:55
Definition server_store.h:54
struct bt_cap_stream cap_streams[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT]
Definition server_store.h:37
size_t num_eps
Definition server_store.h:34
enum bt_audio_context supported_ctx
Definition server_store.h:35
struct bt_bap_ep * eps[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT]
Definition server_store.h:33
bool waiting_for_disc
Definition server_store.h:28
struct bt_bap_lc3_preset lc3_preset[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT]
Definition server_store.h:30
size_t num_codec_caps
Definition server_store.h:32
enum bt_audio_context available_ctx
Definition server_store.h:36
struct bt_audio_codec_cap codec_caps[CONFIG_CODEC_CAP_COUNT_MAX]
Definition server_store.h:31
uint32_t locations
Definition server_store.h:29
Definition server_store.h:27
struct bt_audio_codec_cap codec_caps[CONFIG_CODEC_CAP_COUNT_MAX]
Definition server_store.h:44
uint32_t locations
Definition server_store.h:42
enum bt_audio_context available_ctx
Definition server_store.h:49
enum bt_audio_context supported_ctx
Definition server_store.h:48
struct bt_bap_lc3_preset lc3_preset[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT]
Definition server_store.h:43
size_t num_codec_caps
Definition server_store.h:45
size_t num_eps
Definition server_store.h:47
struct bt_cap_stream cap_streams[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT]
Definition server_store.h:50
struct bt_bap_ep * eps[CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT]
Definition server_store.h:46
bool waiting_for_disc
Definition server_store.h:41
Definition server_store.h:40