## XdpSession XdpSession — a representation of long-lived screencast portal interactions |

## Functions

void | xdp_session_start ()
gboolean | xdp_session_start_finish ()
void | xdp_session_close ()
int | xdp_session_open_pipewire_remote ()
XdpSessionType | xdp_session_get_session_type ()
XdpSessionState | xdp_session_get_session_state ()
XdpDeviceType | xdp_session_get_devices ()
GVariant * | xdp_session_get_streams ()

## Signals

void | closed | No Hooks

## Types and Values

| XdpSession
enum | XdpSessionType
enum | XdpSessionState

## Object Hierarchy

        GObject
        ╰── XdpSession

## Description

The XdpSession object is used to represent portal interactions with the screencast or remote desktop portals that extend over multiple portal calls.

To find out what kind of session an XdpSession object represents and whether it is still active, you can use `xdp_session_get_session_type()` and `xdp_session_get_session_state()`.

All sessions start in an initial state. They can be made active by calling `xdp_session_start()`, and ended by calling `xdp_session_close()`.

## Functions

### xdp_session_start ()

    void
    xdp_session_start (XdpSession *session,
                       XdpParent *parent,
                       GCancellable *cancellable,
                       GAsyncReadyCallback callback,
                       gpointer data);

Starts the session.

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

#### Parameters

session | a XdpSession in initial state |
parent | parent window information. | [nullable]
cancellable | optional GCancellable. | [nullable]
callback | a callback to call when the request is done. | [scope async]
data | data to pass to `callback` . | [closure]

### xdp_session_start_finish ()

    gboolean
    xdp_session_start_finish (XdpSession *session,
                              GAsyncResult *result,
                              GError **error);

Finishes the session-start request.

#### Parameters

session | a XdpSession |
result | a GAsyncResult |
error | return location for an error |

#### Returns

`TRUE` if the session was started successfully.

### xdp_session_close ()

    void
    xdp_session_close (XdpSession *session);

Closes the session.

#### Parameters

session | an active XdpSession |

### xdp_session_open_pipewire_remote ()

    int
    xdp_session_open_pipewire_remote (XdpSession *session);

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

#### Parameters

session | a XdpSession |

#### Returns

the file ddescriptor

### xdp_session_get_session_type ()

    XdpSessionType
    xdp_session_get_session_type (XdpSession *session);

Obtains information about the type of session that is represented by `session` .

#### Parameters

session | an XdpSession |

#### Returns

the type of `session`

### xdp_session_get_session_state ()

    XdpSessionState
    xdp_session_get_session_state (XdpSession *session);

Obtains information about the state of the session that is represented by `session` .

#### Parameters

session | an XdpSession |

#### Returns

the state of `session`

### xdp_session_get_devices ()

    XdpDeviceType
    xdp_session_get_devices (XdpSession *session);

Obtains the devices that the user selected.

Unless the session is active, this function returns `XDP_DEVICE_NONE`.

#### Parameters

session | a XdpSession |

#### Returns

the selected devices

### xdp_session_get_streams ()

    GVariant *
    xdp_session_get_streams (XdpSession *session);

Obtains the streams that the user selected. The information inthe returned GVariant has the format `a(ua{sv})`. Each item in the array is describing a stream. The first member is the pipewire node ID, the second is a dictionary of stream properties, including:

- position, `(ii)`: a tuple consisting of the position (x, y) in the compositor coordinate space. Note that the position may not be equivalent to a position in a pixel coordinate space. Only available for monitor streams.

- size, `(ii)`: a tuple consisting of (width, height). The size represents the size of the stream as it is displayed in the compositor coordinate space. Note that this size may not be equivalent to a size in a pixel coordinate space. The size may differ from the size of the stream.

Unless the session is active, this function returns `NULL`.

#### Parameters

session | a XdpSession |

#### Returns

the selected streams

## Types and Values

### XdpSession

    typedef struct _XdpSession XdpSession;

The XdpSession struct contains only private fields and should not be accessed directly.

### enum XdpSessionType

The type of a session.

#### Members

XDP_SESSION_SCREENCAST | a screencast session. |
XDP_SESSION_REMOTE_DESKTOP | a remote desktop session. |

### enum XdpSessionState

The state of a session.

#### Members

XDP_SESSION_INITIAL | the session has not been started. |
XDP_SESSION_ACTIVE | the session is active. |
XDP_SESSION_CLOSED | the session is no longer active. |

## Signal Details

### The `“closed”` signal

    void
    user_function (XdpSession *xdpsession,
                   gpointer    user_data)

The ::closed signal is emitted when a session is closed externally.

#### Parameters

user_data | user data set when the signal handler was connected. |

Flags: No Hooks