camera icon indicating copy to clipboard operation
camera copied to clipboard

Use portal to request access to camera

Open marbetschar opened this issue 3 years ago • 4 comments

... instead of the --device=all flag. Eventually fixes https://github.com/elementary/camera/issues/234 - however, I don't know how to effectively use the camera after the access was granted.

After access was granted, we should somehow provide the device to gstreamer so we are able to use it around here: https://github.com/elementary/camera/blob/portal/access_camera/src/Widgets/CameraView.vala#L121-L123

Anyone an idea?

marbetschar avatar Jun 05 '22 17:06 marbetschar

I saw this the other day when trying to find more information about porting to Gtk4. Maybe relevant? Here he’s using Pipewire: https://blog.gtk.org/2020/05/20/media-in-gtk-4/

danirabbit avatar Jun 05 '22 20:06 danirabbit

After access was granted, we should somehow provide the device to gstreamer https://github.com/elementary/camera/blob/portal/access_camera/src/Widgets/CameraView.vala#L121-L123

I believe this snippet has what you want.

basically, i would drop the Gst.DeviceMonitor code, since we can't enumerate devices without --device=all, and make create_pipeline() accept the fd instead of a Gst.Device.

AFAIK, the camera portal means an hard dependency in pipewire 0.3 in the host and runtime, and camera would only work in systems with pipewire 0.3 installed.

Marukesu avatar Jun 06 '22 01:06 Marukesu

Thanks guys! I started playing around with it and now getting the below error. It probably makes more sense to finish the Gtk4 port first, so we then can use the new APIs instead of investing more time into legacy stuff:

(io.elementary.camera:2): libportal-DEBUG: 10:18:47.076: Calling AccessCamera
** (io.elementary.camera:2): DEBUG: 10:18:47.284: CameraView.vala:115: access_granted: true
** (io.elementary.camera:2): DEBUG: 10:18:47.286: CameraView.vala:122: camera_fd:  19

** (io.elementary.camera:2): WARNING **: 10:19:17.586: CameraView.vala:200: Unexpected error from pipeline: Internal data stream error.

PS: Had to install the gstreamer1.0-pipewire plugin to get things "working". So we might want to ship this by default at some point.

marbetschar avatar Jun 06 '22 10:06 marbetschar