[PATCH BlueZ 4/4] client: implement SelectQoS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Implement SelectQoS() so that the server-provided values get printed.
We don't take them into account yet otherwise, though.
---
 client/player.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/client/player.c b/client/player.c
index 715598aa9..4ad6b99d9 100644
--- a/client/player.c
+++ b/client/player.c
@@ -91,6 +91,7 @@ struct endpoint {
 	struct queue *transports;
 	DBusMessage *msg;
 	struct preset *preset;
+	struct codec_preset *codec_preset;
 	bool broadcast;
 	struct iovec *bcode;
 };
@@ -2078,6 +2079,8 @@ static void select_properties_response(const char *input, void *user_data)
 	p = preset_find_name(ep->preset, input);
 	if (p) {
 		reply = endpoint_select_properties_reply(ep, ep->msg, p);
+		if (reply)
+			ep->codec_preset = p;
 		goto done;
 	}
 
@@ -2130,6 +2133,49 @@ static DBusMessage *endpoint_select_properties(DBusConnection *conn,
 	return reply;
 }
 
+static DBusMessage *endpoint_select_qos(DBusConnection *conn,
+					DBusMessage *msg, void *user_data)
+{
+	struct endpoint *ep = user_data;
+	struct codec_preset *preset = ep->codec_preset;
+	DBusMessageIter args;
+	DBusMessageIter iter, dict;
+	DBusMessage *reply;
+	struct endpoint_config cfg;
+
+	dbus_message_iter_init(msg, &args);
+
+	bt_shell_printf("Endpoint: SelectQoS\n");
+	print_iter("\t", "Properties", &args);
+
+	if (!preset)
+		return g_dbus_create_error(msg, "org.bluez.Error.Rejected",
+						"No previous codec preset");
+
+	reply = dbus_message_new_method_return(msg);
+	if (!reply)
+		return NULL;
+
+	dbus_message_iter_init_append(reply, &iter);
+
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict);
+
+	/* TODO: we ignore BAP Server supported values here. If they are not
+	 * suitable for the preset, we should prompt for a preset again, and
+	 * call SetConfiguration on the remote endpoint with the new
+	 * configuration to retry.
+	 */
+
+	memset(&cfg, 0, sizeof(cfg));
+	cfg.ep = ep;
+	cfg.qos = &preset->qos;
+	append_qos(&dict, &cfg);
+
+	dbus_message_iter_close_container(&iter, &dict);
+
+	return reply;
+}
+
 static bool match_str(const void *data, const void *user_data)
 {
 	return !strcmp(data, user_data);
@@ -2248,6 +2294,10 @@ static const GDBusMethodTable endpoint_methods[] = {
 					GDBUS_ARGS({ "properties", "a{sv}" } ),
 					GDBUS_ARGS({ "properties", "a{sv}" } ),
 					endpoint_select_properties) },
+	{ GDBUS_ASYNC_METHOD("SelectQoS",
+					GDBUS_ARGS({ "properties", "a{sv}" } ),
+					GDBUS_ARGS({ "properties", "a{sv}" } ),
+					endpoint_select_qos) },
 	{ GDBUS_ASYNC_METHOD("ClearConfiguration",
 					GDBUS_ARGS({ "transport", "o" } ),
 					NULL, endpoint_clear_configuration) },
-- 
2.41.0




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux