Camera: libportal Reference Manual

## Camera Camera — access camera devices |

## Functions

gboolean | xdp_portal_is_camera_present ()
void | xdp_portal_access_camera ()
gboolean | xdp_portal_access_camera_finish ()
int | xdp_portal_open_pipewire_remote_for_camera ()

## Types and Values

enum | XdpCameraFlags

## Description

These functions lets applications access cameras and open pipewire remotes for them.

The underlying portal is org.freedesktop.portal.Camera.

## Functions

### xdp_portal_is_camera_present ()

    gboolean
    xdp_portal_is_camera_present (XdpPortal *portal);

Returns whether any camera are present.

#### Parameters

portal | a XdpPortal |

#### Returns

`TRUE` if the system has cameras

### xdp_portal_access_camera ()

    void
    xdp_portal_access_camera (XdpPortal *portal,
                              XdpParent *parent,
                              XdpCameraFlags flags,
                              GCancellable *cancellable,
                              GAsyncReadyCallback callback,
                              gpointer data);

Request access to a camera.

When the request is done, `callback` will be called. You can then call `xdp_portal_access_camera_finished()` to get the results.

#### Parameters

portal | a XdpPortal |
parent | parent window information. | [nullable]
flags | options for this call |
cancellable | optional GCancellable. | [nullable]
callback | a callback to call when the request is done. | [scope async]
data | data to pass to `callback` . | [closure]

### xdp_portal_access_camera_finish ()

    gboolean
    xdp_portal_access_camera_finish (XdpPortal *portal,
                                     GAsyncResult *result,
                                     GError **error);

Finishes a camera acess request, and returns the result as a boolean.

If the access was granted, you can then call `xdp_portal_open_pipewire_remote_for_camera()` to obtain a pipewire remote.

#### Parameters

portal | a XdpPortal |
result | a GAsyncResult |
error | return location for an error |

#### Returns

`TRUE` if access to a camera was granted

### xdp_portal_open_pipewire_remote_for_camera ()

    int
    xdp_portal_open_pipewire_remote_for_camera
                                   (XdpPortal *portal);

Opens a file descriptor to the pipewire remote where the camera nodes are available. The file descriptor should be used to create a pw_remote object, by using `pw_remote_connect_fd()`. Only the camera nodes will be available from this pipewire node.

#### Parameters

portal | a XdpPortal |

#### Returns

the file descriptor

## Types and Values

### enum XdpCameraFlags

#### Members

XDP_CAMERA_FLAG_NONE |  |