diff mbox series

[BlueZ,v1,1/4] client/player: Add support for entering metadata via endpoint.presets

Message ID 20240819195102.37393-1-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ,v1,1/4] client/player: Add support for entering metadata via endpoint.presets | expand

Commit Message

Luiz Augusto von Dentz Aug. 19, 2024, 7:50 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 client/player.c | 46 ++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 38 insertions(+), 8 deletions(-)

Comments

patchwork-bot+bluetooth@kernel.org Aug. 20, 2024, 3:10 p.m. UTC | #1
Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon, 19 Aug 2024 15:50:59 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> ---
>  client/player.c | 46 ++++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 38 insertions(+), 8 deletions(-)

Here is the summary with links:
  - [BlueZ,v1,1/4] client/player: Add support for entering metadata via endpoint.presets
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=b35d0a45baf2
  - [BlueZ,v1,2/4] client/player: Make endpoint.presets accept endpoint object
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a59529d3bac6
  - [BlueZ,v1,3/4] client/player: Make endpoint.show print local preset
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c909433ed23b
  - [BlueZ,v1,4/4] client/player: Print endpoint preset with endpoint.presets
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=168ea3078066

You are awesome, thank you!
diff mbox series

Patch

diff --git a/client/player.c b/client/player.c
index f1cd909663eb..a52575479299 100644
--- a/client/player.c
+++ b/client/player.c
@@ -1228,6 +1228,7 @@  static const struct capabilities {
 struct codec_preset {
 	char *name;
 	const struct iovec data;
+	const struct iovec meta;
 	struct bt_bap_qos qos;
 	uint8_t target_latency;
 	uint32_t chan_alloc;
@@ -2069,7 +2070,10 @@  static DBusMessage *endpoint_select_properties_reply(struct endpoint *ep,
 	}
 
 	/* Copy metadata */
-	cfg->meta = util_iov_dup(ep->meta, 1);
+	if (preset->meta.iov_len)
+		cfg->meta = util_iov_dup(&preset->meta, 1);
+	else
+		cfg->meta = util_iov_dup(ep->meta, 1);
 
 	if (ep->broadcast)
 		qos = &preset->qos.bcast.io_qos;
@@ -4205,7 +4209,8 @@  static void cmd_presets_endpoint(int argc, char *argv[])
 
 		if (argc > 4) {
 			struct codec_preset *alt_preset;
-			struct iovec *iov = (void *)&default_preset->data;
+			struct iovec *caps = (void *)&default_preset->data;
+			struct iovec *meta = (void *)&default_preset->meta;
 
 			/* Check if and alternative preset was given */
 			alt_preset = preset_find_name(preset, argv[4]);
@@ -4218,14 +4223,37 @@  static void cmd_presets_endpoint(int argc, char *argv[])
 				return;
 			}
 
-			iov->iov_base = str2bytearray(argv[4], &iov->iov_len);
-			if (!iov->iov_base) {
-				bt_shell_printf("Invalid configuration %s\n",
-							argv[4]);
-				return bt_shell_noninteractive_quit(
+			/* Check if Codec Configuration was entered */
+			if (strlen(argv[4])) {
+				caps->iov_base = str2bytearray(argv[4],
+							      &caps->iov_len);
+				if (!caps->iov_base) {
+					bt_shell_printf("Invalid configuration "
+								"%s\n",
+								argv[4]);
+					return bt_shell_noninteractive_quit(
 								EXIT_FAILURE);
+				}
 			}
 
+			/* Check if metadata was entered */
+			if (argc > 5) {
+				meta->iov_base = str2bytearray(argv[5],
+								&meta->iov_len);
+				if (!meta->iov_base) {
+					bt_shell_printf("Invalid metadata %s\n",
+							argv[5]);
+					return bt_shell_noninteractive_quit(
+								EXIT_FAILURE);
+				}
+			}
+
+			/* If configuration was left empty then ask the
+			 * parameters.
+			 */
+			if (!caps->iov_base || !caps->iov_len)
+				goto enter_cc;
+
 			bt_shell_prompt_input("QoS", "Enter Target Latency "
 						"(Low, Balance, High):",
 						custom_target_latency,
@@ -4236,6 +4264,7 @@  static void cmd_presets_endpoint(int argc, char *argv[])
 	} else
 		print_presets(preset);
 
+enter_cc:
 	if (default_preset && default_preset->custom) {
 		bt_shell_prompt_input("Codec", "Enter frequency (Khz):",
 					custom_frequency, default_preset);
@@ -4265,7 +4294,8 @@  static const struct bt_shell_menu endpoint_menu = {
 						cmd_config_endpoint,
 						"Configure Endpoint",
 						endpoint_generator },
-	{ "presets",      "<UUID> <codec[:company]> [preset] [config]",
+	{ "presets",      "<UUID> <codec[:company]> [preset] [codec config] "
+						"[metadata]",
 						cmd_presets_endpoint,
 						"List or add presets",
 						uuid_generator },