After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 784199 - Add screen cast and remote desktop support
Add screen cast and remote desktop support
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2017-06-26 06:51 UTC by Jonas Ådahl
Modified: 2019-02-06 23:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ClutterVirtualInputDevice: Allow passing CLUTTER_CURRENT_TIME (2.98 KB, patch)
2017-06-26 06:51 UTC, Jonas Ådahl
committed Details | Review
clutter/evdev: Move scroll notification to ClutterSeatEvdev (22.42 KB, patch)
2017-06-26 06:51 UTC, Jonas Ådahl
committed Details | Review
ClutterVirtualInputDevice: Add discrete scrolling (6.31 KB, patch)
2017-06-26 06:52 UTC, Jonas Ådahl
committed Details | Review
clutter/stage: Add capture_into API (4.44 KB, patch)
2017-06-26 06:52 UTC, Jonas Ådahl
committed Details | Review
wayland/xdg-foreign: Move out ID generation helper to util.c (2.91 KB, patch)
2017-06-26 06:52 UTC, Jonas Ådahl
committed Details | Review
monitor-manager: Add helper for getting monitor from connector (2.27 KB, patch)
2017-06-26 06:52 UTC, Jonas Ådahl
committed Details | Review
monitor: Add API to get regenerated monitor from old instance (2.06 KB, patch)
2017-06-26 06:52 UTC, Jonas Ådahl
committed Details | Review
Add MetaFraction for dealing with fractions (5.59 KB, patch)
2017-06-26 06:52 UTC, Jonas Ådahl
committed Details | Review
Add remote desktop and screencast functionality (129.59 KB, patch)
2017-06-26 06:52 UTC, Jonas Ådahl
committed Details | Review
screen-cast: Handle PipeWire errors (5.44 KB, patch)
2017-06-26 06:52 UTC, Jonas Ådahl
committed Details | Review
screen-cast-stream-src: Only try to record frames when streaming (8.60 KB, patch)
2017-06-26 06:52 UTC, Jonas Ådahl
committed Details | Review
ScreenCast: Pass PipeWire stream node ID directly (11.76 KB, patch)
2017-06-28 07:25 UTC, Jonas Ådahl
committed Details | Review
screen-cast-stream: Don't broadcast PipeWireStreamAdded signal (11.57 KB, patch)
2017-09-05 03:40 UTC, Jonas Ådahl
reviewed Details | Review

Description Jonas Ådahl 2017-06-26 06:51:43 UTC
These patches indirectly add screen sharing support to mutter.

The main patch (Add remote desktop and screencast functionality) introduces two new D-Bus APIs:

org.gnome.Mutter.ScreenCast
 - org.gnome.Mutter.ScreenCast.Session
 - org.gnome.Mutter.ScreenCast.Stream

and

org.gnome.Mutter.RemoteDesktop
 - org.gnome.Mutter.RemoteDesktop.Session

In short, the screen cast interfaces are used to create PipeWire[0][1] streams
of desktop content, while the remote desktop interfaces are used to inject
input events for remote controlling.

These two APIs together with an external tool can be used to implement screen
sharing and remote desktop application.

One such application is "gnome-remote-desktop", currently residing at
<https://github.com/jadahl/gnome-remote-desktop>.

See individual patches for more details.
Comment 1 Jonas Ådahl 2017-06-26 06:51:50 UTC
Created attachment 354472 [details] [review]
ClutterVirtualInputDevice: Allow passing CLUTTER_CURRENT_TIME

If CLUTTER_CURRENT_TIME is passed, let the backend find an appropriate
time stamp representing the current time in the clock that is used by
that backend.
Comment 2 Jonas Ådahl 2017-06-26 06:51:56 UTC
Created attachment 354473 [details] [review]
clutter/evdev: Move scroll notification to ClutterSeatEvdev

This refactors the scroll event emitting code, moving it behind a
clutter_seat_evdev_ helper.
Comment 3 Jonas Ådahl 2017-06-26 06:52:01 UTC
Created attachment 354474 [details] [review]
ClutterVirtualInputDevice: Add discrete scrolling

Add emitting of discrete scrolling events (such as mouse scroll
wheel-like events).
Comment 4 Jonas Ådahl 2017-06-26 06:52:07 UTC
Created attachment 354475 [details] [review]
clutter/stage: Add capture_into API

Add API similar to clutter_stage_capture() but that draws into
externally allocated memory. It is assumed that the pixel format is
ARGB32, and the memory is structured in a way that the width of the
passed rectangle is identical to the stride divided by 4.
Comment 5 Jonas Ådahl 2017-06-26 06:52:13 UTC
Created attachment 354476 [details] [review]
wayland/xdg-foreign: Move out ID generation helper to util.c

It'll be used to generate ID in the same way in other places later.
Comment 6 Jonas Ådahl 2017-06-26 06:52:18 UTC
Created attachment 354477 [details] [review]
monitor-manager: Add helper for getting monitor from connector

This will be used later.
Comment 7 Jonas Ådahl 2017-06-26 06:52:24 UTC
Created attachment 354478 [details] [review]
monitor: Add API to get regenerated monitor from old instance

When monitors changed, previous monitor instances are defunct, and any
reference holder should drop its reference. Sometimes they will want to
continue having a reference to the same monitor, so add this function
to make it possible to find it.

Currently the output and crtc references are invalid, as they are not
yet reference counted, so this can only look at cached fields.
Comment 8 Jonas Ådahl 2017-06-26 06:52:29 UTC
Created attachment 354479 [details] [review]
Add MetaFraction for dealing with fractions

Add MetaFraction, which consists of two integers, the numerator an the
denominator. The utility function to convert a double to a MetaFraction
comes from gstreamer.
Comment 9 Jonas Ådahl 2017-06-26 06:52:35 UTC
Created attachment 354480 [details] [review]
Add remote desktop and screencast functionality

This commit adds basic screen casting and remote desktoping
functionalty. This works by exposing two D-Bus API services:
org.gnome.Mutter.ScreenCast and org.gnome.Mutter.RemoteDesktop.

The remote desktop API is used to create remote desktop sessions. For
each session, a D-Bus object is created, and an application can manage
the session by sending messages to the session object. A remote desktop
session the user to emit input events using the D-Bus methods on the
session object. To get framebuffer content, the application should
create an associated screen cast session.

The screen cast API is used to create screen cast sessions. One can so
far either create stand-alone screen cast sessions, or a screen cast
session associated with a remote desktop session. A remote desktop
associated screen cast session is managed by the remote desktop session.

So far only remote desktop managed screen cast sessions are implemented.

Each screen cast session may have one or more streams. A screen cast
stream is a stream of buffers of some part of the compositor content.
So far API exists for creating streams of monitors and windows, but
only monitor streams are implemented.

When a screen cast session is started, the one PipeWire stream is
created for each screen cast stream created for the session. When this
has happened, a PipeWireStreamAdded signal is emitted on the stream
object, passing a unique identifier. The application may use this
identifier to find the associated stream being advertised by the
PipeWire daemon.

The remote desktop and screen cast functionality must be explicitly be
enabled at ./configure time by passing --enable-remote-desktop to
./configure. Doing this will build both screen cast and remote desktop
support.

To actually enable the screen casting and remote desktop, the user must
enable the experimental feature. See
org.gnome.mutter.experimental-features.
Comment 10 Jonas Ådahl 2017-06-26 06:52:41 UTC
Created attachment 354481 [details] [review]
screen-cast: Handle PipeWire errors

When the PipeWire context or stream ends up in an error state, signal
that the source has closed. This then triggers the stream and finally
the session to be closed too.
Comment 11 Jonas Ådahl 2017-06-26 06:52:46 UTC
Created attachment 354482 [details] [review]
screen-cast-stream-src: Only try to record frames when streaming

Only when the PipeWire stream state is 'PW_STREAM_STATE STREAMING'
should the signal be connected causing the src to maybe record a frame.
Comment 12 Jonas Ådahl 2017-06-26 06:55:58 UTC
Missed to include the link to PipeWire: https://cgit.freedesktop.org/~wtay/pipewire

To try out the patches, you must first install PipeWire and pass --enable-remote-desktop to mutters ./configure.
Comment 13 Jonas Ådahl 2017-06-28 07:25:39 UTC
Created attachment 354609 [details] [review]
ScreenCast: Pass PipeWire stream node ID directly

As of commit 5f5ef3de2cdc816dab82cb7eb5d7171bee0ad2c5 in pipewire the
stream creator can find out the node ID of the stream it created.

So instead of using a special purpose entry to the info property box to
let the application discover stream by monitoring added nodes searching
for the given special purpose entry, just pass the node directly.
Comment 14 Jonas Ådahl 2017-08-29 06:43:53 UTC
Leaving open, as it's still disabled by default.

Attachment 354472 [details] pushed as 1e7628a - ClutterVirtualInputDevice: Allow passing CLUTTER_CURRENT_TIME
Attachment 354473 [details] pushed as d3c559a - clutter/evdev: Move scroll notification to ClutterSeatEvdev
Attachment 354474 [details] pushed as a10ad57 - ClutterVirtualInputDevice: Add discrete scrolling
Attachment 354475 [details] pushed as 12710dc - clutter/stage: Add capture_into API
Attachment 354476 [details] pushed as 34e7134 - wayland/xdg-foreign: Move out ID generation helper to util.c
Attachment 354477 [details] pushed as 3005a40 - monitor-manager: Add helper for getting monitor from connector
Attachment 354478 [details] pushed as 3ce3a5a - monitor: Add API to compare with old instance
Attachment 354479 [details] pushed as 38235bc - Add MetaFraction for dealing with fractions
Attachment 354480 [details] pushed as 97f2c7c - Add remote desktop and screencast functionality - none
Attachment 354481 [details] pushed as 9d89227 - screen-cast: Handle PipeWire errors
Attachment 354482 [details] pushed as 920541f - screen-cast-stream-src: Only try to record frames when streaming
Attachment 354609 [details] pushed as 53175e8 - ScreenCast: Pass PipeWire stream node ID directly
Comment 15 Jonas Ådahl 2017-09-05 03:40:48 UTC
Created attachment 359154 [details] [review]
screen-cast-stream: Don't broadcast PipeWireStreamAdded signal

The helper function from gdbus-codegen broadcasts the signal emission,
but we really only care about sending it to the specific peer that
created the session. Thus, only emit the signal to the particular peer
that owns the session.
Comment 16 Florian Müllner 2017-09-05 11:56:37 UTC
Review of attachment 359154 [details] [review]:

Would it make sense for the session to expose something like

  meta_screen_cast_session_emit_pipewire_stream_added (session, object_path, node_id)

instead of connection and peer-name?
Comment 17 Jonas Ådahl 2017-09-05 12:07:08 UTC
(In reply to Florian Müllner from comment #16)
> Review of attachment 359154 [details] [review] [review]:
> 
> Would it make sense for the session to expose something like
> 
>   meta_screen_cast_session_emit_pipewire_stream_added (session, object_path,
> node_id)
> 
> instead of connection and peer-name?

I don't think so. "PipeWireStreamAdded" is a signal on the MetaScreenCastStream object/interface, which is implemented in meta-screen-cast-stream.c.
Comment 18 Strangiato 2018-01-22 13:52:31 UTC
Any progress with this issue?
Comment 19 David Dreggors 2018-10-02 14:16:15 UTC
(In reply to Jonas Ådahl from comment #17)
> (In reply to Florian Müllner from comment #16)
> > Review of attachment 359154 [details] [review] [review] [review]:
> > 
> > Would it make sense for the session to expose something like
> > 
> >   meta_screen_cast_session_emit_pipewire_stream_added (session, object_path,
> > node_id)
> > 
> > instead of connection and peer-name?
> 
> I don't think so. "PipeWireStreamAdded" is a signal on the
> MetaScreenCastStream object/interface, which is implemented in
> meta-screen-cast-stream.c.

It has been a year since the last comment by Jonas above, has there been an movement/progress on this? 

Google Hangouts are used a lot in the private and commercial sectors and this is a total show stopper. It would be nice to see that this issue has some traction and is moving.
Comment 20 Florian Müllner 2018-10-02 14:24:21 UTC
(In reply to David Dreggors from comment #19)
> It has been a year since the last comment by Jonas above, has there been an
> movement/progress on this? 

See comment #14 - the feature itself has landed (since 3.26) but is still disabled by default. There is some movement to get browsers to support the API, so that hangouts and co. start working on wayland (but that's outside the scope of this bug).
Comment 21 Jonas Ådahl 2018-10-02 14:38:16 UTC
Browsers etc are not really using (and shouldn't use) this API, they are using org.freedesktop.portal.ScreenCast/RemoteDesktop. While it's disabled by default build time, it's enabled by default if built in now with 3.30. I think we can close this bug actually, but I'll open a MR for the left over patch.