Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

camera: Support selecting a camera #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions libportal/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ response_received (GDBusConnection *bus,
g_variant_get (parameters, "(u@a{sv})", &response, &ret);

if (response == 0)
g_task_return_boolean (call->task, TRUE);
{
GVariant *streams;

g_print ("ret: %s\n", g_variant_print (ret, FALSE));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g_debug?

g_variant_lookup (ret, "streams", "@a(ua{sv})", &streams);
g_object_set_data_full (G_OBJECT (call->task), "streams",
g_variant_ref (streams), (GDestroyNotify)g_variant_unref);
g_task_return_boolean (call->task, TRUE);
}
else if (response == 1)
g_task_return_new_error (call->task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Camera access canceled");
else
Expand All @@ -137,7 +145,7 @@ cancelled_cb (GCancellable *cancellable,
{
AccessCameraCall *call = data;

g_debug ("Calling Close");
g_debug ("Calling Close");
g_dbus_connection_call (call->portal->bus,
PORTAL_BUS_NAME,
call->request_path,
Expand Down Expand Up @@ -196,7 +204,7 @@ access_camera (AccessCameraCall *call)
g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add (&options, "{sv}", "handle_token", g_variant_new_string (token));

g_debug ("Calling AccessCamera");
g_debug ("Calling AccessCamera");
g_dbus_connection_call (call->portal->bus,
PORTAL_BUS_NAME,
PORTAL_OBJECT_PATH,
Expand Down Expand Up @@ -276,6 +284,27 @@ xdp_portal_access_camera_finish (XdpPortal *portal,
return g_task_propagate_boolean (G_TASK (result), error);
}

GVariant *
xdp_portal_access_camera_finish_streams (XdpPortal *portal,
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (XDP_IS_PORTAL (portal), FALSE);
g_return_val_if_fail (g_task_is_valid (result, portal), FALSE);
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == xdp_portal_access_camera, FALSE);

if (g_task_propagate_boolean (G_TASK (result), error))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be necessary to retrieve streams before calling this? I think this could potentially drop the last reference to this GTask.

{
GVariant *streams;

streams = (GVariant *)g_object_get_data (G_OBJECT (result), "streams");
if (streams)
return g_variant_ref (streams);
}

return NULL;
}

/**
* xdp_portal_open_pipewire_remote_for_camera:
* @portal: a #XdpPortal
Expand Down
5 changes: 5 additions & 0 deletions libportal/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ gboolean xdp_portal_access_camera_finish (XdpPortal *portal,
GAsyncResult *result,
GError **error);

XDP_PUBLIC
GVariant * xdp_portal_access_camera_finish_streams (XdpPortal *portal,
GAsyncResult *result,
GError **error);

XDP_PUBLIC
int xdp_portal_open_pipewire_remote_for_camera (XdpPortal *portal);

Expand Down