Skip to content

Commit

Permalink
Bluetooth: BAP: Shell: Add support for decoding LC3 data
Browse files Browse the repository at this point in the history
Add support for decoding incoming LC3 data. At this point
we only instantiate a single LC3 decoder, so only one frequency
and duration is supported.

Signed-off-by: Emil Gydesen <[email protected]>
  • Loading branch information
Thalley committed Mar 8, 2024
1 parent 39049db commit ac3006d
Show file tree
Hide file tree
Showing 2 changed files with 419 additions and 86 deletions.
16 changes: 15 additions & 1 deletion subsys/bluetooth/audio/shell/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ size_t pbp_ad_data_add(struct bt_data data[], size_t data_size);
#include <zephyr/bluetooth/audio/bap_lc3_preset.h>
#include <zephyr/bluetooth/audio/cap.h>

#if defined(CONFIG_LIBLC3)
#include "lc3.h"
#endif /* CONFIG_LIBLC3 */

#define LOCATION BT_AUDIO_LOCATION_FRONT_LEFT | BT_AUDIO_LOCATION_FRONT_RIGHT
#define CONTEXT \
(BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED | BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | \
Expand All @@ -62,12 +66,16 @@ struct shell_stream {
struct bt_cap_stream stream;
struct bt_audio_codec_cfg codec_cfg;
struct bt_audio_codec_qos qos;

#if defined(CONFIG_LIBLC3)
uint32_t lc3_freq_hz;
uint32_t lc3_frame_duration_us;
uint16_t lc3_octets_per_frame;
uint8_t lc3_frames_per_sdu;
uint8_t lc3_frame_blocks_per_sdu;
enum bt_audio_location lc3_chan_allocation;
uint8_t lc3_chan_cnt;
#endif /* CONFIG_LIBLC3 */

#if defined(CONFIG_BT_AUDIO_TX)
int64_t connected_at_ticks; /* The uptime tick measured when stream was connected */
uint16_t seq_num;
Expand All @@ -78,13 +86,19 @@ struct shell_stream {
size_t lc3_sdu_cnt;
#endif /* CONFIG_LIBLC3 */
#endif /* CONFIG_BT_AUDIO_TX */

#if defined(CONFIG_BT_AUDIO_RX)
struct bt_iso_recv_info last_info;
size_t lost_pkts;
size_t err_pkts;
size_t dup_psn;
size_t rx_cnt;
size_t dup_ts;
#if defined(CONFIG_LIBLC3)
lc3_decoder_t lc3_decoder;
struct k_fifo in_fifo;
size_t decoded_cnt;
#endif /* CONFIG_LIBLC3 */
#endif /* CONFIG_BT_AUDIO_RX */
};

Expand Down
Loading

0 comments on commit ac3006d

Please sign in to comment.