mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-15 00:04:29 +08:00
client/player: Expose transport 'Select' method to the user
This exposes the 'Select' method for Broadcast transports. This allows the user to select the desired stream when running the setup with PipeWire since it acquires any transport that is broadcasting.
This commit is contained in:
parent
083d1a7b66
commit
61e16e3b83
@ -4766,6 +4766,23 @@ static void acquire_reply(DBusMessage *message, void *user_data)
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void select_reply(DBusMessage *message, void *user_data)
|
||||
{
|
||||
DBusError error;
|
||||
|
||||
dbus_error_init(&error);
|
||||
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to select: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Select successful");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void prompt_acquire(const char *input, void *user_data)
|
||||
{
|
||||
GDBusProxy *proxy = user_data;
|
||||
@ -4987,6 +5004,38 @@ static void cmd_acquire_transport(int argc, char *argv[])
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void transport_select(GDBusProxy *proxy, bool prompt)
|
||||
{
|
||||
if (!g_dbus_proxy_method_call(proxy, "Select", NULL,
|
||||
select_reply, proxy, NULL)) {
|
||||
bt_shell_printf("Failed select transport\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void cmd_select_transport(int argc, char *argv[])
|
||||
{
|
||||
GDBusProxy *proxy;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
proxy = g_dbus_proxy_lookup(transports, NULL, argv[i],
|
||||
BLUEZ_MEDIA_TRANSPORT_INTERFACE);
|
||||
if (!proxy) {
|
||||
bt_shell_printf("Transport %s not found\n", argv[i]);
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (find_transport(proxy)) {
|
||||
bt_shell_printf("Transport %s already acquired\n",
|
||||
argv[i]);
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
transport_select(proxy, false);
|
||||
}
|
||||
}
|
||||
|
||||
static void release_reply(DBusMessage *message, void *user_data)
|
||||
{
|
||||
struct transport *transport = user_data;
|
||||
@ -5415,6 +5464,9 @@ static const struct bt_shell_menu transport_menu = {
|
||||
{ "volume", "<transport> [value]", cmd_volume_transport,
|
||||
"Get/Set transport volume",
|
||||
transport_generator },
|
||||
{ "select", "<transport> [transport1...]", cmd_select_transport,
|
||||
"Select Transport",
|
||||
transport_generator },
|
||||
{} },
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user