Bluetooth: BAP: Add bt_bap_stream_get_tx_sync
Add bt_bap_stream_get_tx_sync to get the ISO tx info from a BAP stream. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
e882847cf3
commit
8600356f98
|
@ -774,6 +774,26 @@ int bt_bap_stream_release(struct bt_bap_stream *stream);
|
|||
int bt_bap_stream_send(struct bt_bap_stream *stream, struct net_buf *buf, uint16_t seq_num,
|
||||
uint32_t ts);
|
||||
|
||||
/**
|
||||
* @brief Get ISO transmission timing info for a Basic Audio Profile stream
|
||||
*
|
||||
* Reads timing information for transmitted ISO packet on an ISO channel.
|
||||
* The HCI_LE_Read_ISO_TX_Sync HCI command is used to retrieve this information from the controller.
|
||||
*
|
||||
* @note An SDU must have already been successfully transmitted on the ISO channel
|
||||
* for this function to return successfully.
|
||||
* Support for sending must be supported, determined by @kconfig{CONFIG_BT_AUDIO_TX}.
|
||||
*
|
||||
* @param[in] stream Stream object.
|
||||
* @param[out] info Transmit info object.
|
||||
*
|
||||
* @retval 0 on success
|
||||
* @retval -EINVAL if the stream is invalid, if the stream is not configured for sending or if it is
|
||||
* not connected with a isochronous stream
|
||||
* @retval Any return value from bt_iso_chan_get_tx_sync()
|
||||
*/
|
||||
int bt_bap_stream_get_tx_sync(struct bt_bap_stream *stream, struct bt_iso_tx_info *info);
|
||||
|
||||
/**
|
||||
* @defgroup bt_bap_unicast_server BAP Unicast Server APIs
|
||||
* @ingroup bt_bap
|
||||
|
|
|
@ -260,6 +260,23 @@ bool bt_audio_valid_codec_cfg(const struct bt_audio_codec_cfg *codec_cfg)
|
|||
}
|
||||
|
||||
#if defined(CONFIG_BT_AUDIO_TX)
|
||||
static bool bt_bap_stream_can_send(const struct bt_bap_stream *stream)
|
||||
{
|
||||
struct bt_bap_ep_info info;
|
||||
int err;
|
||||
|
||||
if (stream == NULL || stream->ep == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
err = bt_bap_ep_get_info(stream->ep, &info);
|
||||
if (err != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return info.can_send;
|
||||
}
|
||||
|
||||
int bt_bap_stream_send(struct bt_bap_stream *stream, struct net_buf *buf,
|
||||
uint16_t seq_num, uint32_t ts)
|
||||
{
|
||||
|
@ -269,6 +286,12 @@ int bt_bap_stream_send(struct bt_bap_stream *stream, struct net_buf *buf,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!bt_bap_stream_can_send(stream)) {
|
||||
LOG_DBG("Stream is not configured for TX");
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ep = stream->ep;
|
||||
|
||||
if (ep->status.state != BT_BAP_EP_STATE_STREAMING) {
|
||||
|
@ -282,6 +305,37 @@ int bt_bap_stream_send(struct bt_bap_stream *stream, struct net_buf *buf,
|
|||
return bt_iso_chan_send(bt_bap_stream_iso_chan_get(stream),
|
||||
buf, seq_num, ts);
|
||||
}
|
||||
|
||||
int bt_bap_stream_get_tx_sync(struct bt_bap_stream *stream, struct bt_iso_tx_info *info)
|
||||
{
|
||||
struct bt_iso_chan *iso_chan;
|
||||
|
||||
CHECKIF(stream == NULL) {
|
||||
LOG_DBG("stream is null");
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
CHECKIF(info == NULL) {
|
||||
LOG_DBG("info is null");
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!bt_bap_stream_can_send(stream)) {
|
||||
LOG_DBG("Stream is not configured for TX");
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
iso_chan = bt_bap_stream_iso_chan_get(stream);
|
||||
if (iso_chan == NULL) {
|
||||
LOG_DBG("Could not get iso channel from stream %p", stream);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return bt_iso_chan_get_tx_sync(iso_chan, info);
|
||||
}
|
||||
#endif /* CONFIG_BT_AUDIO_TX */
|
||||
|
||||
#if defined(CONFIG_BT_BAP_UNICAST)
|
||||
|
|
|
@ -18,5 +18,7 @@ int mock_bt_iso_disconnect(struct bt_iso_chan *chan);
|
|||
|
||||
DECLARE_FAKE_VALUE_FUNC(int, bt_iso_chan_send, struct bt_iso_chan *, struct net_buf *, uint16_t,
|
||||
uint32_t);
|
||||
DECLARE_FAKE_VALUE_FUNC(int, bt_iso_chan_get_tx_sync, const struct bt_iso_chan *,
|
||||
struct bt_iso_tx_info *);
|
||||
|
||||
#endif /* MOCKS_ISO_H_ */
|
||||
|
|
Loading…
Reference in a new issue