Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
@ 2019-07-12 15:13 Luiz Augusto von Dentz
  2019-07-12 15:13 ` [PATCH BlueZ 2/4] media: Add implementation of RegisterApplication Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 28+ messages in thread
From: Luiz Augusto von Dentz @ 2019-07-12 15:13 UTC (permalink / raw)
  To: linux-bluetooth

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

This uses application ObjectManager to discover the MediaEndpoint and
MediaPlayer object of an application and deprecates the use of
RegisterEndpoint and RegisterPlayer.
---
 doc/media-api.txt | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/doc/media-api.txt b/doc/media-api.txt
index bca8c9563..07f7ac3e0 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -66,7 +66,27 @@ Methods		void RegisterEndpoint(object endpoint, dict properties)
 
 			Unregister sender media player.
 
+		void RegisterApplication(object root, dict options)
 
+			Register endpoints an player objects within root
+			object which must implement ObjectManager.
+
+			The application object path together with the D-Bus
+			system bus connection ID define the identification of
+			the application.
+
+			Possible errors: org.bluez.Error.InvalidArguments
+					 org.bluez.Error.AlreadyExists
+
+		void UnregisterApplication(object application)
+
+			This unregisters the services that has been
+			previously registered. The object path parameter
+			must match the same value that has been used
+			on registration.
+
+			Possible errors: org.bluez.Error.InvalidArguments
+					 org.bluez.Error.DoesNotExist
 Media Control hierarchy
 =======================
 
-- 
2.21.0


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

* [PATCH BlueZ 2/4] media: Add implementation of RegisterApplication
  2019-07-12 15:13 [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method Luiz Augusto von Dentz
@ 2019-07-12 15:13 ` Luiz Augusto von Dentz
  2019-07-12 15:13 ` [PATCH BlueZ 3/4] test: Add example-endpoint Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 28+ messages in thread
From: Luiz Augusto von Dentz @ 2019-07-12 15:13 UTC (permalink / raw)
  To: linux-bluetooth

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

This implements RegisterApplication registering any proxy which does
implement either MediaEndpoint or MediaPlayer.
---
 profiles/audio/media.c | 485 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 482 insertions(+), 3 deletions(-)

diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 28fa70668..993ecb3b3 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -48,6 +48,7 @@
 #include "src/uuid-helper.h"
 #include "src/log.h"
 #include "src/error.h"
+#include "src/shared/util.h"
 #include "src/shared/queue.h"
 
 #include "avdtp.h"
@@ -62,8 +63,21 @@
 
 #define REQUEST_TIMEOUT (3 * 1000)		/* 3 seconds */
 
+struct media_app {
+	struct media_adapter	*adapter;
+	GDBusClient		*client;
+	DBusMessage		*reg;
+	char			*sender;	/* Application bus id */
+	char			*path;		/* Application object path */
+	struct queue		*proxies;	/* Application proxies */
+	struct queue		*endpoints;	/* Application endpoints */
+	struct queue		*players;	/* Application players */
+	int			err;
+};
+
 struct media_adapter {
 	struct btd_adapter	*btd_adapter;
+	struct queue		*apps;		/* Application list */
 	GSList			*endpoints;	/* Endpoints list */
 	GSList			*players;	/* Players list */
 };
@@ -194,8 +208,9 @@ static struct media_endpoint *media_adapter_find_endpoint(
 	return NULL;
 }
 
-static void media_endpoint_remove(struct media_endpoint *endpoint)
+static void media_endpoint_remove(void *data)
 {
+	struct media_endpoint *endpoint = data;
 	struct media_adapter *adapter = endpoint->adapter;
 
 	if (endpoint->sep) {
@@ -996,8 +1011,10 @@ static void media_player_destroy(struct media_player *mp)
 	media_player_free(mp);
 }
 
-static void media_player_remove(struct media_player *mp)
+static void media_player_remove(void *data)
 {
+	struct media_player *mp = data;
+
 	info("Player unregistered: sender=%s path=%s", mp->sender, mp->path);
 
 	media_player_destroy(mp);
@@ -1341,7 +1358,7 @@ static gboolean set_position(struct media_player *mp, DBusMessageIter *iter)
 	const char *status;
 
 	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INT64)
-			return FALSE;
+		return FALSE;
 
 	dbus_message_iter_get_basic(iter, &value);
 
@@ -1870,6 +1887,461 @@ static DBusMessage *unregister_player(DBusConnection *conn, DBusMessage *msg,
 	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
+static void app_free(void *data)
+{
+	struct media_app *app = data;
+
+	queue_destroy(app->endpoints, media_endpoint_remove);
+	queue_destroy(app->players, media_player_remove);
+
+	if (app->client) {
+		g_dbus_client_set_disconnect_watch(app->client, NULL, NULL);
+		g_dbus_client_set_proxy_handlers(app->client, NULL, NULL,
+								NULL, NULL);
+		g_dbus_client_set_ready_watch(app->client, NULL, NULL);
+		g_dbus_client_unref(app->client);
+	}
+
+	if (app->reg)
+		dbus_message_unref(app->reg);
+
+	g_free(app->sender);
+	g_free(app->path);
+
+	free(app);
+}
+
+static void client_disconnect_cb(DBusConnection *conn, void *user_data)
+{
+	struct media_app *app = user_data;
+	struct media_adapter *adapter = app->adapter;
+
+	DBG("Client disconnected");
+
+	if (queue_remove(adapter->apps, app))
+		app_free(app);
+}
+
+static void app_register_endpoint(void *data, void *user_data)
+{
+	struct media_app *app = user_data;
+	GDBusProxy *proxy = data;
+	const char *iface = g_dbus_proxy_get_interface(proxy);
+	const char *path = g_dbus_proxy_get_path(proxy);
+	const char *uuid;
+	gboolean delay_reporting = FALSE;
+	uint8_t codec;
+	uint8_t *capabilities = NULL;
+	int size = 0;
+	DBusMessageIter iter, array;
+	struct media_endpoint *endpoint;
+
+	if (app->err)
+		return;
+
+	if (strcmp(iface, MEDIA_ENDPOINT_INTERFACE))
+		return;
+
+	/* Parse properties */
+	if (!g_dbus_proxy_get_property(proxy, "UUID", &iter))
+		goto fail;
+
+	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+		goto fail;
+
+	dbus_message_iter_get_basic(&iter, &uuid);
+
+	if (!g_dbus_proxy_get_property(proxy, "Codec", &iter))
+		goto fail;
+
+	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BYTE)
+		goto fail;
+
+	dbus_message_iter_get_basic(&iter, &codec);
+
+	/* DelayReporting and Capabilities are considered optional */
+	if (g_dbus_proxy_get_property(proxy, "DelayReporting", &iter))	{
+		if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN)
+			goto fail;
+
+		dbus_message_iter_get_basic(&iter, &delay_reporting);
+	}
+
+	if (g_dbus_proxy_get_property(proxy, "Capabilities", &iter)) {
+		if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
+			goto fail;
+
+		dbus_message_iter_recurse(&iter, &array);
+		dbus_message_iter_get_fixed_array(&array, &capabilities, &size);
+	}
+
+	endpoint = media_endpoint_create(app->adapter, app->sender, path, uuid,
+					delay_reporting, codec, capabilities,
+					size, &app->err);
+	if (!endpoint) {
+		error("Unable to register endpoint %s:%s: %s", app->sender,
+						path, strerror(-app->err));
+		return;
+	}
+
+	queue_push_tail(app->endpoints, endpoint);
+
+	return;
+
+fail:
+	app->err = -EINVAL;
+}
+
+static void app_register_player(void *data, void *user_data)
+{
+	struct media_app *app = user_data;
+	GDBusProxy *proxy = data;
+	const char *iface = g_dbus_proxy_get_interface(proxy);
+	const char *path = g_dbus_proxy_get_path(proxy);
+	struct media_player *player;
+	DBusMessageIter iter;
+
+	if (app->err)
+		return;
+
+	if (strcmp(iface, MEDIA_PLAYER_INTERFACE))
+		return;
+
+	player = media_player_create(app->adapter, app->sender, path,
+							&app->err);
+	if (!player)
+		return;
+
+	if (g_dbus_proxy_get_property(proxy, "PlaybackStatus", &iter)) {
+		if (!set_status(player, &iter))
+			goto fail;
+	}
+
+	if (g_dbus_proxy_get_property(proxy, "Position", &iter)) {
+		if (!set_position(player, &iter))
+			goto fail;
+	}
+
+	if (g_dbus_proxy_get_property(proxy, "Metadata", &iter)) {
+		if (!parse_player_metadata(player, &iter))
+			goto fail;
+	}
+
+	if (g_dbus_proxy_get_property(proxy, "Shuffle", &iter)) {
+		if (!set_shuffle(player, &iter))
+			goto fail;
+	}
+
+	if (g_dbus_proxy_get_property(proxy, "LoopStatus", &iter)) {
+		if (!set_repeat(player, &iter))
+			goto fail;
+	}
+
+	if (g_dbus_proxy_get_property(proxy, "CanPlay", &iter)) {
+		if (!set_flag(player, &iter, &player->play))
+			goto fail;
+	}
+
+	if (g_dbus_proxy_get_property(proxy, "CanPause", &iter)) {
+		if (!set_flag(player, &iter, &player->pause))
+			goto fail;
+	}
+
+	if (g_dbus_proxy_get_property(proxy, "CanGoNext", &iter)) {
+		if (!set_flag(player, &iter, &player->next))
+			goto fail;
+	}
+
+	if (g_dbus_proxy_get_property(proxy, "CanGoPrevious", &iter)) {
+		if (!set_flag(player, &iter, &player->previous))
+			goto fail;
+	}
+
+	if (g_dbus_proxy_get_property(proxy, "CanControl", &iter)) {
+		if (!set_flag(player, &iter, &player->control))
+			goto fail;
+	}
+
+	if (g_dbus_proxy_get_property(proxy, "Identity", &iter)) {
+		if (!set_name(player, &iter))
+			goto fail;
+	}
+
+	queue_push_tail(app->players, player);
+
+	return;
+fail:
+	app->err = -EINVAL;
+	error("Unable to register player %s:%s: %s", app->sender, path,
+							strerror(-app->err));
+	media_player_destroy(player);
+}
+
+static void remove_app(void *data)
+{
+	struct media_app *app = data;
+
+	/*
+	 * Set callback to NULL to avoid potential race condition
+	 * when calling remove_app and GDBusClient unref.
+	 */
+	g_dbus_client_set_disconnect_watch(app->client, NULL, NULL);
+
+	/*
+	 * Set proxy handlers to NULL, so that this gets called only once when
+	 * the first proxy that belongs to this service gets removed.
+	 */
+	g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL);
+
+
+	queue_remove(app->adapter->apps, app);
+
+	app_free(app);
+}
+
+static void client_ready_cb(GDBusClient *client, void *user_data)
+{
+	struct media_app *app = user_data;
+	DBusMessage *reply;
+	bool fail = false;
+
+	/*
+	 * Process received objects
+	 */
+	if (queue_isempty(app->proxies)) {
+		error("No object received");
+		fail = true;
+		reply = btd_error_failed(app->reg, "No object received");
+		goto reply;
+	}
+
+	queue_foreach(app->proxies, app_register_endpoint, app);
+	queue_foreach(app->proxies, app_register_player, app);
+
+	if (app->err) {
+		if (app->err == -EPROTONOSUPPORT)
+			reply = btd_error_not_supported(app->reg);
+		else
+			reply = btd_error_invalid_args(app->reg);
+		goto reply;
+	}
+
+	if ((queue_isempty(app->endpoints) && queue_isempty(app->players))) {
+		error("No valid external Media objects found");
+		fail = true;
+		reply = btd_error_failed(app->reg,
+					"No valid media object found");
+		goto reply;
+	}
+
+	DBG("Media application registered: %s:%s", app->sender, app->path);
+
+	reply = dbus_message_new_method_return(app->reg);
+
+reply:
+	g_dbus_send_message(btd_get_dbus_connection(), reply);
+	dbus_message_unref(app->reg);
+	app->reg = NULL;
+
+	if (fail)
+		remove_app(app);
+}
+
+static void proxy_added_cb(GDBusProxy *proxy, void *user_data)
+{
+	struct media_app *app = user_data;
+	const char *iface, *path;
+
+	if (app->err)
+		return;
+
+	queue_push_tail(app->proxies, proxy);
+
+	iface = g_dbus_proxy_get_interface(proxy);
+	path = g_dbus_proxy_get_path(proxy);
+
+	DBG("Proxy added: %s, iface: %s", path, iface);
+}
+
+static bool match_endpoint_by_path(const void *a, const void *b)
+{
+	const struct media_endpoint *endpoint = a;
+	const char *path = b;
+
+	return !strcmp(endpoint->path, path);
+}
+
+static bool match_player_by_path(const void *a, const void *b)
+{
+	const struct media_player *player = a;
+	const char *path = b;
+
+	return !strcmp(player->path, path);
+}
+
+static void proxy_removed_cb(GDBusProxy *proxy, void *user_data)
+{
+	struct media_app *app = user_data;
+	struct media_endpoint *endpoint;
+	struct media_player *player;
+	const char *iface, *path;
+
+	iface = g_dbus_proxy_get_interface(proxy);
+	path = g_dbus_proxy_get_path(proxy);
+
+	if (!strcmp(iface, MEDIA_ENDPOINT_INTERFACE)) {
+		endpoint = queue_remove_if(app->endpoints,
+						match_endpoint_by_path,
+						(void *) path);
+		if (!endpoint)
+			return;
+
+		if (!g_slist_find(app->adapter->endpoints, endpoint))
+			return;
+
+		DBG("Proxy removed - removing endpoint: %s", endpoint->path);
+
+		media_endpoint_remove(endpoint);
+	} else if (!strcmp(iface, MEDIA_PLAYER_INTERFACE)) {
+		player = queue_remove_if(app->players, match_player_by_path,
+						(void *) path);
+		if (!player)
+			return;
+
+		if (!g_slist_find(app->adapter->players, player))
+			return;
+
+		DBG("Proxy removed - removing player: %s", player->path);
+
+		media_player_remove(player);
+	}
+}
+
+static struct media_app *create_app(DBusConnection *conn, DBusMessage *msg,
+							const char *path)
+{
+	struct media_app *app;
+	const char *sender = dbus_message_get_sender(msg);
+
+	if (!path || !g_str_has_prefix(path, "/"))
+		return NULL;
+
+	app = new0(struct media_app, 1);
+
+	app->client = g_dbus_client_new_full(conn, sender, path, path);
+	if (!app->client)
+		goto fail;
+
+	app->sender = g_strdup(sender);
+	if (!app->sender)
+		goto fail;
+
+	app->path = g_strdup(path);
+	if (!app->path)
+		goto fail;
+
+	app->proxies = queue_new();
+	app->endpoints = queue_new();
+	app->players = queue_new();
+	app->reg = dbus_message_ref(msg);
+
+	g_dbus_client_set_disconnect_watch(app->client, client_disconnect_cb,
+									app);
+	g_dbus_client_set_proxy_handlers(app->client, proxy_added_cb,
+					proxy_removed_cb, NULL, app);
+	g_dbus_client_set_ready_watch(app->client, client_ready_cb, app);
+
+	return app;
+
+fail:
+	app_free(app);
+	return NULL;
+}
+
+struct match_data {
+	const char *path;
+	const char *sender;
+};
+
+static bool match_app(const void *a, const void *b)
+{
+	const struct media_app *app = a;
+	const struct match_data *data = b;
+
+	return g_strcmp0(app->path, data->path) == 0 &&
+				g_strcmp0(app->sender, data->sender) == 0;
+}
+
+static DBusMessage *register_app(DBusConnection *conn, DBusMessage *msg,
+							void *user_data)
+{
+	struct media_adapter *adapter = user_data;
+	const char *sender = dbus_message_get_sender(msg);
+	DBusMessageIter args;
+	const char *path;
+	struct media_app *app;
+	struct match_data match_data;
+
+	if (!dbus_message_iter_init(msg, &args))
+		return btd_error_invalid_args(msg);
+
+	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
+		return btd_error_invalid_args(msg);
+
+	dbus_message_iter_get_basic(&args, &path);
+
+	match_data.path = path;
+	match_data.sender = sender;
+
+	if (queue_find(adapter->apps, match_app, &match_data))
+		return btd_error_already_exists(msg);
+
+	dbus_message_iter_next(&args);
+	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_ARRAY)
+		return btd_error_invalid_args(msg);
+
+	app = create_app(conn, msg, path);
+	if (!app)
+		return btd_error_failed(msg, "Failed to register application");
+
+	DBG("Registering application: %s:%s", sender, path);
+
+	app->adapter = adapter;
+	queue_push_tail(adapter->apps, app);
+
+	return NULL;
+}
+
+static DBusMessage *unregister_app(DBusConnection *conn, DBusMessage *msg,
+							void *user_data)
+{
+	struct media_adapter *adapter = user_data;
+	const char *sender = dbus_message_get_sender(msg);
+	const char *path;
+	DBusMessageIter args;
+	struct media_app *app;
+	struct match_data match_data;
+
+	if (!dbus_message_iter_init(msg, &args))
+		return btd_error_invalid_args(msg);
+
+	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
+		return btd_error_invalid_args(msg);
+
+	dbus_message_iter_get_basic(&args, &path);
+
+	match_data.path = path;
+	match_data.sender = sender;
+
+	app = queue_remove_if(adapter->apps, match_app, &match_data);
+	if (!app)
+		return btd_error_does_not_exist(msg);
+
+	app_free(app);
+
+	return dbus_message_new_method_return(msg);
+}
+
 static const GDBusMethodTable media_methods[] = {
 	{ GDBUS_METHOD("RegisterEndpoint",
 		GDBUS_ARGS({ "endpoint", "o" }, { "properties", "a{sv}" }),
@@ -1881,6 +2353,13 @@ static const GDBusMethodTable media_methods[] = {
 		NULL, register_player) },
 	{ GDBUS_METHOD("UnregisterPlayer",
 		GDBUS_ARGS({ "player", "o" }), NULL, unregister_player) },
+	{ GDBUS_ASYNC_METHOD("RegisterApplication",
+					GDBUS_ARGS({ "application", "o" },
+						{ "options", "a{sv}" }),
+					NULL, register_app) },
+	{ GDBUS_ASYNC_METHOD("UnregisterApplication",
+					GDBUS_ARGS({ "application", "o" }),
+					NULL, unregister_app) },
 	{ },
 };
 
-- 
2.21.0


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

* [PATCH BlueZ 3/4] test: Add example-endpoint
  2019-07-12 15:13 [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method Luiz Augusto von Dentz
  2019-07-12 15:13 ` [PATCH BlueZ 2/4] media: Add implementation of RegisterApplication Luiz Augusto von Dentz
@ 2019-07-12 15:13 ` Luiz Augusto von Dentz
  2019-07-12 15:13 ` [PATCH BlueZ 4/4] test: Add example-player Luiz Augusto von Dentz
  2019-07-13 14:52 ` [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method Luiz Augusto von Dentz
  3 siblings, 0 replies; 28+ messages in thread
From: Luiz Augusto von Dentz @ 2019-07-12 15:13 UTC (permalink / raw)
  To: linux-bluetooth

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

This adds an example of registering an endpoint with use of
RegisterApplication.
---
 test/example-endpoint | 186 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 186 insertions(+)
 create mode 100644 test/example-endpoint

diff --git a/test/example-endpoint b/test/example-endpoint
new file mode 100644
index 000000000..a5f0348a0
--- /dev/null
+++ b/test/example-endpoint
@@ -0,0 +1,186 @@
+#!/usr/bin/python
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+import sys
+import dbus
+import dbus.exceptions
+import dbus.service
+import dbus.mainloop.glib
+
+import array
+try:
+  from gi.repository import GObject
+except ImportError:
+  import gobject as GObject
+import bluezutils
+
+ENDPOINT_IFACE =     'org.bluez.MediaEndpoint1'
+DBUS_OM_IFACE =      'org.freedesktop.DBus.ObjectManager'
+DBUS_PROP_IFACE =    'org.freedesktop.DBus.Properties'
+
+A2DP_SOURCE_UUID =   '0000110A-0000-1000-8000-00805F9B34FB'
+A2DP_SINK_UUID =     '0000110B-0000-1000-8000-00805F9B34FB'
+
+SBC_CODEC = dbus.Byte(0x00)
+#Channel Modes: Mono DualChannel Stereo JointStereo
+#Frequencies: 16Khz 32Khz 44.1Khz 48Khz
+#Subbands: 4 8
+#Blocks: 4 8 12 16
+#Bitpool Range: 2-64
+SBC_CAPABILITIES = dbus.Array([dbus.Byte(0xff), dbus.Byte(0xff), dbus.Byte(2), dbus.Byte(64)])
+# JointStereo 44.1Khz Subbands: Blocks: 16 Bitpool Range: 2-32
+SBC_CONFIGURATION = dbus.Array([dbus.Byte(0x21), dbus.Byte(0x15), dbus.Byte(2), dbus.Byte(32)])
+
+MP3_CODEC = dbus.Byte(0x01)
+#Channel Modes: Mono DualChannel Stereo JointStereo
+#Frequencies: 32Khz 44.1Khz 48Khz
+#CRC: YES
+#Layer: 3
+#Bit Rate: All except Free format
+#VBR: Yes
+#Payload Format: RFC-2250
+MP3_CAPABILITIES = dbus.Array([dbus.Byte(0x3f), dbus.Byte(0x07), dbus.Byte(0xff), dbus.Byte(0xfe)])
+# JointStereo 44.1Khz Layer: 3 Bit Rate: VBR Format: RFC-2250
+MP3_CONFIGURATION = dbus.Array([dbus.Byte(0x21), dbus.Byte(0x02), dbus.Byte(0x00), dbus.Byte(0x80)])
+
+PCM_CODEC = dbus.Byte(0x00)
+PCM_CONFIGURATION = dbus.Array([], signature="ay")
+
+CVSD_CODEC = dbus.Byte(0x01)
+
+class Rejected(dbus.DBusException):
+    _dbus_error_name = "org.bluez.Error.Rejected"
+
+class InvalidArgsException(dbus.exceptions.DBusException):
+    _dbus_error_name = 'org.freedesktop.DBus.Error.InvalidArgs'
+
+class Endpoint(dbus.service.Object):
+    def __init__(self, bus, path, properties, configuration):
+        self.path = path
+        self.bus = bus
+        self.properties = properties
+        self.configuration = configuration
+        self.exit_on_release = True
+        dbus.service.Object.__init__(self, bus, self.path)
+
+    def get_properties(self):
+        return self.properties
+
+    def get_path(self):
+        return dbus.ObjectPath(self.path)
+
+    @dbus.service.method(DBUS_PROP_IFACE, in_signature='s',
+                         out_signature='a{sv}')
+    def GetAll(self, interface):
+        if interface != ENDPOINT_IFACE:
+            raise InvalidArgsException()
+
+        return self.get_properties()
+
+    def set_exit_on_release(self, exit_on_release):
+        self.exit_on_release = exit_on_release
+
+    def default_configuration(self, configuration):
+        self.configuration = configuration
+
+    @dbus.service.method(ENDPOINT_IFACE, in_signature="", out_signature="")
+    def Release(self):
+        print("Release")
+        if self.exit_on_release:
+            mainloop.quit()
+
+    @dbus.service.method(ENDPOINT_IFACE, in_signature="o", out_signature="")
+    def ClearConfiguration(self, transport):
+        print("ClearConfiguration (%s)" % (transport))
+
+    @dbus.service.method(ENDPOINT_IFACE, in_signature="oay", out_signature="")
+    def SetConfiguration(self, transport, config):
+        print("SetConfiguration (%s, %s)" % (transport, config))
+        return
+
+    @dbus.service.method(ENDPOINT_IFACE, in_signature="ay", out_signature="ay")
+    def SelectConfiguration(self, caps):
+        print("SelectConfiguration (%s)" % (caps))
+        return self.configuration
+
+class Application(dbus.service.Object):
+    def __init__(self, bus, path, properties, configuration):
+        self.path = '/'
+        self.endpoints = []
+        dbus.service.Object.__init__(self, bus, self.path)
+        self.add_endpoint(Endpoint(bus, path, properties, configuration))
+
+    def get_path(self):
+        return dbus.ObjectPath(self.path)
+
+    def add_endpoint(self, endpoint):
+        self.endpoints.append(endpoint)
+
+    @dbus.service.method(DBUS_OM_IFACE, out_signature='a{oa{sa{sv}}}')
+    def GetManagedObjects(self):
+        response = {}
+        print('GetManagedObjects')
+
+        for endpoint in self.endpoints:
+            response[endpoint.get_path()] = { ENDPOINT_IFACE:
+                                              endpoint.get_properties() }
+
+        return response
+
+def register_app_cb():
+    print('Media application registered')
+
+
+def register_app_error_cb(error):
+    print('Failed to register application: ' + str(error))
+    mainloop.quit()
+
+if __name__ == '__main__':
+    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+    bus = dbus.SystemBus()
+
+    if len(sys.argv) > 1:
+            path = bluezutils.find_adapter(sys.argv[1]).object_path
+    else:
+            path = bluezutils.find_adapter().object_path
+
+    media = dbus.Interface(bus.get_object("org.bluez", path),
+                           "org.bluez.Media1")
+
+
+    properties = dbus.Dictionary({ "UUID" : A2DP_SOURCE_UUID,
+                                   "Codec" : SBC_CODEC,
+                                   "DelayReporting" : True,
+                                   "Capabilities" : SBC_CAPABILITIES })
+
+    configuration = SBC_CONFIGURATION
+
+    if len(sys.argv) > 2:
+        if sys.argv[2] == "sbcsink":
+            properties = dbus.Dictionary({ "UUID" : A2DP_SINK_UUID,
+                                           "Codec" : SBC_CODEC,
+                                           "DelayReporting" : True,
+                                           "Capabilities" : SBC_CAPABILITIES })
+        if sys.argv[2] == "mp3source":
+            properties = dbus.Dictionary({ "UUID" : A2DP_SOURCE_UUID,
+                                           "Codec" : MP3_CODEC,
+                                           "Capabilities" : MP3_CAPABILITIES })
+            configuration = MP3_CONFIGURATION
+        if sys.argv[2] == "mp3sink":
+            properties = dbus.Dictionary({ "UUID" : A2DP_SINK_UUID,
+                                           "Codec" : MP3_CODEC,
+                                           "Capabilities" : MP3_CAPABILITIES })
+            configuration = MP3_CONFIGURATION
+
+    print(properties)
+
+    path = "/test/endpoint"
+    app = Application(bus, path, properties, configuration)
+    mainloop = GObject.MainLoop()
+
+    media.RegisterApplication(app.get_path(), {},
+                                reply_handler=register_app_cb,
+                                error_handler=register_app_error_cb)
+    mainloop.run()
-- 
2.21.0


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

* [PATCH BlueZ 4/4] test: Add example-player
  2019-07-12 15:13 [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method Luiz Augusto von Dentz
  2019-07-12 15:13 ` [PATCH BlueZ 2/4] media: Add implementation of RegisterApplication Luiz Augusto von Dentz
  2019-07-12 15:13 ` [PATCH BlueZ 3/4] test: Add example-endpoint Luiz Augusto von Dentz
@ 2019-07-12 15:13 ` Luiz Augusto von Dentz
  2019-07-13 14:52 ` [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method Luiz Augusto von Dentz
  3 siblings, 0 replies; 28+ messages in thread
From: Luiz Augusto von Dentz @ 2019-07-12 15:13 UTC (permalink / raw)
  To: linux-bluetooth

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

This adds an example of registering a player with use of
RegisterApplication.
---
 test/example-player | 203 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 203 insertions(+)
 create mode 100644 test/example-player

diff --git a/test/example-player b/test/example-player
new file mode 100644
index 000000000..2beb08e44
--- /dev/null
+++ b/test/example-player
@@ -0,0 +1,203 @@
+#!/usr/bin/python
+
+from __future__ import print_function
+
+import os
+import sys
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+try:
+  from gi.repository import GObject
+except ImportError:
+  import gobject as GObject
+import bluezutils
+
+PLAYER_IFACE =       'org.mpris.MediaPlayer2.Player'
+DBUS_OM_IFACE =      'org.freedesktop.DBus.ObjectManager'
+DBUS_PROP_IFACE =    'org.freedesktop.DBus.Properties'
+
+class InvalidArgsException(dbus.exceptions.DBusException):
+    _dbus_error_name = 'org.freedesktop.DBus.Error.InvalidArgs'
+
+class Player(dbus.service.Object):
+    def __init__(self, bus, path, obj):
+        self.path = path
+        dbus.service.Object.__init__(self, bus, self.path)
+
+        if obj != None:
+            mp = dbus.Interface(bus.get_object("org.bluez", obj),
+                                                "org.bluez.MediaPlayer1")
+            prop = dbus.Interface(bus.get_object("org.bluez", obj),
+                                  "org.freedesktop.DBus.Properties")
+
+            self.properties = prop.GetAll("org.bluez.MediaPlayer1")
+
+            bus.add_signal_receiver(self.properties_changed, path = obj,
+                            dbus_interface = "org.freedesktop.DBus.Properties",
+                            signal_name = "PropertiesChanged")
+        else:
+            self.track = dbus.Dictionary({"xesam:title" : "Title",
+                                     "xesam:artist" : ["Artist"],
+                                     "xesam:album" : "Album",
+                                     "xesam:genre" : ["Genre"],
+                                     "xesam:trackNumber" : dbus.Int32(1),
+                                     "mpris:length" : dbus.Int64(10000) },
+                                     signature="sv")
+
+            self.properties = dbus.Dictionary({"PlaybackStatus" : "playing",
+                                        "Identity" : "SimplePlayer",
+                                        "LoopStatus" : "None",
+                                        "Rate" : dbus.Double(1.0),
+                                        "Shuffle" : dbus.Boolean(False),
+                                        "Metadata" : self.track,
+                                        "Volume" : dbus.Double(1.0),
+                                        "Position" : dbus.Int64(0),
+                                        "MinimumRate" : dbus.Double(1.0),
+                                        "MaximumRate" : dbus.Double(1.0),
+                                        "CanGoNext" : dbus.Boolean(False),
+                                        "CanGoPrevious" : dbus.Boolean(False),
+                                        "CanPlay" : dbus.Boolean(False),
+                                        "CanSeek" : dbus.Boolean(False),
+                                        "CanControl" : dbus.Boolean(False),
+                                        },
+                                        signature="sv")
+
+        print('Register media player with:\n\tProperties: %s' \
+              % (self.properties))
+        handler = InputHandler(self)
+        GObject.io_add_watch(sys.stdin, GObject.IO_IN, handler.handle)
+
+    @dbus.service.method("org.freedesktop.DBus.Properties",
+                         in_signature="ssv", out_signature="")
+    def Set(self, interface, key, value):
+        print("Set (%s, %s)" % (key, value), file=sys.stderr)
+        return
+
+    def get_properties(self):
+        return self.properties
+
+    def get_path(self):
+        return dbus.ObjectPath(self.path)
+
+    @dbus.service.method("org.freedesktop.DBus.Properties",
+                         in_signature='s', out_signature='a{sv}')
+    def GetAll(self, interface):
+        if interface != PLAYER_IFACE:
+            raise InvalidArgsException()
+
+        return self.get_properties()
+
+    @dbus.service.signal("org.freedesktop.DBus.Properties",
+                         signature="sa{sv}as")
+    def PropertiesChanged(self, interface, properties,
+                          invalidated = dbus.Array()):
+        """PropertiesChanged(interface, properties, invalidated)
+
+        Send a PropertiesChanged signal. 'properties' is a dictionary
+        containing string parameters as specified in doc/media-api.txt.
+        """
+        pass
+
+    def help(self, func):
+        help(self.__class__.__dict__[func])
+
+    def properties_changed(self, interface, properties, invalidated):
+        print("properties_changed(%s, %s)" % (properties, invalidated))
+
+        self.PropertiesChanged(interface, properties, invalidated)
+
+class InputHandler:
+    commands = { 'PropertiesChanged': '(interface, properties)',
+                        'help': '(cmd)' }
+    def __init__(self, player):
+        self.player = player
+        print('\n\nAvailable commands:')
+        for cmd in self.commands:
+                print('\t', cmd, self.commands[cmd], sep='')
+
+        print("\nUse python syntax to pass arguments to available methods.\n" \
+                "E.g.: PropertiesChanged({'Metadata' : {'Title': 'My title', \
+                'Album': 'my album' }})")
+        self.prompt()
+
+    def prompt(self):
+        print('\n>>> ', end='')
+        sys.stdout.flush()
+
+    def handle(self, fd, condition):
+        s = os.read(fd.fileno(), 1024).strip()
+        try:
+            cmd = s[:s.find('(')]
+            if not cmd in self.commands:
+                print("Unknown command ", cmd)
+        except ValueError:
+            print("Malformed command")
+            return True
+        try:
+            exec "self.player.%s" % s
+        except Exception as e:
+            print(e)
+            pass
+        self.prompt()
+        return True
+
+class Application(dbus.service.Object):
+    def __init__(self, bus, path, obj):
+        self.path = '/'
+        self.players = []
+        dbus.service.Object.__init__(self, bus, self.path)
+        self.add_player(Player(bus, path, obj))
+
+    def get_path(self):
+        return dbus.ObjectPath(self.path)
+
+    def add_player(self, player):
+        self.players.append(player)
+
+    @dbus.service.method(DBUS_OM_IFACE, out_signature='a{oa{sa{sv}}}')
+    def GetManagedObjects(self):
+        response = {}
+        print('GetManagedObjects')
+
+        for player in self.players:
+            response[player.get_path()] = { PLAYER_IFACE:
+                                            player.get_properties() }
+
+        return response
+
+def register_app_cb():
+    print('Media application registered')
+
+
+def register_app_error_cb(error):
+    print('Failed to register application: ' + str(error))
+    mainloop.quit()
+
+if __name__ == '__main__':
+    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+    bus = dbus.SystemBus()
+
+    if len(sys.argv) > 1:
+        path = bluezutils.find_adapter(sys.argv[1]).object_path
+    else:
+        path = bluezutils.find_adapter().object_path
+
+    media = dbus.Interface(bus.get_object("org.bluez", path),
+                           "org.bluez.Media1")
+
+    path = "/test/player"
+
+    if len(sys.argv) > 2:
+        app = Application(bus, path, sys.argv[2])
+    else:
+        app = Application(bus, path, None)
+
+    mainloop = GObject.MainLoop()
+
+    media.RegisterApplication(app.get_path(), {},
+                                reply_handler=register_app_cb,
+                                error_handler=register_app_error_cb)
+
+    mainloop.run()
-- 
2.21.0


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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-07-12 15:13 [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2019-07-12 15:13 ` [PATCH BlueZ 4/4] test: Add example-player Luiz Augusto von Dentz
@ 2019-07-13 14:52 ` Luiz Augusto von Dentz
  2019-07-18 10:00   ` Pali Rohár
  3 siblings, 1 reply; 28+ messages in thread
From: Luiz Augusto von Dentz @ 2019-07-13 14:52 UTC (permalink / raw)
  To: linux-bluetooth, Pali Rohár

Hi Pali,

On Fri, Jul 12, 2019 at 6:13 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This uses application ObjectManager to discover the MediaEndpoint and
> MediaPlayer object of an application and deprecates the use of
> RegisterEndpoint and RegisterPlayer.
> ---
>  doc/media-api.txt | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/doc/media-api.txt b/doc/media-api.txt
> index bca8c9563..07f7ac3e0 100644
> --- a/doc/media-api.txt
> +++ b/doc/media-api.txt
> @@ -66,7 +66,27 @@ Methods              void RegisterEndpoint(object endpoint, dict properties)
>
>                         Unregister sender media player.
>
> +               void RegisterApplication(object root, dict options)
>
> +                       Register endpoints an player objects within root
> +                       object which must implement ObjectManager.
> +
> +                       The application object path together with the D-Bus
> +                       system bus connection ID define the identification of
> +                       the application.
> +
> +                       Possible errors: org.bluez.Error.InvalidArguments
> +                                        org.bluez.Error.AlreadyExists
> +
> +               void UnregisterApplication(object application)
> +
> +                       This unregisters the services that has been
> +                       previously registered. The object path parameter
> +                       must match the same value that has been used
> +                       on registration.
> +
> +                       Possible errors: org.bluez.Error.InvalidArguments
> +                                        org.bluez.Error.DoesNotExist
>  Media Control hierarchy
>  =======================
>
> --
> 2.21.0

Can you try this set?


-- 
Luiz Augusto von Dentz

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-07-13 14:52 ` [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method Luiz Augusto von Dentz
@ 2019-07-18 10:00   ` Pali Rohár
  2019-07-21 15:55     ` Pali Rohár
  0 siblings, 1 reply; 28+ messages in thread
From: Pali Rohár @ 2019-07-18 10:00 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

On Saturday 13 July 2019 17:52:46 Luiz Augusto von Dentz wrote:
> Hi Pali,
> 
> On Fri, Jul 12, 2019 at 6:13 PM Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
> >
> > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> >
> > This uses application ObjectManager to discover the MediaEndpoint and
> > MediaPlayer object of an application and deprecates the use of
> > RegisterEndpoint and RegisterPlayer.
> > ---
> >  doc/media-api.txt | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> >
> > diff --git a/doc/media-api.txt b/doc/media-api.txt
> > index bca8c9563..07f7ac3e0 100644
> > --- a/doc/media-api.txt
> > +++ b/doc/media-api.txt
> > @@ -66,7 +66,27 @@ Methods              void RegisterEndpoint(object endpoint, dict properties)
> >
> >                         Unregister sender media player.
> >
> > +               void RegisterApplication(object root, dict options)
> >
> > +                       Register endpoints an player objects within root
> > +                       object which must implement ObjectManager.
> > +
> > +                       The application object path together with the D-Bus
> > +                       system bus connection ID define the identification of
> > +                       the application.
> > +
> > +                       Possible errors: org.bluez.Error.InvalidArguments
> > +                                        org.bluez.Error.AlreadyExists
> > +
> > +               void UnregisterApplication(object application)
> > +
> > +                       This unregisters the services that has been
> > +                       previously registered. The object path parameter
> > +                       must match the same value that has been used
> > +                       on registration.
> > +
> > +                       Possible errors: org.bluez.Error.InvalidArguments
> > +                                        org.bluez.Error.DoesNotExist
> >  Media Control hierarchy
> >  =======================
> >
> > --
> > 2.21.0
> 
> Can you try this set?

Hello, I will try it later in next week. To test it would mean to
rewrite pulseaudio bluetooth modules to use this new API, so it would
take me longer time.

-- 
Pali Rohár
pali.rohar@gmail.com

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-07-18 10:00   ` Pali Rohár
@ 2019-07-21 15:55     ` Pali Rohár
  2019-08-10  6:54       ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 28+ messages in thread
From: Pali Rohár @ 2019-07-21 15:55 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

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

On Thursday 18 July 2019 12:00:24 Pali Rohár wrote:
> On Saturday 13 July 2019 17:52:46 Luiz Augusto von Dentz wrote:
> > Hi Pali,
> > 
> > On Fri, Jul 12, 2019 at 6:13 PM Luiz Augusto von Dentz
> > <luiz.dentz@gmail.com> wrote:
> > >
> > > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> > >
> > > This uses application ObjectManager to discover the MediaEndpoint and
> > > MediaPlayer object of an application and deprecates the use of
> > > RegisterEndpoint and RegisterPlayer.
> > > ---
> > >  doc/media-api.txt | 20 ++++++++++++++++++++
> > >  1 file changed, 20 insertions(+)
> > >
> > > diff --git a/doc/media-api.txt b/doc/media-api.txt
> > > index bca8c9563..07f7ac3e0 100644
> > > --- a/doc/media-api.txt
> > > +++ b/doc/media-api.txt
> > > @@ -66,7 +66,27 @@ Methods              void RegisterEndpoint(object endpoint, dict properties)
> > >
> > >                         Unregister sender media player.
> > >
> > > +               void RegisterApplication(object root, dict options)
> > >
> > > +                       Register endpoints an player objects within root
> > > +                       object which must implement ObjectManager.
> > > +
> > > +                       The application object path together with the D-Bus
> > > +                       system bus connection ID define the identification of
> > > +                       the application.
> > > +
> > > +                       Possible errors: org.bluez.Error.InvalidArguments
> > > +                                        org.bluez.Error.AlreadyExists
> > > +
> > > +               void UnregisterApplication(object application)
> > > +
> > > +                       This unregisters the services that has been
> > > +                       previously registered. The object path parameter
> > > +                       must match the same value that has been used
> > > +                       on registration.
> > > +
> > > +                       Possible errors: org.bluez.Error.InvalidArguments
> > > +                                        org.bluez.Error.DoesNotExist
> > >  Media Control hierarchy
> > >  =======================
> > >
> > > --
> > > 2.21.0
> > 
> > Can you try this set?
> 
> Hello, I will try it later in next week. To test it would mean to
> rewrite pulseaudio bluetooth modules to use this new API, so it would
> take me longer time.

Hi! I looked at it. But I do not know how to implement
GetManagedObjects() method via libdbus properly. Any idea?

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-07-21 15:55     ` Pali Rohár
@ 2019-08-10  6:54       ` Luiz Augusto von Dentz
  2019-08-29 12:57         ` Pasi Kärkkäinen
  0 siblings, 1 reply; 28+ messages in thread
From: Luiz Augusto von Dentz @ 2019-08-10  6:54 UTC (permalink / raw)
  To: Pali Rohár; +Cc: linux-bluetooth

Hi,

On Sun, Jul 21, 2019 at 6:55 PM Pali Rohár <pali.rohar@gmail.com> wrote:
>
> On Thursday 18 July 2019 12:00:24 Pali Rohár wrote:
> > On Saturday 13 July 2019 17:52:46 Luiz Augusto von Dentz wrote:
> > > Hi Pali,
> > >
> > > On Fri, Jul 12, 2019 at 6:13 PM Luiz Augusto von Dentz
> > > <luiz.dentz@gmail.com> wrote:
> > > >
> > > > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> > > >
> > > > This uses application ObjectManager to discover the MediaEndpoint and
> > > > MediaPlayer object of an application and deprecates the use of
> > > > RegisterEndpoint and RegisterPlayer.
> > > > ---
> > > >  doc/media-api.txt | 20 ++++++++++++++++++++
> > > >  1 file changed, 20 insertions(+)
> > > >
> > > > diff --git a/doc/media-api.txt b/doc/media-api.txt
> > > > index bca8c9563..07f7ac3e0 100644
> > > > --- a/doc/media-api.txt
> > > > +++ b/doc/media-api.txt
> > > > @@ -66,7 +66,27 @@ Methods              void RegisterEndpoint(object endpoint, dict properties)
> > > >
> > > >                         Unregister sender media player.
> > > >
> > > > +               void RegisterApplication(object root, dict options)
> > > >
> > > > +                       Register endpoints an player objects within root
> > > > +                       object which must implement ObjectManager.
> > > > +
> > > > +                       The application object path together with the D-Bus
> > > > +                       system bus connection ID define the identification of
> > > > +                       the application.
> > > > +
> > > > +                       Possible errors: org.bluez.Error.InvalidArguments
> > > > +                                        org.bluez.Error.AlreadyExists
> > > > +
> > > > +               void UnregisterApplication(object application)
> > > > +
> > > > +                       This unregisters the services that has been
> > > > +                       previously registered. The object path parameter
> > > > +                       must match the same value that has been used
> > > > +                       on registration.
> > > > +
> > > > +                       Possible errors: org.bluez.Error.InvalidArguments
> > > > +                                        org.bluez.Error.DoesNotExist
> > > >  Media Control hierarchy
> > > >  =======================
> > > >
> > > > --
> > > > 2.21.0
> > >
> > > Can you try this set?
> >
> > Hello, I will try it later in next week. To test it would mean to
> > rewrite pulseaudio bluetooth modules to use this new API, so it would
> > take me longer time.
>
> Hi! I looked at it. But I do not know how to implement
> GetManagedObjects() method via libdbus properly. Any idea?

I went ahead and applied this set, you can find some examples of how
to implement ObjectManager interface in gdbus but I guess what you
really need to do is make PA aware of the objects being exposed since
it does make it simpler to to enumerate objects by the clients.

-- 
Luiz Augusto von Dentz

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-08-10  6:54       ` Luiz Augusto von Dentz
@ 2019-08-29 12:57         ` Pasi Kärkkäinen
  2019-08-29 20:05           ` Pali Rohár
  0 siblings, 1 reply; 28+ messages in thread
From: Pasi Kärkkäinen @ 2019-08-29 12:57 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Pali Rohár, linux-bluetooth

Hi,

On Sat, Aug 10, 2019 at 09:54:52AM +0300, Luiz Augusto von Dentz wrote:
> Hi,
> 
> On Sun, Jul 21, 2019 at 6:55 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> >
> > On Thursday 18 July 2019 12:00:24 Pali Rohár wrote:
> > > On Saturday 13 July 2019 17:52:46 Luiz Augusto von Dentz wrote:
> > > > Hi Pali,
> > > >
> > > > On Fri, Jul 12, 2019 at 6:13 PM Luiz Augusto von Dentz
> > > > <luiz.dentz@gmail.com> wrote:
> > > > >
> > > > > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> > > > >
> > > > > This uses application ObjectManager to discover the MediaEndpoint and
> > > > > MediaPlayer object of an application and deprecates the use of
> > > > > RegisterEndpoint and RegisterPlayer.
> > > > > ---
> > > > >  doc/media-api.txt | 20 ++++++++++++++++++++
> > > > >  1 file changed, 20 insertions(+)
> > > > >
> > > > > diff --git a/doc/media-api.txt b/doc/media-api.txt
> > > > > index bca8c9563..07f7ac3e0 100644
> > > > > --- a/doc/media-api.txt
> > > > > +++ b/doc/media-api.txt
> > > > > @@ -66,7 +66,27 @@ Methods              void RegisterEndpoint(object endpoint, dict properties)
> > > > >
> > > > >                         Unregister sender media player.
> > > > >
> > > > > +               void RegisterApplication(object root, dict options)
> > > > >
> > > > > +                       Register endpoints an player objects within root
> > > > > +                       object which must implement ObjectManager.
> > > > > +
> > > > > +                       The application object path together with the D-Bus
> > > > > +                       system bus connection ID define the identification of
> > > > > +                       the application.
> > > > > +
> > > > > +                       Possible errors: org.bluez.Error.InvalidArguments
> > > > > +                                        org.bluez.Error.AlreadyExists
> > > > > +
> > > > > +               void UnregisterApplication(object application)
> > > > > +
> > > > > +                       This unregisters the services that has been
> > > > > +                       previously registered. The object path parameter
> > > > > +                       must match the same value that has been used
> > > > > +                       on registration.
> > > > > +
> > > > > +                       Possible errors: org.bluez.Error.InvalidArguments
> > > > > +                                        org.bluez.Error.DoesNotExist
> > > > >  Media Control hierarchy
> > > > >  =======================
> > > > >
> > > > > --
> > > > > 2.21.0
> > > >
> > > > Can you try this set?
> > >
> > > Hello, I will try it later in next week. To test it would mean to
> > > rewrite pulseaudio bluetooth modules to use this new API, so it would
> > > take me longer time.
> >
> > Hi! I looked at it. But I do not know how to implement
> > GetManagedObjects() method via libdbus properly. Any idea?
> 
> I went ahead and applied this set, you can find some examples of how
> to implement ObjectManager interface in gdbus but I guess what you
> really need to do is make PA aware of the objects being exposed since
> it does make it simpler to to enumerate objects by the clients.
> 

Pali: How does it look with porting the PA patches to use the new interfaces?


Thanks,

-- Pasi


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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-08-29 12:57         ` Pasi Kärkkäinen
@ 2019-08-29 20:05           ` Pali Rohár
  2019-10-03 18:18             ` Pasi Kärkkäinen
  0 siblings, 1 reply; 28+ messages in thread
From: Pali Rohár @ 2019-08-29 20:05 UTC (permalink / raw)
  To: Pasi Kärkkäinen; +Cc: Luiz Augusto von Dentz, linux-bluetooth

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

On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> Pali: How does it look with porting the PA patches to use the new interfaces?

Hello, I have not had a time yet to play with these pulseaudio patches
and porting to the new interface. I guess that I could have more free
time in the last week of next month.

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-08-29 20:05           ` Pali Rohár
@ 2019-10-03 18:18             ` Pasi Kärkkäinen
  2019-10-06 10:05               ` Pali Rohár
  0 siblings, 1 reply; 28+ messages in thread
From: Pasi Kärkkäinen @ 2019-10-03 18:18 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Luiz Augusto von Dentz, linux-bluetooth

Hi,

On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > Pali: How does it look with porting the PA patches to use the new interfaces?
> 
> Hello, I have not had a time yet to play with these pulseaudio patches
> and porting to the new interface. I guess that I could have more free
> time in the last week of next month.
>

It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
So now at least the new interfaces are in a released bluez version.


-- Pasi

> -- 
> Pali Rohár
> pali.rohar@gmail.com


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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-03 18:18             ` Pasi Kärkkäinen
@ 2019-10-06 10:05               ` Pali Rohár
  2019-10-06 10:53                 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 28+ messages in thread
From: Pali Rohár @ 2019-10-06 10:05 UTC (permalink / raw)
  To: Pasi Kärkkäinen; +Cc: Luiz Augusto von Dentz, linux-bluetooth

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

On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> Hi,
> 
> On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > 
> > Hello, I have not had a time yet to play with these pulseaudio patches
> > and porting to the new interface. I guess that I could have more free
> > time in the last week of next month.
> >
> 
> It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> So now at least the new interfaces are in a released bluez version.

Ok! Today I have looked at this new Bluez API, but seems that there is
not only missing some examples or usages with libdbus-1, but also
documentation. I have tried to find something how to register endpoints
throw GetManagedObjects() via libdbus-1, but seems that there is no
usage of it and also unusable documentation for it in libdbus-1. So
currently I'm stuck how to use this exotic API in pulseaudio...

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-06 10:05               ` Pali Rohár
@ 2019-10-06 10:53                 ` Luiz Augusto von Dentz
  2019-10-06 10:56                   ` Pali Rohár
  2019-10-06 12:02                   ` Pali Rohár
  0 siblings, 2 replies; 28+ messages in thread
From: Luiz Augusto von Dentz @ 2019-10-06 10:53 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Pasi Kärkkäinen, linux-bluetooth

Hi Pali,

On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
>
> On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > Hi,
> >
> > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > >
> > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > and porting to the new interface. I guess that I could have more free
> > > time in the last week of next month.
> > >
> >
> > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > So now at least the new interfaces are in a released bluez version.
>
> Ok! Today I have looked at this new Bluez API, but seems that there is
> not only missing some examples or usages with libdbus-1, but also
> documentation. I have tried to find something how to register endpoints
> throw GetManagedObjects() via libdbus-1, but seems that there is no
> usage of it and also unusable documentation for it in libdbus-1. So
> currently I'm stuck how to use this exotic API in pulseaudio...

It is just another D-Bus method, the only difference is that it
carries the entire object tree, btw I did add an example of how to
register Endpoints in python:

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint

You can also have a look at how our gdbus internal library (uses
libdbus) utilize it:

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269

-- 
Luiz Augusto von Dentz

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-06 10:53                 ` Luiz Augusto von Dentz
@ 2019-10-06 10:56                   ` Pali Rohár
  2019-10-06 11:14                     ` Luiz Augusto von Dentz
  2019-10-06 12:02                   ` Pali Rohár
  1 sibling, 1 reply; 28+ messages in thread
From: Pali Rohár @ 2019-10-06 10:56 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Pasi Kärkkäinen, linux-bluetooth

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

On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> Hi Pali,
> 
> On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> >
> > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > Hi,
> > >
> > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > >
> > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > and porting to the new interface. I guess that I could have more free
> > > > time in the last week of next month.
> > > >
> > >
> > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > So now at least the new interfaces are in a released bluez version.
> >
> > Ok! Today I have looked at this new Bluez API, but seems that there is
> > not only missing some examples or usages with libdbus-1, but also
> > documentation. I have tried to find something how to register endpoints
> > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > usage of it and also unusable documentation for it in libdbus-1. So
> > currently I'm stuck how to use this exotic API in pulseaudio...
> 
> It is just another D-Bus method, the only difference is that it
> carries the entire object tree, btw I did add an example of how to
> register Endpoints in python:
> 
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint

Now I found this python example and currently I'm doing observations and
"reverse-engineering" how it is working and how this example behaves on
D-Bus. I think I understood it now.

> You can also have a look at how our gdbus internal library (uses
> libdbus) utilize it:
> 
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> 

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-06 10:56                   ` Pali Rohár
@ 2019-10-06 11:14                     ` Luiz Augusto von Dentz
  2019-10-06 11:17                       ` Pali Rohár
  0 siblings, 1 reply; 28+ messages in thread
From: Luiz Augusto von Dentz @ 2019-10-06 11:14 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Pasi Kärkkäinen, linux-bluetooth

Hi Pali,

On Sun, Oct 6, 2019 at 1:56 PM Pali Rohár <pali.rohar@gmail.com> wrote:
>
> On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> > Hi Pali,
> >
> > On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > >
> > > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > > Hi,
> > > >
> > > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > > >
> > > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > > and porting to the new interface. I guess that I could have more free
> > > > > time in the last week of next month.
> > > > >
> > > >
> > > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > > So now at least the new interfaces are in a released bluez version.
> > >
> > > Ok! Today I have looked at this new Bluez API, but seems that there is
> > > not only missing some examples or usages with libdbus-1, but also
> > > documentation. I have tried to find something how to register endpoints
> > > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > > usage of it and also unusable documentation for it in libdbus-1. So
> > > currently I'm stuck how to use this exotic API in pulseaudio...
> >
> > It is just another D-Bus method, the only difference is that it
> > carries the entire object tree, btw I did add an example of how to
> > register Endpoints in python:
> >
> > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint
>
> Now I found this python example and currently I'm doing observations and
> "reverse-engineering" how it is working and how this example behaves on
> D-Bus. I think I understood it now.

One important detail is that RegisterApplication shall not block since
the daemon will call GetManagedObjects the D-Bus mainloop must be able
to process messages.

> > You can also have a look at how our gdbus internal library (uses
> > libdbus) utilize it:
> >
> > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> >
>
> --
> Pali Rohár
> pali.rohar@gmail.com



-- 
Luiz Augusto von Dentz

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-06 11:14                     ` Luiz Augusto von Dentz
@ 2019-10-06 11:17                       ` Pali Rohár
  2019-10-06 18:02                         ` Pali Rohár
  0 siblings, 1 reply; 28+ messages in thread
From: Pali Rohár @ 2019-10-06 11:17 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Pasi Kärkkäinen, linux-bluetooth

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

On Sunday 06 October 2019 14:14:18 Luiz Augusto von Dentz wrote:
> Hi Pali,
> 
> On Sun, Oct 6, 2019 at 1:56 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> >
> > On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> > > Hi Pali,
> > >
> > > On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > > >
> > > > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > > > Hi,
> > > > >
> > > > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > > > >
> > > > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > > > and porting to the new interface. I guess that I could have more free
> > > > > > time in the last week of next month.
> > > > > >
> > > > >
> > > > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > > > So now at least the new interfaces are in a released bluez version.
> > > >
> > > > Ok! Today I have looked at this new Bluez API, but seems that there is
> > > > not only missing some examples or usages with libdbus-1, but also
> > > > documentation. I have tried to find something how to register endpoints
> > > > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > > > usage of it and also unusable documentation for it in libdbus-1. So
> > > > currently I'm stuck how to use this exotic API in pulseaudio...
> > >
> > > It is just another D-Bus method, the only difference is that it
> > > carries the entire object tree, btw I did add an example of how to
> > > register Endpoints in python:
> > >
> > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint
> >
> > Now I found this python example and currently I'm doing observations and
> > "reverse-engineering" how it is working and how this example behaves on
> > D-Bus. I think I understood it now.
> 
> One important detail is that RegisterApplication shall not block since
> the daemon will call GetManagedObjects the D-Bus mainloop must be able
> to process messages.

Ok. I'm already using non-blocking / async processing as blocking
variants can cause more problems in event-orientated applications.

> > > You can also have a look at how our gdbus internal library (uses
> > > libdbus) utilize it:
> > >
> > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> > >
> >
> > --
> > Pali Rohár
> > pali.rohar@gmail.com
> 
> 
> 

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-06 10:53                 ` Luiz Augusto von Dentz
  2019-10-06 10:56                   ` Pali Rohár
@ 2019-10-06 12:02                   ` Pali Rohár
  2019-10-07 14:33                     ` Pali Rohár
  2019-10-09 13:20                     ` Pali Rohár
  1 sibling, 2 replies; 28+ messages in thread
From: Pali Rohár @ 2019-10-06 12:02 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Pasi Kärkkäinen, linux-bluetooth

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

On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> Hi Pali,
> 
> On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> >
> > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > Hi,
> > >
> > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > >
> > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > and porting to the new interface. I guess that I could have more free
> > > > time in the last week of next month.
> > > >
> > >
> > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > So now at least the new interfaces are in a released bluez version.
> >
> > Ok! Today I have looked at this new Bluez API, but seems that there is
> > not only missing some examples or usages with libdbus-1, but also
> > documentation. I have tried to find something how to register endpoints
> > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > usage of it and also unusable documentation for it in libdbus-1. So
> > currently I'm stuck how to use this exotic API in pulseaudio...
> 
> It is just another D-Bus method, the only difference is that it
> carries the entire object tree, btw I did add an example of how to
> register Endpoints in python:
> 
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint

This example uses undocumented property "DelayReporting". What it is doing?

> You can also have a look at how our gdbus internal library (uses
> libdbus) utilize it:
> 
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> 

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-06 11:17                       ` Pali Rohár
@ 2019-10-06 18:02                         ` Pali Rohár
  0 siblings, 0 replies; 28+ messages in thread
From: Pali Rohár @ 2019-10-06 18:02 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Pasi Kärkkäinen, linux-bluetooth

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

On Sunday 06 October 2019 13:17:00 Pali Rohár wrote:
> On Sunday 06 October 2019 14:14:18 Luiz Augusto von Dentz wrote:
> > Hi Pali,
> > 
> > On Sun, Oct 6, 2019 at 1:56 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > >
> > > On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> > > > Hi Pali,
> > > >
> > > > On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > > > >
> > > > > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > > > > Hi,
> > > > > >
> > > > > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > > > > >
> > > > > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > > > > and porting to the new interface. I guess that I could have more free
> > > > > > > time in the last week of next month.
> > > > > > >
> > > > > >
> > > > > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > > > > So now at least the new interfaces are in a released bluez version.
> > > > >
> > > > > Ok! Today I have looked at this new Bluez API, but seems that there is
> > > > > not only missing some examples or usages with libdbus-1, but also
> > > > > documentation. I have tried to find something how to register endpoints
> > > > > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > > > > usage of it and also unusable documentation for it in libdbus-1. So
> > > > > currently I'm stuck how to use this exotic API in pulseaudio...
> > > >
> > > > It is just another D-Bus method, the only difference is that it
> > > > carries the entire object tree, btw I did add an example of how to
> > > > register Endpoints in python:
> > > >
> > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint
> > >
> > > Now I found this python example and currently I'm doing observations and
> > > "reverse-engineering" how it is working and how this example behaves on
> > > D-Bus. I think I understood it now.
> > 
> > One important detail is that RegisterApplication shall not block since
> > the daemon will call GetManagedObjects the D-Bus mainloop must be able
> > to process messages.
> 
> Ok. I'm already using non-blocking / async processing as blocking
> variants can cause more problems in event-orientated applications.

Now I implemented it in pulseaudio. New patches are now available in
pulseaudio-discuss@lists.freedesktop.org mailing list.

> > > > You can also have a look at how our gdbus internal library (uses
> > > > libdbus) utilize it:
> > > >
> > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> > > >
> > >
> > > --
> > > Pali Rohár
> > > pali.rohar@gmail.com
> > 
> > 
> > 
> 

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-06 12:02                   ` Pali Rohár
@ 2019-10-07 14:33                     ` Pali Rohár
  2019-10-08 10:28                       ` Luiz Augusto von Dentz
  2019-10-09 13:20                     ` Pali Rohár
  1 sibling, 1 reply; 28+ messages in thread
From: Pali Rohár @ 2019-10-07 14:33 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Pasi Kärkkäinen, linux-bluetooth

On Sunday 06 October 2019 14:02:45 Pali Rohár wrote:
> On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> > Hi Pali,
> > 
> > On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > >
> > > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > > Hi,
> > > >
> > > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > > >
> > > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > > and porting to the new interface. I guess that I could have more free
> > > > > time in the last week of next month.
> > > > >
> > > >
> > > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > > So now at least the new interfaces are in a released bluez version.
> > >
> > > Ok! Today I have looked at this new Bluez API, but seems that there is
> > > not only missing some examples or usages with libdbus-1, but also
> > > documentation. I have tried to find something how to register endpoints
> > > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > > usage of it and also unusable documentation for it in libdbus-1. So
> > > currently I'm stuck how to use this exotic API in pulseaudio...
> > 
> > It is just another D-Bus method, the only difference is that it
> > carries the entire object tree, btw I did add an example of how to
> > register Endpoints in python:
> > 
> > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint
> 
> This example uses undocumented property "DelayReporting". What it is doing?

Also this new Managed Objects API bring some inconsistency. Codec
switching API is available only when bluetoothd was started with
--experimental flag, but this new Object API is available also without
it. So it just complicated implementation.

How could application (e.g. pulseaudio) check if A2DP codec switching is
available and based on this decide if via Managed Objects API export
more codecs or just only default SBC?

> > You can also have a look at how our gdbus internal library (uses
> > libdbus) utilize it:
> > 
> > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> > 
> 

-- 
Pali Rohár
pali.rohar@gmail.com

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-07 14:33                     ` Pali Rohár
@ 2019-10-08 10:28                       ` Luiz Augusto von Dentz
  2019-10-08 10:33                         ` Pali Rohár
  0 siblings, 1 reply; 28+ messages in thread
From: Luiz Augusto von Dentz @ 2019-10-08 10:28 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Pasi Kärkkäinen, linux-bluetooth

Hi Pali,

On Mon, Oct 7, 2019 at 5:33 PM Pali Rohár <pali.rohar@gmail.com> wrote:
>
> On Sunday 06 October 2019 14:02:45 Pali Rohár wrote:
> > On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> > > Hi Pali,
> > >
> > > On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > > >
> > > > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > > > Hi,
> > > > >
> > > > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > > > >
> > > > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > > > and porting to the new interface. I guess that I could have more free
> > > > > > time in the last week of next month.
> > > > > >
> > > > >
> > > > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > > > So now at least the new interfaces are in a released bluez version.
> > > >
> > > > Ok! Today I have looked at this new Bluez API, but seems that there is
> > > > not only missing some examples or usages with libdbus-1, but also
> > > > documentation. I have tried to find something how to register endpoints
> > > > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > > > usage of it and also unusable documentation for it in libdbus-1. So
> > > > currently I'm stuck how to use this exotic API in pulseaudio...
> > >
> > > It is just another D-Bus method, the only difference is that it
> > > carries the entire object tree, btw I did add an example of how to
> > > register Endpoints in python:
> > >
> > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint
> >
> > This example uses undocumented property "DelayReporting". What it is doing?
>
> Also this new Managed Objects API bring some inconsistency. Codec
> switching API is available only when bluetoothd was started with
> --experimental flag, but this new Object API is available also without
> it. So it just complicated implementation.
>
> How could application (e.g. pulseaudio) check if A2DP codec switching is
> available and based on this decide if via Managed Objects API export
> more codecs or just only default SBC?

The idea was that this API would be experimental as well but it seems
it is not, they should go hand in hand with Endpoint objects to ensure
they will be available as well so we might have to fix this in 5.52,
too bad we didn't see this before 5.51 went out.

> > > You can also have a look at how our gdbus internal library (uses
> > > libdbus) utilize it:
> > >
> > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> > >
> >
>
> --
> Pali Rohár
> pali.rohar@gmail.com



-- 
Luiz Augusto von Dentz

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-08 10:28                       ` Luiz Augusto von Dentz
@ 2019-10-08 10:33                         ` Pali Rohár
  2019-10-09 13:15                           ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 28+ messages in thread
From: Pali Rohár @ 2019-10-08 10:33 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Pasi Kärkkäinen, linux-bluetooth

On Tuesday 08 October 2019 13:28:53 Luiz Augusto von Dentz wrote:
> Hi Pali,
> 
> On Mon, Oct 7, 2019 at 5:33 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> >
> > On Sunday 06 October 2019 14:02:45 Pali Rohár wrote:
> > > On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> > > > Hi Pali,
> > > >
> > > > On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > > > >
> > > > > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > > > > Hi,
> > > > > >
> > > > > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > > > > >
> > > > > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > > > > and porting to the new interface. I guess that I could have more free
> > > > > > > time in the last week of next month.
> > > > > > >
> > > > > >
> > > > > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > > > > So now at least the new interfaces are in a released bluez version.
> > > > >
> > > > > Ok! Today I have looked at this new Bluez API, but seems that there is
> > > > > not only missing some examples or usages with libdbus-1, but also
> > > > > documentation. I have tried to find something how to register endpoints
> > > > > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > > > > usage of it and also unusable documentation for it in libdbus-1. So
> > > > > currently I'm stuck how to use this exotic API in pulseaudio...
> > > >
> > > > It is just another D-Bus method, the only difference is that it
> > > > carries the entire object tree, btw I did add an example of how to
> > > > register Endpoints in python:
> > > >
> > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint
> > >
> > > This example uses undocumented property "DelayReporting". What it is doing?
> >
> > Also this new Managed Objects API bring some inconsistency. Codec
> > switching API is available only when bluetoothd was started with
> > --experimental flag, but this new Object API is available also without
> > it. So it just complicated implementation.
> >
> > How could application (e.g. pulseaudio) check if A2DP codec switching is
> > available and based on this decide if via Managed Objects API export
> > more codecs or just only default SBC?
> 
> The idea was that this API would be experimental as well but it seems
> it is not,

No, it is not experimental. Managed Objects API is available also when
bluetoothd is started without --experimental argument.

> they should go hand in hand with Endpoint objects to ensure
> they will be available as well so we might have to fix this in 5.52,
> too bad we didn't see this before 5.51 went out.

So... what should applications expects and how they should implement
above decision?

> > > > You can also have a look at how our gdbus internal library (uses
> > > > libdbus) utilize it:
> > > >
> > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> > > >
> > >
> >
> > --
> > Pali Rohár
> > pali.rohar@gmail.com
> 
> 
> 

-- 
Pali Rohár
pali.rohar@gmail.com

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-08 10:33                         ` Pali Rohár
@ 2019-10-09 13:15                           ` Luiz Augusto von Dentz
  2019-10-09 13:19                             ` Pali Rohár
  0 siblings, 1 reply; 28+ messages in thread
From: Luiz Augusto von Dentz @ 2019-10-09 13:15 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Pasi Kärkkäinen, linux-bluetooth

Hi Pali,

On Tue, Oct 8, 2019 at 1:33 PM Pali Rohár <pali.rohar@gmail.com> wrote:
>
> On Tuesday 08 October 2019 13:28:53 Luiz Augusto von Dentz wrote:
> > Hi Pali,
> >
> > On Mon, Oct 7, 2019 at 5:33 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > >
> > > On Sunday 06 October 2019 14:02:45 Pali Rohár wrote:
> > > > On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> > > > > Hi Pali,
> > > > >
> > > > > On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > > > > >
> > > > > > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > > > > > Hi,
> > > > > > >
> > > > > > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > > > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > > > > > >
> > > > > > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > > > > > and porting to the new interface. I guess that I could have more free
> > > > > > > > time in the last week of next month.
> > > > > > > >
> > > > > > >
> > > > > > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > > > > > So now at least the new interfaces are in a released bluez version.
> > > > > >
> > > > > > Ok! Today I have looked at this new Bluez API, but seems that there is
> > > > > > not only missing some examples or usages with libdbus-1, but also
> > > > > > documentation. I have tried to find something how to register endpoints
> > > > > > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > > > > > usage of it and also unusable documentation for it in libdbus-1. So
> > > > > > currently I'm stuck how to use this exotic API in pulseaudio...
> > > > >
> > > > > It is just another D-Bus method, the only difference is that it
> > > > > carries the entire object tree, btw I did add an example of how to
> > > > > register Endpoints in python:
> > > > >
> > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint
> > > >
> > > > This example uses undocumented property "DelayReporting". What it is doing?
> > >
> > > Also this new Managed Objects API bring some inconsistency. Codec
> > > switching API is available only when bluetoothd was started with
> > > --experimental flag, but this new Object API is available also without
> > > it. So it just complicated implementation.
> > >
> > > How could application (e.g. pulseaudio) check if A2DP codec switching is
> > > available and based on this decide if via Managed Objects API export
> > > more codecs or just only default SBC?
> >
> > The idea was that this API would be experimental as well but it seems
> > it is not,
>
> No, it is not experimental. Managed Objects API is available also when
> bluetoothd is started without --experimental argument.
>
> > they should go hand in hand with Endpoint objects to ensure
> > they will be available as well so we might have to fix this in 5.52,
> > too bad we didn't see this before 5.51 went out.
>
> So... what should applications expects and how they should implement
> above decision?

Actually the decision should be based on the presence of
RegisterApplication method, if that exists then endpoint switching
should be supported as well, so has nothing to do the
GetManagedObjects API of the bluetoothd. That said RegisterApplication
was not made experimental which kind makes 5.51 broken because it
would appear that it endpoint objects would be exposed but when in
fact there are not, anyway lets finally have the code to use this
interface and then we can remove the experimental flag from
MediaEndpoint.

> > > > > You can also have a look at how our gdbus internal library (uses
> > > > > libdbus) utilize it:
> > > > >
> > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> > > > >
> > > >
> > >
> > > --
> > > Pali Rohár
> > > pali.rohar@gmail.com
> >
> >
> >
>
> --
> Pali Rohár
> pali.rohar@gmail.com



-- 
Luiz Augusto von Dentz

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-09 13:15                           ` Luiz Augusto von Dentz
@ 2019-10-09 13:19                             ` Pali Rohár
  2019-10-17  9:59                               ` Pali Rohár
  0 siblings, 1 reply; 28+ messages in thread
From: Pali Rohár @ 2019-10-09 13:19 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Pasi Kärkkäinen, linux-bluetooth

On Wednesday 09 October 2019 16:15:59 Luiz Augusto von Dentz wrote:
> Hi Pali,
> 
> On Tue, Oct 8, 2019 at 1:33 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> >
> > On Tuesday 08 October 2019 13:28:53 Luiz Augusto von Dentz wrote:
> > > Hi Pali,
> > >
> > > On Mon, Oct 7, 2019 at 5:33 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > > >
> > > > On Sunday 06 October 2019 14:02:45 Pali Rohár wrote:
> > > > > On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> > > > > > Hi Pali,
> > > > > >
> > > > > > On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > > > > > >
> > > > > > > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > > > > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > > > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > > > > > > >
> > > > > > > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > > > > > > and porting to the new interface. I guess that I could have more free
> > > > > > > > > time in the last week of next month.
> > > > > > > > >
> > > > > > > >
> > > > > > > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > > > > > > So now at least the new interfaces are in a released bluez version.
> > > > > > >
> > > > > > > Ok! Today I have looked at this new Bluez API, but seems that there is
> > > > > > > not only missing some examples or usages with libdbus-1, but also
> > > > > > > documentation. I have tried to find something how to register endpoints
> > > > > > > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > > > > > > usage of it and also unusable documentation for it in libdbus-1. So
> > > > > > > currently I'm stuck how to use this exotic API in pulseaudio...
> > > > > >
> > > > > > It is just another D-Bus method, the only difference is that it
> > > > > > carries the entire object tree, btw I did add an example of how to
> > > > > > register Endpoints in python:
> > > > > >
> > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint
> > > > >
> > > > > This example uses undocumented property "DelayReporting". What it is doing?
> > > >
> > > > Also this new Managed Objects API bring some inconsistency. Codec
> > > > switching API is available only when bluetoothd was started with
> > > > --experimental flag, but this new Object API is available also without
> > > > it. So it just complicated implementation.
> > > >
> > > > How could application (e.g. pulseaudio) check if A2DP codec switching is
> > > > available and based on this decide if via Managed Objects API export
> > > > more codecs or just only default SBC?
> > >
> > > The idea was that this API would be experimental as well but it seems
> > > it is not,
> >
> > No, it is not experimental. Managed Objects API is available also when
> > bluetoothd is started without --experimental argument.
> >
> > > they should go hand in hand with Endpoint objects to ensure
> > > they will be available as well so we might have to fix this in 5.52,
> > > too bad we didn't see this before 5.51 went out.
> >
> > So... what should applications expects and how they should implement
> > above decision?
> 
> Actually the decision should be based on the presence of
> RegisterApplication method, if that exists then endpoint switching
> should be supported as well, so has nothing to do the
> GetManagedObjects API of the bluetoothd. That said RegisterApplication
> was not made experimental which kind makes 5.51 broken because it
> would appear that it endpoint objects would be exposed but when in
> fact there are not, anyway lets finally have the code to use this
> interface and then we can remove the experimental flag from
> MediaEndpoint.

Ok, so can pulseaudio do following?

Call RegisterApplication. If success then expects that codec switching
is possible and via GetManagedObjects exports all available codecs.
If RegisterApplication fails then fallback to RegisterEndpoint, expects
that codec switching is not possible and so register only one SBC codec.

> > > > > > You can also have a look at how our gdbus internal library (uses
> > > > > > libdbus) utilize it:
> > > > > >
> > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> > > > > >
> > > > >
> > > >
> > > > --
> > > > Pali Rohár
> > > > pali.rohar@gmail.com
> > >
> > >
> > >
> >
> > --
> > Pali Rohár
> > pali.rohar@gmail.com
> 
> 
> 

-- 
Pali Rohár
pali.rohar@gmail.com

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-06 12:02                   ` Pali Rohár
  2019-10-07 14:33                     ` Pali Rohár
@ 2019-10-09 13:20                     ` Pali Rohár
  1 sibling, 0 replies; 28+ messages in thread
From: Pali Rohár @ 2019-10-09 13:20 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Pasi Kärkkäinen, linux-bluetooth

On Sunday 06 October 2019 14:02:45 Pali Rohár wrote:
> On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> > Hi Pali,
> > 
> > On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > >
> > > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > > Hi,
> > > >
> > > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > > >
> > > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > > and porting to the new interface. I guess that I could have more free
> > > > > time in the last week of next month.
> > > > >
> > > >
> > > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > > So now at least the new interfaces are in a released bluez version.
> > >
> > > Ok! Today I have looked at this new Bluez API, but seems that there is
> > > not only missing some examples or usages with libdbus-1, but also
> > > documentation. I have tried to find something how to register endpoints
> > > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > > usage of it and also unusable documentation for it in libdbus-1. So
> > > currently I'm stuck how to use this exotic API in pulseaudio...
> > 
> > It is just another D-Bus method, the only difference is that it
> > carries the entire object tree, btw I did add an example of how to
> > register Endpoints in python:
> > 
> > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint
> 
> This example uses undocumented property "DelayReporting". What it is doing?

And I would like to know what is that undocumented DelayReporting is
doing? And to which value should I initialize it in pulseaudio?

> > You can also have a look at how our gdbus internal library (uses
> > libdbus) utilize it:
> > 
> > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> > 
> 

-- 
Pali Rohár
pali.rohar@gmail.com

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-09 13:19                             ` Pali Rohár
@ 2019-10-17  9:59                               ` Pali Rohár
  2019-10-18  8:37                                 ` Pasi Kärkkäinen
  0 siblings, 1 reply; 28+ messages in thread
From: Pali Rohár @ 2019-10-17  9:59 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Pasi Kärkkäinen, linux-bluetooth

On Wednesday 09 October 2019 15:19:21 Pali Rohár wrote:
> On Wednesday 09 October 2019 16:15:59 Luiz Augusto von Dentz wrote:
> > Hi Pali,
> > 
> > On Tue, Oct 8, 2019 at 1:33 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > >
> > > On Tuesday 08 October 2019 13:28:53 Luiz Augusto von Dentz wrote:
> > > > Hi Pali,
> > > >
> > > > On Mon, Oct 7, 2019 at 5:33 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > > > >
> > > > > On Sunday 06 October 2019 14:02:45 Pali Rohár wrote:
> > > > > > On Sunday 06 October 2019 13:53:37 Luiz Augusto von Dentz wrote:
> > > > > > > Hi Pali,
> > > > > > >
> > > > > > > On Sun, Oct 6, 2019 at 1:05 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> > > > > > > >
> > > > > > > > On Thursday 03 October 2019 21:18:55 Pasi Kärkkäinen wrote:
> > > > > > > > > Hi,
> > > > > > > > >
> > > > > > > > > On Thu, Aug 29, 2019 at 10:05:13PM +0200, Pali Rohár wrote:
> > > > > > > > > > On Thursday 29 August 2019 15:57:34 Pasi Kärkkäinen wrote:
> > > > > > > > > > > Pali: How does it look with porting the PA patches to use the new interfaces?
> > > > > > > > > >
> > > > > > > > > > Hello, I have not had a time yet to play with these pulseaudio patches
> > > > > > > > > > and porting to the new interface. I guess that I could have more free
> > > > > > > > > > time in the last week of next month.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > It seems BlueZ 5.51 has been released meanwhile (http://www.bluez.org/release-of-bluez-5-51/)
> > > > > > > > > So now at least the new interfaces are in a released bluez version.
> > > > > > > >
> > > > > > > > Ok! Today I have looked at this new Bluez API, but seems that there is
> > > > > > > > not only missing some examples or usages with libdbus-1, but also
> > > > > > > > documentation. I have tried to find something how to register endpoints
> > > > > > > > throw GetManagedObjects() via libdbus-1, but seems that there is no
> > > > > > > > usage of it and also unusable documentation for it in libdbus-1. So
> > > > > > > > currently I'm stuck how to use this exotic API in pulseaudio...
> > > > > > >
> > > > > > > It is just another D-Bus method, the only difference is that it
> > > > > > > carries the entire object tree, btw I did add an example of how to
> > > > > > > register Endpoints in python:
> > > > > > >
> > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-endpoint
> > > > > >
> > > > > > This example uses undocumented property "DelayReporting". What it is doing?
> > > > >
> > > > > Also this new Managed Objects API bring some inconsistency. Codec
> > > > > switching API is available only when bluetoothd was started with
> > > > > --experimental flag, but this new Object API is available also without
> > > > > it. So it just complicated implementation.
> > > > >
> > > > > How could application (e.g. pulseaudio) check if A2DP codec switching is
> > > > > available and based on this decide if via Managed Objects API export
> > > > > more codecs or just only default SBC?
> > > >
> > > > The idea was that this API would be experimental as well but it seems
> > > > it is not,
> > >
> > > No, it is not experimental. Managed Objects API is available also when
> > > bluetoothd is started without --experimental argument.
> > >
> > > > they should go hand in hand with Endpoint objects to ensure
> > > > they will be available as well so we might have to fix this in 5.52,
> > > > too bad we didn't see this before 5.51 went out.
> > >
> > > So... what should applications expects and how they should implement
> > > above decision?
> > 
> > Actually the decision should be based on the presence of
> > RegisterApplication method, if that exists then endpoint switching
> > should be supported as well, so has nothing to do the
> > GetManagedObjects API of the bluetoothd. That said RegisterApplication
> > was not made experimental which kind makes 5.51 broken because it
> > would appear that it endpoint objects would be exposed but when in
> > fact there are not, anyway lets finally have the code to use this
> > interface and then we can remove the experimental flag from
> > MediaEndpoint.
> 
> Ok, so can pulseaudio do following?
> 
> Call RegisterApplication. If success then expects that codec switching
> is possible and via GetManagedObjects exports all available codecs.
> If RegisterApplication fails then fallback to RegisterEndpoint, expects
> that codec switching is not possible and so register only one SBC codec.

Also can we solve this problem in bluez ASAP? Last released bluez
version is due to that non-experimental API broken and once applications
(e.g. pulseaudio) starts using this new API then A2DP without bluetoothd
-E would be broken.

I would propose to remove experimental mark for codec switching API and
release a new bugfix version of bluez, so people would not use released
5.51 broken version... which could prevent breakage of A2DP in future.

> > > > > > > You can also have a look at how our gdbus internal library (uses
> > > > > > > libdbus) utilize it:
> > > > > > >
> > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n1269
> > > > > > >
> > > > > >
> > > > >
> > > > > --
> > > > > Pali Rohár
> > > > > pali.rohar@gmail.com
> > > >
> > > >
> > > >
> > >
> > > --
> > > Pali Rohár
> > > pali.rohar@gmail.com
> > 
> > 
> > 
> 

-- 
Pali Rohár
pali.rohar@gmail.com

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-17  9:59                               ` Pali Rohár
@ 2019-10-18  8:37                                 ` Pasi Kärkkäinen
  2019-10-18 10:55                                   ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 28+ messages in thread
From: Pasi Kärkkäinen @ 2019-10-18  8:37 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Luiz Augusto von Dentz, linux-bluetooth

On Thu, Oct 17, 2019 at 11:59:57AM +0200, Pali Rohár wrote:
> > > >
> > > > So... what should applications expects and how they should implement
> > > > above decision?
> > > 
> > > Actually the decision should be based on the presence of
> > > RegisterApplication method, if that exists then endpoint switching
> > > should be supported as well, so has nothing to do the
> > > GetManagedObjects API of the bluetoothd. That said RegisterApplication
> > > was not made experimental which kind makes 5.51 broken because it
> > > would appear that it endpoint objects would be exposed but when in
> > > fact there are not, anyway lets finally have the code to use this
> > > interface and then we can remove the experimental flag from
> > > MediaEndpoint.
> > 
> > Ok, so can pulseaudio do following?
> > 
> > Call RegisterApplication. If success then expects that codec switching
> > is possible and via GetManagedObjects exports all available codecs.
> > If RegisterApplication fails then fallback to RegisterEndpoint, expects
> > that codec switching is not possible and so register only one SBC codec.
> 
> Also can we solve this problem in bluez ASAP? Last released bluez
> version is due to that non-experimental API broken and once applications
> (e.g. pulseaudio) starts using this new API then A2DP without bluetoothd
> -E would be broken.
> 
> I would propose to remove experimental mark for codec switching API and
> release a new bugfix version of bluez, so people would not use released
> 5.51 broken version... which could prevent breakage of A2DP in future.
>

+1

It would be nice to get bluez 5.52 released before 5.51 gets released by distros..


-- Pasi


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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-18  8:37                                 ` Pasi Kärkkäinen
@ 2019-10-18 10:55                                   ` Luiz Augusto von Dentz
  2019-10-18 11:30                                     ` Pali Rohár
  0 siblings, 1 reply; 28+ messages in thread
From: Luiz Augusto von Dentz @ 2019-10-18 10:55 UTC (permalink / raw)
  To: Pasi Kärkkäinen; +Cc: Pali Rohár, linux-bluetooth

Hi,

On Fri, Oct 18, 2019 at 1:32 PM Pasi Kärkkäinen <pasik@iki.fi> wrote:
>
> On Thu, Oct 17, 2019 at 11:59:57AM +0200, Pali Rohár wrote:
> > > > >
> > > > > So... what should applications expects and how they should implement
> > > > > above decision?
> > > >
> > > > Actually the decision should be based on the presence of
> > > > RegisterApplication method, if that exists then endpoint switching
> > > > should be supported as well, so has nothing to do the
> > > > GetManagedObjects API of the bluetoothd. That said RegisterApplication
> > > > was not made experimental which kind makes 5.51 broken because it
> > > > would appear that it endpoint objects would be exposed but when in
> > > > fact there are not, anyway lets finally have the code to use this
> > > > interface and then we can remove the experimental flag from
> > > > MediaEndpoint.
> > >
> > > Ok, so can pulseaudio do following?
> > >
> > > Call RegisterApplication. If success then expects that codec switching
> > > is possible and via GetManagedObjects exports all available codecs.
> > > If RegisterApplication fails then fallback to RegisterEndpoint, expects
> > > that codec switching is not possible and so register only one SBC codec.
> >
> > Also can we solve this problem in bluez ASAP? Last released bluez
> > version is due to that non-experimental API broken and once applications
> > (e.g. pulseaudio) starts using this new API then A2DP without bluetoothd
> > -E would be broken.
> >
> > I would propose to remove experimental mark for codec switching API and
> > release a new bugfix version of bluez, so people would not use released
> > 5.51 broken version... which could prevent breakage of A2DP in future.
> >
>
> +1
>
> It would be nice to get bluez 5.52 released before 5.51 gets released by distros..

Just sent a patch marking these APIs as stable, when are we expecting
a new PA release btw?
-- 
Luiz Augusto von Dentz

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

* Re: [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method
  2019-10-18 10:55                                   ` Luiz Augusto von Dentz
@ 2019-10-18 11:30                                     ` Pali Rohár
  0 siblings, 0 replies; 28+ messages in thread
From: Pali Rohár @ 2019-10-18 11:30 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Pasi Kärkkäinen, linux-bluetooth

On Friday 18 October 2019 13:55:10 Luiz Augusto von Dentz wrote:
> Hi,
> 
> On Fri, Oct 18, 2019 at 1:32 PM Pasi Kärkkäinen <pasik@iki.fi> wrote:
> >
> > On Thu, Oct 17, 2019 at 11:59:57AM +0200, Pali Rohár wrote:
> > > > > >
> > > > > > So... what should applications expects and how they should implement
> > > > > > above decision?
> > > > >
> > > > > Actually the decision should be based on the presence of
> > > > > RegisterApplication method, if that exists then endpoint switching
> > > > > should be supported as well, so has nothing to do the
> > > > > GetManagedObjects API of the bluetoothd. That said RegisterApplication
> > > > > was not made experimental which kind makes 5.51 broken because it
> > > > > would appear that it endpoint objects would be exposed but when in
> > > > > fact there are not, anyway lets finally have the code to use this
> > > > > interface and then we can remove the experimental flag from
> > > > > MediaEndpoint.
> > > >
> > > > Ok, so can pulseaudio do following?
> > > >
> > > > Call RegisterApplication. If success then expects that codec switching
> > > > is possible and via GetManagedObjects exports all available codecs.
> > > > If RegisterApplication fails then fallback to RegisterEndpoint, expects
> > > > that codec switching is not possible and so register only one SBC codec.
> > >
> > > Also can we solve this problem in bluez ASAP? Last released bluez
> > > version is due to that non-experimental API broken and once applications
> > > (e.g. pulseaudio) starts using this new API then A2DP without bluetoothd
> > > -E would be broken.
> > >
> > > I would propose to remove experimental mark for codec switching API and
> > > release a new bugfix version of bluez, so people would not use released
> > > 5.51 broken version... which could prevent breakage of A2DP in future.
> > >
> >
> > +1
> >
> > It would be nice to get bluez 5.52 released before 5.51 gets released by distros..
> 
> Just sent a patch marking these APIs as stable

Great! Thank you!

Now there is only my question about undocumented DelayReporting. Can you
look at that email?

> when are we expecting a new PA release btw?

I do not know. I even do not know if release date was announced.

-- 
Pali Rohár
pali.rohar@gmail.com

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

end of thread, back to index

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-12 15:13 [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method Luiz Augusto von Dentz
2019-07-12 15:13 ` [PATCH BlueZ 2/4] media: Add implementation of RegisterApplication Luiz Augusto von Dentz
2019-07-12 15:13 ` [PATCH BlueZ 3/4] test: Add example-endpoint Luiz Augusto von Dentz
2019-07-12 15:13 ` [PATCH BlueZ 4/4] test: Add example-player Luiz Augusto von Dentz
2019-07-13 14:52 ` [PATCH BlueZ 1/4] doc/media-api: Add RegisterApplication method Luiz Augusto von Dentz
2019-07-18 10:00   ` Pali Rohár
2019-07-21 15:55     ` Pali Rohár
2019-08-10  6:54       ` Luiz Augusto von Dentz
2019-08-29 12:57         ` Pasi Kärkkäinen
2019-08-29 20:05           ` Pali Rohár
2019-10-03 18:18             ` Pasi Kärkkäinen
2019-10-06 10:05               ` Pali Rohár
2019-10-06 10:53                 ` Luiz Augusto von Dentz
2019-10-06 10:56                   ` Pali Rohár
2019-10-06 11:14                     ` Luiz Augusto von Dentz
2019-10-06 11:17                       ` Pali Rohár
2019-10-06 18:02                         ` Pali Rohár
2019-10-06 12:02                   ` Pali Rohár
2019-10-07 14:33                     ` Pali Rohár
2019-10-08 10:28                       ` Luiz Augusto von Dentz
2019-10-08 10:33                         ` Pali Rohár
2019-10-09 13:15                           ` Luiz Augusto von Dentz
2019-10-09 13:19                             ` Pali Rohár
2019-10-17  9:59                               ` Pali Rohár
2019-10-18  8:37                                 ` Pasi Kärkkäinen
2019-10-18 10:55                                   ` Luiz Augusto von Dentz
2019-10-18 11:30                                     ` Pali Rohár
2019-10-09 13:20                     ` Pali Rohár

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org linux-bluetooth@archiver.kernel.org
	public-inbox-index linux-bluetooth

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/ public-inbox