ScreenCastPortal

class ScreenCastPortal(connection: DBusConnection)(source)

Wrapper around the org.freedesktop.portal.ScreenCast D-Bus interface. Provides convenient methods to capture screen content via PipeWire streams.

This portal maintains an active session internally. After calling startSession, the PipeWire remote can be opened with openPipeWireRemote.

Constructors

Link copied to clipboard
constructor(connection: DBusConnection)

Properties

Link copied to clipboard
val activeSession: DBusPath?

The currently active session handle, set automatically by startSession.

Link copied to clipboard

Returns the available cursor modes as a set of CursorMode values.

Link copied to clipboard

Returns the available source types as a set of SourceType values.

Link copied to clipboard

Returns the interface version.

Functions

Link copied to clipboard

Clears the active session.

Link copied to clipboard

Creates a new screencast session.

Link copied to clipboard

Returns a Flow that emits when the active session is closed.

Link copied to clipboard
fun openPipeWireRemote(): Result<FileDescriptor>

Opens a PipeWire remote using the active session handle.

fun openPipeWireRemote(sessionHandle: DBusPath): Result<FileDescriptor>

Opens a PipeWire remote for the given session, returning a file descriptor that can be passed to a PipeWire client to access the stream.

Link copied to clipboard
suspend fun selectSources(sessionHandle: DBusPath, types: Set<SourceType>? = null, multiple: Boolean? = null, cursorMode: CursorMode? = null, restoreToken: String? = null, persistMode: PersistMode? = null): Result<Unit>

Select sources to capture for the given session. This must be called before starting the session, and an application may only attempt to select sources once per session.

Link copied to clipboard
suspend fun start(sessionHandle: DBusPath, parentWindow: String = ""): Result<StartResponse>

Start the screencast session. This will typically present a dialog for the user to confirm the selection configured via selectSources.

Link copied to clipboard
suspend fun startSession(types: Set<SourceType>? = null, multiple: Boolean? = null, cursorMode: CursorMode? = null, restoreToken: String? = null, persistMode: PersistMode? = null, parentWindow: String = ""): Result<StartResponse>

Convenience function that performs the complete screencast session flow: creates a session, selects sources, and starts the session.