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

Add App to App ScreenCast #1554

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 5 additions & 1 deletion data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ portal_impl_sources = files(
'org.freedesktop.impl.portal.Wallpaper.xml',
)

portal_app_sources = files(
'org.freedesktop.app.portal.ScreenCast.xml',
)

background_monitor_sources = files(
'org.freedesktop.background.Monitor.xml',
)

install_data([portal_sources, portal_impl_sources],
install_data([portal_sources, portal_impl_sources, portal_app_sources],
install_dir: datadir / 'dbus-1' / 'interfaces',
)
176 changes: 176 additions & 0 deletions data/org.freedesktop.app.portal.ScreenCast.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<?xml version="1.0"?>
<!--
Copyright (C) 2024 tytan652

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
-->

<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
<!--
org.freedesktop.app.portal.ScreenCast:
@short_description: Screen cast application interface

The screen cast app portal allows to share `DMA-BUF PipeWire stream <https://docs.pipewire.org/page_dma_buf.html>`_ as
:ref:`org.freedesktop.portal.ScreenCast` external sources if the portal
implementation supports it.

This interface is to be implemented under the object path
``/org/freedesktop/app/portal`` in a point to point D-Bus connection for
:ref:`org.freedesktop.portal.ScreenCast.ConnectProvisioning`.

This documentation describes version 1 of this interface.
-->
<interface name="org.freedesktop.app.portal.ScreenCast">

<!--
Ready:

Emitted when :ref:`org.freedesktop.portal.ScreenCast.ConnectProvisioning`
request succeeded and the interface is ready to be used.
-->
<signal name="Ready">
</signal>

<!--
GetSources:
@sources: Available sources

Retrieves the current list of sources and their properties

A source is exposed as:

* ``s``: ID of the source, must be persistent between application instances to enable restoring ScreenCast session
* ``a{sv}``: source properties

Known properties:

- ``title`` (``s``): title of the source
-->
<method name="GetSources">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<arg type="a{sa{sv}}" name="sources" direction="out"/>
</method>

<!--
SourcesChanged:
Notifies when any sources is added or removed
-->
<signal name="SourcesChanged"/>

<!--
CreateSession:
@options: Vardict for future-proofing
@session_handle: Object path for the :ref:`org.freedesktop.app.portal.ScreenCast.Session` object

Create a screen cast app session.
-->
<method name="CreateSession">
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
<arg type="a{sv}" name="options" direction="in"/>
<arg type="o" name="session_handle" direction="out" />
</method>

<property name="version" type="u" access="read"/>
</interface>

<!--
org.freedesktop.app.portal.ScreenCast.Session:
@short_description: Screen cast session application interface
-->
<interface name="org.freedesktop.app.portal.ScreenCast.Session">

<!--
Close:

Close the session
-->
<method name="Close">
</method>

<!--
Closed:
@details: A key value Vardict with details about the closed session.

Emitted when a session is closed.

Supported keys in the @details vardict include:

* ``reason`` (``s``)

String indication the reason of session being closed.
-->
<signal name="Closed">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<arg type="a{sv}" name="details"/>
</signal>

<!--
StreamSource:
@id: Id of the source to stream
@options: Vardict for future-proofing
@stream_handle: Object path to the new stream object
@detail: Vardict for future-proofing

Add to sources that the session should stream once started.

TODO: Close session when invalid source is asked ?
-->
<method name="StreamSource">
<arg type="s" name="id" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>
<arg type="a{sv}" name="options" direction="in"/>
<arg type="o" name="stream_handle" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/>
<arg type="a{sv}" name="details" direction="out"/>
</method>

<!--
Start:

Start the screen cast session.

TODO: Document that the session must get closed if a failure happen while starting

TODO: Document behavior about closing if no source is set to be streamed
-->
<method name="Start">
</method>
</interface>

<!--
org.freedesktop.app.portal.ScreenCast.Stream:
@short_description: Screen cast stream application interface

TODO: Recommend using parent session handle as handle prefix to easily avoid duplicate handle across sessions
-->
<interface name="org.freedesktop.app.portal.ScreenCast.Stream">

<!--
PipeWireStreamAdded:
@details: Vardict of detail about the added stream

Emitted after :ref:`org.freedesktop.app.portal.ScreenCast.Session.Start`
when a stream is added as a PipeWire node.

Content of @details:

* ``node_id``: ID of the node (required)
-->
<signal name="PipeWireStreamAdded">
<annotation name="org.gtk.GDBus.C.Name" value="pipewire-stream-added"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<arg type="a{sv}" name="details"/>
</signal>
</interface>
</node>
41 changes: 40 additions & 1 deletion data/org.freedesktop.impl.portal.ScreenCast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

The Screen cast portal allows to create screen cast sessions.

This documentation describes version 5 of this interface.
This documentation describes version 6 of this interface.
-->
<interface name="org.freedesktop.impl.portal.ScreenCast">
<!--
Expand All @@ -44,6 +44,13 @@
* ``session_id`` (``s``)

The session id. A string representing the created screen cast session.

* ``provider`` (``b``)

Create a session to propose sources in the portal rather than requesting them.
Default is no.

This option was added in version 6 of this interface.
-->
<method name="CreateSession">
<arg type="o" name="handle" direction="in"/>
Expand Down Expand Up @@ -234,6 +241,37 @@
<annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/>
<arg type="a{sv}" name="results" direction="out"/>
</method>
<!--
ConnectProvisioning:
@handle: Object path for the :ref:`org.freedesktop.impl.portal.Request` object representing this call
@session_handle: Object path for the :ref:`org.freedesktop.impl.portal.Session` object representing the session
@app_id: App id of the application
@fd: File descriptor of a point to point D-Bus connection
@options: Vardict with optional further information
@response: Numeric response
@results: Vardict with the results of the call

Add the caller app as a sources provider by using the
:ref:`org.freedesktop.app.portal.ScreenCast <org.freedesktop.app.portal.ScreenCast>`
implementation on the point to point D-Bus.

TODO: Document to reject misversioned app portal impl
TODO: Document portal impl behavior

This method was added in version 6 of this interface.
-->
<method name="ConnectProvisioning">
<arg type="o" name="handle" direction="in"/>
<arg type="o" name="session_handle" direction="in"/>
<arg type="s" name="app_id" direction="in"/>
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="h" name="fd" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In4" value="QVariantMap"/>
<arg type="a{sv}" name="options" direction="in"/>
<arg type="u" name="response" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/>
<arg type="a{sv}" name="results" direction="out"/>
</method>
<!--
AvailableSourceTypes:

Expand All @@ -242,6 +280,7 @@
- ``1``: MONITOR: Share existing monitors
- ``2``: WINDOW: Share application windows
- ``4``: VIRTUAL: Extend with new virtual monitor
- ``8``: EXTERNAL: Share application provided sources
-->
<property name="AvailableSourceTypes" type="u" access="read"/>
<!--
Expand Down
46 changes: 45 additions & 1 deletion data/org.freedesktop.portal.ScreenCast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

The Screen cast portal allows to create screen cast sessions.

This documentation describes version 5 of this interface.
This documentation describes version 6 of this interface.
-->
<interface name="org.freedesktop.portal.ScreenCast">
<!--
Expand All @@ -52,6 +52,16 @@
object path element. See the :ref:`org.freedesktop.portal.Session` documentation for
more information about the session handle.

* ``provider`` (``b``)

Create a session to use in org.freedesktop.portal.ScreenCast.ConnectProvisioning()
to propose sources in the portal rather than requesting them. Default is no.

Backends can refuse to support provider session by not setting EXTERNAL as an
available source type.

This option was added in version 6 of this interface.

The following results get returned via the :ref:`org.freedesktop.portal.Request::Response` signal:

* ``session_handle`` (``s``)
Expand Down Expand Up @@ -269,6 +279,39 @@
<arg type="a{sv}" name="options" direction="in"/>
<arg type="h" name="fd" direction="out"/>
</method>
<!--
ConnectProvisioning:
@session_handle: Object path for the :ref:`org.freedesktop.portal.Session` object
@parent_window: Identifier for the application window, see :doc:`window-identifiers`
@fd: File descriptor of a point to point D-Bus connection
@options: Vardict with optional further information
@handle: Object path for the :ref:`org.freedesktop.portal.Request` object representing this call

Add the caller app as a sources provider by using the
:ref:`org.freedesktop.app.portal.ScreenCast <org.freedesktop.app.portal.ScreenCast>`
implementation on the point to point D-Bus.
An application can only attempt to add itself as a provider once per session.
The session must be created with @provider set to true.

Supported keys in the @options vardict include:

* ``handle_token`` (``s``)

A string that will be used as the last element of the @handle. Must be a valid
object path element. See the :ref:`org.freedesktop.portal.Request` documentation for
more information about the @handle.

This method was added in version 6 of this interface.
-->
<method name="ConnectProvisioning">
<arg type="o" name="session_handle" direction="in"/>
<arg type="s" name="parent_window" direction="in"/>
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="h" name="fd" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="QVariantMap"/>
<arg type="a{sv}" name="options" direction="in"/>
<arg type="o" name="handle" direction="out"/>
</method>
<!--
AvailableSourceTypes:

Expand All @@ -277,6 +320,7 @@
- ``1``: MONITOR: Share existing monitors
- ``2``: WINDOW: Share application windows
- ``4``: VIRTUAL: Extend with new virtual monitor
- ``8``: EXTERNAL: Share application provided sources
-->
<property name="AvailableSourceTypes" type="u" access="read"/>
<!--
Expand Down
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ libportal_dep = dependency(
'tests=false',
],
)
pipewire_dep = dependency('libpipewire-0.3', version: '>= 0.2.90')
pipewire_dep = dependency('libpipewire-0.3', version: '>= 0.3.77')
libsystemd_dep = dependency('libsystemd', required: get_option('systemd'))
gudev_dep = dependency('gudev-1.0', required: get_option('gudev'))
umockdev_dep = dependency('umockdev-1.0', required: get_option('pytest'))
Expand Down Expand Up @@ -223,6 +223,7 @@ pkgconfig.generate(
subdir('data')
subdir('src')
subdir('document-portal')
subdir('wireplumber')
subdir('tests')
subdir('po')
subdir('doc')
Expand Down
1 change: 1 addition & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ src/background.c
src/camera.c
src/dynamic-launcher.c
src/location.c
src/screen-cast.c
src/screenshot.c
src/settings.c
src/usb.c
Expand Down
Loading
Loading