Bluetooth: Audio: Add seq_num and ts to bt_audio_stream_send

Added sequence number and timestamp to the bt_audio_stream_send
function. This allows an application to better
control the audio transmission, as it can schedule
one or more audio streams to send a buffer in a specific
SDU interval (ensuring that e.g. left and right is sent in
the same SDU interval).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2022-06-22 15:02:02 +02:00 committed by Carles Cufí
parent 69690e3505
commit aabe7f4835
6 changed files with 15 additions and 14 deletions

View file

@ -1919,12 +1919,21 @@ int bt_audio_stream_release(struct bt_audio_stream *stream, bool cache);
* @note Data will not be sent to linked streams since linking is only
* consider for procedures affecting the state machine.
*
* @param stream Stream object.
* @param buf Buffer containing data to be sent.
* @param stream Stream object.
* @param buf Buffer containing data to be sent.
* @param 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.
* @param 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. Can be
* omitted by using @ref BT_ISO_TIMESTAMP_NONE which will
* simply enqueue the ISO SDU in a FIFO manner.
*
* @return Bytes sent in case of success or negative value in case of error.
*/
int bt_audio_stream_send(struct bt_audio_stream *stream, struct net_buf *buf);
int bt_audio_stream_send(struct bt_audio_stream *stream, struct net_buf *buf,
uint32_t seq_num, uint32_t ts);
/** @brief Create audio unicast group.
*

View file

@ -376,8 +376,6 @@ static void ascs_iso_connected(struct bt_iso_chan *chan)
BT_DBG("stream %p ep %p dir %u", chan, ep, ep != NULL ? ep->dir : 0);
ep->seq_num = 0U;
if (ep->status.state != BT_AUDIO_EP_STATE_ENABLING) {
BT_DBG("endpoint not in enabling state: %s",
bt_audio_ep_state_str(ep->status.state));

View file

@ -148,7 +148,6 @@ static void broadcast_source_iso_connected(struct bt_iso_chan *chan)
BT_DBG("stream %p ep %p", chan, ep);
broadcast_source_set_ep_state(ep, BT_AUDIO_EP_STATE_STREAMING);
ep->seq_num = 0U;
if (ops != NULL && ops->started != NULL) {
ops->started(ep->stream);

View file

@ -42,8 +42,6 @@ struct bt_audio_ep {
uint16_t cp_handle;
uint8_t cig_id;
uint8_t cis_id;
/* ISO sequence number */
uint32_t seq_num;
struct bt_ascs_ase_status status;
struct bt_audio_stream *stream;
struct bt_codec codec;

View file

@ -57,7 +57,8 @@ void bt_audio_stream_attach(struct bt_conn *conn,
}
#if defined(CONFIG_BT_AUDIO_UNICAST) || defined(CONFIG_BT_AUDIO_BROADCAST_SOURCE)
int bt_audio_stream_send(struct bt_audio_stream *stream, struct net_buf *buf)
int bt_audio_stream_send(struct bt_audio_stream *stream, struct net_buf *buf,
uint32_t seq_num, uint32_t ts)
{
struct bt_audio_ep *ep;
@ -75,9 +76,7 @@ int bt_audio_stream_send(struct bt_audio_stream *stream, struct net_buf *buf)
/* TODO: Add checks for broadcast sink */
/* TODO: Ensure that the sequence number is incremented per SDU interval */
return bt_iso_chan_send(stream->iso, buf, ep->seq_num++,
BT_ISO_TIMESTAMP_NONE);
return bt_iso_chan_send(stream->iso, buf, seq_num, ts);
}
#endif /* CONFIG_BT_AUDIO_UNICAST || CONFIG_BT_AUDIO_BROADCAST_SOURCE */

View file

@ -124,8 +124,6 @@ static void unicast_client_ep_iso_connected(struct bt_iso_chan *chan)
BT_DBG("stream %p ep %p dir %u", chan, ep, ep != NULL ? ep->dir : 0);
ep->seq_num = 0U;
if (ep->status.state != BT_AUDIO_EP_STATE_ENABLING) {
BT_DBG("endpoint not in enabling state: %s",
bt_audio_ep_state_str(ep->status.state));