Commit e78678dd authored by Benjamin Berg's avatar Benjamin Berg
Browse files

Add option to disable portal support and switch to X11

If the user does not have a mutter with remote desktop enabled, then it
may be viable to use an X11 image source instead. This is a compile time
option only though, as we generally want to rely on the remote desktop
protocol and possibly portal in the future.

Adding this makes it possible to try on machines that don't have support
in mutter (e.g. ubuntu).
parent 8c043a60
......@@ -5,10 +5,13 @@ project('gnome-screencast', 'c', version: '0.1.0',
gnome = import('gnome')
i18n = import('i18n')
have_screencast_portal = get_option('screencast_portal')
config_h = configuration_data()
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
config_h.set_quoted('GETTEXT_PACKAGE', 'gnome-screencast')
config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
config_h.set10('HAVE_SCREENCAST_PORTAL', have_screencast_portal)
configure_file(
output: 'gnome-screencast-config.h',
configuration: config_h,
......
option('screencast_portal',
type: 'boolean',
value: true,
description: 'Use the screencast portal, if unset uses X11 image source'
)
......@@ -24,7 +24,11 @@
#include "screencast-wfd-p2p-registry.h"
#include "screencast-dummy-provider.h"
#include <gst/gst.h>
#if HAVE_SCREENCAST_PORTAL
#include "screencast-portal.h"
#endif
struct _GnomeScreencastWindow
{
......@@ -33,7 +37,9 @@ struct _GnomeScreencastWindow
ScreencastMetaProvider *meta_provider;
ScreencastWFDP2PRegistry *wfd_p2p_registry;
#if HAVE_SCREENCAST_PORTAL
ScreencastPortal *portal;
#endif
GCancellable *cancellable;
......@@ -51,7 +57,11 @@ sink_create_source_cb (GnomeScreencastWindow *self, ScreencastSink *sink)
GstElement *src, *dst, *res;
bin = GST_BIN (gst_bin_new ("screencast source bin"));
#if HAVE_SCREENCAST_PORTAL
src = screencast_portal_get_source (self->portal);
#else
src = gst_element_factory_make ("ximagesrc", "X11 screencast source");
#endif
gst_bin_add (bin, src);
dst = gst_element_factory_make ("intervideosink", "inter video sink");
......@@ -85,16 +95,18 @@ find_sink_list_row_activated_cb (GnomeScreencastWindow *self, ScreencastSinkRow
ScreencastSink *sink;
g_autoptr(ScreencastSink) streaming_sink = NULL;
#if HAVE_SCREENCAST_PORTAL
if (!self->portal)
{
g_warning ("Cannot start streaming right now as we don't have a portal!");
return;
}
#endif
g_assert (SCREENCAST_IS_SINK_ROW (row));
sink = screencast_sink_row_get_sink (row);
streaming_sink = screencast_sink_start_stream (sink, self->portal);
streaming_sink = screencast_sink_start_stream (sink);
if (streaming_sink)
{
......@@ -136,6 +148,7 @@ gnome_screencast_window_class_init (GnomeScreencastWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GnomeScreencastWindow, find_sink_list);
}
#if HAVE_SCREENCAST_PORTAL
static void
screencast_portal_init_async_cb (GObject *source_object,
GAsyncResult *res,
......@@ -155,18 +168,21 @@ screencast_portal_init_async_cb (GObject *source_object,
gtk_widget_destroy (GTK_WIDGET (window));
}
g_object_unref (source_object);
return;
}
window = GNOME_SCREENCAST_WINDOW (user_data);
window->portal = SCREENCAST_PORTAL (source_object);
}
#endif
static void
gnome_screencast_window_init (GnomeScreencastWindow *self)
{
#if HAVE_SCREENCAST_PORTAL
ScreencastPortal *portal;
#endif
gtk_widget_init_template (GTK_WIDGET (self));
self->meta_provider = screencast_meta_provider_new ();
......@@ -190,10 +206,12 @@ gnome_screencast_window_init (GnomeScreencastWindow *self)
self->cancellable = g_cancellable_new ();
#if HAVE_SCREENCAST_PORTAL
portal = screencast_portal_new ();
g_async_initable_init_async (G_ASYNC_INITABLE (portal),
G_PRIORITY_LOW,
self->cancellable,
screencast_portal_init_async_cb,
self);
#endif
}
......@@ -10,7 +10,6 @@ gnome_screencast_sources = [
'screencast-provider.c',
'screencast-meta-sink.c',
'screencast-meta-provider.c',
'screencast-portal.c',
'screencast-wfd-p2p-sink.c',
'screencast-wfd-p2p-provider.c',
'screencast-wfd-p2p-registry.c',
......@@ -18,6 +17,10 @@ gnome_screencast_sources = [
'screencast-dummy-wfd-sink.c',
]
if have_screencast_portal
gnome_screencast_sources += [ 'screencast-portal.c' ]
endif
enum_headers = files('screencast-sink.h')
gnome_screencast_sources += gnome.mkenums_simple(
......@@ -44,4 +47,4 @@ executable('gnome-screencast',
dependencies: gnome_screencast_deps,
install: true,
link_with: wfd_server,
)
)
\ No newline at end of file
......@@ -29,7 +29,6 @@ struct _ScreencastDummyWFDSink
GCancellable *cancellable;
ScreencastPortal *portal;
WfdServer *server;
};
......@@ -47,7 +46,7 @@ enum {
};
static void screencast_dummy_wfd_sink_sink_iface_init (ScreencastSinkIface *iface);
static ScreencastSink * screencast_dummy_wfd_sink_sink_start_stream (ScreencastSink *sink, ScreencastPortal *portal);
static ScreencastSink * screencast_dummy_wfd_sink_sink_start_stream (ScreencastSink *sink);
G_DEFINE_TYPE_EXTENDED (ScreencastDummyWFDSink, screencast_dummy_wfd_sink, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (SCREENCAST_TYPE_SINK,
......@@ -102,7 +101,6 @@ screencast_dummy_wfd_sink_finalize (GObject *object)
g_cancellable_cancel (sink->cancellable);
g_clear_object (&sink->cancellable);
g_clear_object (&sink->portal);
g_clear_object (&sink->server);
G_OBJECT_CLASS (screencast_dummy_wfd_sink_parent_class)->finalize (object);
......@@ -176,7 +174,7 @@ server_create_source_cb (ScreencastDummyWFDSink *sink, WfdServer *server)
}
static ScreencastSink *
screencast_dummy_wfd_sink_sink_start_stream (ScreencastSink *sink, ScreencastPortal *portal)
screencast_dummy_wfd_sink_sink_start_stream (ScreencastSink *sink)
{
ScreencastDummyWFDSink *self = SCREENCAST_DUMMY_WFD_SINK (sink);
......
......@@ -40,7 +40,7 @@ enum {
};
static void screencast_meta_sink_sink_iface_init (ScreencastSinkIface *iface);
static ScreencastSink * screencast_meta_sink_sink_start_stream (ScreencastSink *sink, ScreencastPortal *portal);
static ScreencastSink * screencast_meta_sink_sink_start_stream (ScreencastSink *sink);
G_DEFINE_TYPE_EXTENDED (ScreencastMetaSink, screencast_meta_sink, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (SCREENCAST_TYPE_SINK,
......@@ -253,13 +253,13 @@ screencast_meta_sink_sink_iface_init (ScreencastSinkIface *iface)
}
static ScreencastSink *
screencast_meta_sink_sink_start_stream (ScreencastSink *sink, ScreencastPortal *portal)
screencast_meta_sink_sink_start_stream (ScreencastSink *sink)
{
ScreencastMetaSink *meta_sink = SCREENCAST_META_SINK (sink);
g_assert (meta_sink->current_sink);
return screencast_sink_start_stream (meta_sink->current_sink, portal);
return screencast_sink_start_stream (meta_sink->current_sink);
}
/******************************************************************
......
......@@ -18,6 +18,7 @@
#include "gnome-screencast-config.h"
#include "screencast-sink.h"
#include <gst/gst.h>
typedef ScreencastSinkIface ScreencastSinkInterface;
G_DEFINE_INTERFACE (ScreencastSink, screencast_sink, G_TYPE_OBJECT);
......@@ -68,21 +69,18 @@ screencast_sink_default_init (ScreencastSinkIface *iface)
/**
* screencast_sink_start_stream
* @sink: the #ScreencastSink
* @portal: the #ScreencastPortal
*
* Start streaming to this sink. The returned sink is the one
* that is actually streaming, and may differ from the one this
* is called on (i.e. if this is a MetaSink grouping multiple sinks).
*
* The portal will be used to create the GStreamer source element.
*
* Returns: (transfer full):
* The streaming sink owned by the caller.
*/
ScreencastSink *
screencast_sink_start_stream (ScreencastSink *sink, ScreencastPortal *portal)
screencast_sink_start_stream (ScreencastSink *sink)
{
ScreencastSinkIface *iface = SCREENCAST_SINK_GET_IFACE (sink);
return iface->start_stream (sink, portal);
return iface->start_stream (sink);
}
......@@ -20,7 +20,6 @@
#include <glib-object.h>
#include "screencast-enum-types.h"
#include "screencast-portal.h"
G_BEGIN_DECLS
......@@ -47,12 +46,12 @@ struct _ScreencastSinkIface
GTypeInterface g_iface;
/*< public >*/
ScreencastSink * (* start_stream) (ScreencastSink *sink, ScreencastPortal *portal);
ScreencastSink * (* start_stream) (ScreencastSink *sink);
};
GType screencast_sink_get_type (void) G_GNUC_CONST;
ScreencastSink *screencast_sink_start_stream (ScreencastSink *sink, ScreencastPortal *portal);
ScreencastSink *screencast_sink_start_stream (ScreencastSink *sink);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScreencastSink, g_object_unref)
......
......@@ -33,7 +33,6 @@ struct _ScreencastWFDP2PSink
NMDevice *nm_device;
NMP2PPeer *nm_peer;
ScreencastPortal *portal;
WfdServer *server;
};
......@@ -51,7 +50,7 @@ enum {
};
static void screencast_wfd_p2p_sink_sink_iface_init (ScreencastSinkIface *iface);
static ScreencastSink * screencast_wfd_p2p_sink_sink_start_stream (ScreencastSink *sink, ScreencastPortal *portal);
static ScreencastSink * screencast_wfd_p2p_sink_sink_start_stream (ScreencastSink *sink);
G_DEFINE_TYPE_EXTENDED (ScreencastWFDP2PSink, screencast_wfd_p2p_sink, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (SCREENCAST_TYPE_SINK,
......@@ -170,7 +169,6 @@ screencast_wfd_p2p_sink_finalize (GObject *object)
g_clear_object (&sink->nm_device);
g_clear_object (&sink->nm_peer);
g_clear_object (&sink->portal);
g_clear_object (&sink->server);
G_OBJECT_CLASS (screencast_wfd_p2p_sink_parent_class)->finalize (object);
......@@ -324,7 +322,7 @@ p2p_connected (GObject *source_object,
}
static ScreencastSink *
screencast_wfd_p2p_sink_sink_start_stream (ScreencastSink *sink, ScreencastPortal *portal)
screencast_wfd_p2p_sink_sink_start_stream (ScreencastSink *sink)
{
ScreencastWFDP2PSink *self = SCREENCAST_WFD_P2P_SINK (sink);
GVariant *options = NULL;
......@@ -332,7 +330,6 @@ screencast_wfd_p2p_sink_sink_start_stream (ScreencastSink *sink, ScreencastPorta
g_return_val_if_fail (self->state == SCREENCAST_SINK_STATE_DISCONNECTED, NULL);
self->portal = g_object_ref (portal);
self->state = SCREENCAST_SINK_STATE_WAIT_P2P;
g_object_notify (G_OBJECT (self), "state");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment