Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Bluetooth Audio

Bluetooth Audio. More...

Topics

 Assigned numbers to string API
 Assigned numbers to string API.
 Codec capability parsing APIs
 Audio codec capabilities APIs.
 Codec config parsing APIs
 Audio codec Config APIs.

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_LANG_SIZE   3
 Size of the stream language value, e.g.
#define BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT(...)
 Channel count support capability.
#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.

Enumerations

enum  bt_audio_codec_cfg_target_latency { BT_AUDIO_CODEC_CFG_TARGET_LATENCY_LOW = 0x01 , BT_AUDIO_CODEC_CFG_TARGET_LATENCY_BALANCED = 0x02 , BT_AUDIO_CODEC_CFG_TARGET_LATENCY_HIGH = 0x03 }
 Codec configuration target latency. More...
enum  bt_audio_codec_cfg_target_phy { BT_AUDIO_CODEC_CFG_TARGET_PHY_1M = 0x01 , BT_AUDIO_CODEC_CFG_TARGET_PHY_2M = 0x02 , BT_AUDIO_CODEC_CFG_TARGET_PHY_CODED = 0x03 }
 Codec configuration target PHY. More...
enum  bt_audio_dir { BT_AUDIO_DIR_SINK = 0x01 , BT_AUDIO_DIR_SOURCE = 0x02 }
 Audio direction from the perspective of the BAP Unicast Server / BAP Broadcast Sink. 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_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.

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.

Detailed Description

Bluetooth Audio.

Macro Definition Documentation

◆ BT_AUDIO_BROADCAST_ID_MAX

#define BT_AUDIO_BROADCAST_ID_MAX   0xFFFFFFU

#include <zephyr/bluetooth/audio/audio.h>

Maximum broadcast ID value.

◆ BT_AUDIO_BROADCAST_ID_SIZE

#define BT_AUDIO_BROADCAST_ID_SIZE   3

#include <zephyr/bluetooth/audio/audio.h>

Size of the broadcast ID in octets.

◆ BT_AUDIO_CODEC_CAP

#define BT_AUDIO_CODEC_CAP ( _id,
_cid,
_vid,
_data,
_meta )

#include <zephyr/bluetooth/audio/audio.h>

Value:
((struct bt_audio_codec_cap){ \
/* Use HCI data path as default, can be overwritten by application */ \
.path_id = BT_ISO_DATA_PATH_HCI, \
.ctlr_transcode = false, \
.id = (_id), \
.cid = (_cid), \
.vid = (_vid), \
.data_len = sizeof((uint8_t[])_data), \
.data = _data, \
.meta_len = sizeof((uint8_t[])_meta), \
.meta = _meta, \
})
#define BT_ISO_DATA_PATH_HCI
Value to set the ISO data path over HCi.
Definition iso.h:70
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Codec capability structure.
Definition audio.h:160

Helper to declare Codec capability parsing APIs structure.

Parameters
_idCodec ID
_cidCompany ID
_vidVendor ID
_dataCodec Specific Data in LVT format
_metaCodec Specific Metadata in LVT format

◆ BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT

#define BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT ( ...)

#include <zephyr/bluetooth/audio/audio.h>

Value:
((enum bt_audio_codec_cap_chan_count)((FOR_EACH(BIT, (|), __VA_ARGS__)) >> 1))
bt_audio_codec_cap_chan_count
Supported audio capabilities channel count bitfield.
Definition assigned_numbers.h:1029
#define FOR_EACH(F, sep,...)
Call a macro F on each provided argument with a given separator between each call.
Definition util_macro.h:501
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44

Channel count support capability.

Macro accepts variable number of channel counts. The allowed channel counts are defined by specification and have to be in range from BT_AUDIO_CODEC_CAP_CHAN_COUNT_MIN to BT_AUDIO_CODEC_CAP_CHAN_COUNT_MAX inclusive.

Example to support 1 and 3 channels: BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT(1, 3)

◆ BT_AUDIO_CODEC_CFG

#define BT_AUDIO_CODEC_CFG ( _id,
_cid,
_vid,
_data,
_meta )

#include <zephyr/bluetooth/audio/audio.h>

Value:
((struct bt_audio_codec_cfg){ \
/* Use HCI data path as default, can be overwritten by application */ \
.path_id = BT_ISO_DATA_PATH_HCI, \
.ctlr_transcode = false, \
COND_CODE_1(IS_ENABLED(CONFIG_BT_BAP_UNICAST), \
()) \
.id = _id, \
.cid = _cid, \
.vid = _vid, \
.data_len = sizeof((uint8_t[])_data), \
.data = _data, \
.meta_len = sizeof((uint8_t[])_meta), \
.meta = _meta, \
})
@ BT_AUDIO_CODEC_CFG_TARGET_LATENCY_BALANCED
Target balanced latency.
Definition audio.h:204
@ BT_AUDIO_CODEC_CFG_TARGET_PHY_2M
LE 2M PHY.
Definition audio.h:220
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:148
Codec specific configuration structure.
Definition audio.h:227

Helper to declare Codec config parsing APIs.

Parameters
_idCodec ID
_cidCompany ID
_vidVendor ID
_dataCodec Specific Data in LVT format
_metaCodec Specific Metadata in LVT format

◆ BT_AUDIO_CODEC_DATA

#define BT_AUDIO_CODEC_DATA ( _type,
_bytes... )

#include <zephyr/bluetooth/audio/audio.h>

Value:
(sizeof((uint8_t)_type) + sizeof((uint8_t[]){_bytes})), (_type), _bytes

Helper to declare elements of bt_audio_codec_cap arrays.

This macro is mainly for creating an array of struct bt_audio_codec_cap data arrays.

Parameters
_typeType of advertising data field
_bytesVariable number of single-byte parameters

◆ BT_AUDIO_LANG_SIZE

#define BT_AUDIO_LANG_SIZE   3

#include <zephyr/bluetooth/audio/audio.h>

Size of the stream language value, e.g.

"eng"

◆ BT_AUDIO_METADATA_TYPE_IS_KNOWN

#define BT_AUDIO_METADATA_TYPE_IS_KNOWN ( _type)

#include <zephyr/bluetooth/audio/audio.h>

Value:
@ BT_AUDIO_METADATA_TYPE_EXTENDED
Extended metadata.
Definition assigned_numbers.h:1350
@ BT_AUDIO_METADATA_TYPE_VENDOR
Vendor specific metadata.
Definition assigned_numbers.h:1353
@ BT_AUDIO_METADATA_TYPE_BROADCAST_IMMEDIATE
Broadcast Audio Immediate Rendering flag.
Definition assigned_numbers.h:1337
@ BT_AUDIO_METADATA_TYPE_PREF_CONTEXT
Preferred audio context.
Definition assigned_numbers.h:1291
#define IN_RANGE(val, min, max)
Checks if a value is within range.
Definition util.h:554

Helper to check whether metadata type is known by the stack.

Note
_type is evaluated thrice.

◆ BT_AUDIO_PD_MAX

#define BT_AUDIO_PD_MAX   0xFFFFFFU

#include <zephyr/bluetooth/audio/audio.h>

Maximum presentation delay in microseconds.

◆ BT_AUDIO_PD_PREF_NONE

#define BT_AUDIO_PD_PREF_NONE   0x000000U

#include <zephyr/bluetooth/audio/audio.h>

Indicates that the server have no preference for the presentation delay.

◆ BT_AUDIO_RTN_PREF_NONE

#define BT_AUDIO_RTN_PREF_NONE   0xFFU

#include <zephyr/bluetooth/audio/audio.h>

Indicates that the unicast server does not have a preference for any retransmission number.

◆ BT_AUDIO_UNICAST_ANNOUNCEMENT_GENERAL

#define BT_AUDIO_UNICAST_ANNOUNCEMENT_GENERAL   0x00

#include <zephyr/bluetooth/audio/audio.h>

Unicast Server is connectable and is requesting a connection.

◆ BT_AUDIO_UNICAST_ANNOUNCEMENT_TARGETED

#define BT_AUDIO_UNICAST_ANNOUNCEMENT_TARGETED   0x01

#include <zephyr/bluetooth/audio/audio.h>

Unicast Server is connectable but is not requesting a connection.

Enumeration Type Documentation

◆ bt_audio_codec_cfg_target_latency

#include <zephyr/bluetooth/audio/audio.h>

Codec configuration target latency.

Set by the BAP Unicast Client to provide context for the BAP Unicast Server for the server to set its QoS preferences.

Enumerator
BT_AUDIO_CODEC_CFG_TARGET_LATENCY_LOW 

Target low latency.

BT_AUDIO_CODEC_CFG_TARGET_LATENCY_BALANCED 

Target balanced latency.

BT_AUDIO_CODEC_CFG_TARGET_LATENCY_HIGH 

Target high latency.

◆ bt_audio_codec_cfg_target_phy

#include <zephyr/bluetooth/audio/audio.h>

Codec configuration target PHY.

The target PHY to achieve the target latency (bt_audio_codec_cfg_target_latency).

Enumerator
BT_AUDIO_CODEC_CFG_TARGET_PHY_1M 

LE 1M PHY.

BT_AUDIO_CODEC_CFG_TARGET_PHY_2M 

LE 2M PHY.

BT_AUDIO_CODEC_CFG_TARGET_PHY_CODED 

LE Coded PHY.

◆ bt_audio_dir

#include <zephyr/bluetooth/audio/audio.h>

Audio direction from the perspective of the BAP Unicast Server / BAP Broadcast Sink.

Enumerator
BT_AUDIO_DIR_SINK 

Audio direction sink.

For a BAP Unicast Client or Broadcast Source this is considered outgoing audio (TX). For a BAP Unicast Server or Broadcast Sink this is considered incoming audio (RX).

BT_AUDIO_DIR_SOURCE 

Audio direction source.

For a BAP Unicast Client or Broadcast Source this is considered incoming audio (RX). For a BAP Unicast Server or Broadcast Sink this is considered outgoing audio (TX).

Function Documentation

◆ bt_audio_data_get_val()

int bt_audio_data_get_val ( const uint8_t ltv_data[],
size_t size,
uint8_t type,
const uint8_t ** data )

#include <zephyr/bluetooth/audio/audio.h>

Get the value of a specific data type in an length-type-value data array.

Parameters
[in]ltv_dataThe array containing the length-type-value tuples
[in]sizeThe size of ltv_data
[in]typeThe type to get the value for. May be any type, but typically either bt_audio_codec_cap_type, bt_audio_codec_cfg_type or bt_audio_metadata_type.
[out]dataPointer to the data-pointer to update when item is found. Any found data will be little endian.
Return values
lengthThe length of found data (may be 0).
-EINVALArguments are invalid
-ENODATAData not found

◆ bt_audio_data_parse()

int bt_audio_data_parse ( const uint8_t ltv[],
size_t size,
bool(* func )(struct bt_data *data, void *user_data),
void * user_data )

#include <zephyr/bluetooth/audio/audio.h>

Helper for parsing length-type-value data.

Parameters
ltvLength-type-value (LTV) encoded data.
sizeSize of the ltv data.
funcCallback function which will be called for each element that's found in the data. The callback should return true to continue parsing, or false to stop parsing.
user_dataUser data to be passed to the callback.
Return values
0All entries were parsed.
-EINVALThe data is incorrectly encoded
-ECANCELEDParsing was prematurely cancelled by the callback

◆ bt_audio_get_chan_count()

uint8_t bt_audio_get_chan_count ( enum bt_audio_location chan_allocation)

#include <zephyr/bluetooth/audio/audio.h>

Function to get the number of channels from the channel allocation.

Parameters
chan_allocationThe channel allocation
Returns
The number of channels