From dc8db3601001de9a085da063e0c5e456074b8963 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 13 Jun 2025 12:29:52 -0400 Subject: [PATCH] client: Add prompt to enter metadata for custom presets When adding a custom preset prompt the user to enter metadata for it e.g.: [bluetoothctl]> endpoint.presets 00002bcb-0000-1000-8000-00805f9b34fb 0x06 custom [Codec] Enter frequency (Khz): ** [Codec] Enter frame duration (ms): * [Codec] Enter channel allocation: * [Codec] Enter frame length: ** [Metadata] Enter Metadata (value/no): --- client/player.c | 21 ++++++++++++++++++++- client/scripts/preset-custom.bt | 6 ++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/client/player.c b/client/player.c index 0314cd303..2702ea542 100644 --- a/client/player.c +++ b/client/player.c @@ -3900,6 +3900,24 @@ fail: return bt_shell_noninteractive_quit(EXIT_FAILURE); } +static void custom_metadata(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct iovec *meta = (void *)&p->meta; + + if (!strcasecmp(input, "n") || !strcasecmp(input, "no")) + goto done; + + meta->iov_base = str2bytearray((void *)input, &meta->iov_len); + if (!meta->iov_base) { + bt_shell_printf("Invalid metadata %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + +done: + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + static void custom_delay(const char *input, void *user_data) { struct codec_preset *p = user_data; @@ -3916,7 +3934,8 @@ static void custom_delay(const char *input, void *user_data) return bt_shell_noninteractive_quit(EXIT_FAILURE); } - return bt_shell_noninteractive_quit(EXIT_SUCCESS); + bt_shell_prompt_input("Metadata", "Enter Metadata (value/no):", + custom_metadata, user_data); } static void custom_latency(const char *input, void *user_data) diff --git a/client/scripts/preset-custom.bt b/client/scripts/preset-custom.bt index 08bfb57b6..dc7269745 100644 --- a/client/scripts/preset-custom.bt +++ b/client/scripts/preset-custom.bt @@ -1,4 +1,4 @@ -endpoint.presets 00002bc9-0000-1000-8000-00805f9b34fb custom +endpoint.presets 00002bc9-0000-1000-8000-00805f9b34fb 0x06 custom 48 10 3 @@ -11,7 +11,8 @@ Unframed 3 10 20000 -endpoint.presets 00002bcb-0000-1000-8000-00805f9b34fb custom +n +endpoint.presets 00002bcb-0000-1000-8000-00805f9b34fb 0x06 custom 48 10 3 @@ -24,3 +25,4 @@ Unframed 3 10 20000 +n -- 2.47.3