Zephyr Project API  3.3.0
A Scalable Open Source RTOS
Codec config parsing APIs

Audio codec Config APIs. More...

Enumerations

enum  bt_audio_codec_parse_err { BT_AUDIO_CODEC_PARSE_ERR_SUCCESS = 0 , BT_AUDIO_CODEC_PARSE_ERR_TYPE_NOT_FOUND = -1 , BT_AUDIO_CODEC_PARSE_ERR_INVALID_VALUE_FOUND = -2 , BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM = -3 }
 Codec parser error codes for Codec config parsing APIs. More...
 

Functions

int bt_codec_cfg_get_freq (const struct bt_codec *codec)
 Extract the frequency from a codec configuration. More...
 
int bt_codec_cfg_get_frame_duration_us (const struct bt_codec *codec)
 Extract frame duration from BT codec config. More...
 
int bt_codec_cfg_get_chan_allocation_val (const struct bt_codec *codec, uint32_t *chan_allocation)
 Extract channel allocation from BT codec config. More...
 
int bt_codec_cfg_get_octets_per_frame (const struct bt_codec *codec)
 Extract frame size in octets from BT codec config. More...
 
int bt_codec_cfg_get_frame_blocks_per_sdu (const struct bt_codec *codec, bool fallback_to_default)
 Extract number of audio frame blockss in each SDU from BT codec config. More...
 
bool bt_codec_get_val (const struct bt_codec *codec, uint8_t type, const struct bt_codec_data **data)
 Lookup a specific value based on type. More...
 

Detailed Description

Audio codec Config APIs.

Functions to parse codec config data when formatted as LTV wrapped into bt_codec.

Enumeration Type Documentation

◆ bt_audio_codec_parse_err

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

Codec parser error codes for Codec config parsing APIs.

Enumerator
BT_AUDIO_CODEC_PARSE_ERR_SUCCESS 

The requested type is not present in the data set.

BT_AUDIO_CODEC_PARSE_ERR_TYPE_NOT_FOUND 

The requested type is not present in the data set.

BT_AUDIO_CODEC_PARSE_ERR_INVALID_VALUE_FOUND 

The value found is invalid.

BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM 

The parameters specified to the function call are not valid.

Function Documentation

◆ bt_codec_cfg_get_chan_allocation_val()

int bt_codec_cfg_get_chan_allocation_val ( const struct bt_codec codec,
uint32_t chan_allocation 
)

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

Extract channel allocation from BT codec config.

The value returned is a bit field representing one or more audio locations as specified by bt_audio_location Shall match one or more of the bits set in BT_PAC_SNK_LOC/BT_PAC_SRC_LOC.

Up to the configured BT_CODEC_LC3_CHAN_COUNT number of channels can be present.

Parameters
codecThe codec configuration to extract data from.
chan_allocationPointer to the variable to store the extracted value in.
Returns
BT_AUDIO_CODEC_PARSE_SUCCESS if value is found and stored in the pointer provided else a negative value of type bt_audio_codec_parse_err.

◆ bt_codec_cfg_get_frame_blocks_per_sdu()

int bt_codec_cfg_get_frame_blocks_per_sdu ( const struct bt_codec codec,
bool  fallback_to_default 
)

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

Extract number of audio frame blockss in each SDU from BT codec config.

The overall SDU size will be octets_per_frame * frame_blocks_per_sdu * number-of-channels.

If this value is not present a default value of 1 shall be used.

A frame block is one or more frames that represents data for the same period of time but for different channels. If the stream have two audio channels and this value is two there will be four frames in the SDU.

Parameters
codecThe codec configuration to extract data from.
fallback_to_defaultIf true this function will return the default value of 1 if the type is not found. In this case the function will only fail if a NULL pointer is provided.
Returns
The count of codec frames in each SDU if value is found else a negative value of type bt_audio_codec_parse_err - unless when fallback_to_default is true then the value 1 is returned if frames per sdu is not found.

◆ bt_codec_cfg_get_frame_duration_us()

int bt_codec_cfg_get_frame_duration_us ( const struct bt_codec codec)

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

Extract frame duration from BT codec config.

Parameters
codecThe codec configuration to extract data from.
Returns
Frame duration in microseconds if value is found else a negative value of type bt_audio_codec_parse_err.

◆ bt_codec_cfg_get_freq()

int bt_codec_cfg_get_freq ( const struct bt_codec codec)

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

Extract the frequency from a codec configuration.

Parameters
codecThe codec configuration to extract data from.
Returns
The frequency in Hz if found else a negative value of type bt_audio_codec_parse_err.

◆ bt_codec_cfg_get_octets_per_frame()

int bt_codec_cfg_get_octets_per_frame ( const struct bt_codec codec)

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

Extract frame size in octets from BT codec config.

The overall SDU size will be octets_per_frame * blocks_per_sdu.

The Bluetooth specificationa are not clear about this value - it does not state that the codec shall use this SDU size only. A codec like LC3 supports variable bit-rate (per SDU) hence it might be allowed for an encoder to reduce the frame size below this value. Hence it is recommended to use the received SDU size and divide by blocks_per_sdu rather than relying on this octets_per_sdu value to be fixed.

Parameters
codecThe codec configuration to extract data from.
Returns
Frame length in octets if value is found else a negative value of type bt_audio_codec_parse_err.

◆ bt_codec_get_val()

bool bt_codec_get_val ( const struct bt_codec codec,
uint8_t  type,
const struct bt_codec_data **  data 
)

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

Lookup a specific value based on type.

Depending on context bt_codec will be either codec capabilities, codec configuration or meta data.

Typically types used are: bt_codec_capability_type bt_codec_config_type bt_audio_metadata_type

Parameters
codecThe codec data to search in.
typeThe type id to look for
dataPointer to the data-pointer to update when item is found
Returns
True if the type is found, false otherwise.