Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
|
Common Audio Profile (CAP) More...
Enumerations | |
enum | bt_cap_set_type { BT_CAP_SET_TYPE_AD_HOC , BT_CAP_SET_TYPE_CSIP } |
Type of CAP set. More... | |
Functions | |
int | bt_cap_acceptor_register (const struct bt_csip_set_member_register_param *param, struct bt_csip_set_member_svc_inst **svc_inst) |
Register the Common Audio Service. | |
int | bt_cap_initiator_unicast_discover (struct bt_conn *conn) |
Discovers audio support on a remote device. | |
void | bt_cap_stream_ops_register (struct bt_cap_stream *stream, struct bt_bap_stream_ops *ops) |
Register Audio operations for a Common Audio Profile stream. | |
int | bt_cap_stream_send (struct bt_cap_stream *stream, struct net_buf *buf, uint16_t seq_num) |
Send data to Common Audio Profile stream without timestamp. | |
int | bt_cap_stream_send_ts (struct bt_cap_stream *stream, struct net_buf *buf, uint16_t seq_num, uint32_t ts) |
Send data to Common Audio Profile stream with timestamp. | |
int | bt_cap_stream_get_tx_sync (struct bt_cap_stream *stream, struct bt_iso_tx_info *info) |
Get ISO transmission timing info for a Common Audio Profile stream. | |
int | bt_cap_initiator_register_cb (const struct bt_cap_initiator_cb *cb) |
Register Common Audio Profile Initiator callbacks. | |
int | bt_cap_initiator_unregister_cb (const struct bt_cap_initiator_cb *cb) |
Unregister Common Audio Profile Initiator callbacks. | |
int | bt_cap_initiator_unicast_audio_start (const struct bt_cap_unicast_audio_start_param *param) |
Setup and start unicast audio streams for a set of devices. | |
int | bt_cap_initiator_unicast_audio_update (const struct bt_cap_unicast_audio_update_param *param) |
Update unicast audio streams. | |
int | bt_cap_initiator_unicast_audio_stop (const struct bt_cap_unicast_audio_stop_param *param) |
Stop unicast audio streams. | |
int | bt_cap_initiator_unicast_audio_cancel (void) |
Cancel any current Common Audio Profile procedure. | |
int | bt_cap_initiator_broadcast_audio_create (const struct bt_cap_initiator_broadcast_create_param *param, struct bt_cap_broadcast_source **broadcast_source) |
Create a Common Audio Profile broadcast source. | |
int | bt_cap_initiator_broadcast_audio_start (struct bt_cap_broadcast_source *broadcast_source, struct bt_le_ext_adv *adv) |
Start Common Audio Profile broadcast source. | |
int | bt_cap_initiator_broadcast_audio_update (struct bt_cap_broadcast_source *broadcast_source, const uint8_t meta[], size_t meta_len) |
Update broadcast audio streams for a Common Audio Profile broadcast source. | |
int | bt_cap_initiator_broadcast_audio_stop (struct bt_cap_broadcast_source *broadcast_source) |
Stop broadcast audio streams for a Common Audio Profile broadcast source. | |
int | bt_cap_initiator_broadcast_audio_delete (struct bt_cap_broadcast_source *broadcast_source) |
Delete Common Audio Profile broadcast source. | |
int | bt_cap_initiator_broadcast_get_base (struct bt_cap_broadcast_source *broadcast_source, struct net_buf_simple *base_buf) |
Get the Broadcast Audio Stream Endpoint of a Common Audio Profile broadcast source. | |
int | bt_cap_initiator_unicast_to_broadcast (const struct bt_cap_unicast_to_broadcast_param *param, struct bt_cap_broadcast_source **source) |
Hands over the data streams in a unicast group to a broadcast source. | |
int | bt_cap_initiator_broadcast_to_unicast (const struct bt_cap_broadcast_to_unicast_param *param, struct bt_bap_unicast_group **unicast_group) |
Hands over the data streams in a broadcast source to a unicast group. | |
int | bt_cap_commander_register_cb (const struct bt_cap_commander_cb *cb) |
Register Common Audio Profile Commander callbacks. | |
int | bt_cap_commander_unregister_cb (const struct bt_cap_commander_cb *cb) |
Unregister Common Audio Profile Commander callbacks. | |
int | bt_cap_commander_discover (struct bt_conn *conn) |
Discovers audio support on a remote device. | |
int | bt_cap_commander_cancel (void) |
Cancel any current Common Audio Profile commander procedure. | |
int | bt_cap_commander_broadcast_reception_start (const struct bt_cap_commander_broadcast_reception_start_param *param) |
Starts the reception of broadcast audio on one or more remote Common Audio Profile Acceptors. | |
int | bt_cap_commander_broadcast_reception_stop (const struct bt_cap_commander_broadcast_reception_stop_param *param) |
Stops the reception of broadcast audio on one or more remote Common Audio Profile Acceptors. | |
int | bt_cap_commander_distribute_broadcast_code (const struct bt_cap_commander_distribute_broadcast_code_param *param) |
Distributes the broadcast code on one or more remote Common Audio Profile Acceptors. | |
int | bt_cap_commander_change_volume (const struct bt_cap_commander_change_volume_param *param) |
Change the volume on one or more Common Audio Profile Acceptors. | |
int | bt_cap_commander_change_volume_offset (const struct bt_cap_commander_change_volume_offset_param *param) |
Change the volume offset on one or more Common Audio Profile Acceptors. | |
int | bt_cap_commander_change_volume_mute_state (const struct bt_cap_commander_change_volume_mute_state_param *param) |
Change the volume mute state on one or more Common Audio Profile Acceptors. | |
int | bt_cap_commander_change_microphone_mute_state (const struct bt_cap_commander_change_microphone_mute_state_param *param) |
Change the microphone mute state on one or more Common Audio Profile Acceptors. | |
int | bt_cap_commander_change_microphone_gain_setting (const struct bt_cap_commander_change_microphone_gain_setting_param *param) |
Change the microphone gain setting on one or more Common Audio Profile Acceptors. | |
Common Audio Profile (CAP)
Common Audio Profile (CAP) provides procedures to start, update, and stop unicast and broadcast Audio Streams on individual or groups of devices using procedures in the Basic Audio Profile (BAP). This profile also provides procedures to control volume and device input on groups of devices using procedures in the Volume Control Profile (VCP) and the Microphone Control Profile (MICP). This profile specification also refers to the Common Audio Service (CAS).
enum bt_cap_set_type |
#include <zephyr/bluetooth/audio/cap.h>
Type of CAP set.
Enumerator | |
---|---|
BT_CAP_SET_TYPE_AD_HOC | The set is an ad-hoc set. |
BT_CAP_SET_TYPE_CSIP | The set is a CSIP Coordinated Set. |
int bt_cap_acceptor_register | ( | const struct bt_csip_set_member_register_param * | param, |
struct bt_csip_set_member_svc_inst ** | svc_inst ) |
#include <zephyr/bluetooth/audio/cap.h>
Register the Common Audio Service.
This will register and enable the service and make it discoverable by clients. This will also register a Coordinated Set Identification Service instance.
This shall only be done as a server, and requires BT_CAP_ACCEPTOR_SET_MEMBER
. If BT_CAP_ACCEPTOR_SET_MEMBER
is not enabled, the Common Audio Service will by statically registered.
[in] | param | Coordinated Set Identification Service register parameters. |
[out] | svc_inst | Pointer to the registered Coordinated Set Identification Service. |
int bt_cap_commander_broadcast_reception_start | ( | const struct bt_cap_commander_broadcast_reception_start_param * | param | ) |
#include <zephyr/bluetooth/audio/cap.h>
Starts the reception of broadcast audio on one or more remote Common Audio Profile Acceptors.
param | The parameters to start the broadcast audio |
int bt_cap_commander_broadcast_reception_stop | ( | const struct bt_cap_commander_broadcast_reception_stop_param * | param | ) |
#include <zephyr/bluetooth/audio/cap.h>
Stops the reception of broadcast audio on one or more remote Common Audio Profile Acceptors.
param | The parameters to stop the broadcast audio |
int bt_cap_commander_cancel | ( | void | ) |
#include <zephyr/bluetooth/audio/cap.h>
Cancel any current Common Audio Profile commander procedure.
This will stop the current procedure from continuing and making it possible to run a new Common Audio Profile procedure.
It is recommended to do this if any existing procedure takes longer time than expected, which could indicate a missing response from the Common Audio Profile Acceptor.
This does not send any requests to any Common Audio Profile Acceptors involved with the current procedure, and thus notifications from the Common Audio Profile Acceptors may arrive after this has been called. It is thus recommended to either only use this if a procedure has stalled, or wait a short while before starting any new Common Audio Profile procedure after this has been called to avoid getting notifications from the cancelled procedure. The wait time depends on the connection interval, the number of devices in the previous procedure and the behavior of the Common Audio Profile Acceptors.
The respective callbacks of the procedure will be called as part of this with the connection pointer set to NULL and the err value set to -ECANCELED.
0 | on success |
-EALREADY | if no procedure is active |
int bt_cap_commander_change_microphone_gain_setting | ( | const struct bt_cap_commander_change_microphone_gain_setting_param * | param | ) |
#include <zephyr/bluetooth/audio/cap.h>
Change the microphone gain setting on one or more Common Audio Profile Acceptors.
param | The parameters for the microphone gain setting change |
int bt_cap_commander_change_microphone_mute_state | ( | const struct bt_cap_commander_change_microphone_mute_state_param * | param | ) |
#include <zephyr/bluetooth/audio/cap.h>
Change the microphone mute state on one or more Common Audio Profile Acceptors.
param | The parameters for the microphone mute state change |
int bt_cap_commander_change_volume | ( | const struct bt_cap_commander_change_volume_param * | param | ) |
#include <zephyr/bluetooth/audio/cap.h>
Change the volume on one or more Common Audio Profile Acceptors.
param | The parameters for the volume change |
int bt_cap_commander_change_volume_mute_state | ( | const struct bt_cap_commander_change_volume_mute_state_param * | param | ) |
#include <zephyr/bluetooth/audio/cap.h>
Change the volume mute state on one or more Common Audio Profile Acceptors.
param | The parameters for the volume mute state change |
int bt_cap_commander_change_volume_offset | ( | const struct bt_cap_commander_change_volume_offset_param * | param | ) |
#include <zephyr/bluetooth/audio/cap.h>
Change the volume offset on one or more Common Audio Profile Acceptors.
param | The parameters for the volume offset change |
int bt_cap_commander_discover | ( | struct bt_conn * | conn | ) |
#include <zephyr/bluetooth/audio/cap.h>
Discovers audio support on a remote device.
This will discover the Common Audio Service (CAS) on the remote device, to verify if the remote device supports the Common Audio Profile.
CONFIG_BT_CAP_COMMANDER
must be enabled for this function. If CONFIG_BT_CAP_INITIATOR
is also enabled, it does not matter if bt_cap_commander_discover() or bt_cap_initiator_unicast_discover() is used.conn | Connection to a remote server. |
0 | Success |
-EINVAL | conn is NULL |
-ENOTCONN | conn is not connected |
-ENOMEM | Could not allocated memory for the request |
-EBUSY | Already doing discovery for conn |
int bt_cap_commander_distribute_broadcast_code | ( | const struct bt_cap_commander_distribute_broadcast_code_param * | param | ) |
#include <zephyr/bluetooth/audio/cap.h>
Distributes the broadcast code on one or more remote Common Audio Profile Acceptors.
param | The parameters for distributing the broadcast code |
int bt_cap_commander_register_cb | ( | const struct bt_cap_commander_cb * | cb | ) |
#include <zephyr/bluetooth/audio/cap.h>
Register Common Audio Profile Commander callbacks.
cb | The callback structure. Shall remain static. |
0 | Success |
-EINVAL | cb is NULL |
-EALREADY | Callbacks are already registered |
int bt_cap_commander_unregister_cb | ( | const struct bt_cap_commander_cb * | cb | ) |
#include <zephyr/bluetooth/audio/cap.h>
Unregister Common Audio Profile Commander callbacks.
cb | The callback structure that was previously registered. |
0 | Success |
-EINVAL | cb is NULL or cb was not registered |
int bt_cap_initiator_broadcast_audio_create | ( | const struct bt_cap_initiator_broadcast_create_param * | param, |
struct bt_cap_broadcast_source ** | broadcast_source ) |
#include <zephyr/bluetooth/audio/cap.h>
Create a Common Audio Profile broadcast source.
Create a new audio broadcast source with one or more audio streams.
CONFIG_BT_CAP_INITIATOR
and CONFIG_BT_BAP_BROADCAST_SOURCE
must be enabled for this function to be enabled.[in] | param | Parameters to start the audio streams. |
[out] | broadcast_source | Pointer to the broadcast source created. |
int bt_cap_initiator_broadcast_audio_delete | ( | struct bt_cap_broadcast_source * | broadcast_source | ) |
#include <zephyr/bluetooth/audio/cap.h>
Delete Common Audio Profile broadcast source.
This can only be done after the broadcast source has been stopped by calling bt_cap_initiator_broadcast_audio_stop() and after the bt_bap_stream_ops.stopped() callback has been called for all streams in the broadcast source.
CONFIG_BT_CAP_INITIATOR
and CONFIG_BT_BAP_BROADCAST_SOURCE
must be enabled for this function to be enabled.broadcast_source | The broadcast source to delete. The broadcast_source will be invalidated. |
int bt_cap_initiator_broadcast_audio_start | ( | struct bt_cap_broadcast_source * | broadcast_source, |
struct bt_le_ext_adv * | adv ) |
#include <zephyr/bluetooth/audio/cap.h>
Start Common Audio Profile broadcast source.
The broadcast source will be visible for scanners once this has been called, and the device will advertise audio announcements.
This will allow the streams in the broadcast source to send audio by calling bt_bap_stream_send().
CONFIG_BT_CAP_INITIATOR
and CONFIG_BT_BAP_BROADCAST_SOURCE
must be enabled for this function to be enabled.broadcast_source | Pointer to the broadcast source. |
adv | Pointer to an extended advertising set with periodic advertising configured. |
int bt_cap_initiator_broadcast_audio_stop | ( | struct bt_cap_broadcast_source * | broadcast_source | ) |
#include <zephyr/bluetooth/audio/cap.h>
Stop broadcast audio streams for a Common Audio Profile broadcast source.
CONFIG_BT_CAP_INITIATOR
and CONFIG_BT_BAP_BROADCAST_SOURCE
must be enabled for this function to be enabled.broadcast_source | The broadcast source to stop. The audio streams in this will be stopped and reset. |
int bt_cap_initiator_broadcast_audio_update | ( | struct bt_cap_broadcast_source * | broadcast_source, |
const uint8_t | meta[], | ||
size_t | meta_len ) |
#include <zephyr/bluetooth/audio/cap.h>
Update broadcast audio streams for a Common Audio Profile broadcast source.
CONFIG_BT_CAP_INITIATOR
and CONFIG_BT_BAP_BROADCAST_SOURCE
must be enabled for this function to be enabled.broadcast_source | The broadcast source to update. |
meta | The new metadata. The metadata shall contain a list of CCIDs as well as a non-0 context bitfield. |
meta_len | The length of meta . |
int bt_cap_initiator_broadcast_get_base | ( | struct bt_cap_broadcast_source * | broadcast_source, |
struct net_buf_simple * | base_buf ) |
#include <zephyr/bluetooth/audio/cap.h>
Get the Broadcast Audio Stream Endpoint of a Common Audio Profile broadcast source.
This will encode the BASE of a broadcast source into a buffer, that can be used for advertisement. The encoded BASE will thus be encoded as little-endian. The BASE shall be put into the periodic advertising data (see bt_le_per_adv_set_data()).
See table 3.15 in the Basic Audio Profile v1.0.1 for the structure.
broadcast_source | Pointer to the broadcast source. |
base_buf | Pointer to a buffer where the BASE will be inserted. |
int bt_cap_initiator_broadcast_to_unicast | ( | const struct bt_cap_broadcast_to_unicast_param * | param, |
struct bt_bap_unicast_group ** | unicast_group ) |
#include <zephyr/bluetooth/audio/cap.h>
Hands over the data streams in a broadcast source to a unicast group.
The streams in the broadcast source will be stopped and the broadcast source will be deleted.
CONFIG_BT_CAP_INITIATOR
, CONFIG_BT_BAP_UNICAST_CLIENT
and CONFIG_BT_BAP_BROADCAST_SOURCE
must be enabled for this function to be enabled.[in] | param | The parameters for the handover. |
[out] | unicast_group | The resulting broadcast source. |
int bt_cap_initiator_register_cb | ( | const struct bt_cap_initiator_cb * | cb | ) |
#include <zephyr/bluetooth/audio/cap.h>
Register Common Audio Profile Initiator callbacks.
cb | The callback structure. Shall remain static. |
int bt_cap_initiator_unicast_audio_cancel | ( | void | ) |
#include <zephyr/bluetooth/audio/cap.h>
Cancel any current Common Audio Profile procedure.
This will stop the current procedure from continuing and making it possible to run a new Common Audio Profile procedure.
It is recommended to do this if any existing procedure takes longer time than expected, which could indicate a missing response from the Common Audio Profile Acceptor.
This does not send any requests to any Common Audio Profile Acceptors involved with the current procedure, and thus notifications from the Common Audio Profile Acceptors may arrive after this has been called. It is thus recommended to either only use this if a procedure has stalled, or wait a short while before starting any new Common Audio Profile procedure after this has been called to avoid getting notifications from the cancelled procedure. The wait time depends on the connection interval, the number of devices in the previous procedure and the behavior of the Common Audio Profile Acceptors.
The respective callbacks of the procedure will be called as part of this with the connection pointer set to 0 and the err value set to -ECANCELED.
0 | on success |
-EALREADY | if no procedure is active |
int bt_cap_initiator_unicast_audio_start | ( | const struct bt_cap_unicast_audio_start_param * | param | ) |
#include <zephyr/bluetooth/audio/cap.h>
Setup and start unicast audio streams for a set of devices.
The result of this operation is that the streams in param
will be initialized and will be usable for streaming audio data. The unicast_group
value can be used to update and stop the streams.
CONFIG_BT_CAP_INITIATOR
and CONFIG_BT_BAP_UNICAST_CLIENT
must be enabled for this function to be enabled.param | Parameters to start the audio streams. |
0 | on success |
-EBUSY | if a CAP procedure is already in progress |
-EINVAL | if any parameter is invalid |
-EALREADY | All streams are already in the streaming state |
int bt_cap_initiator_unicast_audio_stop | ( | const struct bt_cap_unicast_audio_stop_param * | param | ) |
#include <zephyr/bluetooth/audio/cap.h>
Stop unicast audio streams.
This will stop one or more streams.
CONFIG_BT_CAP_INITIATOR
and CONFIG_BT_BAP_UNICAST_CLIENT
must be enabled for this function to be enabled.param | Stop parameters. |
-EBUSY | if a CAP procedure is already in progress |
-EINVAL | if any parameter is invalid |
-EALREADY | if no state changes will occur |
int bt_cap_initiator_unicast_audio_update | ( | const struct bt_cap_unicast_audio_update_param * | param | ) |
#include <zephyr/bluetooth/audio/cap.h>
Update unicast audio streams.
This will update the metadata of one or more streams.
CONFIG_BT_CAP_INITIATOR
and CONFIG_BT_BAP_UNICAST_CLIENT
must be enabled for this function to be enabled.param | Update parameters. |
int bt_cap_initiator_unicast_discover | ( | struct bt_conn * | conn | ) |
#include <zephyr/bluetooth/audio/cap.h>
Discovers audio support on a remote device.
This will discover the Common Audio Service (CAS) on the remote device, to verify if the remote device supports the Common Audio Profile.
conn | Connection to a remote server. |
0 | Success |
-EINVAL | conn is NULL |
-ENOTCONN | conn is not connected |
-ENOMEM | Could not allocated memory for the request |
int bt_cap_initiator_unicast_to_broadcast | ( | const struct bt_cap_unicast_to_broadcast_param * | param, |
struct bt_cap_broadcast_source ** | source ) |
#include <zephyr/bluetooth/audio/cap.h>
Hands over the data streams in a unicast group to a broadcast source.
The streams in the unicast group will be stopped and the unicast group will be deleted. This can only be done for source streams.
CONFIG_BT_CAP_INITIATOR
, CONFIG_BT_BAP_UNICAST_CLIENT
and CONFIG_BT_BAP_BROADCAST_SOURCE
must be enabled for this function to be enabled.param | The parameters for the handover. |
source | The resulting broadcast source. |
int bt_cap_initiator_unregister_cb | ( | const struct bt_cap_initiator_cb * | cb | ) |
#include <zephyr/bluetooth/audio/cap.h>
Unregister Common Audio Profile Initiator callbacks.
cb | The callback structure that was previously registered. |
0 | Success |
-EINVAL | cb is NULL or cb was not registered |
int bt_cap_stream_get_tx_sync | ( | struct bt_cap_stream * | stream, |
struct bt_iso_tx_info * | info ) |
#include <zephyr/bluetooth/audio/cap.h>
Get ISO transmission timing info for a Common Audio Profile stream.
See bt_bap_stream_get_tx_sync() for more information
CONFIG_BT_AUDIO_TX
.[in] | stream | Stream object. |
[out] | info | Transmit info object. |
-EINVAL | if stream object is NULL |
Any | return value from bt_bap_stream_get_tx_sync() |
void bt_cap_stream_ops_register | ( | struct bt_cap_stream * | stream, |
struct bt_bap_stream_ops * | ops ) |
#include <zephyr/bluetooth/audio/cap.h>
Register Audio operations for a Common Audio Profile stream.
Register Audio operations for a stream.
stream | Stream object. |
ops | Stream operations structure. |
int bt_cap_stream_send | ( | struct bt_cap_stream * | stream, |
struct net_buf * | buf, | ||
uint16_t | seq_num ) |
#include <zephyr/bluetooth/audio/cap.h>
Send data to Common Audio Profile stream without timestamp.
See bt_bap_stream_send() for more information
CONFIG_BT_AUDIO_TX
.stream | Stream object. |
buf | Buffer containing data to be sent. |
seq_num | Packet Sequence number. This value shall be incremented for each call to this function and at least once per SDU interval for a specific channel. |
-EINVAL | if stream object is NULL |
Any | return value from bt_bap_stream_send() |
int bt_cap_stream_send_ts | ( | struct bt_cap_stream * | stream, |
struct net_buf * | buf, | ||
uint16_t | seq_num, | ||
uint32_t | ts ) |
#include <zephyr/bluetooth/audio/cap.h>
Send data to Common Audio Profile stream with timestamp.
See bt_bap_stream_send() for more information
CONFIG_BT_AUDIO_TX
.stream | Stream object. |
buf | Buffer containing data to be sent. |
seq_num | Packet Sequence number. This value shall be incremented for each call to this function and at least once per SDU interval for a specific channel. |
ts | Timestamp of the SDU in microseconds (us). This value can be used to transmit multiple SDUs in the same SDU interval in a CIG or BIG. |
-EINVAL | if stream object is NULL |
Any | return value from bt_bap_stream_send() |