public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1 1/3] transport: Add write support to Metadata property
@ 2025-07-22 20:35 Luiz Augusto von Dentz
  2025-07-22 20:35 ` [PATCH BlueZ v1 2/3] transport: Fix not updating MediaTransport.Metadata Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2025-07-22 20:35 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds initial support from writing to Metadata property.
---
 profiles/audio/transport.c | 45 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index 4800570d934f..bf16de958be4 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -1301,6 +1301,49 @@ static gboolean get_metadata(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static void bap_metadata_complete(struct bt_bap_stream *stream,
+					uint8_t code, uint8_t reason,
+					void *user_data)
+{
+	GDBusPendingPropertySet id = PTR_TO_UINT(user_data);
+
+	if (code)
+		g_dbus_pending_property_error(id,
+				ERROR_INTERFACE ".Failed",
+				"Unable to set metadata");
+	else
+		g_dbus_pending_property_success(id);
+}
+
+static void set_metadata(const GDBusPropertyTable *property,
+			DBusMessageIter *iter, GDBusPendingPropertySet id,
+			void *data)
+{
+	struct media_transport *transport = data;
+	struct bap_transport *bap = transport->data;
+	DBusMessageIter array;
+	struct iovec iov;
+	int ret;
+
+	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) {
+		g_dbus_pending_property_error(id,
+				ERROR_INTERFACE ".InvalidArguments",
+				"Expected ARRAY");
+		return;
+	}
+
+	dbus_message_iter_recurse(iter, &array);
+	dbus_message_iter_get_fixed_array(&array, &iov.iov_base,
+					(int *)&iov.iov_len);
+
+	ret = bt_bap_stream_metadata(bap->stream, &iov, bap_metadata_complete,
+				     UINT_TO_PTR(id));
+	if (!ret)
+		g_dbus_pending_property_error(id,
+				ERROR_INTERFACE ".InvalidArguments",
+				"Invalid metadata");
+}
+
 static gboolean links_exists(const GDBusPropertyTable *property, void *data)
 {
 	struct media_transport *transport = data;
@@ -1422,7 +1465,7 @@ static const GDBusPropertyTable transport_bap_uc_properties[] = {
 	{ "QoS", "a{sv}", get_ucast_qos, NULL, qos_ucast_exists },
 	{ "Endpoint", "o", get_endpoint, NULL, endpoint_exists },
 	{ "Location", "u", get_location },
-	{ "Metadata", "ay", get_metadata },
+	{ "Metadata", "ay", get_metadata, set_metadata },
 	{ "Links", "ao", get_links, NULL, links_exists },
 	{ "Volume", "q", get_volume, set_volume, volume_exists },
 	{ }
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ v1 2/3] transport: Fix not updating MediaTransport.Metadata
  2025-07-22 20:35 [PATCH BlueZ v1 1/3] transport: Add write support to Metadata property Luiz Augusto von Dentz
@ 2025-07-22 20:35 ` Luiz Augusto von Dentz
  2025-07-22 20:35 ` [PATCH BlueZ v1 3/3] client: Add transport.metadata command Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2025-07-22 20:35 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

MediaTransport.Metadata needs to be checked for updates when state
changes to Enabling or Streaming otherwise it remains blank.
---
 profiles/audio/transport.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index bf16de958be4..111d4b9b7ed1 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -107,6 +107,7 @@ struct bap_transport {
 	bool			linked;
 	struct bt_bap_qos	qos;
 	guint			resume_id;
+	struct iovec		*meta;
 };
 
 struct media_transport_ops {
@@ -2141,6 +2142,26 @@ static void transport_bap_set_state(struct media_transport *transport,
 							UINT_TO_PTR(state));
 }
 
+static void bap_metadata_changed(struct media_transport *transport)
+{
+	struct bap_transport *bap = transport->data;
+	struct iovec *meta;
+
+	/* Update metadata if it has changed */
+	meta = bt_bap_stream_get_metadata(bap->stream);
+
+	DBG("stream %p: metadata %p old %p", bap->stream, meta, bap->meta);
+
+	if (util_iov_memcmp(meta, bap->meta)) {
+		util_iov_free(bap->meta, 1);
+		bap->meta = util_iov_dup(meta, 1);
+		g_dbus_emit_property_changed(btd_get_dbus_connection(),
+						transport->path,
+						MEDIA_TRANSPORT_INTERFACE,
+						"Metadata");
+	}
+}
+
 static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state,
 				uint8_t new_state, void *user_data)
 {
@@ -2179,11 +2200,16 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state,
 	case BT_BAP_STREAM_STATE_ENABLING:
 		if (!bt_bap_stream_get_io(stream))
 			return;
+
+		bap_metadata_changed(transport);
 		break;
 	case BT_BAP_STREAM_STATE_STREAMING:
 		if ((bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) ||
 			(bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK))
 			bap_update_bcast_qos(transport);
+
+		bap_metadata_changed(transport);
+		transport_update_playing(transport, TRUE);
 		break;
 	case BT_BAP_STREAM_STATE_RELEASING:
 		if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK)
@@ -2253,6 +2279,7 @@ static void transport_bap_destroy(void *data)
 {
 	struct bap_transport *bap = data;
 
+	util_iov_free(bap->meta, 1);
 	bt_bap_state_unregister(bt_bap_stream_get_session(bap->stream),
 							bap->state_id);
 	free(bap);
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ v1 3/3] client: Add transport.metadata command
  2025-07-22 20:35 [PATCH BlueZ v1 1/3] transport: Add write support to Metadata property Luiz Augusto von Dentz
  2025-07-22 20:35 ` [PATCH BlueZ v1 2/3] transport: Fix not updating MediaTransport.Metadata Luiz Augusto von Dentz
@ 2025-07-22 20:35 ` Luiz Augusto von Dentz
  2025-07-22 22:21 ` [BlueZ,v1,1/3] transport: Add write support to Metadata property bluez.test.bot
  2025-07-23 14:40 ` [PATCH BlueZ v1 1/3] " patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2025-07-22 20:35 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds transport.metadata command which can be used to update the
MediaTransport.Metadata property:

> transport.metadata <transport> "0x03 0x02 0x02 0x00"
[CHG] Transport <transport> Metadata:
  03 02 02 00
> transport.show <transport>
...
	Metadata.#0: len 0x03 type 0x02
	Metadata.Context: 0x0002
	Metadata.Context	Conversational (0x0002)
---
 client/player.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/client/player.c b/client/player.c
index e4c2d451acca..b8d7b68753b6 100644
--- a/client/player.c
+++ b/client/player.c
@@ -5855,6 +5855,51 @@ static void cmd_volume_transport(int argc, char *argv[])
 	}
 }
 
+static void set_metadata_cb(const DBusError *error, void *user_data)
+{
+	if (dbus_error_is_set(error)) {
+		bt_shell_printf("Failed to set Metadata: %s\n", error->name);
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+	}
+
+	bt_shell_printf("Changing Metadata succeeded\n");
+
+	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
+static void cmd_metadata_transport(int argc, char *argv[])
+{
+	GDBusProxy *proxy;
+	struct iovec iov;
+
+	proxy = g_dbus_proxy_lookup(transports, NULL, argv[1],
+					BLUEZ_MEDIA_TRANSPORT_INTERFACE);
+	if (!proxy) {
+		bt_shell_printf("Transport %s not found\n", argv[1]);
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+	}
+
+
+	if (argc == 2) {
+		print_property(proxy, "Metadata");
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+	}
+
+	iov.iov_base = str2bytearray((char *) argv[2], &iov.iov_len);
+	if (!iov.iov_base) {
+		bt_shell_printf("Invalid argument: %s\n", argv[2]);
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+	}
+
+	if (!g_dbus_proxy_set_property_array(proxy, "Metadata", DBUS_TYPE_BYTE,
+						iov.iov_base, iov.iov_len,
+						set_metadata_cb,
+						NULL, NULL)) {
+		bt_shell_printf("Failed release transport\n");
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+	}
+}
+
 static const struct bt_shell_menu transport_menu = {
 	.name = "transport",
 	.desc = "Media Transport Submenu",
@@ -5887,6 +5932,9 @@ static const struct bt_shell_menu transport_menu = {
 	{ "unselect",    "<transport> [transport1...]", cmd_unselect_transport,
 						"Unselect Transport",
 						transport_generator },
+	{ "metadata",    "<transport> [value...]", cmd_metadata_transport,
+						"Get/Set Transport Metadata",
+						transport_generator },
 	{} },
 };
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [BlueZ,v1,1/3] transport: Add write support to Metadata property
  2025-07-22 20:35 [PATCH BlueZ v1 1/3] transport: Add write support to Metadata property Luiz Augusto von Dentz
  2025-07-22 20:35 ` [PATCH BlueZ v1 2/3] transport: Fix not updating MediaTransport.Metadata Luiz Augusto von Dentz
  2025-07-22 20:35 ` [PATCH BlueZ v1 3/3] client: Add transport.metadata command Luiz Augusto von Dentz
@ 2025-07-22 22:21 ` bluez.test.bot
  2025-07-23 14:40 ` [PATCH BlueZ v1 1/3] " patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2025-07-22 22:21 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=984872

---Test result---

Test Summary:
CheckPatch                    PENDING   0.22 seconds
GitLint                       PENDING   0.27 seconds
BuildEll                      PASS      20.86 seconds
BluezMake                     PASS      3681.91 seconds
MakeCheck                     PASS      20.70 seconds
MakeDistcheck                 PASS      190.18 seconds
CheckValgrind                 PASS      241.29 seconds
CheckSmatch                   PASS      310.08 seconds
bluezmakeextell               PASS      131.48 seconds
IncrementalBuild              PENDING   0.28 seconds
ScanBuild                     PASS      931.45 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ v1 1/3] transport: Add write support to Metadata property
  2025-07-22 20:35 [PATCH BlueZ v1 1/3] transport: Add write support to Metadata property Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2025-07-22 22:21 ` [BlueZ,v1,1/3] transport: Add write support to Metadata property bluez.test.bot
@ 2025-07-23 14:40 ` patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2025-07-23 14:40 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

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

On Tue, 22 Jul 2025 16:35:06 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This adds initial support from writing to Metadata property.
> ---
>  profiles/audio/transport.c | 45 +++++++++++++++++++++++++++++++++++++-
>  1 file changed, 44 insertions(+), 1 deletion(-)

Here is the summary with links:
  - [BlueZ,v1,1/3] transport: Add write support to Metadata property
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=4549772bb228
  - [BlueZ,v1,2/3] transport: Fix not updating MediaTransport.Metadata
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=75628226ff83
  - [BlueZ,v1,3/3] client: Add transport.metadata command
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=3c0693c5d226

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-23 14:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22 20:35 [PATCH BlueZ v1 1/3] transport: Add write support to Metadata property Luiz Augusto von Dentz
2025-07-22 20:35 ` [PATCH BlueZ v1 2/3] transport: Fix not updating MediaTransport.Metadata Luiz Augusto von Dentz
2025-07-22 20:35 ` [PATCH BlueZ v1 3/3] client: Add transport.metadata command Luiz Augusto von Dentz
2025-07-22 22:21 ` [BlueZ,v1,1/3] transport: Add write support to Metadata property bluez.test.bot
2025-07-23 14:40 ` [PATCH BlueZ v1 1/3] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox