Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
|
Bluetooth Audio handling. More...
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <zephyr/autoconf.h>
#include <zephyr/bluetooth/audio/lc3.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/buf.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/util_macro.h>
Go to the source code of this file.
Data Structures | |
struct | bt_audio_codec_octets_per_codec_frame |
struct to hold minimum and maximum supported codec frame sizes More... | |
struct | bt_audio_codec_cap |
Codec capability structure. More... | |
struct | bt_audio_codec_cfg |
Codec specific configuration structure. More... | |
Macros | |
#define | BT_AUDIO_BROADCAST_ID_SIZE 3 |
Size of the broadcast ID in octets. | |
#define | BT_AUDIO_BROADCAST_ID_MAX 0xFFFFFFU |
Maximum broadcast ID value. | |
#define | BT_AUDIO_PD_PREF_NONE 0x000000U |
Indicates that the server have no preference for the presentation delay. | |
#define | BT_AUDIO_PD_MAX 0xFFFFFFU |
Maximum presentation delay in microseconds. | |
#define | BT_AUDIO_RTN_PREF_NONE 0xFFU |
Indicates that the unicast server does not have a preference for any retransmission number. | |
#define | BT_AUDIO_BROADCAST_NAME_LEN_MIN 4 |
The minimum size of a Broadcast Name as defined by Bluetooth Assigned Numbers. | |
#define | BT_AUDIO_BROADCAST_NAME_LEN_MAX 128 |
The maximum size of a Broadcast Name as defined by Bluetooth Assigned Numbers. | |
#define | BT_AUDIO_LANG_SIZE 3 |
Size of the stream language value, e.g. | |
#define | BT_AUDIO_CODEC_CAP_CHAN_COUNT_MIN 1 |
Minimum supported channel counts. | |
#define | BT_AUDIO_CODEC_CAP_CHAN_COUNT_MAX 8 |
Maximum supported channel counts. | |
#define | BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT(...) |
Channel count support capability. | |
#define | BT_AUDIO_CONTEXT_TYPE_ANY |
Any known context. | |
#define | BT_AUDIO_METADATA_TYPE_IS_KNOWN(_type) |
Helper to check whether metadata type is known by the stack. | |
#define | BT_AUDIO_CODEC_DATA(_type, _bytes...) |
Helper to declare elements of bt_audio_codec_cap arrays. | |
#define | BT_AUDIO_CODEC_CFG(_id, _cid, _vid, _data, _meta) |
Helper to declare Codec config parsing APIs. | |
#define | BT_AUDIO_CODEC_CAP(_id, _cid, _vid, _data, _meta) |
Helper to declare Codec capability parsing APIs structure. | |
#define | BT_AUDIO_LOCATION_ANY |
Any known location. | |
Unicast Announcement Type | |
#define | BT_AUDIO_UNICAST_ANNOUNCEMENT_GENERAL 0x00 |
Unicast Server is connectable and is requesting a connection. | |
#define | BT_AUDIO_UNICAST_ANNOUNCEMENT_TARGETED 0x01 |
Unicast Server is connectable but is not requesting a connection. | |
Functions | |
int | bt_audio_data_parse (const uint8_t ltv[], size_t size, bool(*func)(struct bt_data *data, void *user_data), void *user_data) |
Helper for parsing length-type-value data. | |
int | bt_audio_data_get_val (const uint8_t ltv_data[], size_t size, uint8_t type, const uint8_t **data) |
Get the value of a specific data type in an length-type-value data array. | |
uint8_t | bt_audio_get_chan_count (enum bt_audio_location chan_allocation) |
Function to get the number of channels from the channel allocation. | |
int | bt_audio_codec_cfg_freq_to_freq_hz (enum bt_audio_codec_cfg_freq freq) |
Convert assigned numbers frequency to frequency value. | |
int | bt_audio_codec_cfg_freq_hz_to_freq (uint32_t freq_hz) |
Convert frequency value to assigned numbers frequency. | |
int | bt_audio_codec_cfg_get_freq (const struct bt_audio_codec_cfg *codec_cfg) |
Extract the frequency from a codec configuration. | |
int | bt_audio_codec_cfg_set_freq (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_codec_cfg_freq freq) |
Set the frequency of a codec configuration. | |
int | bt_audio_codec_cfg_frame_dur_to_frame_dur_us (enum bt_audio_codec_cfg_frame_dur frame_dur) |
Convert assigned numbers frame duration to duration in microseconds. | |
int | bt_audio_codec_cfg_frame_dur_us_to_frame_dur (uint32_t frame_dur_us) |
Convert frame duration in microseconds to assigned numbers frame duration. | |
int | bt_audio_codec_cfg_get_frame_dur (const struct bt_audio_codec_cfg *codec_cfg) |
Extract frame duration from BT codec config. | |
int | bt_audio_codec_cfg_set_frame_dur (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_codec_cfg_frame_dur frame_dur) |
Set the frame duration of a codec configuration. | |
int | bt_audio_codec_cfg_get_chan_allocation (const struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_location *chan_allocation, bool fallback_to_default) |
Extract channel allocation from BT codec config. | |
int | bt_audio_codec_cfg_set_chan_allocation (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_location chan_allocation) |
Set the channel allocation of a codec configuration. | |
int | bt_audio_codec_cfg_get_octets_per_frame (const struct bt_audio_codec_cfg *codec_cfg) |
Extract frame size in octets from BT codec config. | |
int | bt_audio_codec_cfg_set_octets_per_frame (struct bt_audio_codec_cfg *codec_cfg, uint16_t octets_per_frame) |
Set the octets per codec frame of a codec configuration. | |
int | bt_audio_codec_cfg_get_frame_blocks_per_sdu (const struct bt_audio_codec_cfg *codec_cfg, bool fallback_to_default) |
Extract number of audio frame blocks in each SDU from BT codec config. | |
int | bt_audio_codec_cfg_set_frame_blocks_per_sdu (struct bt_audio_codec_cfg *codec_cfg, uint8_t frame_blocks) |
Set the frame blocks per SDU of a codec configuration. | |
int | bt_audio_codec_cfg_get_val (const struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_codec_cfg_type type, const uint8_t **data) |
Lookup a specific codec configuration value. | |
int | bt_audio_codec_cfg_set_val (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_codec_cfg_type type, const uint8_t *data, size_t data_len) |
Set or add a specific codec configuration value. | |
int | bt_audio_codec_cfg_unset_val (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_codec_cfg_type type) |
Unset a specific codec configuration value. | |
int | bt_audio_codec_cfg_meta_get_val (const struct bt_audio_codec_cfg *codec_cfg, uint8_t type, const uint8_t **data) |
Lookup a specific metadata value based on type. | |
int | bt_audio_codec_cfg_meta_set_val (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_metadata_type type, const uint8_t *data, size_t data_len) |
Set or add a specific codec configuration metadata value. | |
int | bt_audio_codec_cfg_meta_unset_val (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_metadata_type type) |
Unset a specific codec configuration metadata value. | |
int | bt_audio_codec_cfg_meta_get_pref_context (const struct bt_audio_codec_cfg *codec_cfg, bool fallback_to_default) |
Extract preferred contexts. | |
int | bt_audio_codec_cfg_meta_set_pref_context (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_context ctx) |
Set the preferred context of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_stream_context (const struct bt_audio_codec_cfg *codec_cfg) |
Extract stream contexts. | |
int | bt_audio_codec_cfg_meta_set_stream_context (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_context ctx) |
Set the stream context of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_program_info (const struct bt_audio_codec_cfg *codec_cfg, const uint8_t **program_info) |
Extract program info. | |
int | bt_audio_codec_cfg_meta_set_program_info (struct bt_audio_codec_cfg *codec_cfg, const uint8_t *program_info, size_t program_info_len) |
Set the program info of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_lang (const struct bt_audio_codec_cfg *codec_cfg, const uint8_t **lang) |
Extract language. | |
int | bt_audio_codec_cfg_meta_set_lang (struct bt_audio_codec_cfg *codec_cfg, const uint8_t lang[3]) |
Set the language of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_ccid_list (const struct bt_audio_codec_cfg *codec_cfg, const uint8_t **ccid_list) |
Extract CCID list. | |
int | bt_audio_codec_cfg_meta_set_ccid_list (struct bt_audio_codec_cfg *codec_cfg, const uint8_t *ccid_list, size_t ccid_list_len) |
Set the CCID list of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_parental_rating (const struct bt_audio_codec_cfg *codec_cfg) |
Extract parental rating. | |
int | bt_audio_codec_cfg_meta_set_parental_rating (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_parental_rating parental_rating) |
Set the parental rating of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_program_info_uri (const struct bt_audio_codec_cfg *codec_cfg, const uint8_t **program_info_uri) |
Extract program info URI. | |
int | bt_audio_codec_cfg_meta_set_program_info_uri (struct bt_audio_codec_cfg *codec_cfg, const uint8_t *program_info_uri, size_t program_info_uri_len) |
Set the program info URI of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_audio_active_state (const struct bt_audio_codec_cfg *codec_cfg) |
Extract audio active state. | |
int | bt_audio_codec_cfg_meta_set_audio_active_state (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_active_state state) |
Set the audio active state of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_bcast_audio_immediate_rend_flag (const struct bt_audio_codec_cfg *codec_cfg) |
Extract broadcast audio immediate rendering flag. | |
int | bt_audio_codec_cfg_meta_set_bcast_audio_immediate_rend_flag (struct bt_audio_codec_cfg *codec_cfg) |
Set the broadcast audio immediate rendering flag of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_assisted_listening_stream (const struct bt_audio_codec_cfg *codec_cfg) |
Extract assisted listening stream. | |
int | bt_audio_codec_cfg_meta_set_assisted_listening_stream (struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_assisted_listening_stream val) |
Set the assisted listening stream value of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_broadcast_name (const struct bt_audio_codec_cfg *codec_cfg, const uint8_t **broadcast_name) |
Extract broadcast name. | |
int | bt_audio_codec_cfg_meta_set_broadcast_name (struct bt_audio_codec_cfg *codec_cfg, const uint8_t *broadcast_name, size_t broadcast_name_len) |
Set the broadcast name of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_extended (const struct bt_audio_codec_cfg *codec_cfg, const uint8_t **extended_meta) |
Extract extended metadata. | |
int | bt_audio_codec_cfg_meta_set_extended (struct bt_audio_codec_cfg *codec_cfg, const uint8_t *extended_meta, size_t extended_meta_len) |
Set the extended metadata of a codec configuration metadata. | |
int | bt_audio_codec_cfg_meta_get_vendor (const struct bt_audio_codec_cfg *codec_cfg, const uint8_t **vendor_meta) |
Extract vendor specific metadata. | |
int | bt_audio_codec_cfg_meta_set_vendor (struct bt_audio_codec_cfg *codec_cfg, const uint8_t *vendor_meta, size_t vendor_meta_len) |
Set the vendor specific metadata of a codec configuration metadata. | |
int | bt_audio_codec_cap_get_val (const struct bt_audio_codec_cap *codec_cap, enum bt_audio_codec_cap_type type, const uint8_t **data) |
Lookup a specific value based on type. | |
int | bt_audio_codec_cap_set_val (struct bt_audio_codec_cap *codec_cap, enum bt_audio_codec_cap_type type, const uint8_t *data, size_t data_len) |
Set or add a specific codec capability value. | |
int | bt_audio_codec_cap_unset_val (struct bt_audio_codec_cap *codec_cap, enum bt_audio_codec_cap_type type) |
Unset a specific codec capability value. | |
int | bt_audio_codec_cap_get_freq (const struct bt_audio_codec_cap *codec_cap) |
Extract the frequency from a codec capability. | |
int | bt_audio_codec_cap_set_freq (struct bt_audio_codec_cap *codec_cap, enum bt_audio_codec_cap_freq freq) |
Set the supported frequencies of a codec capability. | |
int | bt_audio_codec_cap_get_frame_dur (const struct bt_audio_codec_cap *codec_cap) |
Extract the frequency from a codec capability. | |
int | bt_audio_codec_cap_set_frame_dur (struct bt_audio_codec_cap *codec_cap, enum bt_audio_codec_cap_frame_dur frame_dur) |
Set the frame duration of a codec capability. | |
int | bt_audio_codec_cap_get_supported_audio_chan_counts (const struct bt_audio_codec_cap *codec_cap, bool fallback_to_default) |
Extract the frequency from a codec capability. | |
int | bt_audio_codec_cap_set_supported_audio_chan_counts (struct bt_audio_codec_cap *codec_cap, enum bt_audio_codec_cap_chan_count chan_count) |
Set the channel count of a codec capability. | |
int | bt_audio_codec_cap_get_octets_per_frame (const struct bt_audio_codec_cap *codec_cap, struct bt_audio_codec_octets_per_codec_frame *codec_frame) |
Extract the supported octets per codec frame from a codec capability. | |
int | bt_audio_codec_cap_set_octets_per_frame (struct bt_audio_codec_cap *codec_cap, const struct bt_audio_codec_octets_per_codec_frame *codec_frame) |
Set the octets per codec frame of a codec capability. | |
int | bt_audio_codec_cap_get_max_codec_frames_per_sdu (const struct bt_audio_codec_cap *codec_cap, bool fallback_to_default) |
Extract the maximum codec frames per SDU from a codec capability. | |
int | bt_audio_codec_cap_set_max_codec_frames_per_sdu (struct bt_audio_codec_cap *codec_cap, uint8_t codec_frames_per_sdu) |
Set the maximum codec frames per SDU of a codec capability. | |
int | bt_audio_codec_cap_meta_get_val (const struct bt_audio_codec_cap *codec_cap, uint8_t type, const uint8_t **data) |
Lookup a specific metadata value based on type. | |
int | bt_audio_codec_cap_meta_set_val (struct bt_audio_codec_cap *codec_cap, enum bt_audio_metadata_type type, const uint8_t *data, size_t data_len) |
Set or add a specific codec capability metadata value. | |
int | bt_audio_codec_cap_meta_unset_val (struct bt_audio_codec_cap *codec_cap, enum bt_audio_metadata_type type) |
Unset a specific codec capability metadata value. | |
int | bt_audio_codec_cap_meta_get_pref_context (const struct bt_audio_codec_cap *codec_cap) |
Extract preferred contexts. | |
int | bt_audio_codec_cap_meta_set_pref_context (struct bt_audio_codec_cap *codec_cap, enum bt_audio_context ctx) |
Set the preferred context of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_stream_context (const struct bt_audio_codec_cap *codec_cap) |
Extract stream contexts. | |
int | bt_audio_codec_cap_meta_set_stream_context (struct bt_audio_codec_cap *codec_cap, enum bt_audio_context ctx) |
Set the stream context of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_program_info (const struct bt_audio_codec_cap *codec_cap, const uint8_t **program_info) |
Extract program info. | |
int | bt_audio_codec_cap_meta_set_program_info (struct bt_audio_codec_cap *codec_cap, const uint8_t *program_info, size_t program_info_len) |
Set the program info of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_lang (const struct bt_audio_codec_cap *codec_cap, const uint8_t **lang) |
Extract language. | |
int | bt_audio_codec_cap_meta_set_lang (struct bt_audio_codec_cap *codec_cap, const uint8_t lang[3]) |
Set the language of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_ccid_list (const struct bt_audio_codec_cap *codec_cap, const uint8_t **ccid_list) |
Extract CCID list. | |
int | bt_audio_codec_cap_meta_set_ccid_list (struct bt_audio_codec_cap *codec_cap, const uint8_t *ccid_list, size_t ccid_list_len) |
Set the CCID list of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_parental_rating (const struct bt_audio_codec_cap *codec_cap) |
Extract parental rating. | |
int | bt_audio_codec_cap_meta_set_parental_rating (struct bt_audio_codec_cap *codec_cap, enum bt_audio_parental_rating parental_rating) |
Set the parental rating of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_program_info_uri (const struct bt_audio_codec_cap *codec_cap, const uint8_t **program_info_uri) |
Extract program info URI. | |
int | bt_audio_codec_cap_meta_set_program_info_uri (struct bt_audio_codec_cap *codec_cap, const uint8_t *program_info_uri, size_t program_info_uri_len) |
Set the program info URI of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_audio_active_state (const struct bt_audio_codec_cap *codec_cap) |
Extract audio active state. | |
int | bt_audio_codec_cap_meta_set_audio_active_state (struct bt_audio_codec_cap *codec_cap, enum bt_audio_active_state state) |
Set the audio active state of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_bcast_audio_immediate_rend_flag (const struct bt_audio_codec_cap *codec_cap) |
Extract broadcast audio immediate rendering flag. | |
int | bt_audio_codec_cap_meta_set_bcast_audio_immediate_rend_flag (struct bt_audio_codec_cap *codec_cap) |
Set the broadcast audio immediate rendering flag of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_assisted_listening_stream (const struct bt_audio_codec_cap *codec_cap) |
Extract assisted listening stream. | |
int | bt_audio_codec_cap_meta_set_assisted_listening_stream (struct bt_audio_codec_cap *codec_cap, enum bt_audio_assisted_listening_stream val) |
Set the assisted listening stream value of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_broadcast_name (const struct bt_audio_codec_cap *codec_cap, const uint8_t **broadcast_name) |
Extract broadcast name. | |
int | bt_audio_codec_cap_meta_set_broadcast_name (struct bt_audio_codec_cap *codec_cap, const uint8_t *broadcast_name, size_t broadcast_name_len) |
Set the broadcast name of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_extended (const struct bt_audio_codec_cap *codec_cap, const uint8_t **extended_meta) |
Extract extended metadata. | |
int | bt_audio_codec_cap_meta_set_extended (struct bt_audio_codec_cap *codec_cap, const uint8_t *extended_meta, size_t extended_meta_len) |
Set the extended metadata of a codec capability metadata. | |
int | bt_audio_codec_cap_meta_get_vendor (const struct bt_audio_codec_cap *codec_cap, const uint8_t **vendor_meta) |
Extract vendor specific metadata. | |
int | bt_audio_codec_cap_meta_set_vendor (struct bt_audio_codec_cap *codec_cap, const uint8_t *vendor_meta, size_t vendor_meta_len) |
Set the vendor specific metadata of a codec capability metadata. | |
static char * | bt_audio_context_bit_to_str (enum bt_audio_context context) |
Returns a string representation of a specific bt_audio_context bit. | |
static char * | bt_audio_parental_rating_to_str (enum bt_audio_parental_rating parental_rating) |
Returns a string representation of a bt_audio_parental_rating value. | |
static char * | bt_audio_active_state_to_str (enum bt_audio_active_state state) |
Returns a string representation of a bt_audio_active_state value. | |
static char * | bt_audio_codec_cap_freq_bit_to_str (enum bt_audio_codec_cap_freq freq) |
Returns a string representation of a specific bt_audio_codec_cap_freq bit. | |
static char * | bt_audio_codec_cap_frame_dur_bit_to_str (enum bt_audio_codec_cap_frame_dur frame_dur) |
Returns a string representation of a specific bt_audio_codec_cap_frame_dur bit. | |
static char * | bt_audio_codec_cap_chan_count_bit_to_str (enum bt_audio_codec_cap_chan_count chan_count) |
Returns a string representation of a specific bt_audio_codec_cap_chan_count bit. | |
static char * | bt_audio_location_bit_to_str (enum bt_audio_location location) |
Returns a string representation of a specific bt_audio_location bit. | |
Bluetooth Audio handling.