Skip to content

Commit

Permalink
samples: broadcast_config_tool: Add experimental tag
Browse files Browse the repository at this point in the history
- Add config for broadcast_config_tool with experimental
- OCT-3120

Signed-off-by: Alexander Svensen <alexander.svensen@nordicsemi.no>
  • Loading branch information
alexsven authored and rlubos committed Oct 8, 2024
1 parent d1c13b2 commit 15c2b52
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion applications/nrf5340_audio/src/modules/lc3_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static void lc3_header_print(struct lc3_file_header *header)
LOG_DBG("Num samples: %d", header->signal_len_lsb | (header->signal_len_msb << 16));
}

int lc3_header_get(struct lc3_file_ctx *file, struct lc3_file_header *header)
int lc3_header_get(struct lc3_file_ctx const *const file, struct lc3_file_header *header)
{
if ((file == NULL) || (header == NULL)) {
LOG_ERR("Nullptr received");
Expand Down
2 changes: 1 addition & 1 deletion applications/nrf5340_audio/src/modules/lc3_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct lc3_file_ctx {
* @retval -EINVAL Invalid file context.
* @retval 0 Success.
*/
int lc3_header_get(struct lc3_file_ctx *file, struct lc3_file_header *header);
int lc3_header_get(struct lc3_file_ctx const *const file, struct lc3_file_header *header);

/**
* @brief Get the next LC3 frame from the file.
Expand Down
4 changes: 2 additions & 2 deletions applications/nrf5340_audio/src/modules/lc3_streamer.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ int lc3_streamer_next_frame_get(const uint8_t streamer_idx, const uint8_t **cons
return 0;
}

bool lc3_streamer_file_header_verify(const char *const filename,
const struct lc3_stream_cfg *const cfg)
bool lc3_streamer_file_compatible_check(const char *const filename,
const struct lc3_stream_cfg *const cfg)
{
int ret;
bool result = true;
Expand Down
4 changes: 2 additions & 2 deletions applications/nrf5340_audio/src/modules/lc3_streamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ int lc3_streamer_next_frame_get(const uint8_t streamer_idx, const uint8_t **cons
* @retval true Success.
* @retval false Header is not matching the configuration.
*/
bool lc3_streamer_file_header_verify(const char *const filename,
const struct lc3_stream_cfg *const cfg);
bool lc3_streamer_file_compatible_check(const char *const filename,
const struct lc3_stream_cfg *const cfg);

/**
* @brief Register a new stream that will be played by the LC3 streamer.
Expand Down
6 changes: 6 additions & 0 deletions samples/bluetooth/broadcast_config_tool/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ rsource "${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/utils/Kconfig"
config TRANSPORT_BIS
bool "Use BIS (Broadcast Isochronous Stream)"

config BROADCAST_CONFIG_TOOL
bool "Broadcast Configuration Tool"
depends on TRANSPORT_BIS
select EXPERIMENTAL
default y

menu "Logging"

module = MAIN
Expand Down
27 changes: 9 additions & 18 deletions samples/bluetooth/broadcast_config_tool/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,40 +1646,31 @@ static int cmd_file_select(const struct shell *shell, size_t argc, char **argv)
struct bt_audio_codec_cfg *codec_cfg =
&broadcast_param[big_index].subgroups[sub_index].group_lc3_preset.codec_cfg;

int freq_hz = 0;
struct lc3_stream_cfg cfg;

ret = le_audio_freq_hz_get(codec_cfg, &freq_hz);
ret = le_audio_freq_hz_get(codec_cfg, &cfg.sample_rate_hz);
if (ret) {
shell_error(shell, "Failed to get frequency: %d", ret);
return ret;
}

int frame_duration = 0;

ret = le_audio_duration_us_get(codec_cfg, &frame_duration);
ret = le_audio_duration_us_get(codec_cfg, &cfg.frame_duration_us);
if (ret) {
shell_error(shell, "Failed to get frame duration: %d", ret);
}

uint32_t bit_rate = 0;

ret = le_audio_bitrate_get(codec_cfg, &bit_rate);
ret = le_audio_bitrate_get(codec_cfg, &cfg.bit_rate_bps);
if (ret) {
shell_error(shell, "Failed to get bitrate: %d", ret);
}

struct lc3_stream_cfg cfg = {
.sample_rate_hz = freq_hz,
.bit_rate_bps = bit_rate,
.frame_duration_us = frame_duration,
};

/* Verify the file header */
/* Verify that the file header matches the stream configurationn */
/* NOTE: This will not abort the streamer if the file is not valid, only give a warning */
bool result = lc3_streamer_file_header_verify(file_name, &cfg);
bool header_valid = lc3_streamer_file_compatible_check(file_name, &cfg);

if (!result) {
shell_warn(shell, "File header verification failed, continue at own risk");
if (!header_valid) {
shell_warn(shell, "File header verification failed. File may not be compatible "
"with stream config.");
}

ret = lc3_streamer_stream_register(
Expand Down

0 comments on commit 15c2b52

Please sign in to comment.