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.

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.

(cherry picked from commit b4eac67)

Original-Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
GitOrigin-RevId: b4eac67
Change-Id: Id42fd318d6e0d57f30c229d10a117c93a083a266
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5459459
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Tested-by: Jeremy Bettis <jbettis@chromium.org>
  • Loading branch information
Thalley authored and Chromeos LUCI committed Apr 16, 2024
1 parent 0d97269 commit 4760ee0
Show file tree
Hide file tree
Showing 2 changed files with 372 additions and 93 deletions.
20 changes: 17 additions & 3 deletions subsys/bluetooth/audio/shell/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ ssize_t cap_initiator_pa_data_add(struct bt_data *data_array, const size_t data_
#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 @@ -67,12 +71,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 @@ -83,6 +91,7 @@ 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 empty_sdu_pkts;
Expand All @@ -91,6 +100,11 @@ struct shell_stream {
size_t dup_psn;
size_t rx_cnt;
size_t dup_ts;
#if defined(CONFIG_LIBLC3)
lc3_decoder_mem_48k_t lc3_decoder_mem;
lc3_decoder_t lc3_decoder;
size_t decoded_cnt;
#endif /* CONFIG_LIBLC3 */
#endif /* CONFIG_BT_AUDIO_RX */
};

Expand Down Expand Up @@ -131,8 +145,8 @@ struct broadcast_sink {
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT), \
(0))

extern struct shell_stream unicast_streams[CONFIG_BT_MAX_CONN * (UNICAST_SERVER_STREAM_COUNT +
UNICAST_CLIENT_STREAM_COUNT)];
extern struct shell_stream unicast_streams[CONFIG_BT_MAX_CONN * MAX(UNICAST_SERVER_STREAM_COUNT,
UNICAST_CLIENT_STREAM_COUNT)];

#if defined(CONFIG_BT_BAP_UNICAST_CLIENT)

Expand Down
Loading

0 comments on commit 4760ee0

Please sign in to comment.