Zephyr Project API 3.5.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
audio.h File Reference

Bluetooth Audio handling. More...

Go to the source code of this file.

Data Structures

struct  bt_audio_codec_cap
 Codec capability structure. More...
 
struct  bt_audio_codec_cfg
 Codec specific configuration structure. More...
 
struct  bt_audio_codec_qos
 Codec QoS structure. More...
 
struct  bt_audio_codec_qos_pref
 Audio Stream Quality of Service Preference structure. More...
 

Macros

#define BT_AUDIO_BROADCAST_ID_SIZE   3 /* 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_BROADCAST_CODE_SIZE   16
 
#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_UNICAST_ANNOUNCEMENT_GENERAL   0x00
 
#define BT_AUDIO_UNICAST_ANNOUNCEMENT_TARGETED   0x01
 
#define BT_AUDIO_CODEC_DATA(_type, _bytes...)    (sizeof((uint8_t)_type) + sizeof((uint8_t[]){_bytes})), (_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.
 
#define BT_AUDIO_CODEC_QOS(_interval, _framing, _phy, _sdu, _rtn, _latency, _pd)
 Helper to declare elements of bt_audio_codec_qos.
 
#define BT_AUDIO_CODEC_QOS_UNFRAMED(_interval, _sdu, _rtn, _latency, _pd)
 Helper to declare Input Unframed bt_audio_codec_qos.
 
#define BT_AUDIO_CODEC_QOS_FRAMED(_interval, _sdu, _rtn, _latency, _pd)
 Helper to declare Input Framed bt_audio_codec_qos.
 
#define BT_AUDIO_CODEC_QOS_PREF(_unframed_supported, _phy, _rtn, _latency, _pd_min, _pd_max, _pref_pd_min, _pref_pd_max)
 Helper to declare elements of bt_audio_codec_qos_pref.
 

Enumerations

enum  bt_audio_context {
  BT_AUDIO_CONTEXT_TYPE_PROHIBITED = 0 , BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED = BIT(0) , BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL = BIT(1) , BT_AUDIO_CONTEXT_TYPE_MEDIA = BIT(2) ,
  BT_AUDIO_CONTEXT_TYPE_GAME = BIT(3) , BT_AUDIO_CONTEXT_TYPE_INSTRUCTIONAL = BIT(4) , BT_AUDIO_CONTEXT_TYPE_VOICE_ASSISTANTS = BIT(5) , BT_AUDIO_CONTEXT_TYPE_LIVE = BIT(6) ,
  BT_AUDIO_CONTEXT_TYPE_SOUND_EFFECTS = BIT(7) , BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS = BIT(8) , BT_AUDIO_CONTEXT_TYPE_RINGTONE = BIT(9) , BT_AUDIO_CONTEXT_TYPE_ALERTS = BIT(10) ,
  BT_AUDIO_CONTEXT_TYPE_EMERGENCY_ALARM = BIT(11)
}
 Audio Context Type for Generic Audio. More...
 
enum  bt_audio_parental_rating {
  BT_AUDIO_PARENTAL_RATING_NO_RATING = 0x00 , BT_AUDIO_PARENTAL_RATING_AGE_ANY = 0x01 , BT_AUDIO_PARENTAL_RATING_AGE_5_OR_ABOVE = 0x02 , BT_AUDIO_PARENTAL_RATING_AGE_6_OR_ABOVE = 0x03 ,
  BT_AUDIO_PARENTAL_RATING_AGE_7_OR_ABOVE = 0x04 , BT_AUDIO_PARENTAL_RATING_AGE_8_OR_ABOVE = 0x05 , BT_AUDIO_PARENTAL_RATING_AGE_9_OR_ABOVE = 0x06 , BT_AUDIO_PARENTAL_RATING_AGE_10_OR_ABOVE = 0x07 ,
  BT_AUDIO_PARENTAL_RATING_AGE_11_OR_ABOVE = 0x08 , BT_AUDIO_PARENTAL_RATING_AGE_12_OR_ABOVE = 0x09 , BT_AUDIO_PARENTAL_RATING_AGE_13_OR_ABOVE = 0x0A , BT_AUDIO_PARENTAL_RATING_AGE_14_OR_ABOVE = 0x0B ,
  BT_AUDIO_PARENTAL_RATING_AGE_15_OR_ABOVE = 0x0C , BT_AUDIO_PARENTAL_RATING_AGE_16_OR_ABOVE = 0x0D , BT_AUDIO_PARENTAL_RATING_AGE_17_OR_ABOVE = 0x0E , BT_AUDIO_PARENTAL_RATING_AGE_18_OR_ABOVE = 0x0F
}
 Parental rating defined by the Generic Audio assigned numbers (bluetooth.com). More...
 
enum  bt_audio_active_state { BT_AUDIO_ACTIVE_STATE_DISABLED = 0x00 , BT_AUDIO_ACTIVE_STATE_ENABLED = 0x01 }
 Audio Active State defined by the Generic Audio assigned numbers (bluetooth.com). More...
 
enum  bt_audio_metadata_type {
  BT_AUDIO_METADATA_TYPE_PREF_CONTEXT = 0x01 , BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT = 0x02 , BT_AUDIO_METADATA_TYPE_PROGRAM_INFO = 0x03 , BT_AUDIO_METADATA_TYPE_STREAM_LANG = 0x04 ,
  BT_AUDIO_METADATA_TYPE_CCID_LIST = 0x05 , BT_AUDIO_METADATA_TYPE_PARENTAL_RATING = 0x06 , BT_AUDIO_METADATA_TYPE_PROGRAM_INFO_URI = 0x07 , BT_AUDIO_METADATA_TYPE_AUDIO_STATE = 0x08 ,
  BT_AUDIO_METADATA_TYPE_BROADCAST_IMMEDIATE = 0x09 , BT_AUDIO_METADATA_TYPE_EXTENDED = 0xFE , BT_AUDIO_METADATA_TYPE_VENDOR = 0xFF
}
 Codec metadata type IDs. More...
 
enum  bt_audio_location {
  BT_AUDIO_LOCATION_PROHIBITED = 0 , BT_AUDIO_LOCATION_FRONT_LEFT = BIT(0) , BT_AUDIO_LOCATION_FRONT_RIGHT = BIT(1) , BT_AUDIO_LOCATION_FRONT_CENTER = BIT(2) ,
  BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_1 = BIT(3) , BT_AUDIO_LOCATION_BACK_LEFT = BIT(4) , BT_AUDIO_LOCATION_BACK_RIGHT = BIT(5) , BT_AUDIO_LOCATION_FRONT_LEFT_OF_CENTER = BIT(6) ,
  BT_AUDIO_LOCATION_FRONT_RIGHT_OF_CENTER = BIT(7) , BT_AUDIO_LOCATION_BACK_CENTER = BIT(8) , BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_2 = BIT(9) , BT_AUDIO_LOCATION_SIDE_LEFT = BIT(10) ,
  BT_AUDIO_LOCATION_SIDE_RIGHT = BIT(11) , BT_AUDIO_LOCATION_TOP_FRONT_LEFT = BIT(12) , BT_AUDIO_LOCATION_TOP_FRONT_RIGHT = BIT(13) , BT_AUDIO_LOCATION_TOP_FRONT_CENTER = BIT(14) ,
  BT_AUDIO_LOCATION_TOP_CENTER = BIT(15) , BT_AUDIO_LOCATION_TOP_BACK_LEFT = BIT(16) , BT_AUDIO_LOCATION_TOP_BACK_RIGHT = BIT(17) , BT_AUDIO_LOCATION_TOP_SIDE_LEFT = BIT(18) ,
  BT_AUDIO_LOCATION_TOP_SIDE_RIGHT = BIT(19) , BT_AUDIO_LOCATION_TOP_BACK_CENTER = BIT(20) , BT_AUDIO_LOCATION_BOTTOM_FRONT_CENTER = BIT(21) , BT_AUDIO_LOCATION_BOTTOM_FRONT_LEFT = BIT(22) ,
  BT_AUDIO_LOCATION_BOTTOM_FRONT_RIGHT = BIT(23) , BT_AUDIO_LOCATION_FRONT_LEFT_WIDE = BIT(24) , BT_AUDIO_LOCATION_FRONT_RIGHT_WIDE = BIT(25) , BT_AUDIO_LOCATION_LEFT_SURROUND = BIT(26) ,
  BT_AUDIO_LOCATION_RIGHT_SURROUND = BIT(27)
}
 Location values for BT Audio. More...
 
enum  bt_audio_dir { BT_AUDIO_DIR_SINK = 0x01 , BT_AUDIO_DIR_SOURCE = 0x02 }
 Audio Capability type. More...
 
enum  bt_audio_codec_qos_framing { BT_AUDIO_CODEC_QOS_FRAMING_UNFRAMED = 0x00 , BT_AUDIO_CODEC_QOS_FRAMING_FRAMED = 0x01 }
 Codec QoS Framing. More...
 
enum  { BT_AUDIO_CODEC_QOS_1M = BIT(0) , BT_AUDIO_CODEC_QOS_2M = BIT(1) , BT_AUDIO_CODEC_QOS_CODED = BIT(2) }
 Codec QoS Preferred PHY. More...
 

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_codec_cfg_freq_to_freq_hz (enum bt_audio_codec_config_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_config_freq freq)
 Set the frequency of a codec configuration.
 
int bt_audio_codec_cfg_get_frame_duration_us (const struct bt_audio_codec_cfg *codec_cfg)
 Extract frame duration from BT codec config.
 
int bt_audio_codec_cfg_get_chan_allocation (const struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_location *chan_allocation)
 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 blockss 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.
 
uint8_t bt_audio_codec_cfg_get_val (const struct bt_audio_codec_cfg *codec_cfg, uint8_t 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, uint8_t type, const uint8_t *data, size_t data_len)
 Set or add 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_get_pref_context (const struct bt_audio_codec_cfg *codec_cfg)
 Extract preferred contexts.
 
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_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_get_stream_lang (const struct bt_audio_codec_cfg *codec_cfg)
 Extract stream language.
 
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_get_parental_rating (const struct bt_audio_codec_cfg *codec_cfg)
 Extract parental rating.
 
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_get_audio_active_state (const struct bt_audio_codec_cfg *codec_cfg)
 Extract audio active state.
 
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_get_extended (const struct bt_audio_codec_cfg *codec_cfg, const uint8_t **extended_meta)
 Extract extended 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.
 
uint8_t bt_audio_codec_cap_get_val (const struct bt_audio_codec_cap *codec_cap, uint8_t type, const uint8_t **data)
 Lookup a specific value based on type.
 
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_get_frame_duration (const struct bt_audio_codec_cap *codec_cap)
 Extract the frequency from a codec capability.
 
int bt_audio_codec_cap_get_supported_audio_chan_counts (const struct bt_audio_codec_cap *codec_cap)
 Extract the frequency from 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 frequency from a codec capability.
 
int bt_audio_codec_cap_get_max_codec_frames_per_sdu (const struct bt_audio_codec_cap *codec_cap)
 Extract the frequency from 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_get_pref_context (const struct bt_audio_codec_cap *codec_cap)
 Extract preferred contexts.
 
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_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_get_stream_lang (const struct bt_audio_codec_cap *codec_cap)
 Extract stream language.
 
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_get_parental_rating (const struct bt_audio_codec_cap *codec_cap)
 Extract parental rating.
 
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_get_audio_active_state (const struct bt_audio_codec_cap *codec_cap)
 Extract audio active state.
 
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_get_extended (const struct bt_audio_codec_cap *codec_cap, const uint8_t **extended_meta)
 Extract extended 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.
 

Detailed Description

Bluetooth Audio handling.