Commit 3a40604a authored by Benjamin Berg's avatar Benjamin Berg
Browse files

Create source bin in main process

This puts everything into one pipeline while still using the
intervideosink/intervideosrc.
parent c9473e68
......@@ -44,6 +44,41 @@ struct _GnomeScreencastWindow
G_DEFINE_TYPE (GnomeScreencastWindow, gnome_screencast_window, GTK_TYPE_APPLICATION_WINDOW)
static GstElement*
sink_create_source_cb (GnomeScreencastWindow *self, ScreencastSink *sink)
{
GstBin *bin;
GstElement *src, *dst, *res;
bin = GST_BIN (gst_bin_new ("screencast source bin"));
src = screencast_portal_get_source (self->portal);
gst_bin_add (bin, src);
dst = gst_element_factory_make ("intervideosink", "inter video sink");
g_object_set (dst,
"channel", "screencast-inter-video",
NULL);
gst_bin_add (bin, dst);
gst_element_link_many (src, dst, NULL);
res = gst_element_factory_make ("intervideosrc", "screencastsrc");
g_object_set (res,
"do-timestamp", TRUE,
"timeout", 10000000000,
"channel", "screencast-inter-video",
NULL);
gst_bin_add (bin, res);
gst_element_add_pad (GST_ELEMENT (bin),
gst_ghost_pad_new ("src",
gst_element_get_static_pad (res,
"src")));
return GST_ELEMENT (bin);
}
static void
find_sink_list_row_activated_cb (GnomeScreencastWindow *self, ScreencastSinkRow *row, ScreencastSinkList *sink_list)
{
......@@ -61,6 +96,16 @@ find_sink_list_row_activated_cb (GnomeScreencastWindow *self, ScreencastSinkRow
sink = screencast_sink_row_get_sink (row);
streaming_sink = screencast_sink_start_stream (sink, self->portal);
if (streaming_sink)
{
g_signal_connect_object (streaming_sink,
"create-source",
(GCallback) sink_create_source_cb,
self,
G_CONNECT_SWAPPED);
}
/* XXX: leak streaming_sink intentionally for now */
g_steal_pointer (&streaming_sink);
}
......@@ -96,8 +141,6 @@ screencast_portal_init_async_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GstPipeline *pipeline;
GstElement *src, *dst;
GnomeScreencastWindow *window;
g_autoptr(GError) error = NULL;
......@@ -117,20 +160,6 @@ screencast_portal_init_async_cb (GObject *source_object,
window = GNOME_SCREENCAST_WINDOW (user_data);
window->portal = SCREENCAST_PORTAL (source_object);
/* Try starting a gstreamer pipeline */
pipeline = GST_PIPELINE (gst_pipeline_new ("pipewire to internal sink"));
src = screencast_portal_get_source (window->portal);
gst_bin_add (GST_BIN(pipeline), src);
/* convert = gst_element_factory_make ("videoconvert", "test convert"); */
/* gst_bin_add (GST_BIN(pipeline), convert); */
dst = gst_element_factory_make ("intervideosink", "inter video sink");
gst_bin_add (GST_BIN(pipeline), dst);
gst_element_link_many (src, dst, NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
}
static void
......
......@@ -166,9 +166,13 @@ client_connected_cb (ScreencastDummyWFDSink *sink, WfdClient *client, WfdServer
}
static GstElement*
server_source_create_cb (ScreencastDummyWFDSink *sink, WfdServer *server)
server_create_source_cb (ScreencastDummyWFDSink *sink, WfdServer *server)
{
return screencast_portal_get_source (sink->portal);
GstElement *res;
g_signal_emit_by_name (sink, "create-source", &res);
return res;
}
static ScreencastSink *
......@@ -201,7 +205,7 @@ screencast_dummy_wfd_sink_sink_start_stream (ScreencastSink *sink, ScreencastPor
g_signal_connect_object (self->server,
"create-source",
(GCallback) server_source_create_cb,
(GCallback) server_create_source_cb,
self,
G_CONNECT_SWAPPED);
......
......@@ -27,6 +27,12 @@ screencast_sink_default_init (ScreencastSinkIface *iface)
{
iface->start_stream = NULL;
g_signal_new ("create-source", SCREENCAST_TYPE_SINK, G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_first_wins, NULL,
NULL,
GST_TYPE_ELEMENT, 0);
g_object_interface_install_property (iface,
g_param_spec_string ("display-name",
"Display Name",
......
......@@ -255,9 +255,13 @@ client_connected_cb (ScreencastWFDP2PSink *sink, WfdClient *client, WfdServer *s
}
static GstElement*
server_source_create_cb (ScreencastWFDP2PSink *sink, WfdServer *server)
server_create_source_cb (ScreencastWFDP2PSink *sink, WfdServer *server)
{
return screencast_portal_get_source (sink->portal);
GstElement *res;
g_signal_emit_by_name (sink, "create-source", &res);
return res;
}
static void
......@@ -311,7 +315,7 @@ p2p_connected (GObject *source_object,
g_signal_connect_object (sink->server,
"create-source",
(GCallback) server_source_create_cb,
(GCallback) server_create_source_cb,
sink,
G_CONNECT_SWAPPED);
......
......@@ -39,11 +39,8 @@ wfd_media_factory_create_element (GstRTSPMediaFactory *factory, const GstRTSPUrl
g_autoptr(GstBin) bin = NULL;
g_autoptr(GstCaps) caps = NULL;
GstElement *source;
GstElement *source = NULL;
GstElement *scale;
GstElement *sourcefilter;
GstElement *imagefreeze;
GstElement *timecode;
GstElement *sizefilter;
GstElement *convert;
GstElement *interlace;
......@@ -58,40 +55,13 @@ wfd_media_factory_create_element (GstRTSPMediaFactory *factory, const GstRTSPUrl
bin = GST_BIN (gst_bin_new ("wfd-encoder-bin"));
/* Test input, will be replaced by real source */
source = gst_element_factory_make ("intervideosrc", "wfd-intervideosrc");
g_signal_emit (self, signals[SIGNAL_CREATE_SOURCE], 0, &source);
g_assert (source);
success &= gst_bin_add (bin, source);
g_object_set (source,
"do-timestamp", TRUE,
NULL);
/* g_signal_emit (self, signals[SIGNAL_CREATE_SOURCE], 0, &source); */
/* g_assert (source); */
/* success &= gst_bin_add (bin, source); */
scale = gst_element_factory_make ("videoscale", "wfd-scale");
success &= gst_bin_add (bin, scale);
/* caps = gst_caps_new_simple ("video/x-raw", */
/* "framerate", GST_TYPE_FRACTION, 0, 1, */
/* // "width", G_TYPE_INT, 600, */
/* // "height", G_TYPE_INT, 400, */
/* NULL); */
/* sourcefilter = gst_element_factory_make ("capsfilter", "wfd-sourcefilter"); */
/* success &= gst_bin_add (bin, sourcefilter); */
/* g_object_set (sourcefilter, */
/* "caps", g_steal_pointer (&caps), */
/* NULL); */
/* imagefreeze = gst_element_factory_make ("imagefreeze", "wfd-imagefreeze"); */
/* success &= gst_bin_add (bin, imagefreeze); */
/* timecode = gst_element_factory_make ("timecodestamper", "wfd-timecodestamper"); */
/* g_object_set (timecode, */
/* "override-existing", TRUE, */
/* "first-timecode-to-now", TRUE, */
/* NULL); */
/* success &= gst_bin_add (bin, timecode); */
caps = gst_caps_new_simple ("video/x-raw",
"framerate", GST_TYPE_FRACTION, 30, 1,
"width", G_TYPE_INT, 1920,
......
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