diff --git a/include/zephyr/bluetooth/audio/audio.h b/include/zephyr/bluetooth/audio/audio.h index 1d7995c66fee3be..2386d50235e0f19 100644 --- a/include/zephyr/bluetooth/audio/audio.h +++ b/include/zephyr/bluetooth/audio/audio.h @@ -178,29 +178,28 @@ enum bt_audio_metadata_type { #define BT_AUDIO_UNICAST_ANNOUNCEMENT_TARGETED 0x01 /** @brief Codec configuration structure */ -struct bt_codec_data { +struct bt_audio_codec_data { struct bt_data data; - uint8_t value[CONFIG_BT_CODEC_MAX_DATA_LEN]; + uint8_t value[CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN]; }; /** - * @brief Helper to declare elements of bt_codec_data arrays + * @brief Helper to declare elements of bt_audio_codec_data arrays * - * This macro is mainly for creating an array of struct bt_codec_data - * elements inside bt_codec which is then passed to the likes of - * bt_bap_stream_config or bt_bap_stream_reconfig. + * This macro is mainly for creating an array of struct bt_audio_codec_data elements which is then + * passed to the likes of bt_bap_stream_config() or bt_bap_stream_reconfig(). * * @param _type Type of advertising data field * @param _bytes Variable number of single-byte parameters */ -#define BT_CODEC_DATA(_type, _bytes...) \ +#define BT_AUDIO_CODEC_DATA(_type, _bytes...) \ { \ - .data = BT_DATA(_type, ((uint8_t []) { _bytes }), \ - sizeof((uint8_t []) { _bytes })) \ + .data = BT_DATA(_type, ((uint8_t[]){_bytes}), \ + sizeof((uint8_t[]){_bytes})) \ } /** - * @brief Helper to declare bt_codec structure + * @brief Helper to declare @ref bt_audio_codec_cfg or @ref bt_audio_codec_cap structure * * @param _id Codec ID * @param _cid Company ID @@ -208,16 +207,16 @@ struct bt_codec_data { * @param _data Codec Specific Data in LVT format * @param _meta Codec Specific Metadata in LVT format */ -#define BT_CODEC(_id, _cid, _vid, _data, _meta) \ +#define BT_AUDIO_CODEC(_id, _cid, _vid, _data, _meta) \ { \ /* Use HCI data path as default, can be overwritten by application */ \ .path_id = BT_ISO_DATA_PATH_HCI, \ .id = _id, \ .cid = _cid, \ .vid = _vid, \ - .data_count = ARRAY_SIZE(((struct bt_codec_data[]) _data)), \ + .data_count = ARRAY_SIZE(((struct bt_audio_codec_data[])_data)), \ .data = _data, \ - .meta_count = ARRAY_SIZE(((struct bt_codec_data[]) _meta)), \ + .meta_count = ARRAY_SIZE(((struct bt_audio_codec_data[])_meta)), \ .meta = _meta, \ } @@ -289,8 +288,36 @@ enum bt_audio_location { BT_AUDIO_LOCATION_LEFT_SURROUND | \ BT_AUDIO_LOCATION_RIGHT_SURROUND) -/** @brief Codec structure. */ -struct bt_codec { +/** @brief Codec capability structure. */ +struct bt_audio_codec_cap { + /** Data path ID + * + * @ref BT_ISO_DATA_PATH_HCI for HCI path, or any other value for + * vendor specific ID. + */ + uint8_t path_id; + /** Codec ID */ + uint8_t id; + /** Codec Company ID */ + uint16_t cid; + /** Codec Company Vendor ID */ + uint16_t vid; +#if defined(CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_COUNT) + /** Codec Specific Capabilities Data count */ + size_t data_count; + /** Codec Specific Capabilities Data */ + struct bt_audio_codec_data data[CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_COUNT]; +#endif /* CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_COUNT */ +#if defined(CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_COUNT) + /** Codec Specific Capabilities Metadata count */ + size_t meta_count; + /** Codec Specific Capabilities Metadata */ + struct bt_audio_codec_data meta[CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_COUNT]; +#endif /* CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_COUNT */ +}; + +/** @brief Codec specific configuration structure. */ +struct bt_audio_codec_cfg { /** Data path ID * * @ref BT_ISO_DATA_PATH_HCI for HCI path, or any other value for @@ -303,18 +330,18 @@ struct bt_codec { uint16_t cid; /** Codec Company Vendor ID */ uint16_t vid; -#if defined(CONFIG_BT_CODEC_MAX_DATA_COUNT) - /** Codec Specific Data count */ +#if defined(CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT) + /** Codec Specific Configuration Data count */ size_t data_count; - /** Codec Specific Data */ - struct bt_codec_data data[CONFIG_BT_CODEC_MAX_DATA_COUNT]; -#endif /* CONFIG_BT_CODEC_MAX_DATA_COUNT */ -#if defined(CONFIG_BT_CODEC_MAX_METADATA_COUNT) - /** Codec Specific Metadata count */ + /** Codec Specific Configuration Data */ + struct bt_audio_codec_data data[CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT]; +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT */ +#if defined(CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT) + /** Codec Specific Configuration Metadata count */ size_t meta_count; - /** Codec Specific Metadata */ - struct bt_codec_data meta[CONFIG_BT_CODEC_MAX_METADATA_COUNT]; -#endif /* CONFIG_BT_CODEC_MAX_METADATA_COUNT */ + /** Codec Specific Configuration Metadata */ + struct bt_audio_codec_data meta[CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT]; +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT */ }; /** @brief Audio Capability type */ @@ -324,7 +351,7 @@ enum bt_audio_dir { }; /** - * @brief Helper to declare elements of bt_codec_qos + * @brief Helper to declare elements of bt_audio_codec_qos * * @param _interval SDU interval (usec) * @param _framing Framing @@ -334,8 +361,7 @@ enum bt_audio_dir { * @param _latency Maximum Transport Latency (msec) * @param _pd Presentation Delay (usec) */ -#define BT_CODEC_QOS(_interval, _framing, _phy, _sdu, _rtn, _latency, \ - _pd) \ +#define BT_AUDIO_CODEC_QOS(_interval, _framing, _phy, _sdu, _rtn, _latency, _pd) \ { \ .interval = _interval, \ .framing = _framing, \ @@ -348,19 +374,19 @@ enum bt_audio_dir { /** @brief Codec QoS Framing */ enum { - BT_CODEC_QOS_UNFRAMED = 0x00, - BT_CODEC_QOS_FRAMED = 0x01, + BT_AUDIO_CODEC_QOS_UNFRAMED = 0x00, + BT_AUDIO_CODEC_QOS_FRAMED = 0x01, }; /** @brief Codec QoS Preferred PHY */ enum { - BT_CODEC_QOS_1M = BIT(0), - BT_CODEC_QOS_2M = BIT(1), - BT_CODEC_QOS_CODED = BIT(2), + BT_AUDIO_CODEC_QOS_1M = BIT(0), + BT_AUDIO_CODEC_QOS_2M = BIT(1), + BT_AUDIO_CODEC_QOS_CODED = BIT(2), }; /** - * @brief Helper to declare Input Unframed bt_codec_qos + * @brief Helper to declare Input Unframed bt_audio_codec_qos * * @param _interval SDU interval (usec) * @param _sdu Maximum SDU Size @@ -368,12 +394,12 @@ enum { * @param _latency Maximum Transport Latency (msec) * @param _pd Presentation Delay (usec) */ -#define BT_CODEC_QOS_UNFRAMED(_interval, _sdu, _rtn, _latency, _pd) \ - BT_CODEC_QOS(_interval, BT_CODEC_QOS_UNFRAMED, BT_CODEC_QOS_2M, _sdu, \ - _rtn, _latency, _pd) +#define BT_AUDIO_CODEC_QOS_UNFRAMED(_interval, _sdu, _rtn, _latency, _pd) \ + BT_AUDIO_CODEC_QOS(_interval, BT_AUDIO_CODEC_QOS_UNFRAMED, BT_AUDIO_CODEC_QOS_2M, _sdu, \ + _rtn, _latency, _pd) /** - * @brief Helper to declare Input Framed bt_codec_qos + * @brief Helper to declare Input Framed bt_audio_codec_qos * * @param _interval SDU interval (usec) * @param _sdu Maximum SDU Size @@ -381,12 +407,12 @@ enum { * @param _latency Maximum Transport Latency (msec) * @param _pd Presentation Delay (usec) */ -#define BT_CODEC_QOS_FRAMED(_interval, _sdu, _rtn, _latency, _pd) \ - BT_CODEC_QOS(_interval, BT_CODEC_QOS_FRAMED, BT_CODEC_QOS_2M, _sdu, \ - _rtn, _latency, _pd) +#define BT_AUDIO_CODEC_QOS_FRAMED(_interval, _sdu, _rtn, _latency, _pd) \ + BT_AUDIO_CODEC_QOS(_interval, BT_AUDIO_CODEC_QOS_FRAMED, BT_AUDIO_CODEC_QOS_2M, _sdu, \ + _rtn, _latency, _pd) /** @brief Codec QoS structure. */ -struct bt_codec_qos { +struct bt_audio_codec_qos { /** QoS PHY */ uint8_t phy; @@ -419,7 +445,7 @@ struct bt_codec_qos { }; /** - * @brief Helper to declare elements of @ref bt_codec_qos_pref + * @brief Helper to declare elements of @ref bt_audio_codec_qos_pref * * @param _unframed_supported Unframed PDUs supported * @param _phy Preferred Target PHY @@ -430,21 +456,16 @@ struct bt_codec_qos { * @param _pref_pd_min Preferred Minimum Presentation Delay (usec) * @param _pref_pd_max Preferred Maximum Presentation Delay (usec) */ -#define BT_CODEC_QOS_PREF(_unframed_supported, _phy, _rtn, _latency, _pd_min, \ - _pd_max, _pref_pd_min, _pref_pd_max) \ - { \ - .unframed_supported = _unframed_supported, \ - .phy = _phy, \ - .rtn = _rtn, \ - .latency = _latency, \ - .pd_min = _pd_min, \ - .pd_max = _pd_max, \ - .pref_pd_min = _pref_pd_min, \ - .pref_pd_max = _pref_pd_max, \ +#define BT_AUDIO_CODEC_QOS_PREF(_unframed_supported, _phy, _rtn, _latency, _pd_min, _pd_max, \ + _pref_pd_min, _pref_pd_max) \ + { \ + .unframed_supported = _unframed_supported, .phy = _phy, .rtn = _rtn, \ + .latency = _latency, .pd_min = _pd_min, .pd_max = _pd_max, \ + .pref_pd_min = _pref_pd_min, .pref_pd_max = _pref_pd_max, \ } /** @brief Audio Stream Quality of Service Preference structure. */ -struct bt_codec_qos_pref { +struct bt_audio_codec_qos_pref { /** @brief Unframed PDUs supported * * Unlike the other fields, this is not a preference but whether @@ -494,7 +515,7 @@ struct bt_codec_qos_pref { uint32_t pref_pd_max; }; -/** @brief Turns an array of bt_codec_data to a flat LTV encoded uint8_t array +/** @brief Turns an array of bt_audio_codec_data to a flat LTV encoded uint8_t array * * The resulting @p buf array can then be used to send over air. * @@ -507,14 +528,14 @@ struct bt_codec_qos_pref { * @retval The length of the encoded data if successful. * @retval -ENOMEM if the @p codec_data did not fit into the @p buf. */ -ssize_t bt_audio_codec_data_to_buf(const struct bt_codec_data *codec_data, size_t count, +ssize_t bt_audio_codec_data_to_buf(const struct bt_audio_codec_data *codec_data, size_t count, uint8_t *buf, size_t buf_size); /** * @brief Audio codec Config APIs * @defgroup bt_audio_codec_cfg Codec config parsing APIs * - * Functions to parse codec config data when formatted as LTV wrapped into @ref bt_codec. + * Functions to parse codec config data when formatted as LTV wrapped into @ref bt_audio_codec_cfg. * * @{ */ @@ -522,7 +543,7 @@ ssize_t bt_audio_codec_data_to_buf(const struct bt_codec_data *codec_data, size_ /** * @brief Codec parser error codes for @ref bt_audio_codec_cfg. */ -enum bt_audio_codec_parse_err { +enum bt_audio_codec_cfg_parse_err { /** @brief The requested type is not present in the data set. */ BT_AUDIO_CODEC_PARSE_ERR_SUCCESS = 0, @@ -539,21 +560,21 @@ enum bt_audio_codec_parse_err { /**@brief Extract the frequency from a codec configuration. * - * @param codec The codec configuration to extract data from. + * @param codec_cfg The codec configuration to extract data from. * * @return The frequency in Hz if found else a negative value of type - * @ref bt_audio_codec_parse_err. + * @ref bt_audio_codec_cfg_parse_err. */ -int bt_codec_cfg_get_freq(const struct bt_codec *codec); +int bt_audio_codec_cfg_get_freq(const struct bt_audio_codec_cfg *codec_cfg); /** @brief Extract frame duration from BT codec config * - * @param codec The codec configuration to extract data from. + * @param codec_cfg The codec configuration to extract data from. * * @return Frame duration in microseconds if value is found else a negative value - * of type @ref bt_audio_codec_parse_err. + * of type @ref bt_audio_codec_cfg_parse_err. */ -int bt_codec_cfg_get_frame_duration_us(const struct bt_codec *codec); +int bt_audio_codec_cfg_get_frame_duration_us(const struct bt_audio_codec_cfg *codec_cfg); /** @brief Extract channel allocation from BT codec config * @@ -561,16 +582,16 @@ int bt_codec_cfg_get_frame_duration_us(const struct bt_codec *codec); * specified by @ref 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 @ref BT_CODEC_LC3_CHAN_COUNT number of channels can be present. + * Up to the configured @ref BT_AUDIO_CODEC_LC3_CHAN_COUNT number of channels can be present. * - * @param codec The codec configuration to extract data from. + * @param codec_cfg The codec configuration to extract data from. * @param chan_allocation Pointer to the variable to store the extracted value in. * * @return BT_AUDIO_CODEC_PARSE_SUCCESS if value is found and stored in the pointer provided - * else a negative value of type @ref bt_audio_codec_parse_err. + * else a negative value of type @ref bt_audio_codec_cfg_parse_err. */ -int bt_codec_cfg_get_chan_allocation_val(const struct bt_codec *codec, - enum bt_audio_location *chan_allocation); +int bt_audio_codec_cfg_get_chan_allocation_val(const struct bt_audio_codec_cfg *codec_cfg, + enum bt_audio_location *chan_allocation); /** @brief Extract frame size in octets from BT codec config * @@ -583,12 +604,12 @@ int bt_codec_cfg_get_chan_allocation_val(const struct bt_codec *codec, * 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. * - * @param codec The codec configuration to extract data from. + * @param codec_cfg The codec configuration to extract data from. * * @return Frame length in octets if value is found else a negative value - * of type @ref bt_audio_codec_parse_err. + * of type @ref bt_audio_codec_cfg_parse_err. */ -int bt_codec_cfg_get_octets_per_frame(const struct bt_codec *codec); +int bt_audio_codec_cfg_get_octets_per_frame(const struct bt_audio_codec_cfg *codec_cfg); /** @brief Extract number of audio frame blockss in each SDU from BT codec config * @@ -600,35 +621,35 @@ int bt_codec_cfg_get_octets_per_frame(const struct bt_codec *codec); * for different channels. If the stream have two audio channels and this value is two * there will be four frames in the SDU. * - * @param codec The codec configuration to extract data from. + * @param codec_cfg The codec configuration to extract data from. * @param fallback_to_default If 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. * * @return The count of codec frames in each SDU if value is found else a negative value - * of type @ref bt_audio_codec_parse_err - unless when \p fallback_to_default is true + * of type @ref bt_audio_codec_cfg_parse_err - unless when \p fallback_to_default is true * then the value 1 is returned if frames per sdu is not found. */ -int bt_codec_cfg_get_frame_blocks_per_sdu(const struct bt_codec *codec, bool fallback_to_default); +int bt_audio_codec_cfg_get_frame_blocks_per_sdu(const struct bt_audio_codec_cfg *codec_cfg, + bool fallback_to_default); /** @brief Lookup a specific value based on type * - * Depending on context bt_codec will be either codec capabilities, codec configuration or - * meta data. + * Depending on context bt_audio_codec_cfg will be either codec capabilities, codec configuration + * or meta data. * * Typically types used are: - * @ref bt_codec_capability_type - * @ref bt_codec_config_type + * @ref bt_audio_codec_capability_type + * @ref bt_audio_codec_config_type * @ref bt_audio_metadata_type * - * @param codec The codec data to search in. + * @param codec_cfg The codec data to search in. * @param type The type id to look for * @param data Pointer to the data-pointer to update when item is found * @return True if the type is found, false otherwise. */ -bool bt_codec_get_val(const struct bt_codec *codec, - uint8_t type, - const struct bt_codec_data **data); +bool bt_audio_codec_cfg_get_val(const struct bt_audio_codec_cfg *codec_cfg, uint8_t type, + const struct bt_audio_codec_data **data); /** @} */ /* End of bt_audio_codec_cfg */ diff --git a/include/zephyr/bluetooth/audio/bap.h b/include/zephyr/bluetooth/audio/bap.h index c1a0c021b0cfabb..eb5829a67b885d9 100644 --- a/include/zephyr/bluetooth/audio/bap.h +++ b/include/zephyr/bluetooth/audio/bap.h @@ -455,10 +455,10 @@ struct bt_bap_stream { struct bt_bap_ep *ep; /** Codec Configuration */ - struct bt_codec *codec; + struct bt_audio_codec_cfg *codec_cfg; /** QoS Configuration */ - struct bt_codec_qos *qos; + struct bt_audio_codec_qos *qos; /** Audio stream operations */ struct bt_bap_stream_ops *ops; @@ -493,7 +493,8 @@ struct bt_bap_stream_ops { * @param stream Stream object that has been configured. * @param pref Remote QoS preferences. */ - void (*configured)(struct bt_bap_stream *stream, const struct bt_codec_qos_pref *pref); + void (*configured)(struct bt_bap_stream *stream, + const struct bt_audio_codec_qos_pref *pref); /** * @brief Stream QoS set callback @@ -614,12 +615,12 @@ void bt_bap_stream_cb_register(struct bt_bap_stream *stream, struct bt_bap_strea * @param conn Connection object * @param stream Stream object being configured * @param ep Remote Audio Endpoint being configured - * @param codec Codec configuration + * @param codec_cfg Codec configuration * * @return Allocated Audio Stream object or NULL in case of error. */ int bt_bap_stream_config(struct bt_conn *conn, struct bt_bap_stream *stream, struct bt_bap_ep *ep, - struct bt_codec *codec); + struct bt_audio_codec_cfg *codec_cfg); /** * @brief Reconfigure Audio Stream @@ -630,11 +631,11 @@ int bt_bap_stream_config(struct bt_conn *conn, struct bt_bap_stream *stream, str * This can only be done for unicast streams. * * @param stream Stream object being reconfigured - * @param codec Codec configuration + * @param codec_cfg Codec configuration * * @return 0 in case of success or negative value in case of error. */ -int bt_bap_stream_reconfig(struct bt_bap_stream *stream, struct bt_codec *codec); +int bt_bap_stream_reconfig(struct bt_bap_stream *stream, struct bt_audio_codec_cfg *codec_cfg); /** * @brief Configure Audio Stream QoS @@ -664,7 +665,7 @@ int bt_bap_stream_qos(struct bt_conn *conn, struct bt_bap_unicast_group *group); * * @return 0 in case of success or negative value in case of error. */ -int bt_bap_stream_enable(struct bt_bap_stream *stream, struct bt_codec_data *meta, +int bt_bap_stream_enable(struct bt_bap_stream *stream, struct bt_audio_codec_data *meta, size_t meta_count); /** @@ -678,7 +679,7 @@ int bt_bap_stream_enable(struct bt_bap_stream *stream, struct bt_codec_data *met * * @return 0 in case of success or negative value in case of error. */ -int bt_bap_stream_metadata(struct bt_bap_stream *stream, struct bt_codec_data *meta, +int bt_bap_stream_metadata(struct bt_bap_stream *stream, struct bt_audio_codec_data *meta, size_t meta_count); /** @@ -787,21 +788,21 @@ struct bt_bap_unicast_server_cb { * Config callback is called whenever an endpoint is requested to be * configured * - * @param[in] conn Connection object. - * @param[in] ep Local Audio Endpoint being configured. - * @param[in] dir Direction of the endpoint. - * @param[in] codec Codec configuration. - * @param[out] stream Pointer to stream that will be configured for the endpoint. - * @param[out] pref Pointer to a QoS preference object that shall be populated with - * values. Invalid values will reject the codec configuration request. - * @param[out] rsp Object for the ASE operation response. Only used if the return - * value is non-zero. + * @param[in] conn Connection object. + * @param[in] ep Local Audio Endpoint being configured. + * @param[in] dir Direction of the endpoint. + * @param[in] codec_cfg Codec configuration. + * @param[out] stream Pointer to stream that will be configured for the endpoint. + * @param[out] pref Pointer to a QoS preference object that shall be populated with + * values. Invalid values will reject the codec configuration request. + * @param[out] rsp Object for the ASE operation response. Only used if the return + * value is non-zero. * * @return 0 in case of success or negative value in case of error. */ int (*config)(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_bap_stream **stream, - struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp); + const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp); /** * @brief Stream reconfig request callback @@ -809,19 +810,19 @@ struct bt_bap_unicast_server_cb { * Reconfig callback is called whenever an Audio Stream needs to be * reconfigured with different codec configuration. * - * @param[in] stream Stream object being reconfigured. - * @param[in] dir Direction of the endpoint. - * @param[in] codec Codec configuration. - * @param[out] pref Pointer to a QoS preference object that shall be populated with - * values. Invalid values will reject the codec configuration request. - * @param[out] rsp Object for the ASE operation response. Only used if the return - * value is non-zero. + * @param[in] stream Stream object being reconfigured. + * @param[in] dir Direction of the endpoint. + * @param[in] codec_cfg Codec configuration. + * @param[out] pref Pointer to a QoS preference object that shall be populated with + * values. Invalid values will reject the codec configuration request. + * @param[out] rsp Object for the ASE operation response. Only used if the return + * value is non-zero. * * @return 0 in case of success or negative value in case of error. */ int (*reconfig)(struct bt_bap_stream *stream, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_codec_qos_pref *const pref, - struct bt_bap_ascs_rsp *rsp); + const struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp); /** * @brief Stream QoS request callback @@ -836,7 +837,7 @@ struct bt_bap_unicast_server_cb { * * @return 0 in case of success or negative value in case of error. */ - int (*qos)(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, + int (*qos)(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos, struct bt_bap_ascs_rsp *rsp); /** @@ -852,7 +853,7 @@ struct bt_bap_unicast_server_cb { * * @return 0 in case of success or negative value in case of error. */ - int (*enable)(struct bt_bap_stream *stream, const struct bt_codec_data *meta, + int (*enable)(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp); /** @@ -881,7 +882,7 @@ struct bt_bap_unicast_server_cb { * * @return 0 in case of success or negative value in case of error. */ - int (*metadata)(struct bt_bap_stream *stream, const struct bt_codec_data *meta, + int (*metadata)(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp); /** @@ -972,14 +973,14 @@ void bt_bap_unicast_server_foreach_ep(struct bt_conn *conn, bt_bap_ep_func_t fun * * @param conn Connection object * @param stream Configured stream object to be attached to the ASE - * @param codec Codec configuration + * @param codec_cfg Codec configuration * @param qos_pref Audio Stream Quality of Service Preference * * @return 0 in case of success or negative value in case of error. */ int bt_bap_unicast_server_config_ase(struct bt_conn *conn, struct bt_bap_stream *stream, - struct bt_codec *codec, - const struct bt_codec_qos_pref *qos_pref); + struct bt_audio_codec_cfg *codec_cfg, + const struct bt_audio_codec_qos_pref *qos_pref); /** @} */ /* End of group bt_bap_unicast_server */ @@ -995,7 +996,7 @@ struct bt_bap_unicast_group_stream_param { struct bt_bap_stream *stream; /** The QoS settings for the stream object. */ - struct bt_codec_qos *qos; + struct bt_audio_codec_qos *qos; }; /** @brief Parameter struct for the unicast group functions @@ -1031,7 +1032,7 @@ struct bt_bap_unicast_group_param { * @brief Create audio unicast group. * * Create a new audio unicast group with one or more audio streams as a unicast client. Streams in - * a unicast group shall share the same interval, framing and latency (see @ref bt_codec_qos). + * a unicast group shall share the same interval, framing and latency (see @ref bt_audio_codec_qos). * * @param[in] param The unicast group create parameters. * @param[out] unicast_group Pointer to the unicast group created. @@ -1224,14 +1225,14 @@ struct bt_bap_unicast_client_cb { * The @p codec is only valid while in the callback, so the values must be stored by the * receiver if future use is wanted. * - * @param conn Connection to the remote unicast server. - * @param dir The type of remote endpoints and capabilities discovered. - * @param codec Remote capabilities. + * @param conn Connection to the remote unicast server. + * @param dir The type of remote endpoints and capabilities discovered. + * @param codec_cap Remote capabilities. * * If discovery procedure has complete both @p codec and @p ep are set to NULL. */ void (*pac_record)(struct bt_conn *conn, enum bt_audio_dir dir, - const struct bt_codec *codec); + const struct bt_audio_codec_cap *codec_cap); /** * @brief Remote Audio Stream Endoint (ASE) discovered @@ -1295,18 +1296,18 @@ int bt_bap_unicast_client_discover(struct bt_conn *conn, enum bt_audio_dir dir); struct bt_bap_base_bis_data { /* Unique index of the BIS */ uint8_t index; -#if defined(CONFIG_BT_CODEC_MAX_DATA_COUNT) +#if defined(CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT) /** Codec Specific Data count. * - * Only valid if the data_count of struct bt_codec in the subgroup is 0 + * Only valid if the data_count of struct bt_audio_codec_cfg in the subgroup is 0 */ size_t data_count; /** Codec Specific Data * - * Only valid if the data_count of struct bt_codec in the subgroup is 0 + * Only valid if the data_count of struct bt_audio_codec_cfg in the subgroup is 0 */ - struct bt_codec_data data[CONFIG_BT_CODEC_MAX_DATA_COUNT]; -#endif /* CONFIG_BT_CODEC_MAX_DATA_COUNT */ + struct bt_audio_codec_data data[CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT]; +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT */ }; struct bt_bap_base_subgroup { @@ -1317,7 +1318,7 @@ struct bt_bap_base_subgroup { * If the data_count of the codec is 0, then codec specific data may be * found for each BIS in the bis_data. */ - struct bt_codec codec; + struct bt_audio_codec_cfg codec_cfg; /* Array of BIS specific data for each BIS in the subgroup */ struct bt_bap_base_bis_data bis_data[BROADCAST_SNK_STREAM_CNT]; }; @@ -1362,7 +1363,7 @@ struct bt_bap_broadcast_source_stream_param { /** Audio stream */ struct bt_bap_stream *stream; -#if CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 /** * @brief The number of elements in the @p data array. * @@ -1371,8 +1372,8 @@ struct bt_bap_broadcast_source_stream_param { size_t data_count; /** BIS Codec Specific Configuration */ - struct bt_codec_data *data; -#endif /* CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 */ + struct bt_audio_codec_data *data; +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 */ }; /** Broadcast Source subgroup parameters*/ @@ -1384,7 +1385,7 @@ struct bt_bap_broadcast_source_subgroup_param { struct bt_bap_broadcast_source_stream_param *params; /** Subgroup Codec configuration. */ - struct bt_codec *codec; + struct bt_audio_codec_cfg *codec_cfg; }; /** Broadcast Source create parameters */ @@ -1396,7 +1397,7 @@ struct bt_bap_broadcast_source_create_param { struct bt_bap_broadcast_source_subgroup_param *params; /** Quality of Service configuration. */ - struct bt_codec_qos *qos; + struct bt_audio_codec_qos *qos; /** * @brief Broadcast Source packing mode. @@ -1449,13 +1450,14 @@ int bt_bap_broadcast_source_create(struct bt_bap_broadcast_source_create_param * * service parameters. This can only be done when the source is stopped. * * @param source Pointer to the broadcast source - * @param codec Codec configuration. + * @param codec_cfg Codec configuration. * @param qos Quality of Service configuration * * @return Zero on success or (negative) error code otherwise. */ -int bt_bap_broadcast_source_reconfig(struct bt_bap_broadcast_source *source, struct bt_codec *codec, - struct bt_codec_qos *qos); +int bt_bap_broadcast_source_reconfig(struct bt_bap_broadcast_source *source, + struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos *qos); /** * @brief Modify the metadata of an audio broadcast source. @@ -1470,7 +1472,8 @@ int bt_bap_broadcast_source_reconfig(struct bt_bap_broadcast_source *source, str * @return Zero on success or (negative) error code otherwise. */ int bt_bap_broadcast_source_update_metadata(struct bt_bap_broadcast_source *source, - const struct bt_codec_data meta[], size_t meta_count); + const struct bt_audio_codec_data meta[], + size_t meta_count); /** * @brief Start audio broadcast source. diff --git a/include/zephyr/bluetooth/audio/bap_lc3_preset.h b/include/zephyr/bluetooth/audio/bap_lc3_preset.h index 0886c1804260899..bc4d0c8078e75e8 100644 --- a/include/zephyr/bluetooth/audio/bap_lc3_preset.h +++ b/include/zephyr/bluetooth/audio/bap_lc3_preset.h @@ -14,15 +14,15 @@ /** Struct to hold a BAP defined LC3 preset */ struct bt_bap_lc3_preset { /** The LC3 Codec */ - struct bt_codec codec; + struct bt_audio_codec_cfg codec_cfg; /** The BAP spec defined QoS values */ - struct bt_codec_qos qos; + struct bt_audio_codec_qos qos; }; /** Helper to declare an LC3 preset structure */ #define BT_BAP_LC3_PRESET(_codec, _qos) \ { \ - .codec = _codec, .qos = _qos, \ + .codec_cfg = _codec, .qos = _qos, \ } /* LC3 Unicast presets defined by table 5.2 in the BAP v1.0 specification */ @@ -34,8 +34,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_8_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_8_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(26u, 2u, 8u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_8_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(26u, 2u, 8u, 40000u)) /** * @brief Helper to declare LC3 Unicast 8_2_1 codec configuration @@ -44,8 +44,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_8_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_8_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(30u, 2u, 10u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_8_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(30u, 2u, 10u, 40000u)) /** * @brief Helper to declare LC3 Unicast 16_1_1 codec configuration @@ -54,8 +54,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_16_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_16_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(30u, 2u, 8u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_16_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(30u, 2u, 8u, 40000u)) /** * @brief Helper to declare LC3 Unicast 16_2_1 codec configuration @@ -66,8 +66,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_16_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_16_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(40u, 2u, 10u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_16_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(40u, 2u, 10u, 40000u)) /** * @brief Helper to declare LC3 Unicast 24_1_1 codec configuration @@ -76,8 +76,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_24_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_24_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(45u, 2u, 8u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_24_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(45u, 2u, 8u, 40000u)) /** * @brief Helper to declare LC3 Unicast 24_2_1 codec configuration @@ -88,8 +88,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_24_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_24_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(60u, 2u, 10u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_24_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(60u, 2u, 10u, 40000u)) /** * @brief Helper to declare LC3 Unicast 32_1_1 codec configuration @@ -98,8 +98,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_32_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_32_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(60u, 2u, 8u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_32_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(60u, 2u, 8u, 40000u)) /** * @brief Helper to declare LC3 Unicast 32_2_1 codec configuration @@ -108,8 +108,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_32_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_32_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(80u, 2u, 10u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_32_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(80u, 2u, 10u, 40000u)) /** * @brief Helper to declare LC3 Unicast 441_1_1 codec configuration @@ -118,9 +118,9 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_441_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET( \ - BT_CODEC_LC3_CONFIG_441_1(_loc, _stream_context), \ - BT_CODEC_QOS(8163u, BT_CODEC_QOS_FRAMED, BT_CODEC_QOS_2M, 97u, 5u, 24u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_441_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_QOS(8163u, BT_AUDIO_CODEC_QOS_FRAMED, \ + BT_AUDIO_CODEC_QOS_2M, 97u, 5u, 24u, 40000u)) /** * @brief Helper to declare LC3 Unicast 441_2_1 codec configuration @@ -129,9 +129,9 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_441_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET( \ - BT_CODEC_LC3_CONFIG_441_2(_loc, _stream_context), \ - BT_CODEC_QOS(10884u, BT_CODEC_QOS_FRAMED, BT_CODEC_QOS_2M, 130u, 5u, 31u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_441_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_QOS(10884u, BT_AUDIO_CODEC_QOS_FRAMED, \ + BT_AUDIO_CODEC_QOS_2M, 130u, 5u, 31u, 40000u)) /** * @brief Helper to declare LC3 Unicast 48_1_1 codec configuration @@ -140,8 +140,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(75u, 5u, 15u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(75u, 5u, 15u, 40000u)) /** * @brief Helper to declare LC3 Unicast 48_2_1 codec configuration @@ -150,8 +150,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(100u, 5u, 20u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(100u, 5u, 20u, 40000u)) /** * @brief Helper to declare LC3 Unicast 48_3_1 codec configuration @@ -160,8 +160,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_3_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_3(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(90u, 5u, 15u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_3(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(90u, 5u, 15u, 40000u)) /** * @brief Helper to declare LC3 Unicast 48_4_1 codec configuration @@ -170,8 +170,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_4_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_4(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(120u, 5u, 20u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_4(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(120u, 5u, 20u, 40000u)) /** * @brief Helper to declare LC3 Unicast 8_5_1 codec configuration @@ -180,8 +180,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_5_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_5(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(117u, 5u, 15u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_5(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(117u, 5u, 15u, 40000u)) /** * @brief Helper to declare LC3 Unicast 48_6_1 codec configuration @@ -190,8 +190,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_6_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_6(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(155u, 5u, 20u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_6(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(155u, 5u, 20u, 40000u)) /** * @brief Helper to declare LC3 Unicast 8_1_2 codec configuration @@ -201,8 +201,8 @@ struct bt_bap_lc3_preset { */ /* Following presets are for unicast high reliability audio data */ #define BT_BAP_LC3_UNICAST_PRESET_8_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_8_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(26u, 13u, 75u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_8_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(26u, 13u, 75u, 40000u)) /** * @brief Helper to declare LC3 Unicast 8_2_2 codec configuration @@ -211,8 +211,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_8_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_8_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(30u, 13u, 95u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_8_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(30u, 13u, 95u, 40000u)) /** * @brief Helper to declare LC3 Unicast 16_1_2 codec configuration @@ -221,8 +221,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_16_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_16_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(30u, 13u, 75u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_16_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(30u, 13u, 75u, 40000u)) /** * @brief Helper to declare LC3 Unicast 16_2_2 codec configuration @@ -231,8 +231,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_16_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_16_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(40u, 13u, 95u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_16_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(40u, 13u, 95u, 40000u)) /** * @brief Helper to declare LC3 Unicast 24_1_2 codec configuration @@ -241,8 +241,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_24_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_24_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(45u, 13u, 75u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_24_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(45u, 13u, 75u, 40000u)) /** * @brief Helper to declare LC3 Unicast 24_2_2 codec configuration @@ -251,8 +251,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_24_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_24_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(60u, 13u, 95u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_24_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(60u, 13u, 95u, 40000u)) /** * @brief Helper to declare LC3 Unicast 32_1_2 codec configuration @@ -261,8 +261,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_32_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_32_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(60u, 13u, 75u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_32_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(60u, 13u, 75u, 40000u)) /** * @brief Helper to declare LC3 Unicast 32_2_2 codec configuration @@ -271,8 +271,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_32_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_32_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(80u, 13u, 95u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_32_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(80u, 13u, 95u, 40000u)) /** * @brief Helper to declare LC3 Unicast 441_1_2 codec configuration @@ -281,9 +281,9 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_441_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET( \ - BT_CODEC_LC3_CONFIG_441_1(_loc, _stream_context), \ - BT_CODEC_QOS(8163u, BT_CODEC_QOS_FRAMED, BT_CODEC_QOS_2M, 97u, 13u, 80u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_441_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_QOS(8163u, BT_AUDIO_CODEC_QOS_FRAMED, \ + BT_AUDIO_CODEC_QOS_2M, 97u, 13u, 80u, 40000u)) /** * @brief Helper to declare LC3 Unicast 441_2_2 codec configuration @@ -292,9 +292,9 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_441_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_441_2(_loc, _stream_context), \ - BT_CODEC_QOS(10884u, BT_CODEC_QOS_FRAMED, BT_CODEC_QOS_2M, 130u, 13u, \ - 85u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_441_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_QOS(10884u, BT_AUDIO_CODEC_QOS_FRAMED, \ + BT_AUDIO_CODEC_QOS_2M, 130u, 13u, 85u, 40000u)) /** * @brief Helper to declare LC3 Unicast 48_1_2 codec configuration @@ -303,8 +303,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(75u, 13u, 75u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(75u, 13u, 75u, 40000u)) /** * @brief Helper to declare LC3 Unicast 48_2_2 codec configuration @@ -313,8 +313,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(100u, 13u, 95u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(100u, 13u, 95u, 40000u)) /** * @brief Helper to declare LC3 Unicast 48_3_2 codec configuration @@ -323,8 +323,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_3_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_3(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(90u, 13u, 75u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_3(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(90u, 13u, 75u, 40000u)) /** * @brief Helper to declare LC3 Unicast 48_4_2 codec configuration @@ -333,8 +333,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_4_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_4(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(120u, 13u, 100u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_4(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(120u, 13u, 100u, 40000u)) /** * @brief Helper to declare LC3 Unicast 48_5_2 codec configuration @@ -343,8 +343,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_5_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_5(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(117u, 13u, 75u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_5(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(117u, 13u, 75u, 40000u)) /** * @brief Helper to declare LC3 Unicast 48_6_2 codec configuration @@ -353,8 +353,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_UNICAST_PRESET_48_6_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_6(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(155u, 13u, 100u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_6(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(155u, 13u, 100u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 8_1_1 codec configuration @@ -364,8 +364,8 @@ struct bt_bap_lc3_preset { */ /* LC3 Broadcast presets defined by table 6.4 in the BAP v1.0 specification */ #define BT_BAP_LC3_BROADCAST_PRESET_8_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_8_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(26u, 2u, 8u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_8_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(26u, 2u, 8u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 8_2_1 codec configuration @@ -374,8 +374,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_8_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_8_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(30u, 2u, 10u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_8_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(30u, 2u, 10u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 16_1_1 codec configuration @@ -384,8 +384,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_16_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_16_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(30u, 2u, 8u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_16_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(30u, 2u, 8u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 16_2_1 codec configuration @@ -396,8 +396,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_16_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_16_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(40u, 2u, 10u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_16_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(40u, 2u, 10u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 24_1_1 codec configuration @@ -406,8 +406,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_24_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_24_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(45u, 2u, 8u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_24_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(45u, 2u, 8u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 24_2_1 codec configuration @@ -418,8 +418,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_24_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_24_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(60u, 2u, 10u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_24_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(60u, 2u, 10u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 32_1_1 codec configuration @@ -428,8 +428,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_32_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_32_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(60u, 2u, 8u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_32_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(60u, 2u, 8u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 32_2_1 codec configuration @@ -438,8 +438,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_32_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_32_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(80u, 2u, 10u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_32_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(80u, 2u, 10u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 441_1_1 codec configuration @@ -448,9 +448,9 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_441_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET( \ - BT_CODEC_LC3_CONFIG_441_1(_loc, _stream_context), \ - BT_CODEC_QOS(8163u, BT_CODEC_QOS_FRAMED, BT_CODEC_QOS_2M, 97u, 4u, 24u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_441_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_QOS(8163u, BT_AUDIO_CODEC_QOS_FRAMED, \ + BT_AUDIO_CODEC_QOS_2M, 97u, 4u, 24u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 441_2_1 codec configuration @@ -459,9 +459,9 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_441_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET( \ - BT_CODEC_LC3_CONFIG_441_2(_loc, _stream_context), \ - BT_CODEC_QOS(10884u, BT_CODEC_QOS_FRAMED, BT_CODEC_QOS_2M, 130u, 4u, 31u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_441_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_QOS(10884u, BT_AUDIO_CODEC_QOS_FRAMED, \ + BT_AUDIO_CODEC_QOS_2M, 130u, 4u, 31u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_1_1 codec configuration @@ -470,8 +470,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_1_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(75u, 4u, 15u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(75u, 4u, 15u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_2_1 codec configuration @@ -480,8 +480,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_2_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(100u, 4u, 20u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(100u, 4u, 20u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_3_1 codec configuration @@ -490,8 +490,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_3_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_3(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(90u, 4u, 15u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_3(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(90u, 4u, 15u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_4_1 codec configuration @@ -500,8 +500,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_4_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_4(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(120u, 4u, 20u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_4(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(120u, 4u, 20u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_5_1 codec configuration @@ -510,8 +510,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_5_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_5(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(117u, 4u, 15u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_5(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(117u, 4u, 15u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_6_1 codec configuration @@ -520,8 +520,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_6_1(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_6(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(155u, 4u, 20u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_6(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(155u, 4u, 20u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 8_1_2 codec configuration @@ -531,8 +531,8 @@ struct bt_bap_lc3_preset { */ /* Following presets are for broadcast high reliability audio data */ #define BT_BAP_LC3_BROADCAST_PRESET_8_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_8_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(26u, 4u, 45u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_8_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(26u, 4u, 45u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 8_2_2 codec configuration @@ -541,8 +541,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_8_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_8_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(30u, 4u, 60u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_8_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(30u, 4u, 60u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 16_1_2 codec configuration @@ -551,8 +551,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_16_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_16_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(30u, 4u, 45u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_16_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(30u, 4u, 45u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 16_2_2 codec configuration @@ -563,8 +563,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_16_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_16_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(40u, 4u, 60u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_16_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(40u, 4u, 60u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 24_1_2 codec configuration @@ -573,8 +573,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_24_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_24_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(45u, 4u, 45u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_24_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(45u, 4u, 45u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 24_2_2 codec configuration @@ -585,8 +585,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_24_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_24_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(60u, 4u, 60u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_24_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(60u, 4u, 60u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 32_1_2 codec configuration @@ -595,8 +595,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_32_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_32_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(60u, 4u, 45u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_32_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(60u, 4u, 45u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 32_2_2 codec configuration @@ -605,8 +605,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_32_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_32_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(80u, 4u, 60u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_32_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(80u, 4u, 60u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 441_1_2 codec configuration @@ -615,9 +615,9 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_441_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET( \ - BT_CODEC_LC3_CONFIG_441_1(_loc, _stream_context), \ - BT_CODEC_QOS(8163u, BT_CODEC_QOS_FRAMED, BT_CODEC_QOS_2M, 97u, 4u, 54u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_441_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_QOS(8163u, BT_AUDIO_CODEC_QOS_FRAMED, \ + BT_AUDIO_CODEC_QOS_2M, 97u, 4u, 54u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 441_2_2 codec configuration @@ -626,9 +626,9 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_441_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET( \ - BT_CODEC_LC3_CONFIG_441_2(_loc, _stream_context), \ - BT_CODEC_QOS(10884u, BT_CODEC_QOS_FRAMED, BT_CODEC_QOS_2M, 130u, 4u, 60u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_441_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_QOS(10884u, BT_AUDIO_CODEC_QOS_FRAMED, \ + BT_AUDIO_CODEC_QOS_2M, 130u, 4u, 60u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_1_2 codec configuration @@ -637,8 +637,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_1_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_1(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(75u, 4u, 50u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_1(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(75u, 4u, 50u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_2_2 codec configuration @@ -647,8 +647,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_2_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_2(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(100u, 4u, 65u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_2(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(100u, 4u, 65u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_3_2 codec configuration @@ -657,8 +657,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_3_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_3(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(90u, 4u, 50u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_3(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(90u, 4u, 50u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_4_2 codec configuration @@ -667,8 +667,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_4_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_4(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(120u, 4u, 65u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_4(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(120u, 4u, 65u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_5_2 codec configuration @@ -677,8 +677,8 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_5_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_5(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_7_5_UNFRAMED(117u, 4u, 50u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_5(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(117u, 4u, 50u, 40000u)) /** * @brief Helper to declare LC3 Broadcast 48_6_2 codec configuration @@ -687,7 +687,7 @@ struct bt_bap_lc3_preset { * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ #define BT_BAP_LC3_BROADCAST_PRESET_48_6_2(_loc, _stream_context) \ - BT_BAP_LC3_PRESET(BT_CODEC_LC3_CONFIG_48_6(_loc, _stream_context), \ - BT_CODEC_LC3_QOS_10_UNFRAMED(155u, 4u, 65u, 40000u)) + BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG_48_6(_loc, _stream_context), \ + BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(155u, 4u, 65u, 40000u)) #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_BAP_LC3_PRESET_ */ diff --git a/include/zephyr/bluetooth/audio/cap.h b/include/zephyr/bluetooth/audio/cap.h index 1436b96ca87416b..8891d905c62c461 100644 --- a/include/zephyr/bluetooth/audio/cap.h +++ b/include/zephyr/bluetooth/audio/cap.h @@ -179,14 +179,14 @@ struct bt_cap_unicast_audio_start_stream_param { /** * @brief Codec configuration. * - * The @p codec.meta shall include a list of CCIDs + * The @p codec_cfg.meta shall include a list of CCIDs * (@ref BT_AUDIO_METADATA_TYPE_CCID_LIST) as well as a non-0 * stream context (@ref BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT) bitfield. */ - struct bt_codec *codec; + struct bt_audio_codec_cfg *codec_cfg; /** Quality of Service configuration. */ - struct bt_codec_qos *qos; + struct bt_audio_codec_qos *qos; }; struct bt_cap_unicast_audio_start_param { @@ -212,7 +212,7 @@ struct bt_cap_unicast_audio_update_param { * The metadata shall a list of CCIDs as * well as a non-0 context bitfield. */ - struct bt_codec_data *meta; + struct bt_audio_codec_data *meta; }; /** @@ -310,7 +310,7 @@ struct bt_cap_initiator_broadcast_stream_param { size_t data_count; /** BIS Codec Specific Configuration */ - struct bt_codec_data *data; + struct bt_audio_codec_data *data; }; struct bt_cap_initiator_broadcast_subgroup_param { @@ -321,7 +321,7 @@ struct bt_cap_initiator_broadcast_subgroup_param { struct bt_cap_initiator_broadcast_stream_param *stream_params; /** Subgroup Codec configuration. */ - struct bt_codec *codec; + struct bt_audio_codec_cfg *codec_cfg; }; struct bt_cap_initiator_broadcast_create_param { @@ -332,7 +332,7 @@ struct bt_cap_initiator_broadcast_create_param { struct bt_cap_initiator_broadcast_subgroup_param *subgroup_params; /** Quality of Service configuration. */ - struct bt_codec_qos *qos; + struct bt_audio_codec_qos *qos; /** @brief Broadcast Source packing mode. * @@ -415,7 +415,7 @@ int bt_cap_initiator_broadcast_audio_start(struct bt_cap_broadcast_source *broad * @return 0 on success or negative error value on failure. */ int bt_cap_initiator_broadcast_audio_update(struct bt_cap_broadcast_source *broadcast_source, - const struct bt_codec_data meta[], + const struct bt_audio_codec_data meta[], size_t meta_count); /** diff --git a/include/zephyr/bluetooth/audio/lc3.h b/include/zephyr/bluetooth/audio/lc3.h index 90647cf1414a50c..cde496df2c49e12 100644 --- a/include/zephyr/bluetooth/audio/lc3.h +++ b/include/zephyr/bluetooth/audio/lc3.h @@ -13,7 +13,7 @@ /** * @brief LC3 - * @defgroup bt_codec_lc3 AUDIO + * @defgroup BT_AUDIO_CODEC_LC3 AUDIO * @ingroup bluetooth * @{ */ @@ -28,7 +28,7 @@ extern "C" { /** * @brief LC3 codec ID */ -#define BT_CODEC_LC3_ID 0x06 +#define BT_AUDIO_CODEC_LC3_ID 0x06 /** * @brief Codec capability type id's @@ -38,119 +38,118 @@ extern "C" { * * Even though they are in-fixed with LC3 they can be used for other codec types as well. */ -enum bt_codec_capability_type { +enum bt_audio_codec_capability_type { /** * @brief LC3 sample frequency capability type */ - BT_CODEC_LC3_FREQ = 0x01, + BT_AUDIO_CODEC_LC3_FREQ = 0x01, /** * @brief LC3 frame duration capability type */ - BT_CODEC_LC3_DURATION = 0x02, + BT_AUDIO_CODEC_LC3_DURATION = 0x02, /** * @brief LC3 channel count capability type */ - BT_CODEC_LC3_CHAN_COUNT = 0x03, + BT_AUDIO_CODEC_LC3_CHAN_COUNT = 0x03, /** * @brief LC3 frame length capability type */ - BT_CODEC_LC3_FRAME_LEN = 0x04, + BT_AUDIO_CODEC_LC3_FRAME_LEN = 0x04, /** * @brief Max codec frame count per SDU capability type */ - BT_CODEC_LC3_FRAME_COUNT = 0x05, + BT_AUDIO_CODEC_LC3_FRAME_COUNT = 0x05, }; /** * @brief LC3 8 Khz frequency capability */ -#define BT_CODEC_LC3_FREQ_8KHZ BIT(0) +#define BT_AUDIO_CODEC_LC3_FREQ_8KHZ BIT(0) /** * @brief LC3 11.025 Khz frequency capability */ -#define BT_CODEC_LC3_FREQ_11KHZ BIT(1) +#define BT_AUDIO_CODEC_LC3_FREQ_11KHZ BIT(1) /** * @brief LC3 16 Khz frequency capability */ -#define BT_CODEC_LC3_FREQ_16KHZ BIT(2) +#define BT_AUDIO_CODEC_LC3_FREQ_16KHZ BIT(2) /** * @brief LC3 22.05 Khz frequency capability */ -#define BT_CODEC_LC3_FREQ_22KHZ BIT(3) +#define BT_AUDIO_CODEC_LC3_FREQ_22KHZ BIT(3) /** * @brief LC3 24 Khz frequency capability */ -#define BT_CODEC_LC3_FREQ_24KHZ BIT(4) +#define BT_AUDIO_CODEC_LC3_FREQ_24KHZ BIT(4) /** * @brief LC3 32 Khz frequency capability */ -#define BT_CODEC_LC3_FREQ_32KHZ BIT(5) +#define BT_AUDIO_CODEC_LC3_FREQ_32KHZ BIT(5) /** * @brief LC3 44.1 Khz frequency capability */ -#define BT_CODEC_LC3_FREQ_44KHZ BIT(6) +#define BT_AUDIO_CODEC_LC3_FREQ_44KHZ BIT(6) /** * @brief LC3 48 Khz frequency capability */ -#define BT_CODEC_LC3_FREQ_48KHZ BIT(7) +#define BT_AUDIO_CODEC_LC3_FREQ_48KHZ BIT(7) /** * @brief LC3 any frequency capability */ -#define BT_CODEC_LC3_FREQ_ANY (BT_CODEC_LC3_FREQ_8KHZ | \ - BT_CODEC_LC3_FREQ_16KHZ | \ - BT_CODEC_LC3_FREQ_24KHZ | \ - BT_CODEC_LC3_FREQ_32KHZ | \ - BT_CODEC_LC3_FREQ_44KHZ | \ - BT_CODEC_LC3_FREQ_48KHZ) +#define BT_AUDIO_CODEC_LC3_FREQ_ANY \ + (BT_AUDIO_CODEC_LC3_FREQ_8KHZ | BT_AUDIO_CODEC_LC3_FREQ_16KHZ | \ + BT_AUDIO_CODEC_LC3_FREQ_24KHZ | BT_AUDIO_CODEC_LC3_FREQ_32KHZ | \ + BT_AUDIO_CODEC_LC3_FREQ_44KHZ | BT_AUDIO_CODEC_LC3_FREQ_48KHZ) /** * @brief LC3 7.5 msec frame duration capability */ -#define BT_CODEC_LC3_DURATION_7_5 BIT(0) +#define BT_AUDIO_CODEC_LC3_DURATION_7_5 BIT(0) /** * @brief LC3 10 msec frame duration capability */ -#define BT_CODEC_LC3_DURATION_10 BIT(1) +#define BT_AUDIO_CODEC_LC3_DURATION_10 BIT(1) /** * @brief LC3 any frame duration capability */ -#define BT_CODEC_LC3_DURATION_ANY (BT_CODEC_LC3_DURATION_7_5 | \ - BT_CODEC_LC3_DURATION_10) +#define BT_AUDIO_CODEC_LC3_DURATION_ANY \ + (BT_AUDIO_CODEC_LC3_DURATION_7_5 | BT_AUDIO_CODEC_LC3_DURATION_10) /** * @brief LC3 7.5 msec preferred frame duration capability */ -#define BT_CODEC_LC3_DURATION_PREFER_7_5 BIT(4) +#define BT_AUDIO_CODEC_LC3_DURATION_PREFER_7_5 BIT(4) /** * @brief LC3 10 msec preferred frame duration capability */ -#define BT_CODEC_LC3_DURATION_PREFER_10 BIT(5) +#define BT_AUDIO_CODEC_LC3_DURATION_PREFER_10 BIT(5) /** * @brief LC3 minimum supported channel counts */ -#define BT_CODEC_LC3_CHAN_COUNT_MIN 1 +#define BT_AUDIO_CODEC_LC3_CHAN_COUNT_MIN 1 /** * @brief LC3 maximum supported channel counts */ -#define BT_CODEC_LC3_CHAN_COUNT_MAX 8 +#define BT_AUDIO_CODEC_LC3_CHAN_COUNT_MAX 8 /** * @brief LC3 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 - * @ref BT_CODEC_LC3_CHAN_COUNT_MIN to @ref BT_CODEC_LC3_CHAN_COUNT_MAX inclusive. + * @ref BT_AUDIO_CODEC_LC3_CHAN_COUNT_MIN to @ref BT_AUDIO_CODEC_LC3_CHAN_COUNT_MAX inclusive. * * Example to support 1 and 3 channels: - * BT_CODEC_LC3_CHAN_COUNT_SUPPORT(1, 3) + * BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1, 3) */ -#define BT_CODEC_LC3_CHAN_COUNT_SUPPORT(...) ((uint8_t)((FOR_EACH(BIT, (|), __VA_ARGS__)) >> 1)) +#define BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(...) \ + ((uint8_t)((FOR_EACH(BIT, (|), __VA_ARGS__)) >> 1)) -struct bt_codec_lc3_frame_len { +struct BT_AUDIO_CODEC_LC3_frame_len { uint16_t min; uint16_t max; }; @@ -163,85 +162,85 @@ struct bt_codec_lc3_frame_len { * * Even though they are in-fixed with LC3 they can be used for other codec types as well. */ -enum bt_codec_config_type { +enum bt_audio_codec_config_type { /** @brief LC3 Sample Frequency configuration type. */ - BT_CODEC_CONFIG_LC3_FREQ = 0x01, + BT_AUDIO_CODEC_CONFIG_LC3_FREQ = 0x01, /** @brief LC3 Frame Duration configuration type. */ - BT_CODEC_CONFIG_LC3_DURATION = 0x02, + BT_AUDIO_CODEC_CONFIG_LC3_DURATION = 0x02, /** @brief LC3 channel Allocation configuration type. */ - BT_CODEC_CONFIG_LC3_CHAN_ALLOC = 0x03, + BT_AUDIO_CODEC_CONFIG_LC3_CHAN_ALLOC = 0x03, /** @brief LC3 Frame Length configuration type. */ - BT_CODEC_CONFIG_LC3_FRAME_LEN = 0x04, + BT_AUDIO_CODEC_CONFIG_LC3_FRAME_LEN = 0x04, /** @brief Codec frame blocks, per SDU configuration type. */ - BT_CODEC_CONFIG_LC3_FRAME_BLKS_PER_SDU = 0x05, + BT_AUDIO_CODEC_CONFIG_LC3_FRAME_BLKS_PER_SDU = 0x05, }; /** * @brief 8 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_8KHZ 0x01 +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_8KHZ 0x01 /** * @brief 11.025 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_11KHZ 0x02 +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_11KHZ 0x02 /** * @brief 16 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_16KHZ 0x03 +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ 0x03 /** * @brief 22.05 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_22KHZ 0x04 +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_22KHZ 0x04 /** * @brief 24 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_24KHZ 0x05 +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_24KHZ 0x05 /** * @brief 32 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_32KHZ 0x06 +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_32KHZ 0x06 /** * @brief 44.1 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_44KHZ 0x07 +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_44KHZ 0x07 /** * @brief 48 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_48KHZ 0x08 +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ 0x08 /** * @brief 88.2 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_88KHZ 0x09 +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_88KHZ 0x09 /** * @brief 96 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_96KHZ 0x0a +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_96KHZ 0x0a /** * @brief 176.4 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_176KHZ 0x0b +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_176KHZ 0x0b /** * @brief 192 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_192KHZ 0x0c +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_192KHZ 0x0c /** * @brief 384 Khz codec Sample Frequency configuration */ -#define BT_CODEC_CONFIG_LC3_FREQ_384KHZ 0x0d +#define BT_AUDIO_CODEC_CONFIG_LC3_FREQ_384KHZ 0x0d /** * @brief LC3 7.5 msec Frame Duration configuration */ -#define BT_CODEC_CONFIG_LC3_DURATION_7_5 0x00 +#define BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5 0x00 /** * @brief LC3 10 msec Frame Duration configuration */ -#define BT_CODEC_CONFIG_LC3_DURATION_10 0x01 +#define BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10 0x01 /** @@ -255,36 +254,38 @@ enum bt_codec_config_type { * If the flags argument is != 1 it will evaluate to the third argument which inserts a LTV * entry for the max_frames_per_sdu value. */ -#define BT_CODEC_LC3_DATA(_freq, _duration, _chan_count, _len_min, _len_max, _max_frames_per_sdu) \ -{ \ - BT_CODEC_DATA(BT_CODEC_LC3_FREQ, BT_BYTES_LIST_LE16(_freq)), \ - BT_CODEC_DATA(BT_CODEC_LC3_DURATION, _duration), \ - BT_CODEC_DATA(BT_CODEC_LC3_CHAN_COUNT, _chan_count), \ - BT_CODEC_DATA(BT_CODEC_LC3_FRAME_LEN, \ - BT_BYTES_LIST_LE16(_len_min), \ - BT_BYTES_LIST_LE16(_len_max)) \ - COND_CODE_1(_max_frames_per_sdu, (), \ - (, BT_CODEC_DATA(BT_CODEC_LC3_FRAME_COUNT, \ - _max_frames_per_sdu))) \ -} +#define BT_AUDIO_CODEC_LC3_DATA(_freq, _duration, _chan_count, _len_min, _len_max, \ + _max_frames_per_sdu) \ + { \ + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_FREQ, BT_BYTES_LIST_LE16(_freq)), \ + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_DURATION, _duration), \ + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_CHAN_COUNT, _chan_count), \ + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_FRAME_LEN, \ + BT_BYTES_LIST_LE16(_len_min), \ + BT_BYTES_LIST_LE16(_len_max)) \ + COND_CODE_1(_max_frames_per_sdu, (), \ + (, BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_FRAME_COUNT, \ + _max_frames_per_sdu))) \ + } /** * @brief Helper to declare LC3 codec metadata */ -#define BT_CODEC_LC3_META(_prefer_context) \ -{ \ - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_PREF_CONTEXT, BT_BYTES_LIST_LE16(_prefer_context)) \ -} +#define BT_AUDIO_CODEC_LC3_META(_prefer_context) \ + { \ + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_PREF_CONTEXT, \ + BT_BYTES_LIST_LE16(_prefer_context)) \ + } /** * @brief Helper to declare LC3 codec */ -#define BT_CODEC_LC3(_freq, _duration, _chan_count, _len_min, _len_max, \ - _max_frames_per_sdu, _prefer_context) \ - BT_CODEC(BT_CODEC_LC3_ID, 0x0000, 0x0000, \ - BT_CODEC_LC3_DATA(_freq, _duration, _chan_count, _len_min, \ - _len_max, _max_frames_per_sdu), \ - BT_CODEC_LC3_META(_prefer_context)) +#define BT_AUDIO_CODEC_LC3(_freq, _duration, _chan_count, _len_min, _len_max, _max_frames_per_sdu, \ + _prefer_context) \ + BT_AUDIO_CODEC(BT_AUDIO_CODEC_LC3_ID, 0x0000, 0x0000, \ + BT_AUDIO_CODEC_LC3_DATA(_freq, _duration, _chan_count, _len_min, _len_max, \ + _max_frames_per_sdu), \ + BT_AUDIO_CODEC_LC3_META(_prefer_context)) /** * @brief Helper to declare LC3 codec data configuration @@ -297,40 +298,44 @@ enum bt_codec_config_type { * If the flags argument is != 1 it will evaluate to the third argument which inserts a LTV * entry for the _frame_blocks_per_sdu value. */ -#define BT_CODEC_LC3_CONFIG_DATA(_freq, _duration, _loc, _len, _frame_blocks_per_sdu) \ -{ \ - BT_CODEC_DATA(BT_CODEC_CONFIG_LC3_FREQ, _freq), \ - BT_CODEC_DATA(BT_CODEC_CONFIG_LC3_DURATION, _duration), \ - BT_CODEC_DATA(BT_CODEC_CONFIG_LC3_CHAN_ALLOC, BT_BYTES_LIST_LE32(_loc)), \ - BT_CODEC_DATA(BT_CODEC_CONFIG_LC3_FRAME_LEN, BT_BYTES_LIST_LE16(_len)), \ - COND_CODE_1(_frame_blocks_per_sdu, (), \ - (, BT_CODEC_DATA(BT_CODEC_CONFIG_LC3_FRAME_BLKS_PER_SDU, \ - _frame_blocks_per_sdu))) \ -} +#define BT_AUDIO_CODEC_LC3_CONFIG_DATA(_freq, _duration, _loc, _len, _frame_blocks_per_sdu) \ + { \ + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_FREQ, _freq), \ + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_DURATION, _duration), \ + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_CHAN_ALLOC, \ + BT_BYTES_LIST_LE32(_loc)), \ + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_FRAME_LEN, \ + BT_BYTES_LIST_LE16(_len)), \ + COND_CODE_1(_frame_blocks_per_sdu, (), \ + (, BT_AUDIO_CODEC_DATA( \ + BT_AUDIO_CODEC_CONFIG_LC3_FRAME_BLKS_PER_SDU, \ + _frame_blocks_per_sdu))) \ + } /** * @brief Helper to declare LC3 codec metadata configuration */ -#define BT_CODEC_LC3_CONFIG_META(_stream_context) \ -{ \ - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, BT_BYTES_LIST_LE16(_stream_context)) \ -} +#define BT_AUDIO_CODEC_LC3_CONFIG_META(_stream_context) \ + { \ + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, \ + BT_BYTES_LIST_LE16(_stream_context)) \ + } /** * @brief Helper to declare LC3 codec configuration. * - * @param _freq Sampling frequency (BT_CODEC_CONFIG_LC3_FREQ_*) - * @param _duration Frame duration (BT_CODEC_CONFIG_LC3_DURATION_*) + * @param _freq Sampling frequency (BT_AUDIO_CODEC_CONFIG_LC3_FREQ_*) + * @param _duration Frame duration (BT_AUDIO_CODEC_CONFIG_LC3_DURATION_*) * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _len Octets per frame (16-bit integer) * @param _frames_per_sdu Frames per SDU (8-bit integer) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG(_freq, _duration, _loc, _len, _frames_per_sdu, \ - _stream_context) \ - BT_CODEC(BT_CODEC_LC3_ID, 0x0000, 0x0000, \ - BT_CODEC_LC3_CONFIG_DATA(_freq, _duration, _loc, _len, _frames_per_sdu), \ - BT_CODEC_LC3_CONFIG_META(_stream_context)) +#define BT_AUDIO_CODEC_LC3_CONFIG(_freq, _duration, _loc, _len, _frames_per_sdu, _stream_context) \ + BT_AUDIO_CODEC( \ + BT_AUDIO_CODEC_LC3_ID, 0x0000, 0x0000, \ + BT_AUDIO_CODEC_LC3_CONFIG_DATA(_freq, _duration, _loc, _len, _frames_per_sdu), \ + BT_AUDIO_CODEC_LC3_CONFIG_META(_stream_context)) /** * @brief Helper to declare LC3 8.1 codec configuration @@ -338,40 +343,40 @@ enum bt_codec_config_type { * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_8_1(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_8KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 26u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_8_1(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_8KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 26u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 8.2 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_8_2(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_8KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_10, _loc, 30u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_8_2(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_8KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 30u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 16.1 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_16_1(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_16KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 30u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_16_1(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 30u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 16.2 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_16_2(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_16KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_10, _loc, 40u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_16_2(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 40u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 24.1 codec configuration @@ -379,142 +384,140 @@ enum bt_codec_config_type { * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_24_1(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_24KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 45u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_24_1(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_24KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 45u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 24.2 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_24_2(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_24KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_10, _loc, 60u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_24_2(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_24KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 60u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 32.1 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_32_1(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_32KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 60u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_32_1(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_32KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 60u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 32.2 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_32_2(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_32KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_10, _loc, 80u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_32_2(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_32KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 80u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 441.1 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_441_1(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_44KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 98u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_441_1(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_44KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 98u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 441.2 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_441_2(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_44KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_10, _loc, 130u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_441_2(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_44KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 130u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 48.1 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_48_1(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_48KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 75u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_48_1(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 75u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 48.2 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_48_2(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_48KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_10, _loc, 100u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_48_2(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 100u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 48.3 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_48_3(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_48KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 90u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_48_3(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 90u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 48.4 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_48_4(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_48KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_10, _loc, 120u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_48_4(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 120u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 48.5 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_48_5(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_48KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 117u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_48_5(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 117u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 48.6 codec configuration * * @param _loc Audio channel location bitfield (@ref bt_audio_location) * @param _stream_context Stream context (BT_AUDIO_CONTEXT_*) */ -#define BT_CODEC_LC3_CONFIG_48_6(_loc, _stream_context) \ - BT_CODEC_LC3_CONFIG(BT_CODEC_CONFIG_LC3_FREQ_48KHZ, \ - BT_CODEC_CONFIG_LC3_DURATION_10, _loc, 155u, \ - 1, _stream_context) +#define BT_AUDIO_CODEC_LC3_CONFIG_48_6(_loc, _stream_context) \ + BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ, \ + BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 155u, 1, \ + _stream_context) /** * @brief Helper to declare LC3 codec QoS for 7.5ms interval */ -#define BT_CODEC_LC3_QOS_7_5(_framing, _sdu, _rtn, _latency, _pd) \ - BT_CODEC_QOS(7500u, _framing, BT_CODEC_QOS_2M, _sdu, _rtn, \ - _latency, _pd) +#define BT_AUDIO_CODEC_LC3_QOS_7_5(_framing, _sdu, _rtn, _latency, _pd) \ + BT_AUDIO_CODEC_QOS(7500u, _framing, BT_AUDIO_CODEC_QOS_2M, _sdu, _rtn, _latency, _pd) /** * @brief Helper to declare LC3 codec QoS for 7.5ms interval unframed input */ -#define BT_CODEC_LC3_QOS_7_5_UNFRAMED(_sdu, _rtn, _latency, _pd) \ - BT_CODEC_QOS_UNFRAMED(7500u, _sdu, _rtn, _latency, _pd) +#define BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(_sdu, _rtn, _latency, _pd) \ + BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, _sdu, _rtn, _latency, _pd) /** * @brief Helper to declare LC3 codec QoS for 10ms frame internal */ -#define BT_CODEC_LC3_QOS_10(_framing, _sdu, _rtn, _latency, _pd) \ - BT_CODEC_QOS(10000u, _framing, BT_CODEC_QOS_2M, _sdu, _rtn, \ - _latency, _pd) +#define BT_AUDIO_CODEC_LC3_QOS_10(_framing, _sdu, _rtn, _latency, _pd) \ + BT_AUDIO_CODEC_QOS(10000u, _framing, BT_AUDIO_CODEC_QOS_2M, _sdu, _rtn, _latency, _pd) /** * @brief Helper to declare LC3 codec QoS for 10ms interval unframed input */ -#define BT_CODEC_LC3_QOS_10_UNFRAMED(_sdu, _rtn, _latency, _pd) \ - BT_CODEC_QOS_UNFRAMED(10000u, _sdu, _rtn, _latency, _pd) +#define BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(_sdu, _rtn, _latency, _pd) \ + BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, _sdu, _rtn, _latency, _pd) #ifdef __cplusplus } diff --git a/include/zephyr/bluetooth/audio/pacs.h b/include/zephyr/bluetooth/audio/pacs.h index 64533abe8ed8b35..3400baac92b96e8 100644 --- a/include/zephyr/bluetooth/audio/pacs.h +++ b/include/zephyr/bluetooth/audio/pacs.h @@ -18,8 +18,8 @@ extern "C" { /** @brief Published Audio Capability structure. */ struct bt_pacs_cap { - /** Capability codec reference */ - struct bt_codec *codec; + /** Codec capability reference */ + struct bt_audio_codec_cap *codec_cap; /* Internally used list node */ sys_snode_t _node; diff --git a/samples/bluetooth/broadcast_audio_sink/src/main.c b/samples/bluetooth/broadcast_audio_sink/src/main.c index 5107b8db9d19658..4a017b6197d65b4 100644 --- a/samples/bluetooth/broadcast_audio_sink/src/main.c +++ b/samples/bluetooth/broadcast_audio_sink/src/main.c @@ -45,8 +45,8 @@ static struct bt_bap_stream *streams_p[ARRAY_SIZE(streams)]; static struct bt_conn *broadcast_assistant_conn; static struct bt_le_ext_adv *ext_adv; -static struct bt_codec codec = BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT, - BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); +static struct bt_audio_codec_cap codec_cap = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); /* Create a mask for the maximum BIS we can sync to using the number of streams * we have. We add an additional 1 since the bis indexes start from 1 and not @@ -416,7 +416,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = { }; static struct bt_pacs_cap cap = { - .codec = &codec, + .codec_cap = &codec_cap, }; static int init(void) diff --git a/samples/bluetooth/broadcast_audio_source/src/main.c b/samples/bluetooth/broadcast_audio_source/src/main.c index bb761c662a65332..668786c657f96db 100644 --- a/samples/bluetooth/broadcast_audio_source/src/main.c +++ b/samples/bluetooth/broadcast_audio_source/src/main.c @@ -102,7 +102,7 @@ static int setup_broadcast_source(struct bt_bap_broadcast_source **source) for (size_t i = 0U; i < ARRAY_SIZE(subgroup_param); i++) { subgroup_param[i].params_count = streams_per_subgroup; subgroup_param[i].params = stream_params + i * streams_per_subgroup; - subgroup_param[i].codec = &preset_16_2_1.codec; + subgroup_param[i].codec_cfg = &preset_16_2_1.codec_cfg; } for (size_t j = 0U; j < ARRAY_SIZE(stream_params); j++) { diff --git a/samples/bluetooth/hap_ha/src/bap_unicast_sr.c b/samples/bluetooth/hap_ha/src/bap_unicast_sr.c index b6c1de0a1b0b499..2ee7faa40b38b5e 100644 --- a/samples/bluetooth/hap_ha/src/bap_unicast_sr.c +++ b/samples/bluetooth/hap_ha/src/bap_unicast_sr.c @@ -21,11 +21,10 @@ NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_ASCS_ASE_SRC_COUNT, BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU), CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL); -static struct bt_codec lc3_codec = - BT_CODEC_LC3(BT_CODEC_LC3_FREQ_16KHZ | BT_CODEC_LC3_FREQ_24KHZ, - BT_CODEC_LC3_DURATION_10, - BT_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 60u, 1u, - (BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA)); +static struct bt_audio_codec_cap lc3_codec_cap = BT_AUDIO_CODEC_LC3( + BT_AUDIO_CODEC_LC3_FREQ_16KHZ | BT_AUDIO_CODEC_LC3_FREQ_24KHZ, + BT_AUDIO_CODEC_LC3_DURATION_10, BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 60u, 1u, + (BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA)); static struct bt_conn *default_conn; static struct k_work_delayable audio_send_work; @@ -36,8 +35,8 @@ static struct audio_source { } source_streams[CONFIG_BT_ASCS_ASE_SRC_COUNT]; static size_t configured_source_stream_count; -static const struct bt_codec_qos_pref qos_pref = BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, - 10, 20000, 40000, 20000, 40000); +static const struct bt_audio_codec_qos_pref qos_pref = + BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 20000, 40000, 20000, 40000); static uint16_t get_and_incr_seq_num(const struct bt_bap_stream *stream) { @@ -59,50 +58,47 @@ static void print_hex(const uint8_t *ptr, size_t len) } } -static void print_codec(const struct bt_codec *codec) +static void print_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg) { - printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n", - codec->id, codec->cid, codec->vid, codec->data_count); - - for (size_t i = 0; i < codec->data_count; i++) { - printk("data #%zu: type 0x%02x len %u\n", - i, codec->data[i].data.type, - codec->data[i].data.data_len); - print_hex(codec->data[i].data.data, - codec->data[i].data.data_len - - sizeof(codec->data[i].data.type)); + printk("codec_cfg 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cfg->id, codec_cfg->cid, + codec_cfg->vid, codec_cfg->data_count); + + for (size_t i = 0; i < codec_cfg->data_count; i++) { + printk("data #%zu: type 0x%02x len %u\n", i, codec_cfg->data[i].data.type, + codec_cfg->data[i].data.data_len); + print_hex(codec_cfg->data[i].data.data, + codec_cfg->data[i].data.data_len - sizeof(codec_cfg->data[i].data.type)); printk("\n"); } - if (codec->id == BT_CODEC_LC3_ID) { + if (codec_cfg->id == BT_AUDIO_CODEC_LC3_ID) { /* LC3 uses the generic LTV format - other codecs might do as well */ enum bt_audio_location chan_allocation; - printk(" Frequency: %d Hz\n", bt_codec_cfg_get_freq(codec)); - printk(" Frame Duration: %d us\n", bt_codec_cfg_get_frame_duration_us(codec)); - if (bt_codec_cfg_get_chan_allocation_val(codec, &chan_allocation) == 0) { + printk(" Frequency: %d Hz\n", bt_audio_codec_cfg_get_freq(codec_cfg)); + printk(" Frame Duration: %d us\n", + bt_audio_codec_cfg_get_frame_duration_us(codec_cfg)); + if (bt_audio_codec_cfg_get_chan_allocation_val(codec_cfg, &chan_allocation) == 0) { printk(" Channel allocation: 0x%x\n", chan_allocation); } printk(" Octets per frame: %d (negative means value not pressent)\n", - bt_codec_cfg_get_octets_per_frame(codec)); + bt_audio_codec_cfg_get_octets_per_frame(codec_cfg)); printk(" Frames per SDU: %d\n", - bt_codec_cfg_get_frame_blocks_per_sdu(codec, true)); + bt_audio_codec_cfg_get_frame_blocks_per_sdu(codec_cfg, true)); } - for (size_t i = 0; i < codec->meta_count; i++) { - printk("meta #%zu: type 0x%02x len %u\n", - i, codec->meta[i].data.type, - codec->meta[i].data.data_len); - print_hex(codec->meta[i].data.data, - codec->meta[i].data.data_len - - sizeof(codec->meta[i].data.type)); + for (size_t i = 0; i < codec_cfg->meta_count; i++) { + printk("meta #%zu: type 0x%02x len %u\n", i, codec_cfg->meta[i].data.type, + codec_cfg->meta[i].data.data_len); + print_hex(codec_cfg->meta[i].data.data, + codec_cfg->meta[i].data.data_len - sizeof(codec_cfg->meta[i].data.type)); printk("\n"); } } -static void print_qos(const struct bt_codec_qos *qos) +static void print_qos(const struct bt_audio_codec_qos *qos) { printk("QoS: interval %u framing 0x%02x phy 0x%02x sdu %u " "rtn %u latency %u pd %u\n", @@ -188,12 +184,12 @@ static struct bt_bap_stream *stream_alloc(void) } static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_bap_stream **stream, - struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { printk("ASE Codec Config: conn %p ep %p dir %u\n", conn, ep, dir); - print_codec(codec); + print_codec_cfg(codec_cfg); *stream = stream_alloc(); if (*stream == NULL) { @@ -214,12 +210,12 @@ static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_ } static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_codec_qos_pref *const pref, - struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { printk("ASE Codec Reconfig: stream %p\n", stream); - print_codec(codec); + print_codec_cfg(codec_cfg); *rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED, BT_BAP_ASCS_REASON_NONE); @@ -227,7 +223,7 @@ static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, return -ENOEXEC; } -static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, +static int lc3_qos(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos, struct bt_bap_ascs_rsp *rsp) { printk("QoS: stream %p qos %p\n", stream, qos); @@ -237,7 +233,7 @@ static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, return 0; } -static int lc3_enable(struct bt_bap_stream *stream, const struct bt_codec_data *meta, +static int lc3_enable(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { printk("Enable: stream %p meta_count %u\n", stream, meta_count); @@ -311,13 +307,13 @@ static bool valid_metadata_type(uint8_t type, uint8_t len) } } -static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_codec_data *meta, +static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { printk("Metadata: stream %p meta_count %u\n", stream, meta_count); for (size_t i = 0; i < meta_count; i++) { - const struct bt_codec_data *data = &meta[i]; + const struct bt_audio_codec_data *data = &meta[i]; if (!valid_metadata_type(data->data.type, data->data.data_len)) { printk("Invalid metadata type %u or length %u\n", @@ -421,11 +417,11 @@ BT_CONN_CB_DEFINE(conn_callbacks) = { }; static struct bt_pacs_cap cap_sink = { - .codec = &lc3_codec, + .codec_cap = &lc3_codec_cap, }; static struct bt_pacs_cap cap_source = { - .codec = &lc3_codec, + .codec_cap = &lc3_codec_cap, }; int bap_unicast_sr_init(void) diff --git a/samples/bluetooth/tmap_central/src/cap_initiator.c b/samples/bluetooth/tmap_central/src/cap_initiator.c index 0daeccffff7cd90..bfe97175a04e611 100644 --- a/samples/bluetooth/tmap_central/src/cap_initiator.c +++ b/samples/bluetooth/tmap_central/src/cap_initiator.c @@ -33,7 +33,7 @@ static K_SEM_DEFINE(sem_discover_source, 0, 1); static K_SEM_DEFINE(sem_audio_start, 0, 1); static void unicast_stream_configured(struct bt_bap_stream *stream, - const struct bt_codec_qos_pref *pref) + const struct bt_audio_codec_qos_pref *pref) { printk("Configured stream %p\n", stream); @@ -180,36 +180,32 @@ static void print_hex(const uint8_t *ptr, size_t len) } } -static void print_codec_capabilities(const struct bt_codec *codec) +static void print_codec_capabilities(const struct bt_audio_codec_cap *codec_cap) { - printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n", - codec->id, codec->cid, codec->vid, codec->data_count); - - for (size_t i = 0; i < codec->data_count; i++) { - printk("data #%zu: type 0x%02x len %u\n", - i, codec->data[i].data.type, - codec->data[i].data.data_len); - print_hex(codec->data[i].data.data, - codec->data[i].data.data_len - - sizeof(codec->data[i].data.type)); + printk("codec_cap 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cap->id, codec_cap->cid, + codec_cap->vid, codec_cap->data_count); + + for (size_t i = 0; i < codec_cap->data_count; i++) { + printk("data #%zu: type 0x%02x len %u\n", i, codec_cap->data[i].data.type, + codec_cap->data[i].data.data_len); + print_hex(codec_cap->data[i].data.data, + codec_cap->data[i].data.data_len - sizeof(codec_cap->data[i].data.type)); printk("\n"); } - for (size_t i = 0; i < codec->meta_count; i++) { - printk("meta #%zu: type 0x%02x len %u\n", - i, codec->meta[i].data.type, - codec->meta[i].data.data_len); - print_hex(codec->meta[i].data.data, - codec->meta[i].data.data_len - - sizeof(codec->meta[i].data.type)); + for (size_t i = 0; i < codec_cap->meta_count; i++) { + printk("meta #%zu: type 0x%02x len %u\n", i, codec_cap->meta[i].data.type, + codec_cap->meta[i].data.data_len); + print_hex(codec_cap->meta[i].data.data, + codec_cap->meta[i].data.data_len - sizeof(codec_cap->meta[i].data.type)); printk("\n"); } } -static void print_remote_codec(const struct bt_codec *codec_capabilities, enum bt_audio_dir dir) +static void print_remote_codec(const struct bt_audio_codec_cap *codec_cap, enum bt_audio_dir dir) { - printk("codec_capabilities %p dir 0x%02x\n", codec_capabilities, dir); - print_codec_capabilities(codec_capabilities); + printk("codec_cap %p dir 0x%02x\n", codec_cap, dir); + print_codec_capabilities(codec_cap); } static void add_remote_sink(struct bt_bap_ep *ep) @@ -250,9 +246,10 @@ static void discover_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir) } } -static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, const struct bt_codec *codec) +static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, + const struct bt_audio_codec_cap *codec_cap) { - print_remote_codec(codec, dir); + print_remote_codec(codec_cap, dir); } static void endpoint_cb(struct bt_conn *conn, enum bt_audio_dir dir, struct bt_bap_ep *ep) @@ -347,7 +344,7 @@ static int unicast_audio_start(struct bt_conn *conn, struct bt_bap_unicast_group stream_param.member.member = conn; stream_param.stream = &unicast_streams[0]; stream_param.ep = unicast_sink_eps[0]; - stream_param.codec = &unicast_preset_48_2_1.codec; + stream_param.codec_cfg = &unicast_preset_48_2_1.codec_cfg; stream_param.qos = &unicast_preset_48_2_1.qos; err = bt_cap_initiator_unicast_audio_start(¶m, unicast_group); diff --git a/samples/bluetooth/tmap_peripheral/src/bap_unicast_sr.c b/samples/bluetooth/tmap_peripheral/src/bap_unicast_sr.c index efecfaec92fec62..35707cdbd6c0b16 100644 --- a/samples/bluetooth/tmap_peripheral/src/bap_unicast_sr.c +++ b/samples/bluetooth/tmap_peripheral/src/bap_unicast_sr.c @@ -23,53 +23,12 @@ #define AVAILABLE_SINK_CONTEXT CONFIG_BT_PACS_SNK_CONTEXT #define AVAILABLE_SOURCE_CONTEXT CONFIG_BT_PACS_SRC_CONTEXT -static struct bt_bap_lc3_preset codec_cfg_src_16_1_1 = - BT_BAP_LC3_UNICAST_PRESET_16_1_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SRC_CONTEXT); - -static struct bt_bap_lc3_preset codec_cfg_snk_16_1_1 = - BT_BAP_LC3_UNICAST_PRESET_16_1_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SNK_CONTEXT); - -static struct bt_bap_lc3_preset codec_cfg_src_32_1_1 = - BT_BAP_LC3_UNICAST_PRESET_32_1_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SRC_CONTEXT); - -static struct bt_bap_lc3_preset codec_cfg_snk_32_1_1 = - BT_BAP_LC3_UNICAST_PRESET_32_1_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SNK_CONTEXT); - -static struct bt_bap_lc3_preset codec_cfg_src_32_2_1 = - BT_BAP_LC3_UNICAST_PRESET_32_2_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SRC_CONTEXT); - -static struct bt_bap_lc3_preset codec_cfg_snk_32_2_1 = - BT_BAP_LC3_UNICAST_PRESET_32_2_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SNK_CONTEXT); - -static struct bt_bap_lc3_preset codec_cfg_snk_48_1_1 = - BT_BAP_LC3_UNICAST_PRESET_48_1_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SNK_CONTEXT); - -static struct bt_bap_lc3_preset codec_cfg_snk_48_2_1 = - BT_BAP_LC3_UNICAST_PRESET_48_2_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SNK_CONTEXT); - -static struct bt_bap_lc3_preset codec_cfg_snk_48_3_1 = - BT_BAP_LC3_UNICAST_PRESET_48_3_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SNK_CONTEXT); - -static struct bt_bap_lc3_preset codec_cfg_snk_48_4_1 = - BT_BAP_LC3_UNICAST_PRESET_48_4_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SNK_CONTEXT); - -static struct bt_bap_lc3_preset codec_cfg_snk_48_5_1 = - BT_BAP_LC3_UNICAST_PRESET_48_5_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SNK_CONTEXT); - -static struct bt_bap_lc3_preset codec_cfg_snk_48_6_1 = - BT_BAP_LC3_UNICAST_PRESET_48_6_1(BT_AUDIO_LOCATION_FRONT_LEFT, - CONFIG_BT_PACS_SNK_CONTEXT); +static struct bt_audio_codec_cap lc3_codec_cap = + BT_AUDIO_CODEC_LC3(BT_AUDIO_CODEC_LC3_FREQ_16KHZ | BT_AUDIO_CODEC_LC3_FREQ_32KHZ | + BT_AUDIO_CODEC_LC3_FREQ_48KHZ, + BT_AUDIO_CODEC_LC3_DURATION_7_5 | BT_AUDIO_CODEC_LC3_DURATION_10, + BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(2), 30, 155u, 1u, + (CONFIG_BT_PACS_SNK_CONTEXT | CONFIG_BT_PACS_SRC_CONTEXT)); static struct bt_conn *default_conn; static struct bt_bap_stream streams[CONFIG_BT_ASCS_ASE_SNK_COUNT + CONFIG_BT_ASCS_ASE_SRC_COUNT]; @@ -79,8 +38,8 @@ static struct audio_source { } source_streams[CONFIG_BT_ASCS_ASE_SRC_COUNT]; static size_t configured_source_stream_count; -static const struct bt_codec_qos_pref qos_pref = BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, - 10, 20000, 40000, 20000, 40000); +static const struct bt_audio_codec_qos_pref qos_pref = + BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 20000, 40000, 20000, 40000); static void print_hex(const uint8_t *ptr, size_t len) { @@ -89,50 +48,47 @@ static void print_hex(const uint8_t *ptr, size_t len) } } -static void print_codec(const struct bt_codec *codec) +static void print_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg) { - printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n", - codec->id, codec->cid, codec->vid, codec->data_count); - - for (size_t i = 0; i < codec->data_count; i++) { - printk("data #%zu: type 0x%02x len %u\n", - i, codec->data[i].data.type, - codec->data[i].data.data_len); - print_hex(codec->data[i].data.data, - codec->data[i].data.data_len - - sizeof(codec->data[i].data.type)); + printk("codec_cfg 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cfg->id, codec_cfg->cid, + codec_cfg->vid, codec_cfg->data_count); + + for (size_t i = 0; i < codec_cfg->data_count; i++) { + printk("data #%zu: type 0x%02x len %u\n", i, codec_cfg->data[i].data.type, + codec_cfg->data[i].data.data_len); + print_hex(codec_cfg->data[i].data.data, + codec_cfg->data[i].data.data_len - sizeof(codec_cfg->data[i].data.type)); printk("\n"); } - if (codec->id == BT_CODEC_LC3_ID) { + if (codec_cfg->id == BT_AUDIO_CODEC_LC3_ID) { /* LC3 uses the generic LTV format - other codecs might do as well */ uint32_t chan_allocation; - printk(" Frequency: %d Hz\n", bt_codec_cfg_get_freq(codec)); - printk(" Frame Duration: %d us\n", bt_codec_cfg_get_frame_duration_us(codec)); - if (bt_codec_cfg_get_chan_allocation_val(codec, &chan_allocation) == 0) { + printk(" Frequency: %d Hz\n", bt_audio_codec_cfg_get_freq(codec_cfg)); + printk(" Frame Duration: %d us\n", + bt_audio_codec_cfg_get_frame_duration_us(codec_cfg)); + if (bt_audio_codec_cfg_get_chan_allocation_val(codec_cfg, &chan_allocation) == 0) { printk(" Channel allocation: 0x%x\n", chan_allocation); } printk(" Octets per frame: %d (negative means value not pressent)\n", - bt_codec_cfg_get_octets_per_frame(codec)); + bt_audio_codec_cfg_get_octets_per_frame(codec_cfg)); printk(" Frames per SDU: %d\n", - bt_codec_cfg_get_frame_blocks_per_sdu(codec, true)); + bt_audio_codec_cfg_get_frame_blocks_per_sdu(codec_cfg, true)); } - for (size_t i = 0; i < codec->meta_count; i++) { - printk("meta #%zu: type 0x%02x len %u\n", - i, codec->meta[i].data.type, - codec->meta[i].data.data_len); - print_hex(codec->meta[i].data.data, - codec->meta[i].data.data_len - - sizeof(codec->meta[i].data.type)); + for (size_t i = 0; i < codec_cfg->meta_count; i++) { + printk("meta #%zu: type 0x%02x len %u\n", i, codec_cfg->meta[i].data.type, + codec_cfg->meta[i].data.data_len); + print_hex(codec_cfg->meta[i].data.data, + codec_cfg->meta[i].data.data_len - sizeof(codec_cfg->meta[i].data.type)); printk("\n"); } } -static void print_qos(const struct bt_codec_qos *qos) +static void print_qos(const struct bt_audio_codec_qos *qos) { printk("QoS: interval %u framing 0x%02x phy 0x%02x sdu %u " "rtn %u latency %u pd %u\n", @@ -154,13 +110,13 @@ static struct bt_bap_stream *stream_alloc(void) } static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_bap_stream **stream, - struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { printk("ASE Codec Config: conn %p ep %p dir %u\n", conn, ep, dir); - print_codec(codec); + print_codec_cfg(codec_cfg); *stream = stream_alloc(); if (*stream == NULL) { @@ -182,17 +138,17 @@ static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_ } static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_codec_qos_pref *const pref, - struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { printk("ASE Codec Reconfig: stream %p\n", stream); - print_codec(codec); + print_codec_cfg(codec_cfg); *pref = qos_pref; return 0; } -static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, +static int lc3_qos(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos, struct bt_bap_ascs_rsp *rsp) { printk("QoS: stream %p qos %p\n", stream, qos); @@ -202,7 +158,7 @@ static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, return 0; } -static int lc3_enable(struct bt_bap_stream *stream, const struct bt_codec_data *meta, +static int lc3_enable(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { printk("Enable: stream %p meta_count %u\n", stream, meta_count); @@ -260,14 +216,14 @@ static bool valid_metadata_type(uint8_t type, uint8_t len) } } -static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_codec_data *meta, +static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { printk("Metadata: stream %p meta_count %u\n", stream, meta_count); bool stream_context_present = false; for (size_t i = 0; i < meta_count; i++) { - const struct bt_codec_data *data = &meta[i]; + const struct bt_audio_codec_data *data = &meta[i]; if (!valid_metadata_type(data->data.type, data->data.data_len)) { printk("Invalid metadata type %u or length %u\n", @@ -392,52 +348,8 @@ BT_CONN_CB_DEFINE(conn_callbacks) = { .disconnected = disconnected, }; -static struct bt_pacs_cap cap_sink_16_1_1 = { - .codec = &codec_cfg_snk_16_1_1.codec, -}; - -static struct bt_pacs_cap cap_source_16_1_1 = { - .codec = &codec_cfg_src_16_1_1.codec, -}; - -static struct bt_pacs_cap cap_sink_32_1_1 = { - .codec = &codec_cfg_snk_32_1_1.codec, -}; - -static struct bt_pacs_cap cap_source_32_1_1 = { - .codec = &codec_cfg_src_32_1_1.codec, -}; - -static struct bt_pacs_cap cap_sink_32_2_1 = { - .codec = &codec_cfg_snk_32_2_1.codec, -}; - -static struct bt_pacs_cap cap_source_32_2_1 = { - .codec = &codec_cfg_src_32_2_1.codec, -}; - -static struct bt_pacs_cap cap_sink_48_1_1 = { - .codec = &codec_cfg_snk_48_1_1.codec, -}; - -static struct bt_pacs_cap cap_sink_48_2_1 = { - .codec = &codec_cfg_snk_48_2_1.codec, -}; - -static struct bt_pacs_cap cap_sink_48_3_1 = { - .codec = &codec_cfg_snk_48_3_1.codec, -}; - -static struct bt_pacs_cap cap_sink_48_4_1 = { - .codec = &codec_cfg_snk_48_4_1.codec, -}; - -static struct bt_pacs_cap cap_sink_48_5_1 = { - .codec = &codec_cfg_snk_48_5_1.codec, -}; - -static struct bt_pacs_cap cap_sink_48_6_1 = { - .codec = &codec_cfg_snk_48_6_1.codec, +static struct bt_pacs_cap cap = { + .codec_cap = &lc3_codec_cap, }; int bap_unicast_sr_init(void) @@ -446,17 +358,7 @@ int bap_unicast_sr_init(void) if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) { /* Register CT required capabilities */ - bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_16_1_1); - bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_32_1_1); - bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_32_2_1); - - /* Register UMR required capabilities */ - bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_1_1); - bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_2_1); - bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_3_1); - bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_4_1); - bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_5_1); - bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink_48_6_1); + bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap); if (IS_ENABLED(CONFIG_TMAP_PERIPHERAL_LEFT)) { bt_pacs_set_location(BT_AUDIO_DIR_SINK, BT_AUDIO_LOCATION_FRONT_LEFT); @@ -472,9 +374,7 @@ int bap_unicast_sr_init(void) if (IS_ENABLED(CONFIG_BT_ASCS_ASE_SRC)) { /* Register CT required capabilities */ - bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source_16_1_1); - bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source_32_1_1); - bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source_32_2_1); + bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap); if (IS_ENABLED(CONFIG_TMAP_PERIPHERAL_LEFT)) { bt_pacs_set_location(BT_AUDIO_DIR_SOURCE, BT_AUDIO_LOCATION_FRONT_LEFT); diff --git a/samples/bluetooth/unicast_audio_client/src/main.c b/samples/bluetooth/unicast_audio_client/src/main.c index 2b7d72cb71888ab..db3cd03efbab6c8 100644 --- a/samples/bluetooth/unicast_audio_client/src/main.c +++ b/samples/bluetooth/unicast_audio_client/src/main.c @@ -223,13 +223,14 @@ static void lc3_audio_timer_timeout(struct k_work *work) static void init_lc3(void) { + const struct bt_audio_codec_cfg *codec_cfg = &codec_configuration.codec_cfg; unsigned int num_samples; - freq_hz = bt_codec_cfg_get_freq(&codec_configuration.codec); - frame_duration_us = bt_codec_cfg_get_frame_duration_us(&codec_configuration.codec); - octets_per_frame = bt_codec_cfg_get_octets_per_frame(&codec_configuration.codec); - frames_per_sdu = bt_codec_cfg_get_frame_blocks_per_sdu(&codec_configuration.codec, true); - octets_per_frame = bt_codec_cfg_get_octets_per_frame(&codec_configuration.codec); + freq_hz = bt_audio_codec_cfg_get_freq(codec_cfg); + frame_duration_us = bt_audio_codec_cfg_get_frame_duration_us(codec_cfg); + octets_per_frame = bt_audio_codec_cfg_get_octets_per_frame(codec_cfg); + frames_per_sdu = bt_audio_codec_cfg_get_frame_blocks_per_sdu(codec_cfg, true); + octets_per_frame = bt_audio_codec_cfg_get_octets_per_frame(codec_cfg); if (freq_hz < 0) { printk("Error: Codec frequency not set, cannot start codec."); @@ -352,28 +353,24 @@ static void print_hex(const uint8_t *ptr, size_t len) } } -static void print_codec_capabilities(const struct bt_codec *codec) +static void print_codec_cap(const struct bt_audio_codec_cap *codec_cap) { - printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n", - codec->id, codec->cid, codec->vid, codec->data_count); - - for (size_t i = 0; i < codec->data_count; i++) { - printk("data #%zu: type 0x%02x len %u\n", - i, codec->data[i].data.type, - codec->data[i].data.data_len); - print_hex(codec->data[i].data.data, - codec->data[i].data.data_len - - sizeof(codec->data[i].data.type)); + printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cap->id, codec_cap->cid, + codec_cap->vid, codec_cap->data_count); + + for (size_t i = 0; i < codec_cap->data_count; i++) { + printk("data #%zu: type 0x%02x len %u\n", i, codec_cap->data[i].data.type, + codec_cap->data[i].data.data_len); + print_hex(codec_cap->data[i].data.data, + codec_cap->data[i].data.data_len - sizeof(codec_cap->data[i].data.type)); printk("\n"); } - for (size_t i = 0; i < codec->meta_count; i++) { - printk("meta #%zu: type 0x%02x len %u\n", - i, codec->meta[i].data.type, - codec->meta[i].data.data_len); - print_hex(codec->meta[i].data.data, - codec->meta[i].data.data_len - - sizeof(codec->meta[i].data.type)); + for (size_t i = 0; i < codec_cap->meta_count; i++) { + printk("meta #%zu: type 0x%02x len %u\n", i, codec_cap->meta[i].data.type, + codec_cap->meta[i].data.data_len); + print_hex(codec_cap->meta[i].data.data, + codec_cap->meta[i].data.data_len - sizeof(codec_cap->meta[i].data.type)); printk("\n"); } } @@ -485,7 +482,7 @@ static void start_scan(void) } static void stream_configured(struct bt_bap_stream *stream, - const struct bt_codec_qos_pref *pref) + const struct bt_audio_codec_qos_pref *pref) { printk("Audio Stream %p configured\n", stream); @@ -591,11 +588,12 @@ static void add_remote_sink(struct bt_bap_ep *ep) printk("Could not add sink ep\n"); } -static void print_remote_codec(const struct bt_codec *codec_capabilities, enum bt_audio_dir dir) +static void print_remote_codec_cap(const struct bt_audio_codec_cap *codec_cap, + enum bt_audio_dir dir) { - printk("codec_capabilities %p dir 0x%02x\n", codec_capabilities, dir); + printk("codec_cap %p dir 0x%02x\n", codec_cap, dir); - print_codec_capabilities(codec_capabilities); + print_codec_cap(codec_cap); } static void discover_sinks_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir) @@ -712,9 +710,10 @@ static void available_contexts_cb(struct bt_conn *conn, printk("snk ctx %u src ctx %u\n", snk_ctx, src_ctx); } -static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, const struct bt_codec *codec) +static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, + const struct bt_audio_codec_cap *codec_cap) { - print_remote_codec(codec, dir); + print_remote_codec_cap(codec_cap, dir); } static void endpoint_cb(struct bt_conn *conn, enum bt_audio_dir dir, struct bt_bap_ep *ep) @@ -837,8 +836,7 @@ static int configure_stream(struct bt_bap_stream *stream, struct bt_bap_ep *ep) { int err; - err = bt_bap_stream_config(default_conn, stream, ep, - &codec_configuration.codec); + err = bt_bap_stream_config(default_conn, stream, ep, &codec_configuration.codec_cfg); if (err != 0) { return err; } @@ -982,9 +980,8 @@ static int enable_streams(void) for (size_t i = 0U; i < configured_stream_count; i++) { int err; - err = bt_bap_stream_enable(&streams[i], - codec_configuration.codec.meta, - codec_configuration.codec.meta_count); + err = bt_bap_stream_enable(&streams[i], codec_configuration.codec_cfg.meta, + codec_configuration.codec_cfg.meta_count); if (err != 0) { printk("Unable to enable stream: %d\n", err); return err; diff --git a/samples/bluetooth/unicast_audio_server/src/main.c b/samples/bluetooth/unicast_audio_server/src/main.c index 8197a9f5e3149db..32268c951784959 100644 --- a/samples/bluetooth/unicast_audio_server/src/main.c +++ b/samples/bluetooth/unicast_audio_server/src/main.c @@ -33,10 +33,10 @@ NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_ASCS_ASE_SRC_COUNT, BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU), CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL); -static struct bt_codec lc3_codec = - BT_CODEC_LC3(BT_CODEC_LC3_FREQ_ANY, BT_CODEC_LC3_DURATION_10, - BT_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u, - (BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA)); +static struct bt_audio_codec_cap lc3_codec_cap = + BT_AUDIO_CODEC_LC3(BT_AUDIO_CODEC_LC3_FREQ_ANY, BT_AUDIO_CODEC_LC3_DURATION_10, + BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u, + (BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA)); static struct bt_conn *default_conn; static struct k_work_delayable audio_send_work; @@ -49,8 +49,8 @@ static struct audio_source { } source_streams[CONFIG_BT_ASCS_ASE_SRC_COUNT]; static size_t configured_source_stream_count; -static const struct bt_codec_qos_pref qos_pref = BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, - 10, 40000, 40000, 40000, 40000); +static const struct bt_audio_codec_qos_pref qos_pref = + BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 40000, 40000, 40000, 40000); static K_SEM_DEFINE(sem_disconnected, 0, 1); @@ -118,50 +118,47 @@ void print_hex(const uint8_t *ptr, size_t len) } } -static void print_codec(const struct bt_codec *codec) +static void print_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg) { - printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n", - codec->id, codec->cid, codec->vid, codec->data_count); - - for (size_t i = 0; i < codec->data_count; i++) { - printk("data #%zu: type 0x%02x len %u\n", - i, codec->data[i].data.type, - codec->data[i].data.data_len); - print_hex(codec->data[i].data.data, - codec->data[i].data.data_len - - sizeof(codec->data[i].data.type)); + printk("codec_cfg 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cfg->id, codec_cfg->cid, + codec_cfg->vid, codec_cfg->data_count); + + for (size_t i = 0; i < codec_cfg->data_count; i++) { + printk("data #%zu: type 0x%02x len %u\n", i, codec_cfg->data[i].data.type, + codec_cfg->data[i].data.data_len); + print_hex(codec_cfg->data[i].data.data, + codec_cfg->data[i].data.data_len - sizeof(codec_cfg->data[i].data.type)); printk("\n"); } - if (codec->id == BT_CODEC_LC3_ID) { + if (codec_cfg->id == BT_AUDIO_CODEC_LC3_ID) { /* LC3 uses the generic LTV format - other codecs might do as well */ enum bt_audio_location chan_allocation; - printk(" Frequency: %d Hz\n", bt_codec_cfg_get_freq(codec)); - printk(" Frame Duration: %d us\n", bt_codec_cfg_get_frame_duration_us(codec)); - if (bt_codec_cfg_get_chan_allocation_val(codec, &chan_allocation) == 0) { + printk(" Frequency: %d Hz\n", bt_audio_codec_cfg_get_freq(codec_cfg)); + printk(" Frame Duration: %d us\n", + bt_audio_codec_cfg_get_frame_duration_us(codec_cfg)); + if (bt_audio_codec_cfg_get_chan_allocation_val(codec_cfg, &chan_allocation) == 0) { printk(" Channel allocation: 0x%x\n", chan_allocation); } printk(" Octets per frame: %d (negative means value not pressent)\n", - bt_codec_cfg_get_octets_per_frame(codec)); + bt_audio_codec_cfg_get_octets_per_frame(codec_cfg)); printk(" Frames per SDU: %d\n", - bt_codec_cfg_get_frame_blocks_per_sdu(codec, true)); + bt_audio_codec_cfg_get_frame_blocks_per_sdu(codec_cfg, true)); } - for (size_t i = 0; i < codec->meta_count; i++) { - printk("meta #%zu: type 0x%02x len %u\n", - i, codec->meta[i].data.type, - codec->meta[i].data.data_len); - print_hex(codec->meta[i].data.data, - codec->meta[i].data.data_len - - sizeof(codec->meta[i].data.type)); + for (size_t i = 0; i < codec_cfg->meta_count; i++) { + printk("meta #%zu: type 0x%02x len %u\n", i, codec_cfg->meta[i].data.type, + codec_cfg->meta[i].data.data_len); + print_hex(codec_cfg->meta[i].data.data, + codec_cfg->meta[i].data.data_len - sizeof(codec_cfg->meta[i].data.type)); printk("\n"); } } -static void print_qos(const struct bt_codec_qos *qos) +static void print_qos(const struct bt_audio_codec_qos *qos) { printk("QoS: interval %u framing 0x%02x phy 0x%02x sdu %u " "rtn %u latency %u pd %u\n", @@ -277,12 +274,12 @@ static struct bt_bap_stream *stream_alloc(enum bt_audio_dir dir) } static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_bap_stream **stream, - struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { printk("ASE Codec Config: conn %p ep %p dir %u\n", conn, ep, dir); - print_codec(codec); + print_codec_cfg(codec_cfg); *stream = stream_alloc(dir); if (*stream == NULL) { @@ -309,12 +306,12 @@ static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_ } static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_codec_qos_pref *const pref, - struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { printk("ASE Codec Reconfig: stream %p\n", stream); - print_codec(codec); + print_codec_cfg(codec_cfg); #if defined(CONFIG_LIBLC3) /* Nothing to free as static memory is used */ @@ -327,7 +324,7 @@ static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, return -ENOEXEC; } -static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, +static int lc3_qos(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos, struct bt_bap_ascs_rsp *rsp) { printk("QoS: stream %p qos %p\n", stream, qos); @@ -344,15 +341,16 @@ static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, return 0; } -static int lc3_enable(struct bt_bap_stream *stream, const struct bt_codec_data *meta, +static int lc3_enable(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { printk("Enable: stream %p meta_count %u\n", stream, meta_count); #if defined(CONFIG_LIBLC3) { - const int freq = bt_codec_cfg_get_freq(stream->codec); - const int frame_duration_us = bt_codec_cfg_get_frame_duration_us(stream->codec); + const int freq = bt_audio_codec_cfg_get_freq(stream->codec_cfg); + const int frame_duration_us = + bt_audio_codec_cfg_get_frame_duration_us(stream->codec_cfg); if (freq < 0) { printk("Error: Codec frequency not set, cannot start codec."); @@ -368,7 +366,8 @@ static int lc3_enable(struct bt_bap_stream *stream, const struct bt_codec_data * return -1; } - frames_per_sdu = bt_codec_cfg_get_frame_blocks_per_sdu(stream->codec, true); + frames_per_sdu = + bt_audio_codec_cfg_get_frame_blocks_per_sdu(stream->codec_cfg, true); lc3_decoder = lc3_setup_decoder(frame_duration_us, freq, @@ -452,13 +451,13 @@ static bool valid_metadata_type(uint8_t type, uint8_t len) } } -static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_codec_data *meta, +static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { printk("Metadata: stream %p meta_count %u\n", stream, meta_count); for (size_t i = 0; i < meta_count; i++) { - const struct bt_codec_data *data = &meta[i]; + const struct bt_audio_codec_data *data = &meta[i]; if (!valid_metadata_type(data->data.type, data->data.data_len)) { printk("Invalid metadata type %u or length %u\n", @@ -644,11 +643,11 @@ BT_CONN_CB_DEFINE(conn_callbacks) = { }; static struct bt_pacs_cap cap_sink = { - .codec = &lc3_codec, + .codec_cap = &lc3_codec_cap, }; static struct bt_pacs_cap cap_source = { - .codec = &lc3_codec, + .codec_cap = &lc3_codec_cap, }; static int set_location(void) diff --git a/subsys/bluetooth/audio/Kconfig.bap b/subsys/bluetooth/audio/Kconfig.bap index d77bacb71803f42..4bb2361dc0a5634 100644 --- a/subsys/bluetooth/audio/Kconfig.bap +++ b/subsys/bluetooth/audio/Kconfig.bap @@ -38,7 +38,15 @@ config BT_BAP_UNICAST_CLIENT This option enables support for Bluetooth Unicast Audio Client using Isochronous channels. -config BT_CODEC_MAX_DATA_COUNT +config BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT + int "Codec Specific Configuration Data Count" + default 5 + range 1 128 + help + This option defines the maximum number of LTV entries a codec can + store. + +config BT_AUDIO_CODEC_CAP_MAX_DATA_COUNT int "Codec Capabilities Data Count" default 5 range 1 128 @@ -46,7 +54,7 @@ config BT_CODEC_MAX_DATA_COUNT This option defines the maximum number of LTV entries a codec can store. -config BT_CODEC_MAX_DATA_LEN +config BT_AUDIO_CODEC_MAX_DATA_LEN int "Codec Capabilities Data Length" default 4 range 1 128 @@ -54,8 +62,16 @@ config BT_CODEC_MAX_DATA_LEN This option defines the maximum value length of an LTV entry a codec can store. -config BT_CODEC_MAX_METADATA_COUNT - int "Codec Metadata Count" +config BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT + int "Codec Specific Configuration Metadata Count" + default 2 + range 1 128 + help + This option defines the maximum number of LTV entries a metadata can + store. + +config BT_AUDIO_CODEC_CAP_MAX_METADATA_COUNT + int "Codec Capabilities Metadata Count" default 2 range 1 128 help diff --git a/subsys/bluetooth/audio/ascs.c b/subsys/bluetooth/audio/ascs.c index fd79ed245bd8f74..cfa3dbe0f332cc3 100644 --- a/subsys/bluetooth/audio/ascs.c +++ b/subsys/bluetooth/audio/ascs.c @@ -62,12 +62,12 @@ static struct bt_ascs_ase { struct k_work_delayable disconnect_work; } ase_pool[CONFIG_BT_ASCS_MAX_ACTIVE_ASES]; -#define MAX_CODEC_CONFIG \ - MIN(UINT8_MAX, \ - CONFIG_BT_CODEC_MAX_DATA_COUNT * CONFIG_BT_CODEC_MAX_DATA_LEN) -#define MAX_METADATA \ - MIN(UINT8_MAX, \ - CONFIG_BT_CODEC_MAX_METADATA_COUNT * CONFIG_BT_CODEC_MAX_DATA_LEN) +#define MAX_CODEC_CONFIG \ + MIN(UINT8_MAX, \ + CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT * CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN) +#define MAX_METADATA \ + MIN(UINT8_MAX, \ + CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT * CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN) /* Minimum state size when in the codec configured state */ #define MIN_CONFIG_STATE_SIZE (1 + 1 + 1 + 1 + 1 + 2 + 3 + 3 + 3 + 3 + 5 + 1) @@ -458,8 +458,8 @@ void ascs_ep_set_state(struct bt_bap_ep *ep, uint8_t state) } } -static void ascs_codec_data_add(struct net_buf_simple *buf, const char *prefix, - uint8_t num, struct bt_codec_data *data) +static void ascs_codec_data_add(struct net_buf_simple *buf, const char *prefix, uint8_t num, + struct bt_audio_codec_data *data) { struct bt_ascs_codec_config *cc; int i; @@ -480,7 +480,7 @@ static void ascs_codec_data_add(struct net_buf_simple *buf, const char *prefix, static void ascs_ep_get_status_config(struct bt_bap_ep *ep, struct net_buf_simple *buf) { struct bt_ascs_ase_status_config *cfg; - struct bt_codec_qos_pref *pref = &ep->qos_pref; + struct bt_audio_codec_qos_pref *pref = &ep->qos_pref; cfg = net_buf_simple_add(buf, sizeof(*cfg)); cfg->framing = pref->unframed_supported ? BT_ASCS_QOS_FRAMING_UNFRAMED @@ -492,18 +492,18 @@ static void ascs_ep_get_status_config(struct bt_bap_ep *ep, struct net_buf_simpl sys_put_le24(pref->pd_max, cfg->pd_max); sys_put_le24(pref->pref_pd_min, cfg->prefer_pd_min); sys_put_le24(pref->pref_pd_max, cfg->prefer_pd_max); - cfg->codec.id = ep->codec.id; - cfg->codec.cid = sys_cpu_to_le16(ep->codec.cid); - cfg->codec.vid = sys_cpu_to_le16(ep->codec.vid); + cfg->codec.id = ep->codec_cfg.id; + cfg->codec.cid = sys_cpu_to_le16(ep->codec_cfg.cid); + cfg->codec.vid = sys_cpu_to_le16(ep->codec_cfg.vid); LOG_DBG("dir %s unframed_supported 0x%02x phy 0x%02x rtn %u " - "latency %u pd_min %u pd_max %u pref_pd_min %u pref_pd_max %u codec 0x%02x", + "latency %u pd_min %u pd_max %u pref_pd_min %u pref_pd_max %u codec id 0x%02x", bt_audio_dir_str(ep->dir), pref->unframed_supported, pref->phy, pref->rtn, pref->latency, pref->pd_min, pref->pd_max, pref->pref_pd_min, pref->pref_pd_max, - ep->stream->codec->id); + ep->stream->codec_cfg->id); cfg->cc_len = buf->len; - ascs_codec_data_add(buf, "data", ep->codec.data_count, ep->codec.data); + ascs_codec_data_add(buf, "data", ep->codec_cfg.data_count, ep->codec_cfg.data); cfg->cc_len = buf->len - cfg->cc_len; } @@ -522,12 +522,11 @@ static void ascs_ep_get_status_qos(struct bt_bap_ep *ep, struct net_buf_simple * qos->latency = sys_cpu_to_le16(ep->stream->qos->latency); sys_put_le24(ep->stream->qos->pd, qos->pd); - LOG_DBG("dir %s codec 0x%02x interval %u framing 0x%02x phy 0x%02x " - "rtn %u latency %u pd %u", - bt_audio_dir_str(ep->dir), ep->stream->codec->id, - ep->stream->qos->interval, ep->stream->qos->framing, - ep->stream->qos->phy, ep->stream->qos->rtn, - ep->stream->qos->latency, ep->stream->qos->pd); + LOG_DBG("dir %s codec id 0x%02x interval %u framing 0x%02x phy 0x%02x " + "rtn %u latency %u pd %u", + bt_audio_dir_str(ep->dir), ep->stream->codec_cfg->id, ep->stream->qos->interval, + ep->stream->qos->framing, ep->stream->qos->phy, ep->stream->qos->rtn, + ep->stream->qos->latency, ep->stream->qos->pd); } static void ascs_ep_get_status_enable(struct bt_bap_ep *ep, struct net_buf_simple *buf) @@ -539,7 +538,7 @@ static void ascs_ep_get_status_enable(struct bt_bap_ep *ep, struct net_buf_simpl enable->cis_id = ep->cis_id; enable->metadata_len = buf->len; - ascs_codec_data_add(buf, "meta", ep->codec.meta_count, ep->codec.meta); + ascs_codec_data_add(buf, "meta", ep->codec_cfg.meta_count, ep->codec_cfg.meta); enable->metadata_len = buf->len - enable->metadata_len; LOG_DBG("dir %s cig 0x%02x cis 0x%02x", @@ -1196,15 +1195,15 @@ static void ascs_cp_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) static bool ascs_codec_config_store(struct bt_data *data, void *user_data) { - struct bt_codec *codec = user_data; - struct bt_codec_data *cdata; + struct bt_audio_codec_cfg *codec_cfg = user_data; + struct bt_audio_codec_data *cdata; - if (codec->data_count >= ARRAY_SIZE(codec->data)) { + if (codec_cfg->data_count >= ARRAY_SIZE(codec_cfg->data)) { LOG_ERR("No slot available for Codec Config"); return false; } - cdata = &codec->data[codec->data_count]; + cdata = &codec_cfg->data[codec_cfg->data_count]; if (data->data_len > sizeof(cdata->value)) { LOG_ERR("Not enough space for Codec Config: %u > %zu", data->data_len, @@ -1212,7 +1211,7 @@ static bool ascs_codec_config_store(struct bt_data *data, void *user_data) return false; } - LOG_DBG("#%u type 0x%02x len %u", codec->data_count, data->type, data->data_len); + LOG_DBG("#%u type 0x%02x len %u", codec_cfg->data_count, data->type, data->data_len); cdata->data.type = data->type; cdata->data.data_len = data->data_len; @@ -1223,25 +1222,25 @@ static bool ascs_codec_config_store(struct bt_data *data, void *user_data) LOG_HEXDUMP_DBG(cdata->value, data->data_len, "data"); - codec->data_count++; + codec_cfg->data_count++; return true; } -struct codec_lookup_id_data { +struct codec_cap_lookup_id_data { uint8_t id; uint16_t cid; uint16_t vid; - struct bt_codec *codec; + struct bt_audio_codec_cap *codec_cap; }; static bool codec_lookup_id(const struct bt_pacs_cap *cap, void *user_data) { - struct codec_lookup_id_data *data = user_data; + struct codec_cap_lookup_id_data *data = user_data; - if (cap->codec->id == data->id && cap->codec->cid == data->cid && - cap->codec->vid == data->vid) { - data->codec = cap->codec; + if (cap->codec_cap->id == data->id && cap->codec_cap->cid == data->cid && + cap->codec_cap->vid == data->vid) { + data->codec_cap = cap->codec_cap; return false; } @@ -1253,8 +1252,8 @@ static int ascs_ep_set_codec(struct bt_bap_ep *ep, uint8_t id, uint16_t cid, uin uint8_t *cc, uint8_t len, struct bt_bap_ascs_rsp *rsp) { struct net_buf_simple ad; - struct bt_codec *codec; - struct codec_lookup_id_data lookup_data = { + struct bt_audio_codec_cfg *codec_cfg; + struct codec_cap_lookup_id_data lookup_data = { .id = id, .cid = cid, .vid = vid, @@ -1266,14 +1265,14 @@ static int ascs_ep_set_codec(struct bt_bap_ep *ep, uint8_t id, uint16_t cid, uin return -EINVAL; } - codec = &ep->codec; + codec_cfg = &ep->codec_cfg; LOG_DBG("ep %p dir %s codec id 0x%02x cid 0x%04x vid 0x%04x len %u", ep, bt_audio_dir_str(ep->dir), id, cid, vid, len); bt_pacs_cap_foreach(ep->dir, codec_lookup_id, &lookup_data); - if (lookup_data.codec == NULL) { + if (lookup_data.codec_cap == NULL) { LOG_DBG("Codec with id %u for dir %s is not supported by our capabilities", id, bt_audio_dir_str(ep->dir)); @@ -1282,11 +1281,11 @@ static int ascs_ep_set_codec(struct bt_bap_ep *ep, uint8_t id, uint16_t cid, uin return -ENOENT; } - codec->id = id; - codec->cid = cid; - codec->vid = vid; - codec->data_count = 0; - codec->path_id = lookup_data.codec->path_id; + codec_cfg->id = id; + codec_cfg->cid = cid; + codec_cfg->vid = vid; + codec_cfg->data_count = 0; + codec_cfg->path_id = lookup_data.codec_cap->path_id; if (len == 0) { *rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_SUCCESS, BT_BAP_ASCS_REASON_NONE); @@ -1296,12 +1295,12 @@ static int ascs_ep_set_codec(struct bt_bap_ep *ep, uint8_t id, uint16_t cid, uin net_buf_simple_init_with_data(&ad, cc, len); /* Parse LTV entries */ - bt_data_parse(&ad, ascs_codec_config_store, codec); + bt_data_parse(&ad, ascs_codec_config_store, codec_cfg); /* Check if all entries could be parsed */ if (ad.len) { LOG_ERR("Unable to parse Codec Config: len %u", ad.len); - (void)memset(codec, 0, sizeof(*codec)); + (void)memset(codec_cfg, 0, sizeof(*codec_cfg)); *rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_CONF_INVALID, BT_BAP_ASCS_REASON_CODEC_DATA); return -EINVAL; @@ -1314,15 +1313,15 @@ static int ascs_ep_set_codec(struct bt_bap_ep *ep, uint8_t id, uint16_t cid, uin static int ase_config(struct bt_ascs_ase *ase, const struct bt_ascs_config *cfg) { struct bt_bap_stream *stream; - struct bt_codec codec; + struct bt_audio_codec_cfg codec_cfg; struct bt_bap_ascs_rsp rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_SUCCESS, BT_BAP_ASCS_REASON_NONE); int err; LOG_DBG("ase %p latency 0x%02x phy 0x%02x codec 0x%02x " - "cid 0x%04x vid 0x%04x codec config len 0x%02x", ase, - cfg->latency, cfg->phy, cfg->codec.id, cfg->codec.cid, - cfg->codec.vid, cfg->cc_len); + "cid 0x%04x vid 0x%04x codec config len 0x%02x", + ase, cfg->latency, cfg->phy, cfg->codec.id, cfg->codec.cid, cfg->codec.vid, + cfg->cc_len); if (cfg->latency < BT_ASCS_CONFIG_LATENCY_LOW || cfg->latency > BT_ASCS_CONFIG_LATENCY_HIGH) { @@ -1359,14 +1358,13 @@ static int ase_config(struct bt_ascs_ase *ase, const struct bt_ascs_config *cfg) /* Store current codec configuration to be able to restore it * in case of error. */ - (void)memcpy(&codec, &ase->ep.codec, sizeof(codec)); + (void)memcpy(&codec_cfg, &ase->ep.codec_cfg, sizeof(codec_cfg)); - err = ascs_ep_set_codec(&ase->ep, cfg->codec.id, - sys_le16_to_cpu(cfg->codec.cid), - sys_le16_to_cpu(cfg->codec.vid), - (uint8_t *)cfg->cc, cfg->cc_len, &rsp); + err = ascs_ep_set_codec(&ase->ep, cfg->codec.id, sys_le16_to_cpu(cfg->codec.cid), + sys_le16_to_cpu(cfg->codec.vid), (uint8_t *)cfg->cc, cfg->cc_len, + &rsp); if (err) { - (void)memcpy(&ase->ep.codec, &codec, sizeof(codec)); + (void)memcpy(&ase->ep.codec_cfg, &codec_cfg, sizeof(codec_cfg)); ascs_cp_rsp_add(ASE_ID(ase), rsp.code, rsp.reason); return err; } @@ -1374,10 +1372,8 @@ static int ase_config(struct bt_ascs_ase *ase, const struct bt_ascs_config *cfg) if (ase->ep.stream != NULL) { if (unicast_server_cb != NULL && unicast_server_cb->reconfig != NULL) { - err = unicast_server_cb->reconfig(ase->ep.stream, - ase->ep.dir, - &ase->ep.codec, - &ase->ep.qos_pref, + err = unicast_server_cb->reconfig(ase->ep.stream, ase->ep.dir, + &ase->ep.codec_cfg, &ase->ep.qos_pref, &rsp); } else { err = -ENOTSUP; @@ -1394,7 +1390,7 @@ static int ase_config(struct bt_ascs_ase *ase, const struct bt_ascs_config *cfg) LOG_ERR("Reconfig failed: err %d, code %u, reason %u", err, rsp.code, rsp.reason); - (void)memcpy(&ase->ep.codec, &codec, sizeof(codec)); + (void)memcpy(&ase->ep.codec_cfg, &codec_cfg, sizeof(codec_cfg)); ascs_cp_rsp_add(ASE_ID(ase), rsp.code, rsp.reason); return err; @@ -1406,7 +1402,7 @@ static int ase_config(struct bt_ascs_ase *ase, const struct bt_ascs_config *cfg) if (unicast_server_cb != NULL && unicast_server_cb->config != NULL) { err = unicast_server_cb->config(ase->conn, &ase->ep, ase->ep.dir, - &ase->ep.codec, &stream, + &ase->ep.codec_cfg, &stream, &ase->ep.qos_pref, &rsp); } else { err = -ENOTSUP; @@ -1423,7 +1419,7 @@ static int ase_config(struct bt_ascs_ase *ase, const struct bt_ascs_config *cfg) LOG_ERR("Config failed: err %d, stream %p, code %u, reason %u", err, stream, rsp.code, rsp.reason); - (void)memcpy(&ase->ep.codec, &codec, sizeof(codec)); + (void)memcpy(&ase->ep.codec_cfg, &codec_cfg, sizeof(codec_cfg)); ascs_cp_rsp_add(ASE_ID(ase), rsp.code, rsp.reason); return err ? err : -ENOMEM; @@ -1434,15 +1430,16 @@ static int ase_config(struct bt_ascs_ase *ase, const struct bt_ascs_config *cfg) ascs_cp_rsp_success(ASE_ID(ase)); - bt_bap_stream_attach(ase->conn, stream, &ase->ep, &ase->ep.codec); + bt_bap_stream_attach(ase->conn, stream, &ase->ep, &ase->ep.codec_cfg); ascs_ep_set_state(&ase->ep, BT_BAP_EP_STATE_CODEC_CONFIGURED); return 0; } -int bt_ascs_config_ase(struct bt_conn *conn, struct bt_bap_stream *stream, struct bt_codec *codec, - const struct bt_codec_qos_pref *qos_pref) +int bt_ascs_config_ase(struct bt_conn *conn, struct bt_bap_stream *stream, + struct bt_audio_codec_cfg *codec_cfg, + const struct bt_audio_codec_qos_pref *qos_pref) { int err; struct bt_ascs_ase *ase; @@ -1450,7 +1447,7 @@ int bt_ascs_config_ase(struct bt_conn *conn, struct bt_bap_stream *stream, struc struct bt_bap_ascs_rsp rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_SUCCESS, BT_BAP_ASCS_REASON_NONE); - CHECKIF(conn == NULL || stream == NULL || codec == NULL || qos_pref == NULL) { + CHECKIF(conn == NULL || stream == NULL || codec_cfg == NULL || qos_pref == NULL) { LOG_DBG("NULL value(s) supplied)"); return -EINVAL; } @@ -1483,15 +1480,15 @@ int bt_ascs_config_ase(struct bt_conn *conn, struct bt_bap_stream *stream, struc return -EBADMSG; } - err = ascs_ep_set_codec(ep, codec->id, sys_le16_to_cpu(codec->cid), - sys_le16_to_cpu(codec->vid), NULL, 0, &rsp); + err = ascs_ep_set_codec(ep, codec_cfg->id, sys_le16_to_cpu(codec_cfg->cid), + sys_le16_to_cpu(codec_cfg->vid), NULL, 0, &rsp); if (err) { return err; } ep->qos_pref = *qos_pref; - bt_bap_stream_attach(conn, stream, ep, &ep->codec); + bt_bap_stream_attach(conn, stream, ep, &ep->codec_cfg); ascs_ep_set_state(ep, BT_BAP_EP_STATE_CODEC_CONFIGURED); @@ -1606,7 +1603,7 @@ void bt_ascs_foreach_ep(struct bt_conn *conn, bt_bap_ep_func_t func, void *user_ } } -static int ase_stream_qos(struct bt_bap_stream *stream, struct bt_codec_qos *qos, +static int ase_stream_qos(struct bt_bap_stream *stream, struct bt_audio_codec_qos *qos, struct bt_conn *conn, uint8_t cig_id, uint8_t cis_id, struct bt_bap_ascs_rsp *rsp) { @@ -1700,9 +1697,9 @@ static int ase_stream_qos(struct bt_bap_stream *stream, struct bt_codec_qos *qos * the CIS ID in the QoS procedure). */ if (ep->dir == BT_AUDIO_DIR_SINK) { - bt_audio_codec_to_iso_path(&ep->iso->rx.path, stream->codec); + bt_audio_codec_cfg_to_iso_path(&ep->iso->rx.path, stream->codec_cfg); } else { - bt_audio_codec_to_iso_path(&ep->iso->tx.path, stream->codec); + bt_audio_codec_cfg_to_iso_path(&ep->iso->tx.path, stream->codec_cfg); } ep->cig_id = cig_id; @@ -1718,7 +1715,7 @@ static void ase_qos(struct bt_ascs_ase *ase, const struct bt_ascs_qos *qos) { struct bt_bap_ep *ep = &ase->ep; struct bt_bap_stream *stream = ep->stream; - struct bt_codec_qos *cqos = &ep->qos; + struct bt_audio_codec_qos *cqos = &ep->qos; const uint8_t cig_id = qos->cig; const uint8_t cis_id = qos->cis; struct bt_bap_ascs_rsp rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_SUCCESS, @@ -1835,10 +1832,10 @@ static ssize_t ascs_qos(struct bt_conn *conn, struct net_buf_simple *buf) static bool ascs_codec_store_metadata(struct bt_data *data, void *user_data) { - struct bt_codec *codec = user_data; - struct bt_codec_data *meta; + struct bt_audio_codec_cfg *codec_cfg = user_data; + struct bt_audio_codec_data *meta; - meta = &codec->meta[codec->meta_count]; + meta = &codec_cfg->meta[codec_cfg->meta_count]; meta->data.type = data->type; meta->data.data_len = data->data_len; @@ -1846,9 +1843,9 @@ static bool ascs_codec_store_metadata(struct bt_data *data, void *user_data) meta->data.data = meta->value; (void)memcpy(meta->value, data->data, data->data_len); - LOG_DBG("#%zu: data: %s", codec->meta_count, bt_hex(meta->value, data->data_len)); + LOG_DBG("#%zu: data: %s", codec_cfg->meta_count, bt_hex(meta->value, data->data_len)); - codec->meta_count++; + codec_cfg->meta_count++; return true; } @@ -1872,9 +1869,9 @@ static bool ascs_parse_metadata(struct bt_data *data, void *user_data) LOG_DBG("#%u type 0x%02x len %u", result->count, data_type, data_len); - if (result->count > CONFIG_BT_CODEC_MAX_METADATA_COUNT) { + if (result->count > CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT) { LOG_ERR("Not enough buffers for Codec Config Metadata: %zu > %zu", result->count, - CONFIG_BT_CODEC_MAX_DATA_LEN); + CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN); *result->rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_NO_MEM, BT_BAP_ASCS_REASON_NONE); result->err = -ENOMEM; @@ -1882,9 +1879,9 @@ static bool ascs_parse_metadata(struct bt_data *data, void *user_data) return false; } - if (data_len > CONFIG_BT_CODEC_MAX_DATA_LEN) { + if (data_len > CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN) { LOG_ERR("Not enough space for Codec Config Metadata: %u > %zu", data->data_len, - CONFIG_BT_CODEC_MAX_DATA_LEN); + CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN); *result->rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_NO_MEM, BT_BAP_ASCS_REASON_NONE); result->err = -ENOMEM; @@ -1972,28 +1969,28 @@ static int ascs_verify_metadata(const struct net_buf_simple *buf, struct bt_bap_ } static int ascs_ep_set_metadata(struct bt_bap_ep *ep, uint8_t *data, uint8_t len, - struct bt_codec *codec, struct bt_bap_ascs_rsp *rsp) + struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_ascs_rsp *rsp) { struct net_buf_simple meta_ltv; int err; *rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_SUCCESS, BT_BAP_ASCS_REASON_NONE); - if (ep == NULL && codec == NULL) { + if (ep == NULL && codec_cfg == NULL) { *rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_INVALID_ASE_STATE, BT_BAP_ASCS_REASON_NONE); return -EINVAL; } - LOG_DBG("ep %p len %u codec %p", ep, len, codec); + LOG_DBG("ep %p len %u codec %p", ep, len, codec_cfg); if (len == 0) { - (void)memset(codec->meta, 0, sizeof(codec->meta)); + (void)memset(codec_cfg->meta, 0, sizeof(codec_cfg->meta)); *rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_SUCCESS, BT_BAP_ASCS_REASON_NONE); return 0; } - if (codec == NULL) { - codec = &ep->codec; + if (codec_cfg == NULL) { + codec_cfg = &ep->codec_cfg; } /* Extract metadata LTV for this specific endpoint */ @@ -2005,17 +2002,17 @@ static int ascs_ep_set_metadata(struct bt_bap_ep *ep, uint8_t *data, uint8_t len } /* reset cached metadata */ - ep->codec.meta_count = 0; + ep->codec_cfg.meta_count = 0; /* store data contents */ - bt_data_parse(&meta_ltv, ascs_codec_store_metadata, codec); + bt_data_parse(&meta_ltv, ascs_codec_store_metadata, codec_cfg); return 0; } static void ase_metadata(struct bt_ascs_ase *ase, struct bt_ascs_metadata *meta) { - struct bt_codec_data metadata_backup[CONFIG_BT_CODEC_MAX_METADATA_COUNT]; + struct bt_audio_codec_data metadata_backup[CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT]; struct bt_bap_stream *stream; struct bt_bap_ep *ep; struct bt_bap_ascs_rsp rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_SUCCESS, @@ -2046,8 +2043,8 @@ static void ase_metadata(struct bt_ascs_ase *ase, struct bt_ascs_metadata *meta) } /* Backup existing metadata */ - (void)memcpy(metadata_backup, ep->codec.meta, sizeof(metadata_backup)); - err = ascs_ep_set_metadata(ep, meta->data, meta->len, &ep->codec, &rsp); + (void)memcpy(metadata_backup, ep->codec_cfg.meta, sizeof(metadata_backup)); + err = ascs_ep_set_metadata(ep, meta->data, meta->len, &ep->codec_cfg, &rsp); if (err) { ascs_cp_rsp_add(ASE_ID(ase), rsp.code, rsp.reason); return; @@ -2055,8 +2052,8 @@ static void ase_metadata(struct bt_ascs_ase *ase, struct bt_ascs_metadata *meta) stream = ep->stream; if (unicast_server_cb != NULL && unicast_server_cb->metadata != NULL) { - err = unicast_server_cb->metadata(stream, ep->codec.meta, - ep->codec.meta_count, &rsp); + err = unicast_server_cb->metadata(stream, ep->codec_cfg.meta, + ep->codec_cfg.meta_count, &rsp); } else { err = -ENOTSUP; rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_UNSPECIFIED, @@ -2070,7 +2067,7 @@ static void ase_metadata(struct bt_ascs_ase *ase, struct bt_ascs_metadata *meta) } /* Restore backup */ - (void)memcpy(ep->codec.meta, metadata_backup, sizeof(metadata_backup)); + (void)memcpy(ep->codec_cfg.meta, metadata_backup, sizeof(metadata_backup)); LOG_ERR("Metadata failed: err %d, code %u, reason %u", err, rsp.code, rsp.reason); ascs_cp_rsp_add(ASE_ID(ase), rsp.code, rsp.reason); @@ -2104,7 +2101,7 @@ static int ase_enable(struct bt_ascs_ase *ase, struct bt_ascs_metadata *meta) return err; } - err = ascs_ep_set_metadata(ep, meta->data, meta->len, &ep->codec, &rsp); + err = ascs_ep_set_metadata(ep, meta->data, meta->len, &ep->codec_cfg, &rsp); if (err) { ascs_cp_rsp_add(ASE_ID(ase), rsp.code, rsp.reason); return err; @@ -2112,8 +2109,8 @@ static int ase_enable(struct bt_ascs_ase *ase, struct bt_ascs_metadata *meta) stream = ep->stream; if (unicast_server_cb != NULL && unicast_server_cb->enable != NULL) { - err = unicast_server_cb->enable(stream, ep->codec.meta, - ep->codec.meta_count, &rsp); + err = unicast_server_cb->enable(stream, ep->codec_cfg.meta, + ep->codec_cfg.meta_count, &rsp); } else { err = -ENOTSUP; rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_UNSPECIFIED, diff --git a/subsys/bluetooth/audio/ascs_internal.h b/subsys/bluetooth/audio/ascs_internal.h index 4e1839de575c6b8..ec8f763ba1573e8 100644 --- a/subsys/bluetooth/audio/ascs_internal.h +++ b/subsys/bluetooth/audio/ascs_internal.h @@ -342,7 +342,8 @@ void bt_ascs_cleanup(void); void ascs_ep_set_state(struct bt_bap_ep *ep, uint8_t state); -int bt_ascs_config_ase(struct bt_conn *conn, struct bt_bap_stream *stream, struct bt_codec *codec, - const struct bt_codec_qos_pref *qos_pref); +int bt_ascs_config_ase(struct bt_conn *conn, struct bt_bap_stream *stream, + struct bt_audio_codec_cfg *codec_cfg, + const struct bt_audio_codec_qos_pref *qos_pref); void bt_ascs_foreach_ep(struct bt_conn *conn, bt_bap_ep_func_t func, void *user_data); diff --git a/subsys/bluetooth/audio/audio.c b/subsys/bluetooth/audio/audio.c index a0ce5cf19d24481..bb9ec4ee5297410 100644 --- a/subsys/bluetooth/audio/audio.c +++ b/subsys/bluetooth/audio/audio.c @@ -109,11 +109,8 @@ ssize_t bt_audio_ccc_cfg_write(struct bt_conn *conn, const struct bt_gatt_attr * /* Broadcast sink depends on Scan Delegator, so we can just guard it with the Scan Delegator */ #if defined(CONFIG_BT_BAP_SCAN_DELEGATOR) -static int decode_codec_ltv(struct net_buf_simple *buf, - struct bt_codec_data *codec_data) +static int decode_codec_ltv(struct net_buf_simple *buf, struct bt_audio_codec_data *codec_data) { - void *value; - if (buf->len < sizeof(codec_data->data.data_len)) { LOG_DBG("Not enough data for LTV length field: %u", buf->len); @@ -135,6 +132,9 @@ static int decode_codec_ltv(struct net_buf_simple *buf, codec_data->data.type = net_buf_simple_pull_u8(buf); +#if CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > 0 + void *value; + codec_data->data.data = codec_data->value; if (buf->len < codec_data->data.data_len) { @@ -146,6 +146,15 @@ static int decode_codec_ltv(struct net_buf_simple *buf, value = net_buf_simple_pull_mem(buf, codec_data->data.data_len); (void)memcpy(codec_data->value, value, codec_data->data.data_len); +#else /* CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN == 0 */ + if (codec_data->data.data_len > 0) { + LOG_DBG("Cannot store data"); + + return -ENOMEM; + } + + codec_data->data.data = NULL; +#endif /* CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > 0 */ return 0; } @@ -177,6 +186,7 @@ static int decode_bis_data(struct net_buf_simple *buf, struct bt_bap_base_bis_da } if (len > 0) { +#if CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > 0 struct net_buf_simple ltv_buf; void *ltv_data; @@ -188,7 +198,7 @@ static int decode_bis_data(struct net_buf_simple *buf, struct bt_bap_base_bis_da while (ltv_buf.len != 0) { - struct bt_codec_data *bis_codec_data; + struct bt_audio_codec_data *bis_codec_data; int err; if (bis->data_count >= ARRAY_SIZE(bis->data)) { @@ -208,6 +218,11 @@ static int decode_bis_data(struct net_buf_simple *buf, struct bt_bap_base_bis_da bis->data_count++; } +#else /* CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN == 0 */ + LOG_DBG("Cannot store codec config data"); + + return -ENOMEM; +#endif /* CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN */ } return 0; @@ -216,11 +231,11 @@ static int decode_bis_data(struct net_buf_simple *buf, struct bt_bap_base_bis_da static int decode_subgroup(struct net_buf_simple *buf, struct bt_bap_base_subgroup *subgroup) { struct net_buf_simple ltv_buf; - struct bt_codec *codec; + struct bt_audio_codec_cfg *codec_cfg; void *ltv_data; uint8_t len; - codec = &subgroup->codec; + codec_cfg = &subgroup->codec_cfg; subgroup->bis_count = net_buf_simple_pull_u8(buf); if (subgroup->bis_count > ARRAY_SIZE(subgroup->bis_data)) { @@ -230,9 +245,9 @@ static int decode_subgroup(struct net_buf_simple *buf, struct bt_bap_base_subgro return -ENOMEM; } - codec->id = net_buf_simple_pull_u8(buf); - codec->cid = net_buf_simple_pull_le16(buf); - codec->vid = net_buf_simple_pull_le16(buf); + codec_cfg->id = net_buf_simple_pull_u8(buf); + codec_cfg->cid = net_buf_simple_pull_le16(buf); + codec_cfg->vid = net_buf_simple_pull_le16(buf); /* codec configuration data length */ len = net_buf_simple_pull_u8(buf); @@ -242,7 +257,7 @@ static int decode_subgroup(struct net_buf_simple *buf, struct bt_bap_base_subgro return -EINVAL; } -#if CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 /* Use an extra net_buf_simple to be able to decode until it * is empty (len = 0) */ @@ -255,25 +270,25 @@ static int decode_subgroup(struct net_buf_simple *buf, struct bt_bap_base_subgro * broadcasted BASEs */ while (ltv_buf.len != 0) { - struct bt_codec_data *codec_data; + struct bt_audio_codec_data *codec_data; int err; - if (codec->data_count >= ARRAY_SIZE(codec->data)) { + if (codec_cfg->data_count >= ARRAY_SIZE(codec_cfg->data)) { LOG_WRN("BIS codec data overflow; discarding"); break; } - codec_data = &codec->data[codec->data_count]; + codec_data = &codec_cfg->data[codec_cfg->data_count]; err = decode_codec_ltv(<v_buf, codec_data); if (err != 0) { LOG_DBG("Failed to decode codec config data for entry %u: %d", - codec->data_count, err); + codec_cfg->data_count, err); return err; } - codec->data_count++; + codec_cfg->data_count++; } if (buf->len < sizeof(len)) { @@ -281,13 +296,13 @@ static int decode_subgroup(struct net_buf_simple *buf, struct bt_bap_base_subgro return -ENOMEM; } -#else /* CONFIG_BT_CODEC_MAX_DATA_COUNT == 0 */ +#else /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT == 0 */ if (len > 0) { LOG_DBG("Cannot store codec config data"); return -ENOMEM; } -#endif /* CONFIG_BT_CODEC_MAX_DATA_COUNT */ +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT */ /* codec metadata length */ len = net_buf_simple_pull_u8(buf); @@ -297,7 +312,7 @@ static int decode_subgroup(struct net_buf_simple *buf, struct bt_bap_base_subgro return -EMSGSIZE; } -#if CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 /* Use an extra net_buf_simple to be able to decode until it * is empty (len = 0) */ @@ -310,33 +325,33 @@ static int decode_subgroup(struct net_buf_simple *buf, struct bt_bap_base_subgro * broadcasted BASEs */ while (ltv_buf.len != 0) { - struct bt_codec_data *metadata; + struct bt_audio_codec_data *metadata; int err; - if (codec->meta_count >= ARRAY_SIZE(codec->meta)) { + if (codec_cfg->meta_count >= ARRAY_SIZE(codec_cfg->meta)) { LOG_WRN("BIS codec metadata overflow; discarding"); break; } - metadata = &codec->meta[codec->meta_count]; + metadata = &codec_cfg->meta[codec_cfg->meta_count]; err = decode_codec_ltv(<v_buf, metadata); if (err != 0) { LOG_DBG("Failed to decode codec metadata for entry %u: %d", - codec->meta_count, err); + codec_cfg->meta_count, err); return err; } - codec->meta_count++; + codec_cfg->meta_count++; } -#else /* CONFIG_BT_CODEC_MAX_METADATA_COUNT == 0 */ +#else /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT == 0 */ if (len > 0) { LOG_DBG("Cannot store metadata"); return -ENOMEM; } -#endif /* CONFIG_BT_CODEC_MAX_METADATA_COUNT */ +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT */ for (size_t i = 0U; i < subgroup->bis_count; i++) { const int err = decode_bis_data(buf, &subgroup->bis_data[i]); @@ -419,7 +434,7 @@ int bt_bap_decode_base(struct bt_data *data, struct bt_bap_base *base) } #endif /* CONFIG_BT_BAP_SCAN_DELEGATOR */ -ssize_t bt_audio_codec_data_to_buf(const struct bt_codec_data *codec_data, size_t count, +ssize_t bt_audio_codec_data_to_buf(const struct bt_audio_codec_data *codec_data, size_t count, uint8_t *buf, size_t buf_size) { size_t total_len = 0; diff --git a/subsys/bluetooth/audio/bap_broadcast_sink.c b/subsys/bluetooth/audio/bap_broadcast_sink.c index d4ecf7d86825ab1..66a45fef555a378 100644 --- a/subsys/bluetooth/audio/bap_broadcast_sink.c +++ b/subsys/bluetooth/audio/bap_broadcast_sink.c @@ -46,9 +46,9 @@ static struct bt_bap_ep broadcast_sink_eps[CONFIG_BT_BAP_BROADCAST_SNK_COUNT] static struct bt_bap_broadcast_sink broadcast_sinks[CONFIG_BT_BAP_BROADCAST_SNK_COUNT]; static struct bt_le_scan_cb broadcast_scan_cb; -struct codec_lookup_id_data { +struct codec_cap_lookup_id_data { uint8_t id; - struct bt_codec *codec; + struct bt_audio_codec_cap *codec_cap; }; static sys_slist_t sink_cbs = SYS_SLIST_STATIC_INIT(&sink_cbs); @@ -244,7 +244,7 @@ static void broadcast_sink_set_ep_state(struct bt_bap_ep *ep, uint8_t state) if (stream != NULL) { bt_bap_iso_unbind_ep(ep->iso, ep); stream->ep = NULL; - stream->codec = NULL; + stream->codec_cfg = NULL; ep->stream = NULL; } } @@ -589,11 +589,11 @@ static void update_recv_state_base_copy_meta(const struct bt_bap_base *base, size_t total_len; /* Copy metadata into subgroup_param, changing it from an array - * of bt_codec_data to a uint8_t buffer + * of bt_audio_codec_data to a uint8_t buffer */ total_len = 0U; - for (size_t j = 0; j < subgroup->codec.meta_count; j++) { - const struct bt_codec_data *meta = &subgroup->codec.meta[j]; + for (size_t j = 0; j < subgroup->codec_cfg.meta_count; j++) { + const struct bt_audio_codec_data *meta = &subgroup->codec_cfg.meta[j]; const struct bt_data *data = &meta->data; const uint8_t len = data->data_len; const uint8_t type = data->type; @@ -1126,7 +1126,8 @@ static struct bt_bap_ep *broadcast_sink_new_ep(uint8_t index) } static int bt_bap_broadcast_sink_setup_stream(struct bt_bap_broadcast_sink *sink, - struct bt_bap_stream *stream, struct bt_codec *codec) + struct bt_bap_stream *stream, + struct bt_audio_codec_cfg *codec_cfg) { struct bt_bap_iso *iso; struct bt_bap_ep *ep; @@ -1152,11 +1153,11 @@ static int bt_bap_broadcast_sink_setup_stream(struct bt_bap_broadcast_sink *sink bt_bap_iso_bind_ep(iso, ep); bt_audio_codec_qos_to_iso_qos(iso->chan.qos->rx, &sink->codec_qos); - bt_audio_codec_to_iso_path(iso->chan.qos->rx->path, codec); + bt_audio_codec_cfg_to_iso_path(iso->chan.qos->rx->path, codec_cfg); bt_bap_iso_unref(iso); - bt_bap_stream_attach(NULL, stream, ep, codec); + bt_bap_stream_attach(NULL, stream, ep, codec_cfg); stream->qos = &sink->codec_qos; return 0; @@ -1174,7 +1175,7 @@ static void broadcast_sink_cleanup_streams(struct bt_bap_broadcast_sink *sink) } stream->qos = NULL; - stream->codec = NULL; + stream->codec_cfg = NULL; stream->group = NULL; sys_slist_remove(&sink->streams, NULL, &stream->_node); @@ -1203,14 +1204,15 @@ static void broadcast_sink_cleanup(struct bt_bap_broadcast_sink *sink) (void)memset(sink, 0, sizeof(*sink)); /* also clears flags */ } -static struct bt_codec *codec_from_base_by_index(struct bt_bap_base *base, uint8_t index) +static struct bt_audio_codec_cfg *codec_cfg_from_base_by_index(struct bt_bap_base *base, + uint8_t index) { for (size_t i = 0U; i < base->subgroup_count; i++) { struct bt_bap_base_subgroup *subgroup = &base->subgroups[i]; for (size_t j = 0U; j < subgroup->bis_count; j++) { if (subgroup->bis_data[j].index == index) { - return &subgroup->codec; + return &subgroup->codec_cfg; } } } @@ -1220,10 +1222,10 @@ static struct bt_codec *codec_from_base_by_index(struct bt_bap_base *base, uint8 static bool codec_lookup_id(const struct bt_pacs_cap *cap, void *user_data) { - struct codec_lookup_id_data *data = user_data; + struct codec_cap_lookup_id_data *data = user_data; - if (cap->codec->id == data->id) { - data->codec = cap->codec; + if (cap->codec_cap->id == data->id) { + data->codec_cap = cap->codec_cap; return false; } @@ -1297,7 +1299,7 @@ int bt_bap_broadcast_sink_sync(struct bt_bap_broadcast_sink *sink, uint32_t inde struct bt_bap_stream *streams[], const uint8_t broadcast_code[16]) { struct bt_iso_big_sync_param param; - struct bt_codec *codecs[BROADCAST_SNK_STREAM_CNT] = { NULL }; + struct bt_audio_codec_cfg *codec_cfgs[BROADCAST_SNK_STREAM_CNT] = {NULL}; uint8_t stream_count; int err; @@ -1348,29 +1350,30 @@ int bt_bap_broadcast_sink_sync(struct bt_bap_broadcast_sink *sink, uint32_t inde stream_count = 0; for (int i = 1; i < BT_ISO_MAX_GROUP_ISO_COUNT; i++) { if ((indexes_bitfield & BIT(i)) != 0) { - struct bt_codec *codec = codec_from_base_by_index(&sink->base, i); - struct codec_lookup_id_data lookup_data = { }; + struct bt_audio_codec_cfg *codec_cfg = + codec_cfg_from_base_by_index(&sink->base, i); + struct codec_cap_lookup_id_data lookup_data = {}; - if (codec == NULL) { + if (codec_cfg == NULL) { LOG_DBG("Index %d not found in BASE", i); return -EINVAL; } /* Lookup and assign path_id based on capabilities */ - lookup_data.id = codec->id; + lookup_data.id = codec_cfg->id; bt_pacs_cap_foreach(BT_AUDIO_DIR_SINK, codec_lookup_id, &lookup_data); - if (lookup_data.codec == NULL) { + if (lookup_data.codec_cap == NULL) { LOG_DBG("Codec with id %u is not supported by our capabilities", - codec->id); + codec_cfg->id); return -ENOENT; } - codec->path_id = lookup_data.codec->path_id; + codec_cfg->path_id = lookup_data.codec_cap->path_id; - codecs[stream_count++] = codec; + codec_cfgs[stream_count++] = codec_cfg; if (stream_count > BROADCAST_SNK_STREAM_CNT) { LOG_DBG("Cannot sync to more than %d streams", @@ -1390,12 +1393,12 @@ int bt_bap_broadcast_sink_sync(struct bt_bap_broadcast_sink *sink, uint32_t inde sink->stream_count = 0U; for (size_t i = 0; i < stream_count; i++) { struct bt_bap_stream *stream; - struct bt_codec *codec; + struct bt_audio_codec_cfg *codec_cfg; stream = streams[i]; - codec = codecs[i]; + codec_cfg = codec_cfgs[i]; - err = bt_bap_broadcast_sink_setup_stream(sink, stream, codec); + err = bt_bap_broadcast_sink_setup_stream(sink, stream, codec_cfg); if (err != 0) { LOG_DBG("Failed to setup streams[%zu]: %d", i, err); broadcast_sink_cleanup_streams(sink); diff --git a/subsys/bluetooth/audio/bap_broadcast_source.c b/subsys/bluetooth/audio/bap_broadcast_source.c index e24b61274a784fa..24e8d9f9cc3e914 100644 --- a/subsys/bluetooth/audio/bap_broadcast_source.c +++ b/subsys/bluetooth/audio/bap_broadcast_source.c @@ -27,7 +27,7 @@ struct bt_bap_broadcast_subgroup { sys_slist_t streams; /* The codec of the subgroup */ - struct bt_codec *codec; + struct bt_audio_codec_cfg *codec_cfg; /* List node */ sys_snode_t _node; @@ -265,7 +265,8 @@ static struct bt_bap_broadcast_subgroup *broadcast_source_new_subgroup(uint8_t i } static int broadcast_source_setup_stream(uint8_t index, struct bt_bap_stream *stream, - struct bt_codec *codec, struct bt_codec_qos *qos, + struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos *qos, struct bt_bap_broadcast_source *source) { struct bt_bap_iso *iso; @@ -287,11 +288,11 @@ static int broadcast_source_setup_stream(uint8_t index, struct bt_bap_stream *st bt_bap_iso_bind_ep(iso, ep); bt_audio_codec_qos_to_iso_qos(iso->chan.qos->tx, qos); - bt_audio_codec_to_iso_path(iso->chan.qos->tx->path, codec); + bt_audio_codec_cfg_to_iso_path(iso->chan.qos->tx->path, codec_cfg); bt_bap_iso_unref(iso); - bt_bap_stream_attach(NULL, stream, ep, codec); + bt_bap_stream_attach(NULL, stream, ep, codec_cfg); stream->qos = qos; ep->broadcast_source = source; @@ -303,7 +304,7 @@ static bool encode_base_subgroup(struct bt_bap_broadcast_subgroup *subgroup, uint8_t *streams_encoded, struct net_buf_simple *buf) { struct bt_bap_stream *stream; - const struct bt_codec *codec; + const struct bt_audio_codec_cfg *codec_cfg; uint8_t stream_count; uint8_t bis_index; uint8_t *start; @@ -314,19 +315,18 @@ static bool encode_base_subgroup(struct bt_bap_broadcast_subgroup *subgroup, stream_count++; } - codec = subgroup->codec; + codec_cfg = subgroup->codec_cfg; net_buf_simple_add_u8(buf, stream_count); - net_buf_simple_add_u8(buf, codec->id); - net_buf_simple_add_le16(buf, codec->cid); - net_buf_simple_add_le16(buf, codec->vid); - + net_buf_simple_add_u8(buf, codec_cfg->id); + net_buf_simple_add_le16(buf, codec_cfg->cid); + net_buf_simple_add_le16(buf, codec_cfg->vid); /* Insert codec configuration data in LTV format */ start = net_buf_simple_add(buf, sizeof(len)); - for (int i = 0; i < codec->data_count; i++) { - const struct bt_data *codec_data = &codec->data[i].data; + for (int i = 0; i < codec_cfg->data_count; i++) { + const struct bt_data *codec_data = &codec_cfg->data[i].data; if ((buf->size - buf->len) < (sizeof(codec_data->data_len) + sizeof(codec_data->type) + @@ -339,7 +339,6 @@ static bool encode_base_subgroup(struct bt_bap_broadcast_subgroup *subgroup, net_buf_simple_add_u8(buf, codec_data->data_len + sizeof(codec_data->type)); net_buf_simple_add_u8(buf, codec_data->type); net_buf_simple_add_mem(buf, codec_data->data, codec_data->data_len); - } /* Calculate length of codec config data */ len = net_buf_simple_tail(buf) - start - sizeof(len); @@ -354,8 +353,8 @@ static bool encode_base_subgroup(struct bt_bap_broadcast_subgroup *subgroup, /* Insert codec metadata in LTV format*/ start = net_buf_simple_add(buf, sizeof(len)); - for (int i = 0; i < codec->meta_count; i++) { - const struct bt_data *metadata = &codec->meta[i].data; + for (int i = 0; i < codec_cfg->meta_count; i++) { + const struct bt_data *metadata = &codec_cfg->meta[i].data; if ((buf->size - buf->len) < (sizeof(metadata->data_len) + sizeof(metadata->type) + @@ -395,7 +394,7 @@ static bool encode_base_subgroup(struct bt_bap_broadcast_subgroup *subgroup, /* Insert codec configuration data in LTV format */ start = net_buf_simple_add(buf, sizeof(len)); -#if defined(CONFIG_BT_CODEC_MAX_DATA_COUNT) +#if defined(CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT) for (size_t j = 0U; j < stream_data[i].data_count; j++) { const struct bt_data *codec_data = &stream_data[i].data[j].data; @@ -412,7 +411,7 @@ static bool encode_base_subgroup(struct bt_bap_broadcast_subgroup *subgroup, net_buf_simple_add_u8(buf, codec_data->type); net_buf_simple_add_mem(buf, codec_data->data, codec_data->data_len); } -#endif /* CONFIG_BT_CODEC_MAX_DATA_COUNT */ +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT */ /* Calculate length of codec config data */ len = net_buf_simple_tail(buf) - start - sizeof(len); @@ -504,7 +503,7 @@ static void broadcast_source_cleanup(struct bt_bap_broadcast_source *source) bt_bap_iso_unbind_ep(stream->ep->iso, stream->ep); stream->ep->stream = NULL; stream->ep = NULL; - stream->codec = NULL; + stream->codec_cfg = NULL; stream->qos = NULL; stream->group = NULL; @@ -519,7 +518,7 @@ static void broadcast_source_cleanup(struct bt_bap_broadcast_source *source) static bool valid_create_param(const struct bt_bap_broadcast_source_create_param *param) { - const struct bt_codec_qos *qos; + const struct bt_audio_codec_qos *qos; CHECKIF(param == NULL) { LOG_DBG("param is NULL"); @@ -580,8 +579,8 @@ static bool valid_create_param(const struct bt_bap_broadcast_source_create_param return false; } - CHECKIF(!bt_audio_valid_codec(subgroup_param->codec)) { - LOG_DBG("subgroup_params[%zu].codec is invalid", i); + CHECKIF(!bt_audio_valid_codec_cfg(subgroup_param->codec_cfg)) { + LOG_DBG("subgroup_params[%zu].codec_cfg is invalid", i); return false; } @@ -610,12 +609,13 @@ static bool valid_create_param(const struct bt_bap_broadcast_source_create_param return false; } -#if CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 - CHECKIF(stream_param->data_count > CONFIG_BT_CODEC_MAX_DATA_COUNT) { +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 + CHECKIF(stream_param->data_count > + CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT) { LOG_DBG("subgroup_params[%zu].stream_params[%zu]->data_count too " "large: %zu/%d", i, j, stream_param->data_count, - CONFIG_BT_CODEC_MAX_DATA_COUNT); + CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT); return false; } @@ -629,7 +629,7 @@ static bool valid_create_param(const struct bt_bap_broadcast_source_create_param } } } -#endif /* CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 */ +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 */ } return true; @@ -673,7 +673,7 @@ int bt_bap_broadcast_source_create(struct bt_bap_broadcast_source_create_param * struct bt_bap_broadcast_source **out_source) { struct bt_bap_broadcast_source *source; - struct bt_codec_qos *qos; + struct bt_audio_codec_qos *qos; size_t stream_count; uint8_t index; int err; @@ -723,7 +723,7 @@ int bt_bap_broadcast_source_create(struct bt_bap_broadcast_source_create_param * return -ENOMEM; } - subgroup->codec = subgroup_param->codec; + subgroup->codec_cfg = subgroup_param->codec_cfg; sys_slist_append(&source->subgroups, &subgroup->_node); /* Check that we are not above the maximum BIS count */ @@ -742,8 +742,7 @@ int bt_bap_broadcast_source_create(struct bt_bap_broadcast_source_create_param * stream = stream_param->stream; err = broadcast_source_setup_stream(index, stream, - subgroup_param->codec, - qos, source); + subgroup_param->codec_cfg, qos, source); if (err != 0) { LOG_DBG("Failed to setup streams[%zu]: %d", i, err); broadcast_source_cleanup(source); @@ -794,8 +793,9 @@ int bt_bap_broadcast_source_create(struct bt_bap_broadcast_source_create_param * return 0; } -int bt_bap_broadcast_source_reconfig(struct bt_bap_broadcast_source *source, struct bt_codec *codec, - struct bt_codec_qos *qos) +int bt_bap_broadcast_source_reconfig(struct bt_bap_broadcast_source *source, + struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos *qos) { struct bt_bap_broadcast_subgroup *subgroup; enum bt_bap_ep_state broadcast_state; @@ -806,8 +806,8 @@ int bt_bap_broadcast_source_reconfig(struct bt_bap_broadcast_source *source, str return -EINVAL; } - CHECKIF(!bt_audio_valid_codec(codec)) { - LOG_DBG("codec is invalid"); + CHECKIF(!bt_audio_valid_codec_cfg(codec_cfg)) { + LOG_DBG("codec_cfg is invalid"); return -EINVAL; } @@ -838,10 +838,10 @@ int bt_bap_broadcast_source_reconfig(struct bt_bap_broadcast_source *source, str iso_qos = stream->ep->iso->chan.qos->tx; - bt_bap_stream_attach(NULL, stream, stream->ep, codec); + bt_bap_stream_attach(NULL, stream, stream->ep, codec_cfg); bt_audio_codec_qos_to_iso_qos(iso_qos, qos); - bt_audio_codec_to_iso_path(iso_qos->path, codec); + bt_audio_codec_cfg_to_iso_path(iso_qos->path, codec_cfg); stream->qos = qos; } } @@ -851,30 +851,30 @@ int bt_bap_broadcast_source_reconfig(struct bt_bap_broadcast_source *source, str return 0; } -static void broadcast_source_store_metadata(struct bt_codec *codec, - const struct bt_codec_data meta[], +static void broadcast_source_store_metadata(struct bt_audio_codec_cfg *codec_cfg, + const struct bt_audio_codec_data meta[], size_t meta_count) { size_t old_meta_count; - old_meta_count = codec->meta_count; + old_meta_count = codec_cfg->meta_count; /* Update metadata */ - codec->meta_count = meta_count; - (void)memcpy(codec->meta, meta, meta_count * sizeof(*meta)); + codec_cfg->meta_count = meta_count; + (void)memcpy(codec_cfg->meta, meta, meta_count * sizeof(*meta)); if (old_meta_count > meta_count) { size_t meta_count_diff = old_meta_count - meta_count; /* If we previously had more metadata entries we reset the * data that was not overwritten by the new metadata */ - (void)memset(&codec->meta[meta_count], - 0, meta_count_diff * sizeof(*meta)); + (void)memset(&codec_cfg->meta[meta_count], 0, meta_count_diff * sizeof(*meta)); } } int bt_bap_broadcast_source_update_metadata(struct bt_bap_broadcast_source *source, - const struct bt_codec_data meta[], size_t meta_count) + const struct bt_audio_codec_data meta[], + size_t meta_count) { struct bt_bap_broadcast_subgroup *subgroup; enum bt_bap_ep_state broadcast_state; @@ -893,9 +893,9 @@ int bt_bap_broadcast_source_update_metadata(struct bt_bap_broadcast_source *sour return -EINVAL; } - CHECKIF(meta_count > CONFIG_BT_CODEC_MAX_METADATA_COUNT) { - LOG_DBG("Invalid meta_count: %zu (max %d)", - meta_count, CONFIG_BT_CODEC_MAX_METADATA_COUNT); + CHECKIF(meta_count > CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT) { + LOG_DBG("Invalid meta_count: %zu (max %d)", meta_count, + CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT); return -EINVAL; } @@ -919,7 +919,7 @@ int bt_bap_broadcast_source_update_metadata(struct bt_bap_broadcast_source *sour * for each subgroup individually */ SYS_SLIST_FOR_EACH_CONTAINER(&source->subgroups, subgroup, _node) { - broadcast_source_store_metadata(subgroup->codec, meta, meta_count); + broadcast_source_store_metadata(subgroup->codec_cfg, meta, meta_count); } return 0; diff --git a/subsys/bluetooth/audio/bap_endpoint.h b/subsys/bluetooth/audio/bap_endpoint.h index b01acfa04118727..bef99f383b37953 100644 --- a/subsys/bluetooth/audio/bap_endpoint.h +++ b/subsys/bluetooth/audio/bap_endpoint.h @@ -38,9 +38,9 @@ struct bt_bap_ep { uint8_t cis_id; struct bt_ascs_ase_status status; struct bt_bap_stream *stream; - struct bt_codec codec; - struct bt_codec_qos qos; - struct bt_codec_qos_pref qos_pref; + struct bt_audio_codec_cfg codec_cfg; + struct bt_audio_codec_qos qos; + struct bt_audio_codec_qos_pref qos_pref; struct bt_bap_iso *iso; /* Used by the unicast server and client */ @@ -56,7 +56,7 @@ struct bt_bap_unicast_group { uint8_t index; bool allocated; /* QoS used to create the CIG */ - const struct bt_codec_qos *qos; + const struct bt_audio_codec_qos *qos; struct bt_iso_cig *cig; /* The ISO API for CIG creation requires an array of pointers to ISO channels */ struct bt_iso_chan *cis[UNICAST_GROUP_STREAM_CNT]; @@ -64,12 +64,12 @@ struct bt_bap_unicast_group { }; struct bt_audio_broadcast_stream_data { -#if defined(CONFIG_BT_CODEC_MAX_DATA_COUNT) +#if defined(CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT) /** Codec Specific Data count */ size_t data_count; /** Codec Specific Data */ - struct bt_codec_data data[CONFIG_BT_CODEC_MAX_DATA_COUNT]; -#endif /* CONFIG_BT_CODEC_MAX_DATA_COUNT */ + struct bt_audio_codec_data data[CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT]; +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT */ }; struct bt_bap_broadcast_source { @@ -79,7 +79,7 @@ struct bt_bap_broadcast_source { uint32_t broadcast_id; /* 24 bit */ struct bt_iso_big *big; - struct bt_codec_qos *qos; + struct bt_audio_codec_qos *qos; /* The codec specific configured data for each stream in the subgroup */ struct bt_audio_broadcast_stream_data stream_data[BROADCAST_STREAM_CNT]; @@ -121,7 +121,7 @@ struct bt_bap_broadcast_sink { uint16_t biginfo_num_bis; uint32_t broadcast_id; /* 24 bit */ struct bt_bap_base base; - struct bt_codec_qos codec_qos; + struct bt_audio_codec_qos codec_qos; struct bt_le_per_adv_sync *pa_sync; struct bt_iso_big *big; struct bt_iso_chan *bis[BROADCAST_SNK_STREAM_CNT]; diff --git a/subsys/bluetooth/audio/bap_iso.h b/subsys/bluetooth/audio/bap_iso.h index ec653065d43e5ce..abc586b9c0fd22e 100644 --- a/subsys/bluetooth/audio/bap_iso.h +++ b/subsys/bluetooth/audio/bap_iso.h @@ -16,7 +16,7 @@ struct bt_bap_iso_dir { struct bt_bap_ep *ep; struct bt_iso_chan_path path; struct bt_iso_chan_io_qos qos; - uint8_t cc[CONFIG_BT_CODEC_MAX_DATA_COUNT * CONFIG_BT_CODEC_MAX_DATA_LEN]; + uint8_t cc[CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT * CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN]; }; struct bt_bap_iso { diff --git a/subsys/bluetooth/audio/bap_stream.c b/subsys/bluetooth/audio/bap_stream.c index 5df9731d081e60e..ce50b22f6536a80 100644 --- a/subsys/bluetooth/audio/bap_stream.c +++ b/subsys/bluetooth/audio/bap_stream.c @@ -31,13 +31,13 @@ LOG_MODULE_REGISTER(bt_bap_stream, CONFIG_BT_BAP_STREAM_LOG_LEVEL); -static uint8_t pack_bt_codec_cc(const struct bt_codec *codec, uint8_t cc[]) +static uint8_t pack_bt_audio_codec_cc(const struct bt_audio_codec_cfg *codec_cfg, uint8_t cc[]) { uint8_t len; len = 0U; - for (size_t i = 0U; i < codec->data_count; i++) { - const struct bt_data *data = &codec->data[i].data; + for (size_t i = 0U; i < codec_cfg->data_count; i++) { + const struct bt_data *data = &codec_cfg->data[i].data; /* We assume that data_len and data has previously been verified * and that based on the Kconfigs we can assume that the length @@ -52,21 +52,21 @@ static uint8_t pack_bt_codec_cc(const struct bt_codec *codec, uint8_t cc[]) return len; } -void bt_audio_codec_to_iso_path(struct bt_iso_chan_path *path, - const struct bt_codec *codec) +void bt_audio_codec_cfg_to_iso_path(struct bt_iso_chan_path *path, + const struct bt_audio_codec_cfg *codec_cfg) { - path->pid = codec->path_id; - path->format = codec->id; - path->cid = codec->cid; - path->vid = codec->vid; - path->delay = 0; /* TODO: Add to bt_codec? Use presentation delay? */ - path->cc_len = pack_bt_codec_cc(codec, path->cc); + path->pid = codec_cfg->path_id; + path->format = codec_cfg->id; + path->cid = codec_cfg->cid; + path->vid = codec_cfg->vid; + path->delay = 0; /* TODO: Add to bt_audio_codec_cfg? Use presentation delay? */ + path->cc_len = pack_bt_audio_codec_cc(codec_cfg, path->cc); } #if defined(CONFIG_BT_BAP_UNICAST_CLIENT) || defined(CONFIG_BT_BAP_BROADCAST_SOURCE) || \ defined(CONFIG_BT_BAP_BROADCAST_SINK) void bt_audio_codec_qos_to_iso_qos(struct bt_iso_chan_io_qos *io, - const struct bt_codec_qos *codec_qos) + const struct bt_audio_codec_qos *codec_qos) { io->sdu = codec_qos->sdu; io->phy = codec_qos->phy; @@ -94,9 +94,9 @@ void bt_bap_stream_init(struct bt_bap_stream *stream) } void bt_bap_stream_attach(struct bt_conn *conn, struct bt_bap_stream *stream, struct bt_bap_ep *ep, - struct bt_codec *codec) + struct bt_audio_codec_cfg *codec_cfg) { - LOG_DBG("conn %p stream %p ep %p codec %p", (void *)conn, stream, ep, codec); + LOG_DBG("conn %p stream %p ep %p codec_cfg %p", (void *)conn, stream, ep, codec_cfg); if (conn != NULL) { __ASSERT(stream->conn == NULL || stream->conn == conn, @@ -105,7 +105,7 @@ void bt_bap_stream_attach(struct bt_conn *conn, struct bt_bap_stream *stream, st stream->conn = bt_conn_ref(conn); } } - stream->codec = codec; + stream->codec_cfg = codec_cfg; stream->ep = ep; ep->stream = stream; } @@ -140,7 +140,7 @@ int bt_bap_ep_get_info(const struct bt_bap_ep *ep, struct bt_bap_ep_info *info) return 0; } -enum bt_bap_ascs_reason bt_audio_verify_qos(const struct bt_codec_qos *qos) +enum bt_bap_ascs_reason bt_audio_verify_qos(const struct bt_audio_codec_qos *qos) { if (qos->interval < BT_ISO_SDU_INTERVAL_MIN || qos->interval > BT_ISO_SDU_INTERVAL_MAX) { @@ -149,14 +149,14 @@ enum bt_bap_ascs_reason bt_audio_verify_qos(const struct bt_codec_qos *qos) return BT_BAP_ASCS_REASON_INTERVAL; } - if (qos->framing > BT_CODEC_QOS_FRAMED) { + if (qos->framing > BT_AUDIO_CODEC_QOS_FRAMED) { LOG_DBG("Invalid Framing 0x%02x", qos->framing); return BT_BAP_ASCS_REASON_FRAMING; } - if (qos->phy != BT_CODEC_QOS_1M && - qos->phy != BT_CODEC_QOS_2M && - qos->phy != BT_CODEC_QOS_CODED) { + if (qos->phy != BT_AUDIO_CODEC_QOS_1M && + qos->phy != BT_AUDIO_CODEC_QOS_2M && + qos->phy != BT_AUDIO_CODEC_QOS_CODED) { LOG_DBG("Invalid PHY 0x%02x", qos->phy); return BT_BAP_ASCS_REASON_PHY; } @@ -182,7 +182,8 @@ enum bt_bap_ascs_reason bt_audio_verify_qos(const struct bt_codec_qos *qos) return BT_BAP_ASCS_REASON_NONE; } -bool bt_audio_valid_codec_data(const struct bt_codec_data *data) +#if CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > 0 +bool bt_audio_valid_codec_data(const struct bt_audio_codec_data *data) { if (data->data.data_len > ARRAY_SIZE(data->value)) { LOG_DBG("data invalid length: %zu/%zu", data->data.data_len, @@ -192,41 +193,42 @@ bool bt_audio_valid_codec_data(const struct bt_codec_data *data) return true; } +#endif /* CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > 0 */ -bool bt_audio_valid_codec(const struct bt_codec *codec) +bool bt_audio_valid_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg) { - if (codec == NULL) { + if (codec_cfg == NULL) { LOG_DBG("codec is NULL"); return false; } -#if CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 - if (codec->data_count > CONFIG_BT_CODEC_MAX_DATA_COUNT) { - LOG_DBG("codec->data_count (%zu) is invalid", codec->data_count); +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 + if (codec_cfg->data_count > CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT) { + LOG_DBG("codec_cfg->data_count (%zu) is invalid", codec_cfg->data_count); return false; } - for (size_t i = 0U; i < codec->data_count; i++) { - if (!bt_audio_valid_codec_data(&codec->data[i])) { - LOG_DBG("codec->data[%zu] invalid", i); + for (size_t i = 0U; i < codec_cfg->data_count; i++) { + if (!bt_audio_valid_codec_data(&codec_cfg->data[i])) { + LOG_DBG("codec_cfg->data[%zu] invalid", i); return false; } } -#endif /* CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 */ +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 */ -#if CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 - if (codec->meta_count > CONFIG_BT_CODEC_MAX_METADATA_COUNT) { - LOG_DBG("codec->meta_count (%zu) is invalid", codec->meta_count); +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 + if (codec_cfg->meta_count > CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT) { + LOG_DBG("codec_cfg->meta_count (%zu) is invalid", codec_cfg->meta_count); return false; } - for (size_t i = 0U; i < codec->meta_count; i++) { - if (!bt_audio_valid_codec_data(&codec->meta[i])) { - LOG_DBG("codec->meta[%zu] invalid", i); + for (size_t i = 0U; i < codec_cfg->meta_count; i++) { + if (!bt_audio_valid_codec_data(&codec_cfg->meta[i])) { + LOG_DBG("codec_cfg->meta[%zu] invalid", i); return false; } } -#endif /* CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 */ +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 */ return true; } @@ -304,9 +306,9 @@ static bool bt_bap_stream_is_broadcast(const struct bt_bap_stream *stream) } enum bt_bap_ascs_reason bt_bap_stream_verify_qos(const struct bt_bap_stream *stream, - const struct bt_codec_qos *qos) + const struct bt_audio_codec_qos *qos) { - const struct bt_codec_qos_pref *qos_pref = &stream->ep->qos_pref; + const struct bt_audio_codec_qos_pref *qos_pref = &stream->ep->qos_pref; if (qos_pref->latency < qos->latency) { /* Latency is a preferred value. Print debug info but do not fail. */ @@ -332,7 +334,7 @@ void bt_bap_stream_detach(struct bt_bap_stream *stream) bt_conn_unref(stream->conn); stream->conn = NULL; } - stream->codec = NULL; + stream->codec_cfg = NULL; stream->ep->stream = NULL; stream->ep = NULL; @@ -387,17 +389,17 @@ static uint8_t conn_get_role(const struct bt_conn *conn) #if defined(CONFIG_BT_BAP_UNICAST_CLIENT) int bt_bap_stream_config(struct bt_conn *conn, struct bt_bap_stream *stream, struct bt_bap_ep *ep, - struct bt_codec *codec) + struct bt_audio_codec_cfg *codec_cfg) { uint8_t role; int err; - LOG_DBG("conn %p stream %p, ep %p codec %p codec id 0x%02x " + LOG_DBG("conn %p stream %p, ep %p codec_cfg %p codec id 0x%02x " "codec cid 0x%04x codec vid 0x%04x", (void *)conn, stream, ep, - codec, codec ? codec->id : 0, codec ? codec->cid : 0, - codec ? codec->vid : 0); + codec_cfg, codec_cfg ? codec_cfg->id : 0, codec_cfg ? codec_cfg->cid : 0, + codec_cfg ? codec_cfg->vid : 0); - CHECKIF(conn == NULL || stream == NULL || codec == NULL) { + CHECKIF(conn == NULL || stream == NULL || codec_cfg == NULL) { LOG_DBG("NULL value(s) supplied)"); return -EINVAL; } @@ -426,9 +428,9 @@ int bt_bap_stream_config(struct bt_conn *conn, struct bt_bap_stream *stream, str return -EBADMSG; } - bt_bap_stream_attach(conn, stream, ep, codec); + bt_bap_stream_attach(conn, stream, ep, codec_cfg); - err = bt_bap_unicast_client_config(stream, codec); + err = bt_bap_unicast_client_config(stream, codec_cfg); if (err != 0) { LOG_DBG("Failed to configure stream: %d", err); return err; @@ -475,7 +477,7 @@ int bt_bap_stream_qos(struct bt_conn *conn, struct bt_bap_unicast_group *group) } int bt_bap_stream_enable(struct bt_bap_stream *stream, - struct bt_codec_data *meta, + struct bt_audio_codec_data *meta, size_t meta_count) { uint8_t role; @@ -548,21 +550,21 @@ int bt_bap_stream_stop(struct bt_bap_stream *stream) #endif /* CONFIG_BT_BAP_UNICAST_CLIENT */ int bt_bap_stream_reconfig(struct bt_bap_stream *stream, - struct bt_codec *codec) + struct bt_audio_codec_cfg *codec_cfg) { uint8_t state; uint8_t role; int err; - LOG_DBG("stream %p codec %p", stream, codec); + LOG_DBG("stream %p codec_cfg %p", stream, codec_cfg); CHECKIF(stream == NULL || stream->ep == NULL || stream->conn == NULL) { LOG_DBG("Invalid stream"); return -EINVAL; } - CHECKIF(codec == NULL) { - LOG_DBG("codec is NULL"); + CHECKIF(codec_cfg == NULL) { + LOG_DBG("codec_cfg is NULL"); return -EINVAL; } @@ -582,9 +584,9 @@ int bt_bap_stream_reconfig(struct bt_bap_stream *stream, role = conn_get_role(stream->conn); if (IS_ENABLED(CONFIG_BT_BAP_UNICAST_CLIENT) && role == BT_HCI_ROLE_CENTRAL) { - err = bt_bap_unicast_client_config(stream, codec); + err = bt_bap_unicast_client_config(stream, codec_cfg); } else if (IS_ENABLED(CONFIG_BT_BAP_UNICAST_SERVER) && role == BT_HCI_ROLE_PERIPHERAL) { - err = bt_bap_unicast_server_reconfig(stream, codec); + err = bt_bap_unicast_server_reconfig(stream, codec_cfg); } else { err = -EOPNOTSUPP; } @@ -592,7 +594,7 @@ int bt_bap_stream_reconfig(struct bt_bap_stream *stream, if (err != 0) { LOG_DBG("reconfiguring stream failed: %d", err); } else { - stream->codec = codec; + stream->codec_cfg = codec_cfg; } return 0; @@ -639,7 +641,7 @@ int bt_bap_stream_start(struct bt_bap_stream *stream) } int bt_bap_stream_metadata(struct bt_bap_stream *stream, - struct bt_codec_data *meta, + struct bt_audio_codec_data *meta, size_t meta_count) { uint8_t state; diff --git a/subsys/bluetooth/audio/bap_stream.h b/subsys/bluetooth/audio/bap_stream.h index e7777f8d5a0b203..62bb51d0b269981 100644 --- a/subsys/bluetooth/audio/bap_stream.h +++ b/subsys/bluetooth/audio/bap_stream.h @@ -15,20 +15,21 @@ int bt_bap_stream_disconnect(struct bt_bap_stream *stream); void bt_bap_stream_reset(struct bt_bap_stream *stream); void bt_bap_stream_attach(struct bt_conn *conn, struct bt_bap_stream *stream, struct bt_bap_ep *ep, - struct bt_codec *codec); + struct bt_audio_codec_cfg *codec_cfg); -void bt_audio_codec_to_iso_path(struct bt_iso_chan_path *path, - const struct bt_codec *codec); +void bt_audio_codec_cfg_to_iso_path(struct bt_iso_chan_path *path, + const struct bt_audio_codec_cfg *codec_cfg); void bt_audio_codec_qos_to_iso_qos(struct bt_iso_chan_io_qos *io, - const struct bt_codec_qos *codec_qos); + const struct bt_audio_codec_qos *codec_qos); void bt_bap_stream_detach(struct bt_bap_stream *stream); -enum bt_bap_ascs_reason bt_audio_verify_qos(const struct bt_codec_qos *qos); -bool bt_audio_valid_codec_data(const struct bt_codec_data *data); -bool bt_audio_valid_codec(const struct bt_codec *codec); +enum bt_bap_ascs_reason bt_audio_verify_qos(const struct bt_audio_codec_qos *qos); +bool bt_audio_valid_codec_data(const struct bt_audio_codec_data *data); +bool bt_audio_valid_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg); bool bt_bap_stream_can_disconnect(const struct bt_bap_stream *stream); + enum bt_bap_ascs_reason bt_bap_stream_verify_qos(const struct bt_bap_stream *stream, - const struct bt_codec_qos *qos); + const struct bt_audio_codec_qos *qos); struct bt_iso_chan *bt_bap_stream_iso_chan_get(struct bt_bap_stream *stream); diff --git a/subsys/bluetooth/audio/bap_unicast_client.c b/subsys/bluetooth/audio/bap_unicast_client.c index 37b243acfdc758f..53b4ca3ef4d49e9 100644 --- a/subsys/bluetooth/audio/bap_unicast_client.c +++ b/subsys/bluetooth/audio/bap_unicast_client.c @@ -115,10 +115,11 @@ static const struct bt_bap_unicast_client_cb *unicast_client_cbs; /* TODO: Move the functions to avoid these prototypes */ static int unicast_client_ep_set_metadata(struct bt_bap_ep *ep, void *data, uint8_t len, - struct bt_codec *codec); + struct bt_audio_codec_cfg *codec_cfg); -static int unicast_client_ep_set_codec(struct bt_bap_ep *ep, uint8_t id, uint16_t cid, uint16_t vid, - void *data, uint8_t len, struct bt_codec *codec); +static int unicast_client_ep_set_codec_cfg(struct bt_bap_ep *ep, uint8_t id, uint16_t cid, + uint16_t vid, void *data, uint8_t len, + struct bt_audio_codec_cfg *codec_cfg); static int unicast_client_ep_start(struct bt_bap_ep *ep, struct net_buf_simple *buf); @@ -629,7 +630,7 @@ static void unicast_client_ep_config_state(struct bt_bap_ep *ep, struct net_buf_ struct bt_bap_unicast_client_ep *client_ep = CONTAINER_OF(ep, struct bt_bap_unicast_client_ep, ep); struct bt_ascs_ase_status_config *cfg; - struct bt_codec_qos_pref *pref; + struct bt_audio_codec_qos_pref *pref; struct bt_bap_stream *stream; void *cc; @@ -652,11 +653,12 @@ static void unicast_client_ep_config_state(struct bt_bap_ep *ep, struct net_buf_ cfg = net_buf_simple_pull_mem(buf, sizeof(*cfg)); - if (stream->codec == NULL) { + if (stream->codec_cfg == NULL) { LOG_ERR("Stream %p does not have a codec configured", stream); return; - } else if (stream->codec->id != cfg->codec.id) { - LOG_ERR("Codec configuration mismatched: %u, %u", stream->codec->id, cfg->codec.id); + } else if (stream->codec_cfg->id != cfg->codec.id) { + LOG_ERR("Codec configuration mismatched: %u, %u", stream->codec_cfg->id, + cfg->codec.id); /* TODO: Release the stream? */ return; } @@ -685,10 +687,10 @@ static void unicast_client_ep_config_state(struct bt_bap_ep *ep, struct net_buf_ "latency %u pd_min %u pd_max %u pref_pd_min %u pref_pd_max %u codec 0x%02x ", bt_audio_dir_str(ep->dir), pref->unframed_supported, pref->phy, pref->rtn, pref->latency, pref->pd_min, pref->pd_max, pref->pref_pd_min, pref->pref_pd_max, - stream->codec->id); + stream->codec_cfg->id); - unicast_client_ep_set_codec(ep, cfg->codec.id, sys_le16_to_cpu(cfg->codec.cid), - sys_le16_to_cpu(cfg->codec.vid), cc, cfg->cc_len, NULL); + unicast_client_ep_set_codec_cfg(ep, cfg->codec.id, sys_le16_to_cpu(cfg->codec.cid), + sys_le16_to_cpu(cfg->codec.vid), cc, cfg->cc_len, NULL); /* Notify upper layer */ if (stream->ops != NULL && stream->ops->configured != NULL) { @@ -745,7 +747,7 @@ static void unicast_client_ep_qos_state(struct bt_bap_ep *ep, struct net_buf_sim LOG_DBG("dir %s cig 0x%02x cis 0x%02x codec 0x%02x interval %u " "framing 0x%02x phy 0x%02x rtn %u latency %u pd %u", - bt_audio_dir_str(ep->dir), ep->cig_id, ep->cis_id, stream->codec->id, + bt_audio_dir_str(ep->dir), ep->cig_id, ep->cis_id, stream->codec_cfg->id, stream->qos->interval, stream->qos->framing, stream->qos->phy, stream->qos->rtn, stream->qos->latency, stream->qos->pd); @@ -765,12 +767,12 @@ static void unicast_client_ep_qos_state(struct bt_bap_ep *ep, struct net_buf_sim /* If the endpoint is a source, then we need to * configure our RX parameters */ - bt_audio_codec_to_iso_path(&ep->iso->rx.path, stream->codec); + bt_audio_codec_cfg_to_iso_path(&ep->iso->rx.path, stream->codec_cfg); } else { /* If the endpoint is a sink, then we need to * configure our TX parameters */ - bt_audio_codec_to_iso_path(&ep->iso->tx.path, stream->codec); + bt_audio_codec_cfg_to_iso_path(&ep->iso->tx.path, stream->codec_cfg); } } @@ -1109,7 +1111,7 @@ static void unicast_client_ep_set_status(struct bt_bap_ep *ep, struct net_buf_si } static void unicast_client_codec_data_add(struct net_buf_simple *buf, const char *prefix, - size_t num, const struct bt_codec_data *data) + size_t num, const struct bt_audio_codec_data *data) { for (size_t i = 0; i < num; i++) { const struct bt_data *d = &data[i].data; @@ -1125,17 +1127,9 @@ static void unicast_client_codec_data_add(struct net_buf_simple *buf, const char } } -static bool unicast_client_codec_config_store(struct bt_data *data, void *user_data) +static bool unicast_client_codec_data_store(struct bt_data *data, void *user_data) { - struct bt_codec *codec = user_data; - struct bt_codec_data *cdata; - - if (codec->data_count >= ARRAY_SIZE(codec->data)) { - LOG_ERR("No slot available for Codec Config"); - return false; - } - - cdata = &codec->data[codec->data_count]; + struct bt_audio_codec_data *cdata = user_data; if (data->data_len > sizeof(cdata->value)) { LOG_ERR("Not enough space for Codec Config: %u > %zu", data->data_len, @@ -1143,8 +1137,6 @@ static bool unicast_client_codec_config_store(struct bt_data *data, void *user_d return false; } - LOG_DBG("#%u type 0x%02x len %u", codec->data_count, data->type, data->data_len); - cdata->data.type = data->type; cdata->data.data_len = data->data_len; @@ -1154,33 +1146,78 @@ static bool unicast_client_codec_config_store(struct bt_data *data, void *user_d LOG_HEXDUMP_DBG(cdata->value, data->data_len, "data"); - codec->data_count++; - return true; } -static int unicast_client_ep_set_codec(struct bt_bap_ep *ep, uint8_t id, uint16_t cid, uint16_t vid, - void *data, uint8_t len, struct bt_codec *codec) +static bool unicast_client_codec_config_cfg_store(struct bt_data *data, void *user_data) +{ + struct bt_audio_codec_cfg *codec_cfg = user_data; + struct bt_audio_codec_data *cdata; + + if (codec_cfg->data_count >= ARRAY_SIZE(codec_cfg->data)) { + LOG_ERR("No slot available for Codec Config"); + return false; + } + + cdata = &codec_cfg->data[codec_cfg->data_count]; + + LOG_DBG("#%u type 0x%02x len %u", codec_cfg->data_count, data->type, data->data_len); + + if (unicast_client_codec_data_store(data, cdata)) { + codec_cfg->data_count++; + + return true; + } + + return false; +} + +static bool unicast_client_codec_config_cap_store(struct bt_data *data, void *user_data) +{ + struct bt_audio_codec_cap *codec_cap = user_data; + struct bt_audio_codec_data *cdata; + + if (codec_cap->data_count >= ARRAY_SIZE(codec_cap->data)) { + LOG_ERR("No slot available for Codec Config"); + return false; + } + + cdata = &codec_cap->data[codec_cap->data_count]; + + LOG_DBG("#%u type 0x%02x len %u", codec_cap->data_count, data->type, data->data_len); + + if (unicast_client_codec_data_store(data, cdata)) { + codec_cap->data_count++; + + return true; + } + + return false; +} + +static int unicast_client_ep_set_codec_cfg(struct bt_bap_ep *ep, uint8_t id, uint16_t cid, + uint16_t vid, void *data, uint8_t len, + struct bt_audio_codec_cfg *codec_cfg) { struct net_buf_simple ad; - if (!ep && !codec) { + if (!ep && !codec_cfg) { return -EINVAL; } LOG_DBG("ep %p codec id 0x%02x cid 0x%04x vid 0x%04x len %u", ep, id, cid, vid, len); - if (!codec) { - codec = &ep->codec; + if (!codec_cfg) { + codec_cfg = &ep->codec_cfg; } - codec->id = id; - codec->cid = cid; - codec->vid = vid; + codec_cfg->id = id; + codec_cfg->cid = cid; + codec_cfg->vid = vid; /* Reset current metadata */ - codec->data_count = 0; - (void)memset(codec->data, 0, sizeof(codec->data)); + codec_cfg->data_count = 0; + (void)memset(codec_cfg->data, 0, sizeof(codec_cfg->data)); if (!len) { return 0; @@ -1189,7 +1226,7 @@ static int unicast_client_ep_set_codec(struct bt_bap_ep *ep, uint8_t id, uint16_ net_buf_simple_init_with_data(&ad, data, len); /* Parse LTV entries */ - bt_data_parse(&ad, unicast_client_codec_config_store, codec); + bt_data_parse(&ad, unicast_client_codec_config_cfg_store, codec_cfg); /* Check if all entries could be parsed */ if (ad.len) { @@ -1200,63 +1237,162 @@ static int unicast_client_ep_set_codec(struct bt_bap_ep *ep, uint8_t id, uint16_ return 0; fail: - (void)memset(codec, 0, sizeof(*codec)); + (void)memset(codec_cfg, 0, sizeof(*codec_cfg)); return -EINVAL; } -static bool unicast_client_codec_metadata_store(struct bt_data *data, void *user_data) +static int unicast_client_set_codec_cap(uint8_t id, uint16_t cid, uint16_t vid, void *data, + uint8_t len, struct bt_audio_codec_cap *codec_cap) { - struct bt_codec *codec = user_data; - struct bt_codec_data *meta; + struct net_buf_simple ad; - if (codec->meta_count >= ARRAY_SIZE(codec->meta)) { - LOG_ERR("No slot available for Codec Config Metadata"); - return false; + if (!codec_cap) { + return -EINVAL; } - meta = &codec->meta[codec->meta_count]; + LOG_DBG("codec id 0x%02x cid 0x%04x vid 0x%04x len %u", id, cid, vid, len); - if (data->data_len > sizeof(meta->value)) { - LOG_ERR("Not enough space for Codec Config Metadata: %u > %zu", data->data_len, - sizeof(meta->value)); - return false; + codec_cap->id = id; + codec_cap->cid = cid; + codec_cap->vid = vid; + + /* Reset current metadata */ + codec_cap->data_count = 0; + (void)memset(codec_cap->data, 0, sizeof(codec_cap->data)); + + if (!len) { + return 0; } - LOG_DBG("#%u type 0x%02x len %u", codec->meta_count, data->type, data->data_len); + net_buf_simple_init_with_data(&ad, data, len); + + /* Parse LTV entries */ + bt_data_parse(&ad, unicast_client_codec_config_cap_store, codec_cap); - meta->data.type = data->type; - meta->data.data_len = data->data_len; + /* Check if all entries could be parsed */ + if (ad.len) { + LOG_ERR("Unable to parse Codec Config: len %u", ad.len); + goto fail; + } - /* Deep copy data contents */ - meta->data.data = meta->value; - (void)memcpy(meta->value, data->data, data->data_len); + return 0; - LOG_HEXDUMP_DBG(meta->value, data->data_len, "data"); +fail: + (void)memset(codec_cap, 0, sizeof(*codec_cap)); + return -EINVAL; +} - codec->meta_count++; +static bool unicast_client_codec_cfg_metadata_store(struct bt_data *data, void *user_data) +{ + struct bt_audio_codec_cfg *codec_cfg = user_data; + struct bt_audio_codec_data *meta; - return true; + if (codec_cfg->data_count >= ARRAY_SIZE(codec_cfg->data)) { + LOG_ERR("No slot available for Codec Config"); + return false; + } + + meta = &codec_cfg->data[codec_cfg->meta_count]; + + LOG_DBG("#%u type 0x%02x len %u", codec_cfg->meta_count, data->type, data->data_len); + + if (unicast_client_codec_data_store(data, meta)) { + codec_cfg->meta_count++; + + return true; + } + + return false; } static int unicast_client_ep_set_metadata(struct bt_bap_ep *ep, void *data, uint8_t len, - struct bt_codec *codec) + struct bt_audio_codec_cfg *codec_cfg) { struct net_buf_simple meta; int err; - if (!ep && !codec) { + if (!ep && !codec_cfg) { return -EINVAL; } - LOG_DBG("ep %p len %u codec %p", ep, len, codec); + LOG_DBG("ep %p len %u codec_cfg %p", ep, len, codec_cfg); + + if (!codec_cfg) { + codec_cfg = &ep->codec_cfg; + } + + /* Reset current metadata */ + codec_cfg->meta_count = 0; + (void)memset(codec_cfg->meta, 0, sizeof(codec_cfg->meta)); + + if (!len) { + return 0; + } + + net_buf_simple_init_with_data(&meta, data, len); + + /* Parse LTV entries */ + bt_data_parse(&meta, unicast_client_codec_cfg_metadata_store, codec_cfg); + + /* Check if all entries could be parsed */ + if (meta.len) { + LOG_ERR("Unable to parse Metadata: len %u", meta.len); + err = -EINVAL; + + if (meta.len > 2) { + /* Value of the Metadata Type field in error */ + err = meta.data[2]; + } + + goto fail; + } + + return 0; + +fail: + codec_cfg->meta_count = 0; + (void)memset(codec_cfg->meta, 0, sizeof(codec_cfg->meta)); + return err; +} + +static bool unicast_client_codec_cap_metadata_store(struct bt_data *data, void *user_data) +{ + struct bt_audio_codec_cap *codec_cap = user_data; + struct bt_audio_codec_data *meta; + + if (codec_cap->meta_count >= ARRAY_SIZE(codec_cap->meta)) { + LOG_ERR("No slot available for Codec Config"); + return false; + } + + meta = &codec_cap->meta[codec_cap->meta_count]; + + LOG_DBG("#%u type 0x%02x len %u", codec_cap->meta_count, data->type, data->data_len); + + if (unicast_client_codec_data_store(data, meta)) { + codec_cap->meta_count++; - if (!codec) { - codec = &ep->codec; + return true; } + return false; +} + +static int unicast_client_set_codec_cap_metadata(void *data, uint8_t len, + struct bt_audio_codec_cap *codec_cap) +{ + struct net_buf_simple meta; + int err; + + if (!codec_cap) { + return -EINVAL; + } + + LOG_DBG("len %u codec_cap %p", len, codec_cap); + /* Reset current metadata */ - codec->meta_count = 0; - (void)memset(codec->meta, 0, sizeof(codec->meta)); + codec_cap->meta_count = 0; + (void)memset(codec_cap->meta, 0, sizeof(codec_cap->meta)); if (!len) { return 0; @@ -1265,7 +1401,7 @@ static int unicast_client_ep_set_metadata(struct bt_bap_ep *ep, void *data, uint net_buf_simple_init_with_data(&meta, data, len); /* Parse LTV entries */ - bt_data_parse(&meta, unicast_client_codec_metadata_store, codec); + bt_data_parse(&meta, unicast_client_codec_cap_metadata_store, codec_cap); /* Check if all entries could be parsed */ if (meta.len) { @@ -1283,8 +1419,8 @@ static int unicast_client_ep_set_metadata(struct bt_bap_ep *ep, void *data, uint return 0; fail: - codec->meta_count = 0; - (void)memset(codec->meta, 0, sizeof(codec->meta)); + codec_cap->meta_count = 0; + (void)memset(codec_cap->meta, 0, sizeof(codec_cap->meta)); return err; } @@ -1608,7 +1744,7 @@ static int unicast_client_ep_subscribe(struct bt_conn *conn, struct bt_bap_ep *e return bt_gatt_subscribe(conn, &client_ep->subscribe); } -static void pac_record_cb(struct bt_conn *conn, const struct bt_codec *codec) +static void pac_record_cb(struct bt_conn *conn, const struct bt_audio_codec_cap *codec_cap) { if (unicast_client_cbs != NULL && unicast_client_cbs->pac_record != NULL) { struct unicast_client *client = &uni_cli_insts[bt_conn_index(conn)]; @@ -1618,7 +1754,7 @@ static void pac_record_cb(struct bt_conn *conn, const struct bt_codec *codec) * index and total count of records in the callback, so that it easier for the * upper layers to determine when a new set of PAC records is being reported. */ - unicast_client_cbs->pac_record(conn, dir, codec); + unicast_client_cbs->pac_record(conn, dir, codec_cap); } } @@ -1723,12 +1859,12 @@ struct net_buf_simple *bt_bap_unicast_client_ep_create_pdu(struct bt_conn *conn, } static int unicast_client_ep_config(struct bt_bap_ep *ep, struct net_buf_simple *buf, - const struct bt_codec *codec) + const struct bt_audio_codec_cfg *codec_cfg) { struct bt_ascs_config *req; uint8_t cc_len; - LOG_DBG("ep %p buf %p codec %p", ep, buf, codec); + LOG_DBG("ep %p buf %p codec %p", ep, buf, codec_cfg); if (!ep) { return -EINVAL; @@ -1748,25 +1884,25 @@ static int unicast_client_ep_config(struct bt_bap_ep *ep, struct net_buf_simple } LOG_DBG("id 0x%02x dir %s codec 0x%02x", ep->status.id, bt_audio_dir_str(ep->dir), - codec->id); + codec_cfg->id); req = net_buf_simple_add(buf, sizeof(*req)); req->ase = ep->status.id; req->latency = 0x02; /* TODO: Select target latency based on additional input? */ req->phy = 0x02; /* TODO: Select target PHY based on additional input? */ - req->codec.id = codec->id; - req->codec.cid = codec->cid; - req->codec.vid = codec->vid; + req->codec.id = codec_cfg->id; + req->codec.cid = codec_cfg->cid; + req->codec.vid = codec_cfg->vid; cc_len = buf->len; - unicast_client_codec_data_add(buf, "data", codec->data_count, codec->data); + unicast_client_codec_data_add(buf, "data", codec_cfg->data_count, codec_cfg->data); req->cc_len = buf->len - cc_len; return 0; } int bt_bap_unicast_client_ep_qos(struct bt_bap_ep *ep, struct net_buf_simple *buf, - struct bt_codec_qos *qos) + struct bt_audio_codec_qos *qos) { struct bt_ascs_qos *req; struct bt_conn_iso *conn_iso; @@ -1812,7 +1948,7 @@ int bt_bap_unicast_client_ep_qos(struct bt_bap_ep *ep, struct net_buf_simple *bu } static int unicast_client_ep_enable(struct bt_bap_ep *ep, struct net_buf_simple *buf, - struct bt_codec_data *meta, size_t meta_count) + struct bt_audio_codec_data *meta, size_t meta_count) { struct bt_ascs_metadata *req; @@ -1840,7 +1976,7 @@ static int unicast_client_ep_enable(struct bt_bap_ep *ep, struct net_buf_simple } static int unicast_client_ep_metadata(struct bt_bap_ep *ep, struct net_buf_simple *buf, - struct bt_codec_data *meta, size_t meta_count) + struct bt_audio_codec_data *meta, size_t meta_count) { struct bt_ascs_metadata *req; @@ -2094,7 +2230,7 @@ static void unicast_client_ep_reset(struct bt_conn *conn) } static void bt_audio_codec_qos_to_cig_param(struct bt_iso_cig_param *cig_param, - const struct bt_codec_qos *qos) + const struct bt_audio_codec_qos *qos) { cig_param->framing = qos->framing; cig_param->packing = BT_ISO_PACKING_SEQUENTIAL; /* TODO: Add to QoS struct */ @@ -2107,7 +2243,8 @@ static void bt_audio_codec_qos_to_cig_param(struct bt_iso_cig_param *cig_param, * between CIS'es. The implementation shall take the CIG parameters from * unicast_group instead. */ -static int bt_audio_cig_create(struct bt_bap_unicast_group *group, const struct bt_codec_qos *qos) +static int bt_audio_cig_create(struct bt_bap_unicast_group *group, + const struct bt_audio_codec_qos *qos) { struct bt_iso_cig_param param; uint8_t cis_count; @@ -2141,7 +2278,7 @@ static int bt_audio_cig_create(struct bt_bap_unicast_group *group, const struct } static int bt_audio_cig_reconfigure(struct bt_bap_unicast_group *group, - const struct bt_codec_qos *qos) + const struct bt_audio_codec_qos *qos) { struct bt_iso_cig_param param; uint8_t cis_count; @@ -2280,7 +2417,7 @@ static void unicast_group_del_iso(struct bt_bap_unicast_group *group, struct bt_ } static void unicast_client_codec_qos_to_iso_qos(struct bt_bap_iso *iso, - const struct bt_codec_qos *qos, + const struct bt_audio_codec_qos *qos, enum bt_audio_dir dir) { struct bt_iso_chan_io_qos *io_qos; @@ -2323,7 +2460,7 @@ static void unicast_group_add_stream(struct bt_bap_unicast_group *group, struct bt_bap_iso *iso, enum bt_audio_dir dir) { struct bt_bap_stream *stream = param->stream; - struct bt_codec_qos *qos = param->qos; + struct bt_audio_codec_qos *qos = param->qos; LOG_DBG("group %p stream %p qos %p iso %p dir %u", group, stream, qos, iso, dir); @@ -2519,7 +2656,7 @@ static int stream_pair_param_check(const struct bt_bap_unicast_group_stream_pair return 0; } -static int group_qos_common_set(const struct bt_codec_qos **group_qos, +static int group_qos_common_set(const struct bt_audio_codec_qos **group_qos, const struct bt_bap_unicast_group_stream_pair_param *param) { if (param->rx_param != NULL && *group_qos == NULL) { @@ -2537,7 +2674,7 @@ int bt_bap_unicast_group_create(struct bt_bap_unicast_group_param *param, struct bt_bap_unicast_group **out_unicast_group) { struct bt_bap_unicast_group *unicast_group; - const struct bt_codec_qos *group_qos = NULL; + const struct bt_audio_codec_qos *group_qos = NULL; int err; CHECKIF(out_unicast_group == NULL) @@ -2608,7 +2745,7 @@ int bt_bap_unicast_group_add_streams(struct bt_bap_unicast_group *unicast_group, struct bt_bap_unicast_group_stream_pair_param params[], size_t num_param) { - const struct bt_codec_qos *group_qos = unicast_group->qos; + const struct bt_audio_codec_qos *group_qos = unicast_group->qos; struct bt_bap_stream *tmp_stream; size_t total_stream_cnt; struct bt_iso_cig *cig; @@ -2727,7 +2864,8 @@ int bt_bap_unicast_group_delete(struct bt_bap_unicast_group *unicast_group) return 0; } -int bt_bap_unicast_client_config(struct bt_bap_stream *stream, const struct bt_codec *codec) +int bt_bap_unicast_client_config(struct bt_bap_stream *stream, + const struct bt_audio_codec_cfg *codec_cfg) { struct bt_bap_ep *ep = stream->ep; struct bt_ascs_config_op *op; @@ -2751,7 +2889,7 @@ int bt_bap_unicast_client_config(struct bt_bap_stream *stream, const struct bt_c op = net_buf_simple_add(buf, sizeof(*op)); op->num_ases = 0x01; - err = unicast_client_ep_config(ep, buf, codec); + err = unicast_client_ep_config(ep, buf, codec_cfg); if (err != 0) { return err; } @@ -2891,7 +3029,7 @@ int bt_bap_unicast_client_qos(struct bt_conn *conn, struct bt_bap_unicast_group return 0; } -int bt_bap_unicast_client_enable(struct bt_bap_stream *stream, struct bt_codec_data *meta, +int bt_bap_unicast_client_enable(struct bt_bap_stream *stream, struct bt_audio_codec_data *meta, size_t meta_count) { struct bt_bap_ep *ep = stream->ep; @@ -2924,7 +3062,7 @@ int bt_bap_unicast_client_enable(struct bt_bap_stream *stream, struct bt_codec_d return bt_bap_unicast_client_ep_send(stream->conn, ep, buf); } -int bt_bap_unicast_client_metadata(struct bt_bap_stream *stream, struct bt_codec_data *meta, +int bt_bap_unicast_client_metadata(struct bt_bap_stream *stream, struct bt_audio_codec_data *meta, size_t meta_count) { struct bt_bap_ep *ep = stream->ep; @@ -3838,10 +3976,10 @@ static uint8_t unicast_client_read_func(struct bt_conn *conn, uint8_t err, } for (i = 0U; i < rsp->num_pac; i++) { + struct bt_audio_codec_cap codec_cap; struct bt_pac_codec *pac_codec; struct bt_pac_ltv_data *meta, *cc; void *cc_ltv, *meta_ltv; - struct bt_codec codec; LOG_DBG("pac #%u/%u", i + 1, rsp->num_pac); @@ -3883,22 +4021,22 @@ static uint8_t unicast_client_read_func(struct bt_conn *conn, uint8_t err, meta_ltv = net_buf_simple_pull_mem(buf, meta->len); - if (unicast_client_ep_set_codec( - NULL, pac_codec->id, sys_le16_to_cpu(pac_codec->cid), - sys_le16_to_cpu(pac_codec->vid), cc_ltv, cc->len, &codec)) { + if (unicast_client_set_codec_cap(pac_codec->id, sys_le16_to_cpu(pac_codec->cid), + sys_le16_to_cpu(pac_codec->vid), cc_ltv, cc->len, + &codec_cap)) { LOG_ERR("Unable to parse Codec"); break; } - if (unicast_client_ep_set_metadata(NULL, meta_ltv, meta->len, &codec)) { + if (unicast_client_set_codec_cap_metadata(meta_ltv, meta->len, &codec_cap)) { LOG_ERR("Unable to parse Codec Metadata"); break; } - LOG_DBG("codec 0x%02x config count %u meta count %u ", codec.id, codec.data_count, - codec.meta_count); + LOG_DBG("codec 0x%02x config count %u meta count %u ", codec_cap.id, + codec_cap.data_count, codec_cap.meta_count); - pac_record_cb(conn, &codec); + pac_record_cb(conn, &codec_cap); } reset_att_buf(client); diff --git a/subsys/bluetooth/audio/bap_unicast_client_internal.h b/subsys/bluetooth/audio/bap_unicast_client_internal.h index cb8f350ce234f95..2a5b25dea6eb32b 100644 --- a/subsys/bluetooth/audio/bap_unicast_client_internal.h +++ b/subsys/bluetooth/audio/bap_unicast_client_internal.h @@ -6,14 +6,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -int bt_bap_unicast_client_config(struct bt_bap_stream *stream, const struct bt_codec *codec); +int bt_bap_unicast_client_config(struct bt_bap_stream *stream, + const struct bt_audio_codec_cfg *codec_cfg); int bt_bap_unicast_client_qos(struct bt_conn *conn, struct bt_bap_unicast_group *group); -int bt_bap_unicast_client_enable(struct bt_bap_stream *stream, struct bt_codec_data *meta, +int bt_bap_unicast_client_enable(struct bt_bap_stream *stream, struct bt_audio_codec_data *meta, size_t meta_count); -int bt_bap_unicast_client_metadata(struct bt_bap_stream *stream, struct bt_codec_data *meta, +int bt_bap_unicast_client_metadata(struct bt_bap_stream *stream, struct bt_audio_codec_data *meta, size_t meta_count); int bt_bap_unicast_client_disable(struct bt_bap_stream *stream); @@ -27,7 +28,7 @@ int bt_bap_unicast_client_release(struct bt_bap_stream *stream); struct net_buf_simple *bt_bap_unicast_client_ep_create_pdu(struct bt_conn *conn, uint8_t op); int bt_bap_unicast_client_ep_qos(struct bt_bap_ep *ep, struct net_buf_simple *buf, - struct bt_codec_qos *qos); + struct bt_audio_codec_qos *qos); int bt_bap_unicast_client_ep_send(struct bt_conn *conn, struct bt_bap_ep *ep, struct net_buf_simple *buf); diff --git a/subsys/bluetooth/audio/bap_unicast_server.c b/subsys/bluetooth/audio/bap_unicast_server.c index 9c66a6fdc3ff560..d204a6b3babfa12 100644 --- a/subsys/bluetooth/audio/bap_unicast_server.c +++ b/subsys/bluetooth/audio/bap_unicast_server.c @@ -63,7 +63,8 @@ int bt_bap_unicast_server_unregister_cb(const struct bt_bap_unicast_server_cb *c return 0; } -int bt_bap_unicast_server_reconfig(struct bt_bap_stream *stream, const struct bt_codec *codec) +int bt_bap_unicast_server_reconfig(struct bt_bap_stream *stream, + const struct bt_audio_codec_cfg *codec_cfg) { struct bt_bap_ep *ep; struct bt_bap_ascs_rsp rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_SUCCESS, @@ -74,8 +75,7 @@ int bt_bap_unicast_server_reconfig(struct bt_bap_stream *stream, const struct bt if (unicast_server_cb != NULL && unicast_server_cb->reconfig != NULL) { - err = unicast_server_cb->reconfig(stream, ep->dir, codec, - &ep->qos_pref, &rsp); + err = unicast_server_cb->reconfig(stream, ep->dir, codec_cfg, &ep->qos_pref, &rsp); } else { err = -ENOTSUP; } @@ -84,7 +84,7 @@ int bt_bap_unicast_server_reconfig(struct bt_bap_stream *stream, const struct bt return err; } - (void)memcpy(&ep->codec, &codec, sizeof(codec)); + (void)memcpy(&ep->codec_cfg, codec_cfg, sizeof(*codec_cfg)); ascs_ep_set_state(ep, BT_BAP_EP_STATE_CODEC_CONFIGURED); @@ -114,7 +114,7 @@ int bt_bap_unicast_server_start(struct bt_bap_stream *stream) return 0; } -int bt_bap_unicast_server_metadata(struct bt_bap_stream *stream, struct bt_codec_data meta[], +int bt_bap_unicast_server_metadata(struct bt_bap_stream *stream, struct bt_audio_codec_data meta[], size_t meta_count) { struct bt_bap_ep *ep; @@ -131,8 +131,7 @@ int bt_bap_unicast_server_metadata(struct bt_bap_stream *stream, struct bt_codec ep = stream->ep; for (size_t i = 0U; i < meta_count; i++) { - (void)memcpy(&ep->codec.meta[i], &meta[i], - sizeof(ep->codec.meta[i])); + (void)memcpy(&ep->codec_cfg.meta[i], &meta[i], sizeof(ep->codec_cfg.meta[i])); } if (err) { @@ -204,10 +203,10 @@ int bt_bap_unicast_server_release(struct bt_bap_stream *stream) } int bt_bap_unicast_server_config_ase(struct bt_conn *conn, struct bt_bap_stream *stream, - struct bt_codec *codec, - const struct bt_codec_qos_pref *qos_pref) + struct bt_audio_codec_cfg *codec_cfg, + const struct bt_audio_codec_qos_pref *qos_pref) { - return bt_ascs_config_ase(conn, stream, codec, qos_pref); + return bt_ascs_config_ase(conn, stream, codec_cfg, qos_pref); } void bt_bap_unicast_server_foreach_ep(struct bt_conn *conn, bt_bap_ep_func_t func, void *user_data) diff --git a/subsys/bluetooth/audio/bap_unicast_server.h b/subsys/bluetooth/audio/bap_unicast_server.h index 26198bcf4721f90..8470ace1237ff70 100644 --- a/subsys/bluetooth/audio/bap_unicast_server.h +++ b/subsys/bluetooth/audio/bap_unicast_server.h @@ -9,9 +9,10 @@ #include #include -int bt_bap_unicast_server_reconfig(struct bt_bap_stream *stream, const struct bt_codec *codec); +int bt_bap_unicast_server_reconfig(struct bt_bap_stream *stream, + const struct bt_audio_codec_cfg *codec_cfg); int bt_bap_unicast_server_start(struct bt_bap_stream *stream); -int bt_bap_unicast_server_metadata(struct bt_bap_stream *stream, struct bt_codec_data meta[], +int bt_bap_unicast_server_metadata(struct bt_bap_stream *stream, struct bt_audio_codec_data meta[], size_t meta_count); int bt_bap_unicast_server_disable(struct bt_bap_stream *stream); int bt_bap_unicast_server_release(struct bt_bap_stream *stream); diff --git a/subsys/bluetooth/audio/cap_initiator.c b/subsys/bluetooth/audio/cap_initiator.c index d877f99b80b3f63..ec164de4b73b4fc 100644 --- a/subsys/bluetooth/audio/cap_initiator.c +++ b/subsys/bluetooth/audio/cap_initiator.c @@ -38,8 +38,7 @@ int bt_cap_initiator_register_cb(const struct bt_cap_initiator_cb *cb) return 0; } -static bool cap_initiator_valid_metadata(const struct bt_codec_data meta[], - size_t meta_count) +static bool cap_initiator_valid_metadata(const struct bt_audio_codec_data meta[], size_t meta_count) { bool stream_context_found; @@ -82,21 +81,21 @@ static bool cap_initiator_broadcast_audio_start_valid_param( for (size_t i = 0U; i < param->subgroup_count; i++) { const struct bt_cap_initiator_broadcast_subgroup_param *subgroup_param; - const struct bt_codec *codec; + const struct bt_audio_codec_cfg *codec_cfg; bool valid_metadata; subgroup_param = ¶m->subgroup_params[i]; - codec = subgroup_param->codec; + codec_cfg = subgroup_param->codec_cfg; /* Streaming Audio Context shall be present in CAP */ - CHECKIF(codec == NULL) { - LOG_DBG("subgroup[%zu]->codec is NULL", i); + CHECKIF(codec_cfg == NULL) { + LOG_DBG("subgroup[%zu]->codec_cfg is NULL", i); return false; } - valid_metadata = cap_initiator_valid_metadata(codec->meta, - codec->meta_count); + valid_metadata = + cap_initiator_valid_metadata(codec_cfg->meta, codec_cfg->meta_count); CHECKIF(!valid_metadata) { LOG_DBG("Invalid metadata supplied for subgroup[%zu]", i); @@ -135,7 +134,7 @@ static void cap_initiator_broadcast_to_bap_broadcast_param( struct bt_bap_broadcast_source_subgroup_param *bap_subgroup_param = &bap_param->params[i]; - bap_subgroup_param->codec = cap_subgroup_param->codec; + bap_subgroup_param->codec_cfg = cap_subgroup_param->codec_cfg; bap_subgroup_param->params_count = cap_subgroup_param->stream_count; bap_subgroup_param->params = &bap_stream_params[stream_cnt]; @@ -146,13 +145,13 @@ static void cap_initiator_broadcast_to_bap_broadcast_param( &bap_subgroup_param->params[j]; bap_stream_param->stream = &cap_stream_param->stream->bap_stream; -#if CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 bap_stream_param->data_count = cap_stream_param->data_count; /* We do not need to copy the data, as that is the same type of struct, so * we can just point to the CAP parameter data */ bap_stream_param->data = cap_stream_param->data; -#endif /* CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 */ +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 */ } } } @@ -212,7 +211,7 @@ int bt_cap_initiator_broadcast_audio_start(struct bt_cap_broadcast_source *broad } int bt_cap_initiator_broadcast_audio_update(struct bt_cap_broadcast_source *broadcast_source, - const struct bt_codec_data meta[], + const struct bt_audio_codec_data meta[], size_t meta_count) { CHECKIF(broadcast_source == NULL) { @@ -654,18 +653,16 @@ static bool valid_unicast_audio_start_param(const struct bt_cap_unicast_audio_st ¶m->stream_params[i]; const union bt_cap_set_member *member = &stream_param->member; const struct bt_cap_stream *cap_stream = stream_param->stream; - const struct bt_codec *codec = stream_param->codec; + const struct bt_audio_codec_cfg *codec_cfg = stream_param->codec_cfg; const struct bt_bap_stream *bap_stream; - CHECKIF(stream_param->codec == NULL) { - LOG_DBG("param->stream_params[%zu].codec is NULL", i); + CHECKIF(stream_param->codec_cfg == NULL) { + LOG_DBG("param->stream_params[%zu].codec_cfg is NULL", i); return false; } - CHECKIF(!cap_initiator_valid_metadata(codec->meta, - codec->meta_count)) { - LOG_DBG("param->stream_params[%zu].codec is invalid", - i); + CHECKIF(!cap_initiator_valid_metadata(codec_cfg->meta, codec_cfg->meta_count)) { + LOG_DBG("param->stream_params[%zu].codec_cfg is invalid", i); return false; } @@ -775,7 +772,7 @@ static int cap_initiator_unicast_audio_configure( struct bt_cap_stream *cap_stream = stream_param->stream; struct bt_bap_stream *bap_stream = &cap_stream->bap_stream; struct bt_bap_ep *ep = stream_param->ep; - struct bt_codec *codec = stream_param->codec; + struct bt_audio_codec_cfg *codec_cfg = stream_param->codec_cfg; struct bt_conn *conn; int err; @@ -797,7 +794,7 @@ static int cap_initiator_unicast_audio_configure( active_proc.streams[i] = cap_stream; - err = bt_bap_stream_config(conn, bap_stream, ep, codec); + err = bt_bap_stream_config(conn, bap_stream, ep, codec_cfg); if (err != 0) { LOG_DBG("bt_bap_stream_config failed for param->stream_params[%zu]: %d", i, err); @@ -1022,9 +1019,8 @@ void bt_cap_initiator_qos_configured(struct bt_cap_stream *cap_stream) int err; /* TODO: Add metadata */ - err = bt_bap_stream_enable(bap_stream, - bap_stream->codec->meta, - bap_stream->codec->meta_count); + err = bt_bap_stream_enable(bap_stream, bap_stream->codec_cfg->meta, + bap_stream->codec_cfg->meta_count); if (err != 0) { LOG_DBG("Failed to enable stream %p: %d", cap_stream_active, err); diff --git a/subsys/bluetooth/audio/cap_stream.c b/subsys/bluetooth/audio/cap_stream.c index c36c0beab55e5cd..c9c91de1f4adae0 100644 --- a/subsys/bluetooth/audio/cap_stream.c +++ b/subsys/bluetooth/audio/cap_stream.c @@ -14,7 +14,7 @@ LOG_MODULE_REGISTER(bt_cap_stream, CONFIG_BT_CAP_STREAM_LOG_LEVEL); #if defined(CONFIG_BT_BAP_UNICAST) static void cap_stream_configured_cb(struct bt_bap_stream *bap_stream, - const struct bt_codec_qos_pref *pref) + const struct bt_audio_codec_qos_pref *pref) { struct bt_cap_stream *cap_stream = CONTAINER_OF(bap_stream, struct bt_cap_stream, diff --git a/subsys/bluetooth/audio/codec.c b/subsys/bluetooth/audio/codec.c index 59b82539f373a17..4f83d75045f227a 100644 --- a/subsys/bluetooth/audio/codec.c +++ b/subsys/bluetooth/audio/codec.c @@ -18,18 +18,17 @@ LOG_MODULE_REGISTER(bt_audio_codec, CONFIG_BT_AUDIO_CODEC_LOG_LEVEL); -bool bt_codec_get_val(const struct bt_codec *codec, - uint8_t type, - const struct bt_codec_data **data) +bool bt_audio_codec_cfg_get_val(const struct bt_audio_codec_cfg *codec_cfg, uint8_t type, + const struct bt_audio_codec_data **data) { - CHECKIF(codec == NULL) { + CHECKIF(codec_cfg == NULL) { LOG_DBG("codec is NULL"); return false; } - for (size_t i = 0; i < codec->data_count; i++) { - if (codec->data[i].data.type == type) { - *data = &codec->data[i]; + for (size_t i = 0; i < codec_cfg->data_count; i++) { + if (codec_cfg->data[i].data.type == type) { + *data = &codec_cfg->data[i]; return true; } @@ -38,43 +37,43 @@ bool bt_codec_get_val(const struct bt_codec *codec, return false; } -int bt_codec_cfg_get_freq(const struct bt_codec *codec) +int bt_audio_codec_cfg_get_freq(const struct bt_audio_codec_cfg *codec_cfg) { - const struct bt_codec_data *element; + const struct bt_audio_codec_data *element; - CHECKIF(codec == NULL) { + CHECKIF(codec_cfg == NULL) { LOG_DBG("codec is NULL"); return BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM; } - if (bt_codec_get_val(codec, BT_CODEC_CONFIG_LC3_FREQ, &element)) { + if (bt_audio_codec_cfg_get_val(codec_cfg, BT_AUDIO_CODEC_CONFIG_LC3_FREQ, &element)) { switch (element->data.data[0]) { - case BT_CODEC_CONFIG_LC3_FREQ_8KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_8KHZ: return 8000; - case BT_CODEC_CONFIG_LC3_FREQ_11KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_11KHZ: return 11025; - case BT_CODEC_CONFIG_LC3_FREQ_16KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ: return 16000; - case BT_CODEC_CONFIG_LC3_FREQ_22KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_22KHZ: return 22050; - case BT_CODEC_CONFIG_LC3_FREQ_24KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_24KHZ: return 24000; - case BT_CODEC_CONFIG_LC3_FREQ_32KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_32KHZ: return 32000; - case BT_CODEC_CONFIG_LC3_FREQ_44KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_44KHZ: return 44100; - case BT_CODEC_CONFIG_LC3_FREQ_48KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ: return 48000; - case BT_CODEC_CONFIG_LC3_FREQ_88KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_88KHZ: return 88200; - case BT_CODEC_CONFIG_LC3_FREQ_96KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_96KHZ: return 96000; - case BT_CODEC_CONFIG_LC3_FREQ_176KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_176KHZ: return 176400; - case BT_CODEC_CONFIG_LC3_FREQ_192KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_192KHZ: return 192000; - case BT_CODEC_CONFIG_LC3_FREQ_384KHZ: + case BT_AUDIO_CODEC_CONFIG_LC3_FREQ_384KHZ: return 384000; default: return BT_AUDIO_CODEC_PARSE_ERR_INVALID_VALUE_FOUND; @@ -84,20 +83,20 @@ int bt_codec_cfg_get_freq(const struct bt_codec *codec) return BT_AUDIO_CODEC_PARSE_ERR_TYPE_NOT_FOUND; } -int bt_codec_cfg_get_frame_duration_us(const struct bt_codec *codec) +int bt_audio_codec_cfg_get_frame_duration_us(const struct bt_audio_codec_cfg *codec_cfg) { - const struct bt_codec_data *element; + const struct bt_audio_codec_data *element; - CHECKIF(codec == NULL) { + CHECKIF(codec_cfg == NULL) { LOG_DBG("codec is NULL"); return BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM; } - if (bt_codec_get_val(codec, BT_CODEC_CONFIG_LC3_DURATION, &element)) { + if (bt_audio_codec_cfg_get_val(codec_cfg, BT_AUDIO_CODEC_CONFIG_LC3_DURATION, &element)) { switch (element->data.data[0]) { - case BT_CODEC_CONFIG_LC3_DURATION_7_5: + case BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5: return 7500; - case BT_CODEC_CONFIG_LC3_DURATION_10: + case BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10: return 10000; default: return BT_AUDIO_CODEC_PARSE_ERR_INVALID_VALUE_FOUND; @@ -107,12 +106,12 @@ int bt_codec_cfg_get_frame_duration_us(const struct bt_codec *codec) return BT_AUDIO_CODEC_PARSE_ERR_TYPE_NOT_FOUND; } -int bt_codec_cfg_get_chan_allocation_val(const struct bt_codec *codec, +int bt_audio_codec_cfg_get_chan_allocation_val(const struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_location *chan_allocation) { - const struct bt_codec_data *element; + const struct bt_audio_codec_data *element; - CHECKIF(codec == NULL) { + CHECKIF(codec_cfg == NULL) { LOG_DBG("codec is NULL"); return BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM; } @@ -122,7 +121,7 @@ int bt_codec_cfg_get_chan_allocation_val(const struct bt_codec *codec, } *chan_allocation = 0; - if (bt_codec_get_val(codec, BT_CODEC_CONFIG_LC3_CHAN_ALLOC, &element)) { + if (bt_audio_codec_cfg_get_val(codec_cfg, BT_AUDIO_CODEC_CONFIG_LC3_CHAN_ALLOC, &element)) { *chan_allocation = sys_le32_to_cpu(*((uint32_t *)&element->data.data[0])); @@ -132,16 +131,16 @@ int bt_codec_cfg_get_chan_allocation_val(const struct bt_codec *codec, return BT_AUDIO_CODEC_PARSE_ERR_TYPE_NOT_FOUND; } -int bt_codec_cfg_get_octets_per_frame(const struct bt_codec *codec) +int bt_audio_codec_cfg_get_octets_per_frame(const struct bt_audio_codec_cfg *codec_cfg) { - const struct bt_codec_data *element; + const struct bt_audio_codec_data *element; - CHECKIF(codec == NULL) { + CHECKIF(codec_cfg == NULL) { LOG_DBG("codec is NULL"); return BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM; } - if (bt_codec_get_val(codec, BT_CODEC_CONFIG_LC3_FRAME_LEN, &element)) { + if (bt_audio_codec_cfg_get_val(codec_cfg, BT_AUDIO_CODEC_CONFIG_LC3_FRAME_LEN, &element)) { return sys_le16_to_cpu(*((uint16_t *)&element->data.data[0])); } @@ -149,16 +148,18 @@ int bt_codec_cfg_get_octets_per_frame(const struct bt_codec *codec) return BT_AUDIO_CODEC_PARSE_ERR_TYPE_NOT_FOUND; } -int bt_codec_cfg_get_frame_blocks_per_sdu(const struct bt_codec *codec, bool fallback_to_default) +int bt_audio_codec_cfg_get_frame_blocks_per_sdu(const struct bt_audio_codec_cfg *codec_cfg, + bool fallback_to_default) { - const struct bt_codec_data *element; + const struct bt_audio_codec_data *element; - CHECKIF(codec == NULL) { + CHECKIF(codec_cfg == NULL) { LOG_DBG("codec is NULL"); return BT_AUDIO_CODEC_PARSE_ERR_INVALID_PARAM; } - if (bt_codec_get_val(codec, BT_CODEC_CONFIG_LC3_FRAME_BLKS_PER_SDU, &element)) { + if (bt_audio_codec_cfg_get_val(codec_cfg, BT_AUDIO_CODEC_CONFIG_LC3_FRAME_BLKS_PER_SDU, + &element)) { return element->data.data[0]; } diff --git a/subsys/bluetooth/audio/pacs.c b/subsys/bluetooth/audio/pacs.c index ce8144d1b2f469c..8b5c664fa99ceed 100644 --- a/subsys/bluetooth/audio/pacs.c +++ b/subsys/bluetooth/audio/pacs.c @@ -76,7 +76,7 @@ static K_SEM_DEFINE(read_buf_sem, 1, 1); NET_BUF_SIMPLE_DEFINE_STATIC(read_buf, BT_ATT_MAX_ATTRIBUTE_LEN); static ssize_t pac_data_add(struct net_buf_simple *buf, size_t count, - struct bt_codec_data *data) + struct bt_audio_codec_data *data) { size_t len = 0; @@ -108,7 +108,7 @@ struct pac_records_build_data { static bool build_pac_records(const struct bt_pacs_cap *cap, void *user_data) { struct pac_records_build_data *data = user_data; - struct bt_codec *codec = cap->codec; + struct bt_audio_codec_cap *codec_cap = cap->codec_cap; struct net_buf_simple *buf = data->buf; struct net_buf_simple_state state; struct bt_pac_ltv_data *cc, *meta; @@ -122,9 +122,9 @@ static bool build_pac_records(const struct bt_pacs_cap *cap, void *user_data) } pac_codec = net_buf_simple_add(buf, sizeof(*pac_codec)); - pac_codec->id = codec->id; - pac_codec->cid = sys_cpu_to_le16(codec->cid); - pac_codec->vid = sys_cpu_to_le16(codec->vid); + pac_codec->id = codec_cap->id; + pac_codec->cid = sys_cpu_to_le16(codec_cap->cid); + pac_codec->vid = sys_cpu_to_le16(codec_cap->vid); if (net_buf_simple_tailroom(buf) < sizeof(*cc)) { goto fail; @@ -132,7 +132,7 @@ static bool build_pac_records(const struct bt_pacs_cap *cap, void *user_data) cc = net_buf_simple_add(buf, sizeof(*cc)); - len = pac_data_add(buf, codec->data_count, codec->data); + len = pac_data_add(buf, codec_cap->data_count, codec_cap->data); if (len < 0 || len > UINT8_MAX) { goto fail; } @@ -145,7 +145,7 @@ static bool build_pac_records(const struct bt_pacs_cap *cap, void *user_data) meta = net_buf_simple_add(buf, sizeof(*meta)); - len = pac_data_add(buf, codec->meta_count, codec->meta); + len = pac_data_add(buf, codec_cap->meta_count, codec_cap->meta); if (len < 0 || len > UINT8_MAX) { goto fail; } @@ -777,20 +777,22 @@ void bt_pacs_cap_foreach(enum bt_audio_dir dir, bt_pacs_cap_foreach_func_t func, /* Register Audio Capability */ int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap) { + const struct bt_audio_codec_cap *codec_cap; struct pacs *pac; - if (!cap || !cap->codec) { + if (!cap || !cap->codec_cap) { return -EINVAL; } + codec_cap = cap->codec_cap; + pac = pacs_get(dir); if (!pac) { return -EINVAL; } - LOG_DBG("cap %p dir %s codec 0x%02x codec cid 0x%04x " - "codec vid 0x%04x", cap, bt_audio_dir_str(dir), cap->codec->id, - cap->codec->cid, cap->codec->vid); + LOG_DBG("cap %p dir %s codec_cap id 0x%02x codec_cap cid 0x%04x codec_cap vid 0x%04x", cap, + bt_audio_dir_str(dir), codec_cap->id, codec_cap->cid, codec_cap->vid); sys_slist_append(&pac->list, &cap->_node); diff --git a/subsys/bluetooth/audio/pacs_internal.h b/subsys/bluetooth/audio/pacs_internal.h index 3befe6ae8538257..9f5291ae5797fd2 100644 --- a/subsys/bluetooth/audio/pacs_internal.h +++ b/subsys/bluetooth/audio/pacs_internal.h @@ -17,11 +17,6 @@ struct bt_pac_codec { uint16_t vid; /* Vendor specific Codec ID */ } __packed; -/* TODO: Figure out the capabilities types */ -#define BT_CODEC_CAP_PARAMS 0x01 -#define BT_CODEC_CAP_DRM 0x0a -#define BT_CODEC_CAP_DRM_VALUE 0x0b - struct bt_pac_ltv { uint8_t len; uint8_t type; diff --git a/subsys/bluetooth/audio/shell/audio.h b/subsys/bluetooth/audio/shell/audio.h index 4abc62aa095745a..4c3842616ed1006 100644 --- a/subsys/bluetooth/audio/shell/audio.h +++ b/subsys/bluetooth/audio/shell/audio.h @@ -56,13 +56,13 @@ struct named_lc3_preset { struct unicast_stream { struct bt_cap_stream stream; - struct bt_codec codec; - struct bt_codec_qos qos; + struct bt_audio_codec_cfg codec_cfg; + struct bt_audio_codec_qos qos; }; struct broadcast_stream { struct bt_cap_stream stream; - struct bt_codec_data data; + struct bt_audio_codec_data data; }; struct broadcast_source { @@ -70,8 +70,8 @@ struct broadcast_source { struct bt_bap_broadcast_source *bap_source; struct bt_cap_broadcast_source *cap_source; }; - struct bt_codec codec; - struct bt_codec_qos qos; + struct bt_audio_codec_cfg codec_cfg; + struct bt_audio_codec_qos qos; }; extern struct unicast_stream unicast_streams[CONFIG_BT_MAX_CONN * (UNICAST_SERVER_STREAM_COUNT + @@ -87,7 +87,7 @@ extern const struct named_lc3_preset *default_source_preset; #endif /* CONFIG_BT_BAP_UNICAST_CLIENT */ #endif /* CONFIG_BT_BAP_UNICAST */ -static inline void print_qos(const struct shell *sh, const struct bt_codec_qos *qos) +static inline void print_qos(const struct shell *sh, const struct bt_audio_codec_qos *qos) { #if defined(CONFIG_BT_BAP_BROADCAST_SOURCE) || defined(CONFIG_BT_BAP_UNICAST) shell_print(sh, @@ -100,29 +100,62 @@ static inline void print_qos(const struct shell *sh, const struct bt_codec_qos * #endif /* CONFIG_BT_BAP_BROADCAST_SOURCE || CONFIG_BT_BAP_UNICAST */ } -static inline void print_codec(const struct shell *sh, const struct bt_codec *codec) +static inline void print_codec_cap(const struct shell *sh, + const struct bt_audio_codec_cap *codec_cap) { - shell_print(sh, "codec 0x%02x cid 0x%04x vid 0x%04x", codec->id, codec->cid, codec->vid); - -#if CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 - shell_print(sh, "data_count %u", codec->data_count); - for (size_t i = 0U; i < codec->data_count; i++) { - shell_print(sh, "data #%u: type 0x%02x len %u", i, codec->data[i].data.type, - codec->data[i].data.data_len); - shell_hexdump(sh, codec->data[i].data.data, - codec->data[i].data.data_len - sizeof(codec->data[i].data.type)); + shell_print(sh, "codec cap id 0x%02x cid 0x%04x vid 0x%04x", codec_cap->id, codec_cap->cid, + codec_cap->vid); + +#if CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_COUNT > 0 + shell_print(sh, "data_count %u", codec_cap->data_count); + for (size_t i = 0U; i < codec_cap->data_count; i++) { + shell_print(sh, "data #%u: type 0x%02x len %u", i, codec_cap->data[i].data.type, + codec_cap->data[i].data.data_len); + shell_hexdump(sh, codec_cap->data[i].data.data, + codec_cap->data[i].data.data_len - + sizeof(codec_cap->data[i].data.type)); } -#endif /* CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 */ - -#if CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 - shell_print(sh, "meta_count %u", codec->data_count); - for (size_t i = 0U; i < codec->meta_count; i++) { - shell_print(sh, "meta #%u: type 0x%02x len %u", i, codec->meta[i].data.type, - codec->meta[i].data.data_len); - shell_hexdump(sh, codec->meta[i].data.data, - codec->meta[i].data.data_len - sizeof(codec->meta[i].data.type)); +#endif /* CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_COUNT > 0 */ + +#if CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_COUNT > 0 + shell_print(sh, "meta_count %u", codec_cap->data_count); + for (size_t i = 0U; i < codec_cap->meta_count; i++) { + shell_print(sh, "meta #%u: type 0x%02x len %u", i, codec_cap->meta[i].data.type, + codec_cap->meta[i].data.data_len); + shell_hexdump(sh, codec_cap->meta[i].data.data, + codec_cap->meta[i].data.data_len - + sizeof(codec_cap->meta[i].data.type)); } -#endif /* CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 */ +#endif /* CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_COUNT > 0 */ +} + +static inline void print_codec_cfg(const struct shell *sh, + const struct bt_audio_codec_cfg *codec_cfg) +{ + shell_print(sh, "codec cfg id 0x%02x cid 0x%04x vid 0x%04x", codec_cfg->id, codec_cfg->cid, + codec_cfg->vid); + +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 + shell_print(sh, "data_count %u", codec_cfg->data_count); + for (size_t i = 0U; i < codec_cfg->data_count; i++) { + shell_print(sh, "data #%u: type 0x%02x len %u", i, codec_cfg->data[i].data.type, + codec_cfg->data[i].data.data_len); + shell_hexdump(sh, codec_cfg->data[i].data.data, + codec_cfg->data[i].data.data_len - + sizeof(codec_cfg->data[i].data.type)); + } +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 */ + +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 + shell_print(sh, "meta_count %u", codec_cfg->data_count); + for (size_t i = 0U; i < codec_cfg->meta_count; i++) { + shell_print(sh, "meta #%u: type 0x%02x len %u", i, codec_cfg->meta[i].data.type, + codec_cfg->meta[i].data.data_len); + shell_hexdump(sh, codec_cfg->meta[i].data.data, + codec_cfg->meta[i].data.data_len - + sizeof(codec_cfg->meta[i].data.type)); + } +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 */ } #if defined(CONFIG_BT_BAP_BROADCAST_SOURCE) @@ -144,7 +177,7 @@ static inline void print_base(const struct shell *sh, const struct bt_bap_base * subgroup = &base->subgroups[i]; shell_print(sh, "Subgroup[%d]:", i); - print_codec(sh, &subgroup->codec); + print_codec_cfg(sh, &subgroup->codec_cfg); for (size_t j = 0U; j < subgroup->bis_count; j++) { const struct bt_bap_base_bis_data *bis_data; @@ -154,9 +187,9 @@ static inline void print_base(const struct shell *sh, const struct bt_bap_base * shell_print(sh, "BIS[%d] index 0x%02x", j, bis_data->index); bis_indexes[index_count++] = bis_data->index; -#if CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 for (size_t k = 0U; k < bis_data->data_count; k++) { - const struct bt_codec_data *codec_data; + const struct bt_audio_codec_data *codec_data; codec_data = &bis_data->data[k]; @@ -166,7 +199,7 @@ static inline void print_base(const struct shell *sh, const struct bt_bap_base * codec_data->data.data_len - sizeof(codec_data->data.type)); } -#endif /* CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 */ +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 */ } } @@ -190,64 +223,76 @@ static inline void copy_unicast_stream_preset(struct unicast_stream *stream, const struct named_lc3_preset *named_preset) { memcpy(&stream->qos, &named_preset->preset.qos, sizeof(stream->qos)); - memcpy(&stream->codec, &named_preset->preset.codec, sizeof(stream->codec)); + memcpy(&stream->codec_cfg, &named_preset->preset.codec_cfg, sizeof(stream->codec_cfg)); -#if CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 && CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > 0 /* Need to update the `bt_data.data` pointer to the new value after copying the codec */ - for (size_t i = 0U; i < ARRAY_SIZE(stream->codec.data); i++) { - const struct bt_codec_data *preset_data = &named_preset->preset.codec.data[i]; - struct bt_codec_data *data = &stream->codec.data[i]; + for (size_t i = 0U; i < ARRAY_SIZE(stream->codec_cfg.data); i++) { + const struct bt_audio_codec_data *preset_data = + &named_preset->preset.codec_cfg.data[i]; + struct bt_audio_codec_data *data = &stream->codec_cfg.data[i]; const uint8_t data_len = preset_data->data.data_len; data->data.data = data->value; data->data.data_len = data_len; memcpy(data->value, preset_data->data.data, data_len); } -#endif /* CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 */ - -#if CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 - for (size_t i = 0U; i < ARRAY_SIZE(stream->codec.meta); i++) { - const struct bt_codec_data *preset_data = &named_preset->preset.codec.meta[i]; - struct bt_codec_data *data = &stream->codec.meta[i]; +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 && \ + * CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > 0 \ + */ + +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 && CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > 0 + for (size_t i = 0U; i < ARRAY_SIZE(stream->codec_cfg.meta); i++) { + const struct bt_audio_codec_data *preset_data = + &named_preset->preset.codec_cfg.meta[i]; + struct bt_audio_codec_data *data = &stream->codec_cfg.meta[i]; const uint8_t data_len = preset_data->data.data_len; data->data.data = data->value; data->data.data_len = data_len; memcpy(data->value, preset_data->data.data, data_len); } -#endif /* CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 */ +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 && \ + * CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > 0 \ + */ } static inline void copy_broadcast_source_preset(struct broadcast_source *source, const struct named_lc3_preset *named_preset) { memcpy(&source->qos, &named_preset->preset.qos, sizeof(source->qos)); - memcpy(&source->codec, &named_preset->preset.codec, sizeof(source->codec)); + memcpy(&source->codec_cfg, &named_preset->preset.codec_cfg, sizeof(source->codec_cfg)); -#if CONFIG_BT_CODEC_MAX_DATA_COUNT > 0 +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT > 0 && CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > 0 /* Need to update the `bt_data.data` pointer to the new value after copying the codec */ - for (size_t i = 0U; i < ARRAY_SIZE(source->codec.data); i++) { - const struct bt_codec_data *preset_data = &named_preset->preset.codec.data[i]; - struct bt_codec_data *data = &source->codec.data[i]; + for (size_t i = 0U; i < ARRAY_SIZE(source->codec_cfg.data); i++) { + const struct bt_audio_codec_data *preset_data = + &named_preset->preset.codec_cfg.data[i]; + struct bt_audio_codec_data *data = &source->codec_cfg.data[i]; const uint8_t data_len = preset_data->data.data_len; data->data.data = data->value; data->data.data_len = data_len; memcpy(data->value, preset_data->data.data, data_len); } -#endif /* CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 */ - -#if CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 - for (size_t i = 0U; i < ARRAY_SIZE(source->codec.meta); i++) { - const struct bt_codec_data *preset_data = &named_preset->preset.codec.meta[i]; - struct bt_codec_data *data = &source->codec.meta[i]; +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 && CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > \ + * 0 \ + */ + +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 && CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > 0 + for (size_t i = 0U; i < ARRAY_SIZE(source->codec_cfg.meta); i++) { + const struct bt_audio_codec_data *preset_data = + &named_preset->preset.codec_cfg.meta[i]; + struct bt_audio_codec_data *data = &source->codec_cfg.meta[i]; const uint8_t data_len = preset_data->data.data_len; data->data.data = data->value; data->data.data_len = data_len; memcpy(data->value, preset_data->data.data, data_len); } -#endif /* CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 */ +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 && CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN > \ + * 0 \ + */ } #endif /* CONFIG_BT_AUDIO */ diff --git a/subsys/bluetooth/audio/shell/bap.c b/subsys/bluetooth/audio/shell/bap.c index 18c154aed0ac571..e52456f4d25c37e 100644 --- a/subsys/bluetooth/audio/shell/bap.c +++ b/subsys/bluetooth/audio/shell/bap.c @@ -37,8 +37,8 @@ struct unicast_stream unicast_streams[CONFIG_BT_MAX_CONN * (UNICAST_SERVER_STREAM_COUNT + UNICAST_CLIENT_STREAM_COUNT)]; -static const struct bt_codec_qos_pref qos_pref = BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0u, 60u, - 20000u, 40000u, 20000u, 40000u); +static const struct bt_audio_codec_qos_pref qos_pref = + BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0u, 60u, 20000u, 40000u, 20000u, 40000u); #if defined(CONFIG_BT_BAP_UNICAST_CLIENT) struct bt_bap_unicast_group *default_unicast_group; @@ -229,16 +229,16 @@ static void init_lc3(const struct bt_bap_stream *stream) { size_t num_samples; - if (stream == NULL || stream->codec == NULL) { + if (stream == NULL || stream->codec_cfg == NULL) { shell_error(ctx_shell, "invalid stream to init LC3"); return; } - freq_hz = bt_codec_cfg_get_freq(stream->codec); - frame_duration_us = bt_codec_cfg_get_frame_duration_us(stream->codec); - octets_per_frame = bt_codec_cfg_get_octets_per_frame(stream->codec); - frames_per_sdu = bt_codec_cfg_get_frame_blocks_per_sdu(stream->codec, true); - octets_per_frame = bt_codec_cfg_get_octets_per_frame(stream->codec); + freq_hz = bt_audio_codec_cfg_get_freq(stream->codec_cfg); + frame_duration_us = bt_audio_codec_cfg_get_frame_duration_us(stream->codec_cfg); + octets_per_frame = bt_audio_codec_cfg_get_octets_per_frame(stream->codec_cfg); + frames_per_sdu = bt_audio_codec_cfg_get_frame_blocks_per_sdu(stream->codec_cfg, true); + octets_per_frame = bt_audio_codec_cfg_get_octets_per_frame(stream->codec_cfg); if (freq_hz < 0) { printk("Error: Codec frequency not set, cannot start codec."); @@ -416,12 +416,12 @@ static struct bt_bap_stream *stream_alloc(void) } static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_bap_stream **stream, - struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { shell_print(ctx_shell, "ASE Codec Config: conn %p ep %p dir %u", conn, ep, dir); - print_codec(ctx_shell, codec); + print_codec_cfg(ctx_shell, codec_cfg); *stream = stream_alloc(); if (*stream == NULL) { @@ -442,12 +442,12 @@ static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_ } static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_codec_qos_pref *const pref, - struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { shell_print(ctx_shell, "ASE Codec Reconfig: stream %p", stream); - print_codec(ctx_shell, codec); + print_codec_cfg(ctx_shell, codec_cfg); if (default_stream == NULL) { set_unicast_stream(stream); @@ -458,7 +458,7 @@ static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, return 0; } -static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, +static int lc3_qos(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos, struct bt_bap_ascs_rsp *rsp) { shell_print(ctx_shell, "QoS: stream %p %p", stream, qos); @@ -468,7 +468,7 @@ static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, return 0; } -static int lc3_enable(struct bt_bap_stream *stream, const struct bt_codec_data *meta, +static int lc3_enable(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { shell_print(ctx_shell, "Enable: stream %p meta_count %zu", stream, @@ -532,14 +532,14 @@ static bool valid_metadata_type(uint8_t type, uint8_t len) } } -static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_codec_data *meta, +static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { shell_print(ctx_shell, "Metadata: stream %p meta_count %zu", stream, meta_count); for (size_t i = 0; i < meta_count; i++) { - const struct bt_codec_data *data = &meta[i]; + const struct bt_audio_codec_data *data = &meta[i]; if (!valid_metadata_type(data->data.type, data->data.data_len)) { shell_print(ctx_shell, @@ -579,11 +579,10 @@ static int lc3_release(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp return 0; } -static struct bt_codec lc3_codec = BT_CODEC_LC3(BT_CODEC_LC3_FREQ_ANY, - BT_CODEC_LC3_DURATION_ANY, - BT_CODEC_LC3_CHAN_COUNT_SUPPORT(1, 2), 30, 240, 2, - (BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | - BT_AUDIO_CONTEXT_TYPE_MEDIA)); +static struct bt_audio_codec_cap lc3_codec_cap = + BT_AUDIO_CODEC_LC3(BT_AUDIO_CODEC_LC3_FREQ_ANY, BT_AUDIO_CODEC_LC3_DURATION_ANY, + BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1, 2), 30, 240, 2, + (BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA)); static const struct bt_bap_unicast_server_cb unicast_server_cb = { .config = lc3_config, @@ -598,11 +597,11 @@ static const struct bt_bap_unicast_server_cb unicast_server_cb = { }; static struct bt_pacs_cap cap_sink = { - .codec = &lc3_codec, + .codec_cap = &lc3_codec_cap, }; static struct bt_pacs_cap cap_source = { - .codec = &lc3_codec, + .codec_cap = &lc3_codec_cap, }; #if defined(CONFIG_BT_BAP_UNICAST) @@ -637,7 +636,7 @@ static uint16_t strmeta(const char *name) return 0u; } -static int set_metadata(struct bt_codec *codec, const char *meta_str) +static int set_metadata(struct bt_audio_codec_cfg *codec_cfg, const char *meta_str) { uint16_t context; @@ -647,7 +646,7 @@ static int set_metadata(struct bt_codec *codec, const char *meta_str) } /* TODO: Check the type and only overwrite the streaming context */ - sys_put_le16(context, codec->meta[0].value); + sys_put_le16(context, codec_cfg->meta[0].value); return 0; } @@ -683,12 +682,14 @@ static uint8_t stream_dir(const struct bt_bap_stream *stream) return 0; } -static void print_remote_codec(const struct bt_conn *conn, const struct bt_codec *codec, - enum bt_audio_dir dir) +static void print_remote_codec_cap(const struct bt_conn *conn, + const struct bt_audio_codec_cap *codec_cap, + enum bt_audio_dir dir) { - shell_print(ctx_shell, "conn %p: codec %p dir 0x%02x", conn, codec, dir); + shell_print(ctx_shell, "conn %p: codec_cap %p dir 0x%02x", conn, codec_cap, + dir); - print_codec(ctx_shell, codec); + print_codec_cap(ctx_shell, codec_cap); } #if CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0 @@ -727,9 +728,10 @@ static void add_source(const struct bt_conn *conn, struct bt_bap_ep *ep) } #endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0 */ -static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, const struct bt_codec *codec) +static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, + const struct bt_audio_codec_cap *codec_cap) { - print_remote_codec(conn, codec, dir); + print_remote_codec_cap(conn, codec_cap, dir); } static void endpoint_cb(struct bt_conn *conn, enum bt_audio_dir dir, struct bt_bap_ep *ep) @@ -1031,11 +1033,11 @@ static int cmd_config(const struct shell *sh, size_t argc, char *argv[]) /* If location has been modifed, we update the location in the codec configuration */ if (location != BT_AUDIO_LOCATION_PROHIBITED) { - for (size_t i = 0U; i < uni_stream->codec.data_count; i++) { - struct bt_codec_data *data = &uni_stream->codec.data[i]; + for (size_t i = 0U; i < uni_stream->codec_cfg.data_count; i++) { + struct bt_audio_codec_data *data = &uni_stream->codec_cfg.data[i]; /* Overwrite the location value */ - if (data->data.type == BT_CODEC_CONFIG_LC3_CHAN_ALLOC) { + if (data->data.type == BT_AUDIO_CODEC_CONFIG_LC3_CHAN_ALLOC) { const uint32_t loc_32 = location; sys_put_le32(loc_32, data->value); @@ -1047,13 +1049,14 @@ static int cmd_config(const struct shell *sh, size_t argc, char *argv[]) } if (bap_stream->ep == ep) { - err = bt_bap_stream_reconfig(bap_stream, &uni_stream->codec); + err = bt_bap_stream_reconfig(bap_stream, &uni_stream->codec_cfg); if (err != 0) { shell_error(sh, "Unable reconfig stream: %d", err); return -ENOEXEC; } } else { - err = bt_bap_stream_config(default_conn, bap_stream, ep, &uni_stream->codec); + err = bt_bap_stream_config(default_conn, bap_stream, ep, + &uni_stream->codec_cfg); if (err != 0) { shell_error(sh, "Unable to config stream: %d", err); return err; @@ -1067,7 +1070,7 @@ static int cmd_config(const struct shell *sh, size_t argc, char *argv[]) static int cmd_stream_qos(const struct shell *sh, size_t argc, char *argv[]) { - struct bt_codec_qos *qos; + struct bt_audio_codec_qos *qos; unsigned long interval; int err; @@ -1280,7 +1283,7 @@ static int cmd_qos(const struct shell *sh, size_t argc, char *argv[]) static int cmd_enable(const struct shell *sh, size_t argc, char *argv[]) { - struct bt_codec *codec; + struct bt_audio_codec_cfg *codec_cfg; int err; if (default_stream == NULL) { @@ -1288,17 +1291,17 @@ static int cmd_enable(const struct shell *sh, size_t argc, char *argv[]) return -ENOEXEC; } - codec = default_stream->codec; + codec_cfg = default_stream->codec_cfg; if (argc > 1) { - err = set_metadata(codec, argv[1]); + err = set_metadata(codec_cfg, argv[1]); if (err != 0) { shell_error(sh, "Unable to handle metadata update: %d", err); return err; } } - err = bt_bap_stream_enable(default_stream, codec->meta, codec->meta_count); + err = bt_bap_stream_enable(default_stream, codec_cfg->meta, codec_cfg->meta_count); if (err) { shell_error(sh, "Unable to enable Channel"); return -ENOEXEC; @@ -1362,18 +1365,18 @@ static int cmd_preset(const struct shell *sh, size_t argc, char *argv[]) shell_print(sh, "%s", named_preset->name); - print_codec(ctx_shell, &named_preset->preset.codec); + print_codec_cfg(ctx_shell, &named_preset->preset.codec_cfg); print_qos(ctx_shell, &named_preset->preset.qos); return 0; } -#define MAX_META_DATA \ - (CONFIG_BT_CODEC_MAX_METADATA_COUNT * sizeof(struct bt_codec_data)) +#define MAX_META_DATA \ + (CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT * sizeof(struct bt_audio_codec_data)) static int cmd_metadata(const struct shell *sh, size_t argc, char *argv[]) { - struct bt_codec *codec; + struct bt_audio_codec_cfg *codec_cfg; int err; if (default_stream == NULL) { @@ -1381,17 +1384,17 @@ static int cmd_metadata(const struct shell *sh, size_t argc, char *argv[]) return -ENOEXEC; } - codec = default_stream->codec; + codec_cfg = default_stream->codec_cfg; if (argc > 1) { - err = set_metadata(codec, argv[1]); + err = set_metadata(codec_cfg, argv[1]); if (err != 0) { shell_error(sh, "Unable to handle metadata update: %d", err); return err; } } - err = bt_bap_stream_metadata(default_stream, codec->meta, codec->meta_count); + err = bt_bap_stream_metadata(default_stream, codec_cfg->meta, codec_cfg->meta_count); if (err) { shell_error(sh, "Unable to set Channel metadata"); return -ENOEXEC; @@ -1573,7 +1576,7 @@ static void base_recv(struct bt_bap_broadcast_sink *sink, const struct bt_bap_ba subgroup = &base->subgroups[i]; shell_print(ctx_shell, "Subgroup[%d]:", i); - print_codec(ctx_shell, &subgroup->codec); + print_codec_cfg(ctx_shell, &subgroup->codec_cfg); for (int j = 0; j < subgroup->bis_count; j++) { const struct bt_bap_base_bis_data *bis_data; @@ -1585,7 +1588,7 @@ static void base_recv(struct bt_bap_broadcast_sink *sink, const struct bt_bap_ba bis_indexes[index_count++] = bis_data->index; for (int k = 0; k < bis_data->data_count; k++) { - const struct bt_codec_data *codec_data; + const struct bt_audio_codec_data *codec_data; codec_data = &bis_data->data[k]; @@ -1904,7 +1907,7 @@ static int cmd_create_broadcast(const struct shell *sh, size_t argc, } subgroup_param.params_count = ARRAY_SIZE(stream_params); subgroup_param.params = stream_params; - subgroup_param.codec = &default_source.codec; + subgroup_param.codec_cfg = &default_source.codec_cfg; create_param.params_count = 1U; create_param.params = &subgroup_param; create_param.qos = &default_source.qos; diff --git a/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c b/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c index dd551d490f6899f..51a69a82618a3cd 100644 --- a/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c +++ b/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c @@ -871,9 +871,9 @@ static int cmd_bap_broadcast_assistant_add_pa_sync(const struct shell *sh, subgroup_param->bis_sync = subgroup_bis_indexes & bis_bitfield_req; -#if CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 - metadata_len = bt_audio_codec_data_to_buf(subgroup->codec.meta, - subgroup->codec.meta_count, +#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 + metadata_len = bt_audio_codec_data_to_buf(subgroup->codec_cfg.meta, + subgroup->codec_cfg.meta_count, subgroup_param->metadata, sizeof(subgroup_param->metadata)); if (metadata_len < 0) { @@ -881,7 +881,7 @@ static int cmd_bap_broadcast_assistant_add_pa_sync(const struct shell *sh, } #else metadata_len = 0U; -#endif /* CONFIG_BT_CODEC_MAX_METADATA_COUNT > 0 */ +#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT > 0 */ subgroup_param->metadata_len = metadata_len; } diff --git a/subsys/bluetooth/audio/shell/cap_initiator.c b/subsys/bluetooth/audio/shell/cap_initiator.c index bc7e6c6fa844652..0fabfdf1429987c 100644 --- a/subsys/bluetooth/audio/shell/cap_initiator.c +++ b/subsys/bluetooth/audio/shell/cap_initiator.c @@ -249,7 +249,7 @@ static int cmd_cap_initiator_unicast_start(const struct shell *sh, size_t argc, stream_param[start_param.count].stream = stream; stream_param[start_param.count].ep = snk_ep; copy_unicast_stream_preset(uni_stream, default_sink_preset); - stream_param[start_param.count].codec = &uni_stream->codec; + stream_param[start_param.count].codec_cfg = &uni_stream->codec_cfg; stream_param[start_param.count].qos = &uni_stream->qos; group_stream_params[start_param.count].qos = @@ -283,7 +283,7 @@ static int cmd_cap_initiator_unicast_start(const struct shell *sh, size_t argc, stream_param[start_param.count].stream = stream; stream_param[start_param.count].ep = src_ep; copy_unicast_stream_preset(uni_stream, default_source_preset); - stream_param[start_param.count].codec = &uni_stream->codec; + stream_param[start_param.count].codec_cfg = &uni_stream->codec_cfg; stream_param[start_param.count].qos = &uni_stream->qos; group_stream_params[start_param.count].qos = @@ -388,8 +388,8 @@ static int cmd_cap_initiator_unicast_update(const struct shell *sh, size_t argc, copy_unicast_stream_preset(uni_stream, default_source_preset); } - params[count].meta = uni_stream->codec.meta; - params[count].meta_count = uni_stream->codec.meta_count; + params[count].meta = uni_stream->codec_cfg.meta; + params[count].meta_count = uni_stream->codec_cfg.meta_count; count++; } @@ -430,8 +430,8 @@ static int cmd_cap_initiator_unicast_update(const struct shell *sh, size_t argc, copy_unicast_stream_preset(uni_stream, default_source_preset); } - params[count].meta = uni_stream->codec.meta; - params[count].meta_count = uni_stream->codec.meta_count; + params[count].meta = uni_stream->codec_cfg.meta; + params[count].meta_count = uni_stream->codec_cfg.meta_count; count++; } diff --git a/tests/bluetooth/audio/ascs/src/test_ase_control_params.c b/tests/bluetooth/audio/ascs/src/test_ase_control_params.c index 7cca787fba62340..e56a30f7f4a8f5b 100644 --- a/tests/bluetooth/audio/ascs/src/test_ase_control_params.c +++ b/tests/bluetooth/audio/ascs/src/test_ase_control_params.c @@ -319,14 +319,14 @@ ZTEST_F(test_ase_control_params, test_codec_configure_invalid_ase_id_0x00) } static struct bt_bap_stream test_stream; -static const struct bt_codec_qos_pref qos_pref = BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, - 0x02, 10, 40000, 40000, - 40000, 40000); +static const struct bt_audio_codec_qos_pref qos_pref = + BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 40000, 40000, 40000, 40000); static int unicast_server_cb_config_custom_fake(struct bt_conn *conn, const struct bt_bap_ep *ep, - enum bt_audio_dir dir, const struct bt_codec *codec, + enum bt_audio_dir dir, + const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream, - struct bt_codec_qos_pref *const pref, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { *stream = &test_stream; diff --git a/tests/bluetooth/audio/ascs/src/test_ase_state_transition.c b/tests/bluetooth/audio/ascs/src/test_ase_state_transition.c index fbe2a6d6b6664f2..17fb10e9dd3e0eb 100644 --- a/tests/bluetooth/audio/ascs/src/test_ase_state_transition.c +++ b/tests/bluetooth/audio/ascs/src/test_ase_state_transition.c @@ -28,9 +28,8 @@ #define test_sink_ase_state_transition_fixture test_ase_state_transition_fixture #define test_source_ase_state_transition_fixture test_ase_state_transition_fixture -static const struct bt_codec_qos_pref qos_pref = BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, - 0x02, 10, 40000, 40000, - 40000, 40000); +static const struct bt_audio_codec_qos_pref qos_pref = + BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 40000, 40000, 40000, 40000); struct test_ase_state_transition_fixture { struct bt_conn conn; @@ -322,15 +321,15 @@ ZTEST_F(test_sink_ase_state_transition, test_client_streaming_to_qos_configured) ZTEST_F(test_sink_ase_state_transition, test_server_idle_to_codec_configured) { - struct bt_codec codec = BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT, - BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); + struct bt_audio_codec_cfg codec_cfg = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); struct bt_bap_stream *stream = &fixture->stream; struct bt_conn *conn = &fixture->conn; int err; Z_TEST_SKIP_IFNDEF(CONFIG_BT_ASCS_ASE_SNK); - err = bt_bap_unicast_server_config_ase(conn, stream, &codec, &qos_pref); + err = bt_bap_unicast_server_config_ase(conn, stream, &codec_cfg, &qos_pref); zassert_false(err < 0, "bt_bap_unicast_server_config_ase returned err %d", err); /* Verification */ @@ -340,8 +339,8 @@ ZTEST_F(test_sink_ase_state_transition, test_server_idle_to_codec_configured) ZTEST_F(test_sink_ase_state_transition, test_server_codec_configured_to_codec_configured) { - struct bt_codec codec = BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT, - BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); + struct bt_audio_codec_cfg codec_cfg = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); struct bt_bap_stream *stream = &fixture->stream; struct bt_conn *conn = &fixture->conn; uint8_t ase_id = fixture->ase.id; @@ -351,7 +350,7 @@ ZTEST_F(test_sink_ase_state_transition, test_server_codec_configured_to_codec_co test_preamble_state_codec_configured(conn, ase_id, stream); - err = bt_bap_stream_reconfig(stream, &codec); + err = bt_bap_stream_reconfig(stream, &codec_cfg); zassert_false(err < 0, "bt_bap_stream_reconfig returned err %d", err); /* Verification */ @@ -380,8 +379,8 @@ ZTEST_F(test_sink_ase_state_transition, test_server_codec_configured_to_releasin ZTEST_F(test_sink_ase_state_transition, test_server_qos_configured_to_codec_configured) { - struct bt_codec codec = BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT, - BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); + struct bt_audio_codec_cfg codec_cfg = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); struct bt_bap_stream *stream = &fixture->stream; struct bt_conn *conn = &fixture->conn; uint8_t ase_id = fixture->ase.id; @@ -391,7 +390,7 @@ ZTEST_F(test_sink_ase_state_transition, test_server_qos_configured_to_codec_conf test_preamble_state_qos_configured(conn, ase_id, stream); - err = bt_bap_stream_reconfig(stream, &codec); + err = bt_bap_stream_reconfig(stream, &codec_cfg); zassert_false(err < 0, "bt_bap_stream_reconfig returned err %d", err); /* Verification */ @@ -439,8 +438,8 @@ ZTEST_F(test_sink_ase_state_transition, test_server_enabling_to_releasing) ZTEST_F(test_sink_ase_state_transition, test_server_enabling_to_enabling) { - struct bt_codec_data meta[] = { - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, + struct bt_audio_codec_data meta[] = { + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, (BT_AUDIO_CONTEXT_TYPE_MEDIA & 0xFFU), ((BT_AUDIO_CONTEXT_TYPE_MEDIA >> 8) & 0xFFU)), }; @@ -505,8 +504,8 @@ ZTEST_F(test_sink_ase_state_transition, test_server_enabling_to_streaming) ZTEST_F(test_sink_ase_state_transition, test_server_streaming_to_streaming) { - struct bt_codec_data meta[] = { - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, + struct bt_audio_codec_data meta[] = { + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, (BT_AUDIO_CONTEXT_TYPE_MEDIA & 0xFFU), ((BT_AUDIO_CONTEXT_TYPE_MEDIA >> 8) & 0xFFU)), }; @@ -897,15 +896,15 @@ ZTEST_F(test_source_ase_state_transition, test_client_streaming_to_disabling_to_ ZTEST_F(test_source_ase_state_transition, test_server_idle_to_codec_configured) { - struct bt_codec codec = BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT, - BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); + struct bt_audio_codec_cfg codec_cfg = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); struct bt_bap_stream *stream = &fixture->stream; struct bt_conn *conn = &fixture->conn; int err; Z_TEST_SKIP_IFNDEF(CONFIG_BT_ASCS_ASE_SRC); - err = bt_bap_unicast_server_config_ase(conn, stream, &codec, &qos_pref); + err = bt_bap_unicast_server_config_ase(conn, stream, &codec_cfg, &qos_pref); zassert_false(err < 0, "bt_bap_unicast_server_config_ase returned err %d", err); /* Verification */ @@ -915,8 +914,8 @@ ZTEST_F(test_source_ase_state_transition, test_server_idle_to_codec_configured) ZTEST_F(test_source_ase_state_transition, test_server_codec_configured_to_codec_configured) { - struct bt_codec codec = BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT, - BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); + struct bt_audio_codec_cfg codec_cfg = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); struct bt_bap_stream *stream = &fixture->stream; struct bt_conn *conn = &fixture->conn; uint8_t ase_id = fixture->ase.id; @@ -926,7 +925,7 @@ ZTEST_F(test_source_ase_state_transition, test_server_codec_configured_to_codec_ test_preamble_state_codec_configured(conn, ase_id, stream); - err = bt_bap_stream_reconfig(stream, &codec); + err = bt_bap_stream_reconfig(stream, &codec_cfg); zassert_false(err < 0, "bt_bap_stream_reconfig returned err %d", err); /* Verification */ @@ -955,8 +954,8 @@ ZTEST_F(test_source_ase_state_transition, test_server_codec_configured_to_releas ZTEST_F(test_source_ase_state_transition, test_server_qos_configured_to_codec_configured) { - struct bt_codec codec = BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT, - BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); + struct bt_audio_codec_cfg codec_cfg = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); struct bt_bap_stream *stream = &fixture->stream; struct bt_conn *conn = &fixture->conn; uint8_t ase_id = fixture->ase.id; @@ -966,7 +965,7 @@ ZTEST_F(test_source_ase_state_transition, test_server_qos_configured_to_codec_co test_preamble_state_qos_configured(conn, ase_id, stream); - err = bt_bap_stream_reconfig(stream, &codec); + err = bt_bap_stream_reconfig(stream, &codec_cfg); zassert_false(err < 0, "bt_bap_stream_reconfig returned err %d", err); /* Verification */ @@ -1014,8 +1013,8 @@ ZTEST_F(test_source_ase_state_transition, test_server_enabling_to_releasing) ZTEST_F(test_source_ase_state_transition, test_server_enabling_to_enabling) { - struct bt_codec_data meta[] = { - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, + struct bt_audio_codec_data meta[] = { + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, (BT_AUDIO_CONTEXT_TYPE_MEDIA & 0xFFU), ((BT_AUDIO_CONTEXT_TYPE_MEDIA >> 8) & 0xFFU)), }; @@ -1057,8 +1056,8 @@ ZTEST_F(test_source_ase_state_transition, test_server_enabling_to_disabling) ZTEST_F(test_source_ase_state_transition, test_server_streaming_to_streaming) { - struct bt_codec_data meta[] = { - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, + struct bt_audio_codec_data meta[] = { + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, (BT_AUDIO_CONTEXT_TYPE_MEDIA & 0xFFU), ((BT_AUDIO_CONTEXT_TYPE_MEDIA >> 8) & 0xFFU)), }; diff --git a/tests/bluetooth/audio/ascs/src/test_ase_state_transition_invalid.c b/tests/bluetooth/audio/ascs/src/test_ase_state_transition_invalid.c index de613815eaabd30..32c0c7767cc8463 100644 --- a/tests/bluetooth/audio/ascs/src/test_ase_state_transition_invalid.c +++ b/tests/bluetooth/audio/ascs/src/test_ase_state_transition_invalid.c @@ -449,11 +449,11 @@ ZTEST_F(test_ase_state_transition_invalid, test_client_source_state_disabling) static void test_server_config_codec_expect_error(struct bt_bap_stream *stream) { - struct bt_codec codec = BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT, - BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); + struct bt_audio_codec_cfg codec_cfg = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); int err; - err = bt_bap_stream_reconfig(stream, &codec); + err = bt_bap_stream_reconfig(stream, &codec_cfg); zassert_false(err == 0, "bt_bap_stream_reconfig unexpected success"); } @@ -490,8 +490,8 @@ static void test_server_config_qos_expect_error(struct bt_bap_stream *stream) static void test_server_enable_expect_error(struct bt_bap_stream *stream) { - struct bt_codec_data meta[] = { - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, + struct bt_audio_codec_data meta[] = { + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, (BT_AUDIO_CONTEXT_TYPE_RINGTONE & 0xFFU), ((BT_AUDIO_CONTEXT_TYPE_RINGTONE >> 8) & 0xFFU)), }; @@ -516,8 +516,8 @@ static void test_server_receiver_stop_ready_expect_error(struct bt_bap_stream *s static void test_server_update_metadata_expect_error(struct bt_bap_stream *stream) { - struct bt_codec_data meta[] = { - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, + struct bt_audio_codec_data meta[] = { + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, (BT_AUDIO_CONTEXT_TYPE_RINGTONE & 0xFFU), ((BT_AUDIO_CONTEXT_TYPE_RINGTONE >> 8) & 0xFFU)), }; diff --git a/tests/bluetooth/audio/ascs/src/test_common.c b/tests/bluetooth/audio/ascs/src/test_common.c index adecbf2f2c37e6a..bc529097b8f3a08 100644 --- a/tests/bluetooth/audio/ascs/src/test_common.c +++ b/tests/bluetooth/audio/ascs/src/test_common.c @@ -133,14 +133,14 @@ uint8_t test_ase_id_get(const struct bt_gatt_attr *ase) } static struct bt_bap_stream *stream_allocated; -static const struct bt_codec_qos_pref qos_pref = BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, - 0x02, 10, 40000, 40000, - 40000, 40000); +static const struct bt_audio_codec_qos_pref qos_pref = + BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 40000, 40000, 40000, 40000); static int unicast_server_cb_config_custom_fake(struct bt_conn *conn, const struct bt_bap_ep *ep, - enum bt_audio_dir dir, const struct bt_codec *codec, + enum bt_audio_dir dir, + const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream, - struct bt_codec_qos_pref *const pref, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { *stream = stream_allocated; diff --git a/tests/bluetooth/audio/mocks/include/bap_stream.h b/tests/bluetooth/audio/mocks/include/bap_stream.h index 553c0cded746046..41d146f810d2ce3 100644 --- a/tests/bluetooth/audio/mocks/include/bap_stream.h +++ b/tests/bluetooth/audio/mocks/include/bap_stream.h @@ -16,7 +16,7 @@ void mock_bap_stream_init(void); void mock_bap_stream_cleanup(void); DECLARE_FAKE_VOID_FUNC(mock_bap_stream_configured_cb, struct bt_bap_stream *, - const struct bt_codec_qos_pref *); + const struct bt_audio_codec_qos_pref *); DECLARE_FAKE_VOID_FUNC(mock_bap_stream_qos_set_cb, struct bt_bap_stream *); DECLARE_FAKE_VOID_FUNC(mock_bap_stream_enabled_cb, struct bt_bap_stream *); DECLARE_FAKE_VOID_FUNC(mock_bap_stream_metadata_updated_cb, struct bt_bap_stream *); diff --git a/tests/bluetooth/audio/mocks/include/bap_unicast_server.h b/tests/bluetooth/audio/mocks/include/bap_unicast_server.h index 77d10b3f5d5b212..61d02a8f47026a1 100644 --- a/tests/bluetooth/audio/mocks/include/bap_unicast_server.h +++ b/tests/bluetooth/audio/mocks/include/bap_unicast_server.h @@ -16,20 +16,20 @@ void mock_bap_unicast_server_init(void); void mock_bap_unicast_server_cleanup(void); DECLARE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_config, struct bt_conn *, - const struct bt_bap_ep *, enum bt_audio_dir, const struct bt_codec *, - struct bt_bap_stream **, struct bt_codec_qos_pref *const, - struct bt_bap_ascs_rsp *); + const struct bt_bap_ep *, enum bt_audio_dir, + const struct bt_audio_codec_cfg *, struct bt_bap_stream **, + struct bt_audio_codec_qos_pref *const, struct bt_bap_ascs_rsp *); DECLARE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_reconfig, struct bt_bap_stream *, - enum bt_audio_dir, const struct bt_codec *, - struct bt_codec_qos_pref *const, struct bt_bap_ascs_rsp *); + enum bt_audio_dir, const struct bt_audio_codec_cfg *, + struct bt_audio_codec_qos_pref *const, struct bt_bap_ascs_rsp *); DECLARE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_qos, struct bt_bap_stream *, - const struct bt_codec_qos *, struct bt_bap_ascs_rsp *); + const struct bt_audio_codec_qos *, struct bt_bap_ascs_rsp *); DECLARE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_enable, struct bt_bap_stream *, - const struct bt_codec_data *, size_t, struct bt_bap_ascs_rsp *); + const struct bt_audio_codec_data *, size_t, struct bt_bap_ascs_rsp *); DECLARE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_start, struct bt_bap_stream *, struct bt_bap_ascs_rsp *); DECLARE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_metadata, struct bt_bap_stream *, - const struct bt_codec_data *, size_t, struct bt_bap_ascs_rsp *); + const struct bt_audio_codec_data *, size_t, struct bt_bap_ascs_rsp *); DECLARE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_disable, struct bt_bap_stream *, struct bt_bap_ascs_rsp *); DECLARE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_stop, struct bt_bap_stream *, diff --git a/tests/bluetooth/audio/mocks/src/bap_stream.c b/tests/bluetooth/audio/mocks/src/bap_stream.c index d4597b65362e40c..c022865dc0a17aa 100644 --- a/tests/bluetooth/audio/mocks/src/bap_stream.c +++ b/tests/bluetooth/audio/mocks/src/bap_stream.c @@ -24,7 +24,7 @@ struct bt_bap_stream_ops mock_bap_stream_ops; DEFINE_FAKE_VOID_FUNC(mock_bap_stream_configured_cb, struct bt_bap_stream *, - const struct bt_codec_qos_pref *); + const struct bt_audio_codec_qos_pref *); DEFINE_FAKE_VOID_FUNC(mock_bap_stream_qos_set_cb, struct bt_bap_stream *); DEFINE_FAKE_VOID_FUNC(mock_bap_stream_enabled_cb, struct bt_bap_stream *); DEFINE_FAKE_VOID_FUNC(mock_bap_stream_metadata_updated_cb, struct bt_bap_stream *); diff --git a/tests/bluetooth/audio/mocks/src/bap_unicast_client.c b/tests/bluetooth/audio/mocks/src/bap_unicast_client.c index 44179310b0c05b8..d5cfd4823f78386 100644 --- a/tests/bluetooth/audio/mocks/src/bap_unicast_client.c +++ b/tests/bluetooth/audio/mocks/src/bap_unicast_client.c @@ -11,7 +11,8 @@ bool bt_bap_ep_is_unicast_client(const struct bt_bap_ep *ep) return false; } -int bt_bap_unicast_client_config(struct bt_bap_stream *stream, const struct bt_codec *codec) +int bt_bap_unicast_client_config(struct bt_bap_stream *stream, + const struct bt_audio_codec_cfg *codec_cfg) { zassert_unreachable("Unexpected call to '%s()' occurred", __func__); return 0; @@ -23,14 +24,14 @@ int bt_bap_unicast_client_qos(struct bt_conn *conn, struct bt_bap_unicast_group return 0; } -int bt_bap_unicast_client_enable(struct bt_bap_stream *stream, struct bt_codec_data *meta, +int bt_bap_unicast_client_enable(struct bt_bap_stream *stream, struct bt_audio_codec_data *meta, size_t meta_count) { zassert_unreachable("Unexpected call to '%s()' occurred", __func__); return 0; } -int bt_bap_unicast_client_metadata(struct bt_bap_stream *stream, struct bt_codec_data *meta, +int bt_bap_unicast_client_metadata(struct bt_bap_stream *stream, struct bt_audio_codec_data *meta, size_t meta_count) { zassert_unreachable("Unexpected call to '%s()' occurred", __func__); diff --git a/tests/bluetooth/audio/mocks/src/bap_unicast_server.c b/tests/bluetooth/audio/mocks/src/bap_unicast_server.c index b59180d0a426917..e6907a32b5b2c69 100644 --- a/tests/bluetooth/audio/mocks/src/bap_unicast_server.c +++ b/tests/bluetooth/audio/mocks/src/bap_unicast_server.c @@ -31,20 +31,20 @@ void mock_bap_unicast_server_cleanup(void) } DEFINE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_config, struct bt_conn *, - const struct bt_bap_ep *, enum bt_audio_dir, const struct bt_codec *, - struct bt_bap_stream **, struct bt_codec_qos_pref *const, - struct bt_bap_ascs_rsp *); + const struct bt_bap_ep *, enum bt_audio_dir, + const struct bt_audio_codec_cfg *, struct bt_bap_stream **, + struct bt_audio_codec_qos_pref *const, struct bt_bap_ascs_rsp *); DEFINE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_reconfig, struct bt_bap_stream *, - enum bt_audio_dir, const struct bt_codec *, struct bt_codec_qos_pref *const, - struct bt_bap_ascs_rsp *); + enum bt_audio_dir, const struct bt_audio_codec_cfg *, + struct bt_audio_codec_qos_pref *const, struct bt_bap_ascs_rsp *); DEFINE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_qos, struct bt_bap_stream *, - const struct bt_codec_qos *, struct bt_bap_ascs_rsp *); + const struct bt_audio_codec_qos *, struct bt_bap_ascs_rsp *); DEFINE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_enable, struct bt_bap_stream *, - const struct bt_codec_data *, size_t, struct bt_bap_ascs_rsp *); + const struct bt_audio_codec_data *, size_t, struct bt_bap_ascs_rsp *); DEFINE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_start, struct bt_bap_stream *, struct bt_bap_ascs_rsp *); DEFINE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_metadata, struct bt_bap_stream *, - const struct bt_codec_data *, size_t, struct bt_bap_ascs_rsp *); + const struct bt_audio_codec_data *, size_t, struct bt_bap_ascs_rsp *); DEFINE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_disable, struct bt_bap_stream *, struct bt_bap_ascs_rsp *); DEFINE_FAKE_VALUE_FUNC(int, mock_bap_unicast_server_cb_stop, struct bt_bap_stream *, diff --git a/tests/bluetooth/audio/mocks/src/pacs.c b/tests/bluetooth/audio/mocks/src/pacs.c index 61e24859a3fedb5..11cfd629dbcd524 100644 --- a/tests/bluetooth/audio/mocks/src/pacs.c +++ b/tests/bluetooth/audio/mocks/src/pacs.c @@ -13,9 +13,9 @@ #define PACS_FFF_FAKES_LIST(FAKE) \ FAKE(bt_pacs_cap_foreach) \ -static struct bt_codec lc3_codec = - BT_CODEC_LC3(BT_CODEC_LC3_FREQ_ANY, BT_CODEC_LC3_DURATION_10, - BT_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u, +static struct bt_audio_codec_cfg lc3_codec = + BT_AUDIO_CODEC_LC3(BT_AUDIO_CODEC_LC3_FREQ_ANY, BT_AUDIO_CODEC_LC3_DURATION_10, + BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u, (BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA)); DEFINE_FAKE_VOID_FUNC(bt_pacs_cap_foreach, enum bt_audio_dir, bt_pacs_cap_foreach_func_t, void *); diff --git a/tests/bluetooth/shell/audio.conf b/tests/bluetooth/shell/audio.conf index 40d24233f6a84df..14fa76b3db2ec4b 100644 --- a/tests/bluetooth/shell/audio.conf +++ b/tests/bluetooth/shell/audio.conf @@ -61,11 +61,14 @@ CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT=4 CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT=2 CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT=2 -CONFIG_BT_CODEC_MAX_METADATA_COUNT=10 -CONFIG_BT_CODEC_MAX_DATA_LEN=40 -CONFIG_BT_CODEC_MAX_DATA_COUNT=10 -CONFIG_BT_CODEC_MAX_DATA_LEN=40 +CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT=10 +CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN=40 +CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_COUNT=10 +CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN=40 +CONFIG_BT_ASCS_ASE_SNK_COUNT=2 +CONFIG_BT_ASCS_ASE_SRC_COUNT=2 +CONFIG_BT_BAP_UNICAST_CLIENT=y CONFIG_BT_BAP_BROADCAST_SOURCE=y CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT=4 CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT=4 diff --git a/tests/bluetooth/tester/src/btp_bap.c b/tests/bluetooth/tester/src/btp_bap.c index 4ef9f1b68f944db..425d7aa6f8fa911 100644 --- a/tests/bluetooth/tester/src/btp_bap.c +++ b/tests/bluetooth/tester/src/btp_bap.c @@ -40,12 +40,10 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL); #define AVAILABLE_SINK_CONTEXT SUPPORTED_SINK_CONTEXT #define AVAILABLE_SOURCE_CONTEXT SUPPORTED_SOURCE_CONTEXT -static struct bt_codec default_codec = - BT_CODEC_LC3(BT_CODEC_LC3_FREQ_ANY, BT_CODEC_LC3_DURATION_10, - BT_CODEC_LC3_CHAN_COUNT_SUPPORT(1), - 40u, 120u, 1u, - (BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | - BT_AUDIO_CONTEXT_TYPE_MEDIA)); +static struct bt_audio_codec_cap default_codec_cap = + BT_AUDIO_CODEC_LC3(BT_AUDIO_CODEC_LC3_FREQ_ANY, BT_AUDIO_CODEC_LC3_DURATION_10, + BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u, + (BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA)); struct audio_stream { struct bt_bap_stream stream; @@ -69,15 +67,15 @@ struct audio_connection { struct audio_stream streams[MAX_STREAMS_COUNT]; size_t configured_sink_stream_count; size_t configured_source_stream_count; - struct bt_codec codec; - struct bt_codec_qos qos; + struct bt_audio_codec_cfg codec_cfg; + struct bt_audio_codec_qos qos; struct bt_bap_unicast_group *unicast_group; struct bt_bap_ep *end_points[MAX_END_POINTS_COUNT]; size_t end_points_count; } connections[CONFIG_BT_MAX_CONN]; -static struct bt_codec_qos_pref qos_pref = BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, - 10, 10000, 40000, 10000, 40000); +static struct bt_audio_codec_qos_pref qos_pref = + BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 10000, 40000, 10000, 40000); NET_BUF_POOL_FIXED_DEFINE(tx_pool, MAX(CONFIG_BT_ASCS_ASE_SRC_COUNT, CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT), @@ -97,45 +95,73 @@ static void audio_send_timeout(struct k_work *work); K_THREAD_STACK_DEFINE(iso_data_thread_stack_area, ISO_DATA_THREAD_STACK_SIZE); static struct k_work_q iso_data_work_q; - -static void print_codec(const struct bt_codec *codec) +static void print_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg) { - LOG_DBG("codec 0x%02x cid 0x%04x vid 0x%04x count %zu", - codec->id, codec->cid, codec->vid, codec->data_count); + LOG_DBG("codec_cfg 0x%02x cid 0x%04x vid 0x%04x count %zu", codec_cfg->id, codec_cfg->cid, + codec_cfg->vid, codec_cfg->data_count); - for (size_t i = 0; i < codec->data_count; i++) { - LOG_DBG("data #%zu: type 0x%02x len %u", i, codec->data[i].data.type, - codec->data[i].data.data_len); - LOG_HEXDUMP_DBG(codec->data[i].data.data, codec->data[i].data.data_len - - sizeof(codec->data[i].data.type), ""); + for (size_t i = 0; i < codec_cfg->data_count; i++) { + LOG_DBG("data #%zu: type 0x%02x len %u", i, codec_cfg->data[i].data.type, + codec_cfg->data[i].data.data_len); + LOG_HEXDUMP_DBG(codec_cfg->data[i].data.data, + codec_cfg->data[i].data.data_len - + sizeof(codec_cfg->data[i].data.type), + ""); } - if (codec->id == BT_CODEC_LC3_ID) { + if (codec_cfg->id == BT_AUDIO_CODEC_LC3_ID) { /* LC3 uses the generic LTV format - other codecs might do as well */ enum bt_audio_location chan_allocation; - LOG_DBG(" Frequency: %d Hz", bt_codec_cfg_get_freq(codec)); - LOG_DBG(" Frame Duration: %d us", bt_codec_cfg_get_frame_duration_us(codec)); - if (bt_codec_cfg_get_chan_allocation_val(codec, &chan_allocation) == 0) { + LOG_DBG(" Frequency: %d Hz", bt_audio_codec_cfg_get_freq(codec_cfg)); + LOG_DBG(" Frame Duration: %d us", + bt_audio_codec_cfg_get_frame_duration_us(codec_cfg)); + if (bt_audio_codec_cfg_get_chan_allocation_val(codec_cfg, &chan_allocation) == 0) { LOG_DBG(" Channel allocation: 0x%x", chan_allocation); } LOG_DBG(" Octets per frame: %d (negative means value not pressent)", - bt_codec_cfg_get_octets_per_frame(codec)); + bt_audio_codec_cfg_get_octets_per_frame(codec_cfg)); LOG_DBG(" Frames per SDU: %d", - bt_codec_cfg_get_frame_blocks_per_sdu(codec, true)); + bt_audio_codec_cfg_get_frame_blocks_per_sdu(codec_cfg, true)); + } + + for (size_t i = 0; i < codec_cfg->meta_count; i++) { + LOG_DBG("meta #%zu: type 0x%02x len %u", i, codec_cfg->meta[i].data.type, + codec_cfg->meta[i].data.data_len); + LOG_HEXDUMP_DBG(codec_cfg->meta[i].data.data, + codec_cfg->meta[i].data.data_len - + sizeof(codec_cfg->meta[i].data.type), + ""); + } +} + +static void print_codec_cap(const struct bt_audio_codec_cap *codec_cap) +{ + LOG_DBG("codec_cap 0x%02x cid 0x%04x vid 0x%04x count %zu", codec_cap->id, codec_cap->cid, + codec_cap->vid, codec_cap->data_count); + + for (size_t i = 0; i < codec_cap->data_count; i++) { + LOG_DBG("data #%zu: type 0x%02x len %u", i, codec_cap->data[i].data.type, + codec_cap->data[i].data.data_len); + LOG_HEXDUMP_DBG(codec_cap->data[i].data.data, + codec_cap->data[i].data.data_len - + sizeof(codec_cap->data[i].data.type), + ""); } - for (size_t i = 0; i < codec->meta_count; i++) { - LOG_DBG("meta #%zu: type 0x%02x len %u", i, codec->meta[i].data.type, - codec->meta[i].data.data_len); - LOG_HEXDUMP_DBG(codec->meta[i].data.data, codec->meta[i].data.data_len - - sizeof(codec->meta[i].data.type), ""); + for (size_t i = 0; i < codec_cap->meta_count; i++) { + LOG_DBG("meta #%zu: type 0x%02x len %u", i, codec_cap->meta[i].data.type, + codec_cap->meta[i].data.data_len); + LOG_HEXDUMP_DBG(codec_cap->meta[i].data.data, + codec_cap->meta[i].data.data_len - + sizeof(codec_cap->meta[i].data.type), + ""); } } -static inline void print_qos(const struct bt_codec_qos *qos) +static inline void print_qos(const struct bt_audio_codec_qos *qos) { LOG_DBG("QoS: interval %u framing 0x%02x phy 0x%02x sdu %u rtn %u latency %u pd %u", qos->interval, qos->framing, qos->phy, qos->sdu, qos->rtn, qos->latency, qos->pd); @@ -196,7 +222,7 @@ static void btp_send_ascs_operation_completed_ev(struct bt_conn *conn, uint8_t a tester_event(BTP_SERVICE_ID_ASCS, BTP_ASCS_EV_OPERATION_COMPLETED, &ev, sizeof(ev)); } -static int validate_codec_parameters(const struct bt_codec *codec) +static int validate_codec_parameters(const struct bt_audio_codec_cfg *codec_cfg) { int freq_hz; int frame_duration_us; @@ -205,11 +231,12 @@ static int validate_codec_parameters(const struct bt_codec *codec) int chan_allocation_err; enum bt_audio_location chan_allocation; - freq_hz = bt_codec_cfg_get_freq(codec); - frame_duration_us = bt_codec_cfg_get_frame_duration_us(codec); - chan_allocation_err = bt_codec_cfg_get_chan_allocation_val(codec, &chan_allocation); - octets_per_frame = bt_codec_cfg_get_octets_per_frame(codec); - frames_per_sdu = bt_codec_cfg_get_frame_blocks_per_sdu(codec, true); + freq_hz = bt_audio_codec_cfg_get_freq(codec_cfg); + frame_duration_us = bt_audio_codec_cfg_get_frame_duration_us(codec_cfg); + chan_allocation_err = + bt_audio_codec_cfg_get_chan_allocation_val(codec_cfg, &chan_allocation); + octets_per_frame = bt_audio_codec_cfg_get_octets_per_frame(codec_cfg); + frames_per_sdu = bt_audio_codec_cfg_get_frame_blocks_per_sdu(codec_cfg, true); if (freq_hz < 0) { LOG_DBG("Error: Invalid codec frequency."); @@ -240,17 +267,17 @@ static int validate_codec_parameters(const struct bt_codec *codec) } static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_bap_stream **stream, - struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { struct audio_connection *audio_conn; struct audio_stream *stream_wrap; LOG_DBG("ASE Codec Config: ep %p dir %u", ep, dir); - print_codec(codec); + print_codec_cfg(codec_cfg); - if (validate_codec_parameters(codec)) { + if (validate_codec_parameters(codec_cfg)) { *rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_CONF_REJECTED, BT_BAP_ASCS_REASON_CODEC_DATA); @@ -288,17 +315,17 @@ static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_ } static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_codec_qos_pref *const pref, - struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { LOG_DBG("ASE Codec Reconfig: stream %p", stream); - print_codec(codec); + print_codec_cfg(codec_cfg); return 0; } -static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, +static int lc3_qos(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos, struct bt_bap_ascs_rsp *rsp) { LOG_DBG("QoS: stream %p qos %p", stream, qos); @@ -308,7 +335,7 @@ static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, return 0; } -static int lc3_enable(struct bt_bap_stream *stream, const struct bt_codec_data *meta, +static int lc3_enable(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { LOG_DBG("Enable: stream %p meta_count %zu", stream, meta_count); @@ -374,14 +401,13 @@ static bool valid_metadata_type(uint8_t type, uint8_t len, const uint8_t *data) } } -static int lc3_metadata(struct bt_bap_stream *stream, - const struct bt_codec_data *meta, +static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { LOG_DBG("Metadata: stream %p meta_count %zu", stream, meta_count); for (size_t i = 0; i < meta_count; i++) { - const struct bt_codec_data *data = data = &meta[i]; + const struct bt_audio_codec_data *data = data = &meta[i]; if (!valid_metadata_type(data->data.type, data->data.data_len, data->data.data)) { LOG_DBG("Invalid metadata type %u or length %u", @@ -459,7 +485,7 @@ static void btp_send_stream_received_ev(struct bt_conn *conn, struct bt_bap_ep * } static void stream_configured(struct bt_bap_stream *stream, - const struct bt_codec_qos_pref *pref) + const struct bt_audio_codec_qos_pref *pref) { struct audio_connection *audio_conn; struct audio_stream *a_stream = CONTAINER_OF(stream, struct audio_stream, stream); @@ -622,26 +648,27 @@ static void btp_send_discovery_completed_ev(struct bt_conn *conn, uint8_t status tester_event(BTP_SERVICE_ID_BAP, BTP_BAP_EV_DISCOVERY_COMPLETED, &ev, sizeof(ev)); } -static void btp_send_pac_codec_found_ev(struct bt_conn *conn, const struct bt_codec *codec, +static void btp_send_pac_codec_found_ev(struct bt_conn *conn, + const struct bt_audio_codec_cfg *codec_cfg, enum bt_audio_dir dir) { struct btp_bap_codec_cap_found_ev ev; struct bt_conn_info info; - const struct bt_codec_data *data; + const struct bt_audio_codec_data *data; (void)bt_conn_get_info(conn, &info); bt_addr_le_copy(&ev.address, info.le.dst); ev.dir = dir; - ev.coding_format = codec->id; + ev.coding_format = codec_cfg->id; - bt_codec_get_val(codec, BT_CODEC_LC3_FREQ, &data); + bt_audio_codec_cfg_get_val(codec_cfg, BT_AUDIO_CODEC_LC3_FREQ, &data); memcpy(&ev.frequencies, data->data.data, sizeof(ev.frequencies)); - bt_codec_get_val(codec, BT_CODEC_LC3_DURATION, &data); + bt_audio_codec_cfg_get_val(codec_cfg, BT_AUDIO_CODEC_LC3_DURATION, &data); memcpy(&ev.frame_durations, data->data.data, sizeof(ev.frame_durations)); - bt_codec_get_val(codec, BT_CODEC_LC3_FRAME_LEN, &data); + bt_audio_codec_cfg_get_val(codec_cfg, BT_AUDIO_CODEC_LC3_FRAME_LEN, &data); memcpy(&ev.octets_per_frame, data->data.data, sizeof(ev.octets_per_frame)); bt_codec_get_val(codec, BT_CODEC_LC3_CHAN_COUNT, &data); @@ -728,14 +755,15 @@ static void release_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code r LOG_DBG("stream %p release operation rsp_code %u reason %u", stream, rsp_code, reason); } -static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, const struct bt_codec *codec) +static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, + const struct bt_audio_codec_cap *codec_cap) { LOG_DBG(""); - if (codec != NULL) { - LOG_DBG("Discovered codec capabilities %p", codec); - print_codec(codec); - btp_send_pac_codec_found_ev(conn, codec, dir); + if (codec_cap != NULL) { + LOG_DBG("Discovered codec capabilities %p", codec_cap); + print_codec_cap(codec_cap); + btp_send_pac_codec_found_ev(conn, codec_cap, dir); } } @@ -1012,11 +1040,11 @@ static struct bt_conn_cb conn_callbacks = { }; static struct bt_pacs_cap cap_sink = { - .codec = &default_codec, + .codec_cap = &default_codec_cap, }; static struct bt_pacs_cap cap_source = { - .codec = &default_codec, + .codec_cap = &default_codec_cap, }; static uint8_t ascs_supported_commands(const void *cmd, uint16_t cmd_len, @@ -1033,17 +1061,18 @@ static uint8_t ascs_supported_commands(const void *cmd, uint16_t cmd_len, } static int server_stream_config(struct bt_conn *conn, struct bt_bap_stream *stream, - struct bt_codec *codec, struct bt_codec_qos_pref *qos) + struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos_pref *qos) { int err; struct bt_bap_ep *ep; - err = bt_bap_unicast_server_config_ase(conn, stream, codec, qos); + err = bt_bap_unicast_server_config_ase(conn, stream, codec_cfg, qos); if (err != 0) { return err; } - print_codec(&default_codec); + print_codec_cfg(&codec_cfg); ep = stream->ep; LOG_DBG("ASE Codec Config: ase_id %u dir %u", ep->status.id, ep->dir); @@ -1105,15 +1134,15 @@ static int client_create_unicast_group(struct audio_connection *audio_conn, uint static bool codec_config_store(struct bt_data *data, void *user_data) { - struct bt_codec *codec = user_data; - struct bt_codec_data *cdata; + struct bt_audio_codec_cfg *codec_cfg = user_data; + struct bt_audio_codec_data *cdata; - if (codec->data_count >= ARRAY_SIZE(codec->data)) { + if (codec_cfg->data_count >= ARRAY_SIZE(codec_cfg->data)) { LOG_ERR("No slot available for Codec Config"); return false; } - cdata = &codec->data[codec->data_count]; + cdata = &codec_cfg->data[codec_cfg->data_count]; if (data->data_len > sizeof(cdata->value)) { LOG_ERR("Not enough space for Codec Config: %u > %zu", data->data_len, @@ -1121,7 +1150,7 @@ static bool codec_config_store(struct bt_data *data, void *user_data) return false; } - LOG_DBG("#%u type 0x%02x len %u", codec->data_count, data->type, data->data_len); + LOG_DBG("#%u type 0x%02x len %u", codec_cfg->data_count, data->type, data->data_len); cdata->data.type = data->type; cdata->data.data_len = data->data_len; @@ -1132,7 +1161,7 @@ static bool codec_config_store(struct bt_data *data, void *user_data) LOG_HEXDUMP_DBG(cdata->value, data->data_len, "data"); - codec->data_count++; + codec_cfg->data_count++; return true; } @@ -1146,7 +1175,7 @@ static uint8_t ascs_configure_codec(const void *cmd, uint16_t cmd_len, struct bt_conn_info conn_info; struct audio_connection *audio_conn; struct audio_stream *stream; - struct bt_codec *codec; + struct bt_audio_codec_cfg *codec_cfg; struct bt_bap_ep *ep; struct net_buf_simple buf; @@ -1160,18 +1189,18 @@ static uint8_t ascs_configure_codec(const void *cmd, uint16_t cmd_len, (void)bt_conn_get_info(conn, &conn_info); - codec = &audio_conn->codec; - memset(codec, 0, sizeof(*codec)); + codec_cfg = &audio_conn->codec_cfg; + memset(codec_cfg, 0, sizeof(*codec_cfg)); - codec->id = cp->coding_format; - codec->vid = cp->vid; - codec->cid = cp->cid; + codec_cfg->id = cp->coding_format; + codec_cfg->vid = cp->vid; + codec_cfg->cid = cp->cid; if (cp->ltvs_len != 0) { net_buf_simple_init_with_data(&buf, (uint8_t *)cp->ltvs, cp->ltvs_len); /* Parse LTV entries */ - bt_data_parse(&buf, codec_config_store, codec); + bt_data_parse(&buf, codec_config_store, codec_cfg); /* Check if all entries could be parsed */ if (buf.len) { @@ -1209,13 +1238,13 @@ static uint8_t ascs_configure_codec(const void *cmd, uint16_t cmd_len, return BTP_STATUS_FAILED; } - err = bt_bap_stream_config(conn, &stream->stream, ep, codec); + err = bt_bap_stream_config(conn, &stream->stream, ep, codec_cfg); } else { - err = server_stream_config(conn, &stream->stream, codec, &qos_pref); + err = server_stream_config(conn, &stream->stream, codec_cfg, &qos_pref); } } else { /* Reconfigure a stream */ - err = bt_bap_stream_reconfig(&stream->stream, codec); + err = bt_bap_stream_reconfig(&stream->stream, codec_cfg); } bt_conn_unref(conn); @@ -1235,7 +1264,7 @@ static uint8_t ascs_configure_qos(const void *cmd, uint16_t cmd_len, const struct btp_ascs_configure_qos_cmd *cp = cmd; struct bt_conn_info conn_info; struct audio_connection *audio_conn; - struct bt_codec_qos *qos; + struct bt_audio_codec_qos *qos; struct bt_conn *conn; conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); @@ -1266,7 +1295,7 @@ static uint8_t ascs_configure_qos(const void *cmd, uint16_t cmd_len, } qos = &audio_conn->qos; - qos->phy = BT_CODEC_QOS_2M; + qos->phy = BT_AUDIO_CODEC_QOS_2M; qos->framing = cp->framing; qos->rtn = cp->retransmission_num; qos->sdu = cp->max_sdu; @@ -1468,7 +1497,7 @@ static uint8_t ascs_update_metadata(const void *cmd, uint16_t cmd_len, void *rsp const struct btp_ascs_update_metadata_cmd *cp = cmd; struct audio_connection *audio_conn; struct audio_stream *stream; - struct bt_codec_data meta; + struct bt_audio_codec_data meta; struct bt_conn *conn; conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); diff --git a/tests/bsim/bluetooth/audio/prj.conf b/tests/bsim/bluetooth/audio/prj.conf index 4f9459c168e0b5d..c70248cd5128118 100644 --- a/tests/bsim/bluetooth/audio/prj.conf +++ b/tests/bsim/bluetooth/audio/prj.conf @@ -24,7 +24,7 @@ CONFIG_BT_ASCS_ASE_SNK_COUNT=2 CONFIG_BT_ASCS_ASE_SRC_COUNT=2 CONFIG_BT_BAP_BROADCAST_SOURCE=y CONFIG_BT_BAP_BROADCAST_SINK=y -CONFIG_BT_CODEC_MAX_DATA_LEN=128 +CONFIG_BT_AUDIO_CODEC_MAX_DATA_LEN=128 CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT=1 CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT=1 CONFIG_BT_BAP_BROADCAST_SNK_SUBGROUP_COUNT=1 diff --git a/tests/bsim/bluetooth/audio/src/bap_broadcast_sink_test.c b/tests/bsim/bluetooth/audio/src/bap_broadcast_sink_test.c index 82cdab957980dbd..af0e4272f0761e7 100644 --- a/tests/bsim/bluetooth/audio/src/bap_broadcast_sink_test.c +++ b/tests/bsim/bluetooth/audio/src/bap_broadcast_sink_test.c @@ -26,13 +26,13 @@ CREATE_FLAG(flag_received); static struct bt_bap_broadcast_sink *g_sink; static struct bt_bap_stream broadcast_sink_streams[CONFIG_BT_BAP_BROADCAST_SNK_STREAM_COUNT]; static struct bt_bap_stream *streams[ARRAY_SIZE(broadcast_sink_streams)]; -static struct bt_bap_lc3_preset preset_16_2_1 = BT_BAP_LC3_BROADCAST_PRESET_16_2_1( +static struct bt_audio_codec_cap codec_cap_16_2_1 = BT_AUDIO_CODEC_LC3_CONFIG_16_2( BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); static K_SEM_DEFINE(sem_started, 0U, ARRAY_SIZE(streams)); static K_SEM_DEFINE(sem_stopped, 0U, ARRAY_SIZE(streams)); -static struct bt_codec_data metadata[CONFIG_BT_CODEC_MAX_METADATA_COUNT]; +static struct bt_audio_codec_data metadata[CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_COUNT]; /* Create a mask for the maximum BIS we can sync to using the number of streams * we have. We add an additional 1 since the bis indexes start from 1 and not @@ -81,11 +81,11 @@ static void base_recv_cb(struct bt_bap_broadcast_sink *sink, const struct bt_bap if (TEST_FLAG(base_received)) { if (base->subgroup_count > 0 && - memcmp(metadata, base->subgroups[0].codec.meta, - sizeof(base->subgroups[0].codec.meta)) != 0) { + memcmp(metadata, base->subgroups[0].codec_cfg.meta, + sizeof(base->subgroups[0].codec_cfg.meta)) != 0) { - (void)memcpy(metadata, base->subgroups[0].codec.meta, - sizeof(base->subgroups[0].codec.meta)); + (void)memcpy(metadata, base->subgroups[0].codec_cfg.meta, + sizeof(base->subgroups[0].codec_cfg.meta)); SET_FLAG(flag_base_metadata_updated); } @@ -145,7 +145,7 @@ static struct bt_bap_broadcast_sink_cb broadcast_sink_cbs = { }; static struct bt_pacs_cap cap = { - .codec = &preset_16_2_1.codec, + .codec_cap = &codec_cap_16_2_1, }; static void started_cb(struct bt_bap_stream *stream) diff --git a/tests/bsim/bluetooth/audio/src/bap_broadcast_source_test.c b/tests/bsim/bluetooth/audio/src/bap_broadcast_source_test.c index 421093695477d72..4d5edf1a05b78c1 100644 --- a/tests/bsim/bluetooth/audio/src/bap_broadcast_source_test.c +++ b/tests/bsim/bluetooth/audio/src/bap_broadcast_source_test.c @@ -99,8 +99,8 @@ static struct bt_bap_stream_ops stream_ops = { static int setup_broadcast_source(struct bt_bap_broadcast_source **source) { - struct bt_codec_data bis_codec_data = BT_CODEC_DATA(BT_CODEC_CONFIG_LC3_FREQ, - BT_CODEC_CONFIG_LC3_FREQ_16KHZ); + struct bt_audio_codec_data bis_codec_data = BT_AUDIO_CODEC_DATA( + BT_AUDIO_CODEC_CONFIG_LC3_FREQ, BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ); struct bt_bap_broadcast_source_stream_param stream_params[ARRAY_SIZE(broadcast_source_streams)]; struct bt_bap_broadcast_source_subgroup_param @@ -122,7 +122,7 @@ static int setup_broadcast_source(struct bt_bap_broadcast_source **source) for (size_t i = 0U; i < ARRAY_SIZE(subgroup_params); i++) { subgroup_params[i].params_count = 1U; subgroup_params[i].params = &stream_params[i]; - subgroup_params[i].codec = &preset_16_2_1.codec; + subgroup_params[i].codec_cfg = &preset_16_2_1.codec_cfg; } create_param.params_count = ARRAY_SIZE(subgroup_params); @@ -246,8 +246,8 @@ static int stop_extended_adv(struct bt_le_ext_adv *adv) static void test_main(void) { - struct bt_codec_data new_metadata[1] = - BT_CODEC_LC3_CONFIG_META(BT_AUDIO_CONTEXT_TYPE_ALERTS); + struct bt_audio_codec_data new_metadata[1] = + BT_AUDIO_CODEC_LC3_CONFIG_META(BT_AUDIO_CONTEXT_TYPE_ALERTS); struct bt_bap_broadcast_source *source; struct bt_le_ext_adv *adv; int err; @@ -273,7 +273,8 @@ static void test_main(void) } printk("Reconfiguring broadcast source\n"); - err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec, &preset_16_2_1.qos); + err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg, + &preset_16_2_1.qos); if (err != 0) { FAIL("Unable to reconfigure broadcast source: %d\n", err); return; diff --git a/tests/bsim/bluetooth/audio/src/bap_unicast_client_test.c b/tests/bsim/bluetooth/audio/src/bap_unicast_client_test.c index 275379087e199de..53c816d5e18ed2d 100644 --- a/tests/bsim/bluetooth/audio/src/bap_unicast_client_test.c +++ b/tests/bsim/bluetooth/audio/src/bap_unicast_client_test.c @@ -32,7 +32,7 @@ static struct bt_bap_lc3_preset preset_16_2_1 = BT_BAP_LC3_UNICAST_PRESET_16_2_1 CREATE_FLAG(flag_mtu_exchanged); CREATE_FLAG(flag_sink_discovered); CREATE_FLAG(flag_source_discovered); -CREATE_FLAG(flag_codec_found); +CREATE_FLAG(flag_codec_cap_found); CREATE_FLAG(flag_endpoint_found); CREATE_FLAG(flag_stream_codec_configured); static atomic_t flag_stream_qos_configured; @@ -43,7 +43,7 @@ CREATE_FLAG(flag_stream_released); CREATE_FLAG(flag_operation_success); static void stream_configured(struct bt_bap_stream *stream, - const struct bt_codec_qos_pref *pref) + const struct bt_audio_codec_qos_pref *pref) { printk("Configured stream %p\n", stream); @@ -231,11 +231,12 @@ static void add_remote_source(struct bt_bap_ep *ep) FAIL("Could not add source ep\n"); } -static void print_remote_codec(const struct bt_codec *codec, enum bt_audio_dir dir) +static void print_remote_codec_cap(const struct bt_audio_codec_cap *codec_cap, + enum bt_audio_dir dir) { - printk("codec %p dir 0x%02x\n", codec, dir); + printk("codec %p dir 0x%02x\n", codec_cap, dir); - print_codec(codec); + print_codec_cap(codec_cap); } static void discover_sinks_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir) @@ -262,10 +263,11 @@ static void discover_sources_cb(struct bt_conn *conn, int err, enum bt_audio_dir SET_FLAG(flag_source_discovered); } -static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, const struct bt_codec *codec) +static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, + const struct bt_audio_codec_cap *codec_cap) { - print_remote_codec(codec, dir); - SET_FLAG(flag_codec_found); + print_remote_codec_cap(codec_cap, dir); + SET_FLAG(flag_codec_cap_found); } static void endpoint_cb(struct bt_conn *conn, enum bt_audio_dir dir, struct bt_bap_ep *ep) @@ -352,7 +354,7 @@ static void discover_sinks(void) unicast_client_cbs.discover = discover_sinks_cb; - UNSET_FLAG(flag_codec_found); + UNSET_FLAG(flag_codec_cap_found); UNSET_FLAG(flag_sink_discovered); UNSET_FLAG(flag_endpoint_found); @@ -364,7 +366,7 @@ static void discover_sinks(void) memset(g_sinks, 0, sizeof(g_sinks)); - WAIT_FOR_FLAG(flag_codec_found); + WAIT_FOR_FLAG(flag_codec_cap_found); WAIT_FOR_FLAG(flag_endpoint_found); WAIT_FOR_FLAG(flag_sink_discovered); } @@ -375,7 +377,7 @@ static void discover_sources(void) unicast_client_cbs.discover = discover_sources_cb; - UNSET_FLAG(flag_codec_found); + UNSET_FLAG(flag_codec_cap_found); UNSET_FLAG(flag_source_discovered); err = bt_bap_unicast_client_discover(default_conn, BT_AUDIO_DIR_SOURCE); @@ -386,7 +388,7 @@ static void discover_sources(void) memset(g_sources, 0, sizeof(g_sources)); - WAIT_FOR_FLAG(flag_codec_found); + WAIT_FOR_FLAG(flag_codec_cap_found); WAIT_FOR_FLAG(flag_source_discovered); } @@ -399,7 +401,7 @@ static int codec_configure_stream(struct bt_bap_stream *stream, struct bt_bap_ep do { - err = bt_bap_stream_config(default_conn, stream, ep, &preset_16_2_1.codec); + err = bt_bap_stream_config(default_conn, stream, ep, &preset_16_2_1.codec_cfg); if (err == -EBUSY) { k_sleep(BAP_STREAM_RETRY_WAIT); } else if (err != 0) { @@ -499,7 +501,7 @@ static void enable_streams(size_t stream_cnt) static int metadata_update_stream(struct bt_bap_stream *stream) { - struct bt_codec_data new_meta = BT_CODEC_DATA( + struct bt_audio_codec_data new_meta = BT_AUDIO_CODEC_DATA( BT_AUDIO_METADATA_TYPE_VENDOR, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, diff --git a/tests/bsim/bluetooth/audio/src/bap_unicast_common.c b/tests/bsim/bluetooth/audio/src/bap_unicast_common.c index c335a1929fb4b36..8da762058423b68 100644 --- a/tests/bsim/bluetooth/audio/src/bap_unicast_common.c +++ b/tests/bsim/bluetooth/audio/src/bap_unicast_common.c @@ -14,33 +14,55 @@ void print_hex(const uint8_t *ptr, size_t len) } } -void print_codec(const struct bt_codec *codec) +void print_codec_cap(const struct bt_audio_codec_cap *codec_cap) { - printk("codec 0x%02x cid 0x%04x vid 0x%04x count %u\n", - codec->id, codec->cid, codec->vid, codec->data_count); + printk("codec_cfg ID 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cap->id, + codec_cap->cid, codec_cap->vid, codec_cap->data_count); - for (uint8_t i = 0; i < codec->data_count; i++) { + for (uint8_t i = 0; i < codec_cap->data_count; i++) { + printk("data #%u: type 0x%02x len %u\n", i, codec_cap->data[i].data.type, + codec_cap->data[i].data.data_len); + print_hex(codec_cap->data[i].data.data, + codec_cap->data[i].data.data_len - sizeof(codec_cap->data[i].data.type)); + printk("\n"); + } + + for (uint8_t i = 0; i < codec_cap->meta_count; i++) { + printk("meta #%u: type 0x%02x len %u\n", i, codec_cap->meta[i].data.type, + codec_cap->meta[i].data.data_len); + print_hex(codec_cap->meta[i].data.data, + codec_cap->meta[i].data.data_len - sizeof(codec_cap->meta[i].data.type)); + printk("\n"); + } +} + +void print_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg) +{ + printk("codec_cap ID 0x%02x cid 0x%04x vid 0x%04x count %u\n", codec_cfg->id, + codec_cfg->cid, codec_cfg->vid, codec_cfg->data_count); + + for (uint8_t i = 0; i < codec_cfg->data_count; i++) { printk("data #%u: type 0x%02x len %u\n", - i, codec->data[i].data.type, - codec->data[i].data.data_len); - print_hex(codec->data[i].data.data, - codec->data[i].data.data_len - - sizeof(codec->data[i].data.type)); + i, codec_cfg->data[i].data.type, + codec_cfg->data[i].data.data_len); + print_hex(codec_cfg->data[i].data.data, + codec_cfg->data[i].data.data_len - + sizeof(codec_cfg->data[i].data.type)); printk("\n"); } - for (uint8_t i = 0; i < codec->meta_count; i++) { + for (uint8_t i = 0; i < codec_cfg->meta_count; i++) { printk("meta #%u: type 0x%02x len %u\n", - i, codec->meta[i].data.type, - codec->meta[i].data.data_len); - print_hex(codec->meta[i].data.data, - codec->meta[i].data.data_len - - sizeof(codec->meta[i].data.type)); + i, codec_cfg->meta[i].data.type, + codec_cfg->meta[i].data.data_len); + print_hex(codec_cfg->meta[i].data.data, + codec_cfg->meta[i].data.data_len - + sizeof(codec_cfg->meta[i].data.type)); printk("\n"); } } -void print_qos(const struct bt_codec_qos *qos) +void print_qos(const struct bt_audio_codec_qos *qos) { printk("QoS: interval %u framing 0x%02x phy 0x%02x sdu %u " "rtn %u latency %u pd %u\n", diff --git a/tests/bsim/bluetooth/audio/src/bap_unicast_common.h b/tests/bsim/bluetooth/audio/src/bap_unicast_common.h index acc8ccd963458b5..86edcb57677f51f 100644 --- a/tests/bsim/bluetooth/audio/src/bap_unicast_common.h +++ b/tests/bsim/bluetooth/audio/src/bap_unicast_common.h @@ -13,7 +13,8 @@ #include void print_hex(const uint8_t *ptr, size_t len); -void print_codec(const struct bt_codec *codec); -void print_qos(const struct bt_codec_qos *qos); +void print_codec_cap(const struct bt_audio_codec_cap *codec_cap); +void print_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg); +void print_qos(const struct bt_audio_codec_qos *qos); #endif /* ZEPHYR_TEST_BSIM_BT_AUDIO_TEST_UNICAST_COMMON_ */ diff --git a/tests/bsim/bluetooth/audio/src/bap_unicast_server_test.c b/tests/bsim/bluetooth/audio/src/bap_unicast_server_test.c index 88ab2fd7164e026..b5a4ea32eeb7094 100644 --- a/tests/bsim/bluetooth/audio/src/bap_unicast_server_test.c +++ b/tests/bsim/bluetooth/audio/src/bap_unicast_server_test.c @@ -20,52 +20,49 @@ extern enum bst_result_t bst_result; #define PREF_CONTEXT \ (BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA) -static struct bt_codec lc3_codec = { +static struct bt_audio_codec_cap lc3_codec_cap = { .path_id = BT_ISO_DATA_PATH_HCI, - .id = BT_CODEC_LC3_ID, + .id = BT_AUDIO_CODEC_LC3_ID, .cid = 0x0000U, .vid = 0x0000U, .data_count = 5U, .data = { - BT_CODEC_DATA(BT_CODEC_LC3_FREQ, - (BT_CODEC_LC3_FREQ_16KHZ & 0xFFU), - ((BT_CODEC_LC3_FREQ_16KHZ >> 8) & 0xFFU)), - BT_CODEC_DATA(BT_CODEC_LC3_DURATION, BT_CODEC_LC3_DURATION_10), - BT_CODEC_DATA(BT_CODEC_LC3_CHAN_COUNT, CHANNEL_COUNT_1), - BT_CODEC_DATA(BT_CODEC_LC3_FRAME_LEN, - (40U & 0xFFU), ((40U >> 8) & 0xFFU), - (40U & 0xFFU), ((40U >> 8) & 0xFFU)), - BT_CODEC_DATA(BT_CODEC_LC3_FRAME_COUNT, 1U) - }, + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_FREQ, + BT_BYTES_LIST_LE16(BT_AUDIO_CODEC_LC3_FREQ_16KHZ)), + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_DURATION, + BT_AUDIO_CODEC_LC3_DURATION_10), + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_CHAN_COUNT, CHANNEL_COUNT_1), + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_FRAME_LEN, BT_BYTES_LIST_LE32(40U)), + BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_FRAME_COUNT, 1U), + }, .meta_count = 2, .meta = { - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_PREF_CONTEXT, - (PREF_CONTEXT & 0xFFU), - ((PREF_CONTEXT >> 8) & 0xFFU)), - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_VENDOR, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f) - } + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_PREF_CONTEXT, + BT_BYTES_LIST_LE32(PREF_CONTEXT)), + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_VENDOR, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f), + }, }; static struct bt_bap_stream streams[CONFIG_BT_ASCS_ASE_SNK_COUNT + CONFIG_BT_ASCS_ASE_SRC_COUNT]; -static const struct bt_codec_qos_pref qos_pref = - BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 40000, 40000, 40000, 40000); +static const struct bt_audio_codec_qos_pref qos_pref = + BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0x02, 10, 40000, 40000, 40000, 40000); /* TODO: Expand with BAP data */ static const struct bt_data unicast_server_ad[] = { @@ -97,12 +94,12 @@ static struct bt_bap_stream *stream_alloc(void) } static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_bap_stream **stream, - struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { printk("ASE Codec Config: conn %p ep %p dir %u\n", conn, ep, dir); - print_codec(codec); + print_codec_cfg(codec_cfg); *stream = stream_alloc(); if (*stream == NULL) { @@ -123,19 +120,19 @@ static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_ } static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, - const struct bt_codec *codec, struct bt_codec_qos_pref *const pref, - struct bt_bap_ascs_rsp *rsp) + const struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { printk("ASE Codec Reconfig: stream %p\n", stream); - print_codec(codec); + print_codec_cfg(codec_cfg); *rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED, BT_BAP_ASCS_REASON_NONE); /* We only support one QoS at the moment, reject changes */ return -ENOEXEC; } -static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, +static int lc3_qos(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos, struct bt_bap_ascs_rsp *rsp) { printk("QoS: stream %p qos %p\n", stream, qos); @@ -145,7 +142,7 @@ static int lc3_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, return 0; } -static int lc3_enable(struct bt_bap_stream *stream, const struct bt_codec_data *meta, +static int lc3_enable(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { printk("Enable: stream %p meta_count %zu\n", stream, meta_count); @@ -203,13 +200,13 @@ static bool valid_metadata_type(uint8_t type, uint8_t len) } } -static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_codec_data *meta, +static int lc3_metadata(struct bt_bap_stream *stream, const struct bt_audio_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp) { printk("Metadata: stream %p meta_count %zu\n", stream, meta_count); for (size_t i = 0; i < meta_count; i++) { - const struct bt_codec_data *data = &meta[i]; + const struct bt_audio_codec_data *data = &meta[i]; if (!valid_metadata_type(data->data.type, data->data.data_len)) { printk("Invalid metadata type %u or length %u\n", data->data.type, @@ -294,7 +291,7 @@ static struct bt_bap_stream_ops stream_ops = { static void init(void) { static struct bt_pacs_cap cap = { - .codec = &lc3_codec, + .codec_cap = &lc3_codec_cap, }; int err; diff --git a/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c b/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c index eae27963e580117..0827a77fdd6ef03 100644 --- a/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c +++ b/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c @@ -29,15 +29,11 @@ CREATE_FLAG(flag_pa_sync_lost); static struct bt_bap_broadcast_sink *g_broadcast_sink; static struct bt_cap_stream broadcast_sink_streams[CONFIG_BT_BAP_BROADCAST_SNK_STREAM_COUNT]; -static struct bt_bap_lc3_preset unicast_preset_16_2_1 = - BT_BAP_LC3_UNICAST_PRESET_16_2_1(BT_AUDIO_LOCATION_FRONT_LEFT, - SINK_CONTEXT); -static struct bt_bap_lc3_preset broadcast_preset_16_2_1 = - BT_BAP_LC3_BROADCAST_PRESET_16_2_1(BT_AUDIO_LOCATION_FRONT_LEFT, - BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); +static struct bt_audio_codec_cap codec_cap_16_2_1 = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED); -static const struct bt_codec_qos_pref unicast_qos_pref = - BT_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0u, 60u, 20000u, 40000u, 20000u, 40000u); +static const struct bt_audio_codec_qos_pref unicast_qos_pref = + BT_AUDIO_CODEC_QOS_PREF(true, BT_GAP_LE_PHY_2M, 0u, 60u, 20000u, 40000u, 20000u, 40000u); static bool auto_start_sink_streams; @@ -95,8 +91,8 @@ static bool valid_subgroup_metadata(const struct bt_bap_base_subgroup *subgroup) { bool stream_context_found = false; - for (size_t j = 0U; j < subgroup->codec.meta_count; j++) { - const struct bt_data *metadata = &subgroup->codec.meta[j].data; + for (size_t j = 0U; j < subgroup->codec_cfg.meta_count; j++) { + const struct bt_data *metadata = &subgroup->codec_cfg.meta[j].data; if (metadata->type == BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT) { if (metadata->data_len != 2) { /* Stream context size */ @@ -257,14 +253,14 @@ static struct bt_bap_stream *unicast_stream_alloc(void) } static int unicast_server_config(struct bt_conn *conn, const struct bt_bap_ep *ep, - enum bt_audio_dir dir, const struct bt_codec *codec, + enum bt_audio_dir dir, const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream, - struct bt_codec_qos_pref *const pref, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { printk("ASE Codec Config: conn %p ep %p dir %u\n", conn, ep, dir); - print_codec(codec); + print_codec_cfg(codec_cfg); *stream = unicast_stream_alloc(); if (*stream == NULL) { @@ -284,13 +280,13 @@ static int unicast_server_config(struct bt_conn *conn, const struct bt_bap_ep *e } static int unicast_server_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, - const struct bt_codec *codec, - struct bt_codec_qos_pref *const pref, + const struct bt_audio_codec_cfg *codec_cfg, + struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp) { printk("ASE Codec Reconfig: stream %p\n", stream); - print_codec(codec); + print_codec_cfg(codec_cfg); *pref = unicast_qos_pref; @@ -300,7 +296,7 @@ static int unicast_server_reconfig(struct bt_bap_stream *stream, enum bt_audio_d return -ENOEXEC; } -static int unicast_server_qos(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, +static int unicast_server_qos(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos, struct bt_bap_ascs_rsp *rsp) { printk("QoS: stream %p qos %p\n", stream, qos); @@ -310,8 +306,9 @@ static int unicast_server_qos(struct bt_bap_stream *stream, const struct bt_code return 0; } -static int unicast_server_enable(struct bt_bap_stream *stream, const struct bt_codec_data *meta, - size_t meta_count, struct bt_bap_ascs_rsp *rsp) +static int unicast_server_enable(struct bt_bap_stream *stream, + const struct bt_audio_codec_data *meta, size_t meta_count, + struct bt_bap_ascs_rsp *rsp) { printk("Enable: stream %p meta_count %zu\n", stream, meta_count); @@ -368,13 +365,14 @@ static bool valid_metadata_type(uint8_t type, uint8_t len) } } -static int unicast_server_metadata(struct bt_bap_stream *stream, const struct bt_codec_data *meta, - size_t meta_count, struct bt_bap_ascs_rsp *rsp) +static int unicast_server_metadata(struct bt_bap_stream *stream, + const struct bt_audio_codec_data *meta, size_t meta_count, + struct bt_bap_ascs_rsp *rsp) { printk("Metadata: stream %p meta_count %zu\n", stream, meta_count); for (size_t i = 0; i < meta_count; i++) { - const struct bt_codec_data *data = &meta[i]; + const struct bt_audio_codec_data *data = &meta[i]; if (!valid_metadata_type(data->data.type, data->data.data_len)) { printk("Invalid metadata type %u or length %u\n", data->data.type, @@ -526,7 +524,7 @@ static void init(void) if (IS_ENABLED(CONFIG_BT_BAP_UNICAST_SERVER)) { static struct bt_pacs_cap unicast_cap = { - .codec = &unicast_preset_16_2_1.codec, + .codec_cap = &codec_cap_16_2_1, }; err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &unicast_cap); @@ -559,7 +557,7 @@ static void init(void) if (IS_ENABLED(CONFIG_BT_BAP_BROADCAST_SINK)) { static struct bt_pacs_cap broadcast_cap = { - .codec = &broadcast_preset_16_2_1.codec, + .codec_cap = &codec_cap_16_2_1, }; err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &broadcast_cap); diff --git a/tests/bsim/bluetooth/audio/src/cap_initiator_broadcast_test.c b/tests/bsim/bluetooth/audio/src/cap_initiator_broadcast_test.c index d28bd4a88261198..a2305b9d2638cc9 100644 --- a/tests/bsim/bluetooth/audio/src/cap_initiator_broadcast_test.c +++ b/tests/bsim/bluetooth/audio/src/cap_initiator_broadcast_test.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "common.h" #define BROADCAST_STREMT_CNT CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT @@ -224,15 +225,15 @@ static void stop_and_delete_extended_adv(struct bt_le_ext_adv *adv) static void test_broadcast_audio_create_inval(void) { - struct bt_codec_data bis_codec_data = - BT_CODEC_DATA(BT_CODEC_CONFIG_LC3_FREQ, BT_CODEC_CONFIG_LC3_FREQ_16KHZ); + struct bt_audio_codec_data bis_codec_data = BT_AUDIO_CODEC_DATA( + BT_AUDIO_CODEC_CONFIG_LC3_FREQ, BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ); struct bt_cap_initiator_broadcast_stream_param stream_params[ARRAY_SIZE(broadcast_source_streams)]; struct bt_cap_initiator_broadcast_subgroup_param subgroup_param; struct bt_cap_initiator_broadcast_create_param create_param; struct bt_cap_broadcast_source *broadcast_source; - struct bt_codec invalid_codec = - BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_MEDIA); + struct bt_audio_codec_cfg invalid_codec = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_MEDIA); int err; for (size_t i = 0U; i < ARRAY_SIZE(broadcast_streams); i++) { @@ -243,7 +244,7 @@ static void test_broadcast_audio_create_inval(void) subgroup_param.stream_count = ARRAY_SIZE(broadcast_streams); subgroup_param.stream_params = stream_params; - subgroup_param.codec = &broadcast_preset_16_2_1.codec; + subgroup_param.codec_cfg = &broadcast_preset_16_2_1.codec_cfg; create_param.subgroup_count = 1U; create_param.subgroup_params = &subgroup_param; @@ -267,7 +268,7 @@ static void test_broadcast_audio_create_inval(void) /* Clear metadata so that it does not contain the mandatory stream context */ memset(&invalid_codec.meta, 0, sizeof(invalid_codec.meta)); - subgroup_param.codec = &invalid_codec; + subgroup_param.codec_cfg = &invalid_codec; err = bt_cap_initiator_broadcast_audio_create(&create_param, NULL); if (err == 0) { FAIL("bt_cap_initiator_broadcast_audio_create with invalid metadata did not " @@ -282,8 +283,8 @@ static void test_broadcast_audio_create_inval(void) static void test_broadcast_audio_create(struct bt_cap_broadcast_source **broadcast_source) { - struct bt_codec_data bis_codec_data = - BT_CODEC_DATA(BT_CODEC_CONFIG_LC3_FREQ, BT_CODEC_CONFIG_LC3_FREQ_16KHZ); + struct bt_audio_codec_data bis_codec_data = BT_AUDIO_CODEC_DATA( + BT_AUDIO_CODEC_CONFIG_LC3_FREQ, BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ); struct bt_cap_initiator_broadcast_stream_param stream_params[ARRAY_SIZE(broadcast_source_streams)]; struct bt_cap_initiator_broadcast_subgroup_param subgroup_param; @@ -298,7 +299,7 @@ static void test_broadcast_audio_create(struct bt_cap_broadcast_source **broadca subgroup_param.stream_count = ARRAY_SIZE(broadcast_streams); subgroup_param.stream_params = stream_params; - subgroup_param.codec = &broadcast_preset_16_2_1.codec; + subgroup_param.codec_cfg = &broadcast_preset_16_2_1.codec_cfg; create_param.subgroup_count = 1U; create_param.subgroup_params = &subgroup_param; @@ -357,16 +358,16 @@ static void test_broadcast_audio_start(struct bt_cap_broadcast_source *broadcast static void test_broadcast_audio_update_inval(struct bt_cap_broadcast_source *broadcast_source) { const uint16_t mock_ccid = 0x1234; - const struct bt_codec_data new_metadata[] = { - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, - (BT_AUDIO_CONTEXT_TYPE_MEDIA & 0xFFU), - ((BT_AUDIO_CONTEXT_TYPE_MEDIA >> 8) & 0xFFU)), - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_CCID_LIST, (mock_ccid & 0xFFU), - ((mock_ccid >> 8) & 0xFFU)), + const struct bt_audio_codec_data new_metadata[] = { + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, + (BT_AUDIO_CONTEXT_TYPE_MEDIA & 0xFFU), + ((BT_AUDIO_CONTEXT_TYPE_MEDIA >> 8) & 0xFFU)), + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_CCID_LIST, (mock_ccid & 0xFFU), + ((mock_ccid >> 8) & 0xFFU)), }; - const struct bt_codec_data invalid_metadata[] = { - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_CCID_LIST, (mock_ccid & 0xFFU), - ((mock_ccid >> 8) & 0xFFU)), + const struct bt_audio_codec_data invalid_metadata[] = { + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_CCID_LIST, (mock_ccid & 0xFFU), + ((mock_ccid >> 8) & 0xFFU)), }; int err; @@ -407,10 +408,11 @@ static void test_broadcast_audio_update_inval(struct bt_cap_broadcast_source *br static void test_broadcast_audio_update(struct bt_cap_broadcast_source *broadcast_source) { const uint16_t mock_ccid = 0x1234; - const struct bt_codec_data new_metadata[] = { - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, - BT_BYTES_LIST_LE16(BT_AUDIO_CONTEXT_TYPE_MEDIA)), - BT_CODEC_DATA(BT_AUDIO_METADATA_TYPE_CCID_LIST, BT_BYTES_LIST_LE16(mock_ccid)), + const struct bt_audio_codec_data new_metadata[] = { + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, + BT_BYTES_LIST_LE16(BT_AUDIO_CONTEXT_TYPE_MEDIA)), + BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_CCID_LIST, + BT_BYTES_LIST_LE16(mock_ccid)), }; int err; diff --git a/tests/bsim/bluetooth/audio/src/cap_initiator_unicast_test.c b/tests/bsim/bluetooth/audio/src/cap_initiator_unicast_test.c index 39ae4d672b22baa..a3f17800112e4c8 100644 --- a/tests/bsim/bluetooth/audio/src/cap_initiator_unicast_test.c +++ b/tests/bsim/bluetooth/audio/src/cap_initiator_unicast_test.c @@ -33,7 +33,7 @@ CREATE_FLAG(flag_mtu_exchanged); CREATE_FLAG(flag_sink_discovered); static void unicast_stream_configured(struct bt_bap_stream *stream, - const struct bt_codec_qos_pref *pref) + const struct bt_audio_codec_qos_pref *pref) { printk("Configured stream %p\n", stream); @@ -167,16 +167,17 @@ static void add_remote_sink(struct bt_bap_ep *ep) FAIL("Could not add source ep\n"); } -static void print_remote_codec(const struct bt_codec *codec, enum bt_audio_dir dir) +static void print_remote_codec(const struct bt_audio_codec_cap *codec_cap, enum bt_audio_dir dir) { - printk("codec %p dir 0x%02x\n", codec, dir); + printk("codec_cap %p dir 0x%02x\n", codec_cap, dir); - print_codec(codec); + print_codec_cap(codec_cap); } -static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, const struct bt_codec *codec) +static void pac_record_cb(struct bt_conn *conn, enum bt_audio_dir dir, + const struct bt_audio_codec_cap *codec_cap) { - print_remote_codec(codec, dir); + print_remote_codec(codec_cap, dir); SET_FLAG(flag_codec_found); } @@ -351,8 +352,8 @@ static void unicast_group_create(struct bt_bap_unicast_group **out_unicast_group static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group) { - struct bt_codec invalid_codec = - BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_MEDIA); + struct bt_audio_codec_cfg invalid_codec = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_MEDIA); struct bt_cap_unicast_audio_start_stream_param invalid_stream_param; struct bt_cap_unicast_audio_start_stream_param valid_stream_param; struct bt_cap_unicast_audio_start_param invalid_start_param; @@ -366,7 +367,7 @@ static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group valid_stream_param.member.member = default_conn; valid_stream_param.stream = &unicast_client_streams[0]; valid_stream_param.ep = unicast_sink_eps[0]; - valid_stream_param.codec = &unicast_preset_16_2_1.codec; + valid_stream_param.codec_cfg = &unicast_preset_16_2_1.codec_cfg; valid_stream_param.qos = &unicast_preset_16_2_1.qos; /* Test NULL parameters */ @@ -439,7 +440,7 @@ static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group memcpy(&invalid_stream_param, &valid_stream_param, sizeof(valid_stream_param)); - invalid_stream_param.codec = NULL; + invalid_stream_param.codec_cfg = NULL; err = bt_cap_initiator_unicast_audio_start(&invalid_start_param, unicast_group); if (err == 0) { FAIL("bt_cap_initiator_unicast_audio_start with NULL stream params codec did not " @@ -461,7 +462,7 @@ static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group memcpy(&invalid_stream_param, &valid_stream_param, sizeof(valid_stream_param)); memset(&invalid_codec.meta, 0, sizeof(invalid_codec.meta)); - invalid_stream_param.codec = &invalid_codec; + invalid_stream_param.codec_cfg = &invalid_codec; err = bt_cap_initiator_unicast_audio_start(&invalid_start_param, unicast_group); if (err == 0) { FAIL("bt_cap_initiator_unicast_audio_start with invalid Codec metadata did not " @@ -482,7 +483,7 @@ static void unicast_audio_start(struct bt_bap_unicast_group *unicast_group, bool stream_param[0].member.member = default_conn; stream_param[0].stream = &unicast_client_streams[0]; stream_param[0].ep = unicast_sink_eps[0]; - stream_param[0].codec = &unicast_preset_16_2_1.codec; + stream_param[0].codec_cfg = &unicast_preset_16_2_1.codec_cfg; stream_param[0].qos = &unicast_preset_16_2_1.qos; UNSET_FLAG(flag_started); @@ -500,14 +501,14 @@ static void unicast_audio_start(struct bt_bap_unicast_group *unicast_group, bool static void unicast_audio_update_inval(void) { - struct bt_codec invalid_codec = - BT_CODEC_LC3_CONFIG_16_2(BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_MEDIA); + struct bt_audio_codec_cfg invalid_codec = BT_AUDIO_CODEC_LC3_CONFIG_16_2( + BT_AUDIO_LOCATION_FRONT_LEFT, BT_AUDIO_CONTEXT_TYPE_MEDIA); struct bt_cap_unicast_audio_update_param param; int err; param.stream = &unicast_client_streams[0]; - param.meta = unicast_preset_16_2_1.codec.meta; - param.meta_count = unicast_preset_16_2_1.codec.meta_count; + param.meta = unicast_preset_16_2_1.codec_cfg.meta; + param.meta_count = unicast_preset_16_2_1.codec_cfg.meta_count; err = bt_cap_initiator_unicast_audio_update(NULL, 1); if (err == 0) { @@ -539,8 +540,8 @@ static void unicast_audio_update(void) int err; param.stream = &unicast_client_streams[0]; - param.meta = unicast_preset_16_2_1.codec.meta; - param.meta_count = unicast_preset_16_2_1.codec.meta_count; + param.meta = unicast_preset_16_2_1.codec_cfg.meta; + param.meta_count = unicast_preset_16_2_1.codec_cfg.meta_count; UNSET_FLAG(flag_updated);