Skip to content

Commit b4eac67

Browse files
Thalleyaescolar
authored andcommitted
Bluetooth: BAP: Shell: Add support for decoding LC3 data
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. To accomodate for the increased RAM usage, the number of unicast streams support have been decreased. Further more, the LC3 handling in the shell has overall been improved, also for encoding. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 91fdf59 commit b4eac67

File tree

2 files changed

+372
-93
lines changed

2 files changed

+372
-93
lines changed

subsys/bluetooth/audio/shell/audio.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ ssize_t cap_initiator_pa_data_add(struct bt_data *data_array, const size_t data_
4646
#include <zephyr/bluetooth/audio/bap_lc3_preset.h>
4747
#include <zephyr/bluetooth/audio/cap.h>
4848

49+
#if defined(CONFIG_LIBLC3)
50+
#include "lc3.h"
51+
#endif /* CONFIG_LIBLC3 */
52+
4953
#define LOCATION BT_AUDIO_LOCATION_FRONT_LEFT | BT_AUDIO_LOCATION_FRONT_RIGHT
5054
#define CONTEXT \
5155
(BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED | BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | \
@@ -67,12 +71,16 @@ struct shell_stream {
6771
struct bt_cap_stream stream;
6872
struct bt_audio_codec_cfg codec_cfg;
6973
struct bt_audio_codec_qos qos;
74+
7075
#if defined(CONFIG_LIBLC3)
7176
uint32_t lc3_freq_hz;
7277
uint32_t lc3_frame_duration_us;
7378
uint16_t lc3_octets_per_frame;
74-
uint8_t lc3_frames_per_sdu;
79+
uint8_t lc3_frame_blocks_per_sdu;
80+
enum bt_audio_location lc3_chan_allocation;
81+
uint8_t lc3_chan_cnt;
7582
#endif /* CONFIG_LIBLC3 */
83+
7684
#if defined(CONFIG_BT_AUDIO_TX)
7785
int64_t connected_at_ticks; /* The uptime tick measured when stream was connected */
7886
uint16_t seq_num;
@@ -83,6 +91,7 @@ struct shell_stream {
8391
size_t lc3_sdu_cnt;
8492
#endif /* CONFIG_LIBLC3 */
8593
#endif /* CONFIG_BT_AUDIO_TX */
94+
8695
#if defined(CONFIG_BT_AUDIO_RX)
8796
struct bt_iso_recv_info last_info;
8897
size_t empty_sdu_pkts;
@@ -91,6 +100,11 @@ struct shell_stream {
91100
size_t dup_psn;
92101
size_t rx_cnt;
93102
size_t dup_ts;
103+
#if defined(CONFIG_LIBLC3)
104+
lc3_decoder_mem_48k_t lc3_decoder_mem;
105+
lc3_decoder_t lc3_decoder;
106+
size_t decoded_cnt;
107+
#endif /* CONFIG_LIBLC3 */
94108
#endif /* CONFIG_BT_AUDIO_RX */
95109
};
96110

@@ -131,8 +145,8 @@ struct broadcast_sink {
131145
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT), \
132146
(0))
133147

134-
extern struct shell_stream unicast_streams[CONFIG_BT_MAX_CONN * (UNICAST_SERVER_STREAM_COUNT +
135-
UNICAST_CLIENT_STREAM_COUNT)];
148+
extern struct shell_stream unicast_streams[CONFIG_BT_MAX_CONN * MAX(UNICAST_SERVER_STREAM_COUNT,
149+
UNICAST_CLIENT_STREAM_COUNT)];
136150

137151
#if defined(CONFIG_BT_BAP_UNICAST_CLIENT)
138152

0 commit comments

Comments
 (0)